gitoria

components

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitadfe2c4dadfe2c4dAdd shuffle, repeat and repeatOne shared iconsmreadfe2c4d/components/md-editor/demo.hl

2.8 KB

  1. // demo.hl — `/md-editor`: three editors on one page (the second starts empty and shows its placeholder, the third holds a table), and the Markdown each holds
  2. // shown below. The editor announces a change with a bubbling DOM `input` event on its hidden field: `e.target.value` is the Markdown.
  3. parent '../main.hl'
  4. import MdEditor from './md-editor.hl'
  5. import { storeMdFiles } from '../../lib/uploads.hl'
  6. __title = 'Markdown editor · Hybriel components'
  7. static NL = "
  8. "
  9. String note = '# Hello' + NL + NL + 'Some **bold** and *italic* text with `code` and a [link](https://example.com).' + NL + NL + '- first' + NL + '- second'
  10. String summary = ''
  11. Number outsideN = 0
  12. // a GitHub pipe table (mission 004): alignment, an escaped pipe, bold and code in cells, a long row that scrolls on a phone
  13. String plan = '## Shopping' + NL + NL + '| Item | Qty | Note \| x |' + NL + '|:-----|:---:|---:|' + NL + '| **milk** | `2` | fresh |' + NL + '| bread | 1 | wholegrainsourdoughwithseedsfromthebakeryaroundthecorner |' + NL + NL + 'Tab moves to the next cell, Enter adds a row.'
  14. View {
  15. mdEditorDemo {
  16. h1 { "Markdown editor" }
  17. p { class = "muted" "Edit it visually: headings look like headings, bold is bold, lists are lists. The value below each editor is plain Markdown; paste Markdown in and it shows formatted." }
  18. // a value that arrives from outside after the editor is built (a kept state, a push from another device): the editor shows it
  19. p { button { id = "md-outside" type = "button" "Set the second editor from outside" on click(e) { outsideN = outsideN + 1 summary = '# Outside ' + outsideN + NL + NL + 'set by **the page**' } }
  20. button { id = "md-stale" type = "button" "Hand the second editor its first text back" on click(e) { summary = '' } } }
  21. form { id = "md-form" method = "get" action = "/md-editor" on input(e) { emit demoValue(e) }
  22. MdEditor { name = "note" value = note }
  23. h2 { "Value of “note”" }
  24. pre { id = "md-value" note }
  25. MdEditor { name = "summary" value = summary placeholder = "A second editor, empty: type here…" }
  26. h2 { "Value of “summary”" }
  27. pre { id = "md-value-summary" summary }
  28. MdEditor { name = "plan" value = plan }
  29. h2 { "Value of “plan”" }
  30. pre { id = "md-value-plan" plan }
  31. p { button { type = "submit" "Send (posts both as Markdown)" } }
  32. }
  33. p { a { id = "readme" href = "/md-editor/README.md" "README (how to use it)" } }
  34. }
  35. }
  36. on demoValue(e) {
  37. if (e.target.name == 'note') { note = e.target.value }
  38. if (e.target.name == 'summary') { summary = e.target.value }
  39. if (e.target.name == 'plan') { plan = e.target.value }
  40. }
  41. // WHERE THE FILES GO IS THE APP'S DECISION: the editor sends dropped / pasted / chosen files here (`emit server mdUpload`), this site
  42. // keeps them for one day and answers the address of each file, in order (lib/uploads.hl storeMdFiles).
  43. on server mdUpload(files) { return storeMdFiles(files) }

Branches

Latest commits

  • adfe2c4dAdd shuffle, repeat and repeatOne shared iconsmre
  • c96709c8media-player: skip = false and repeat = 'one' options (jukebox#19)mre
  • bd4aa808Record VL24 deployment and live verificationmre
  • e5b98ecfRun virtual-list gate before deploymentmre
  • 2e9b4a8evirtual-list: into main, with centerId and scrollTop/onScroll (jukebox#20)mre
  • 69954249Align all plugin sources with Hybriel day38bmre
  • f740f666Re-vendor components to Hybriel set day38bmre
  • 8176eb14Record CS23b deployment and live verificationmre
  • 84e3ddaaRemove blank line before pagination Style closing bracemre
  • a92298ddRecord exact CSS and same-date proof after specificity reviewmre
  • c71a0abePreserve consumer theme specificity with nested tag rulesmre
  • 64a2bc27Document CS23b style formatting proof and review statusmre
  • a72b57cficons: nest Style rules in the language's formmre
  • 927616e2pagination: nest Style rules in the language's formmre
  • aab8ad29code-editor: nest Style rules in the language's formmre
  • ba30727afile-upload: nest Style rules in the language's formmre
  • 42fefa4emodal: nest Style rules in the language's formmre
  • 6fd953e3range-picker: nest Style rules in the language's formmre
  • f661951ddate-picker: nest Style rules in the language's formmre
  • 363577e6media-player: nest Style rules in the language's formmre