components
All repositories: gitoria
2.8 KB
// 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// shown below. The editor announces a change with a bubbling DOM `input` event on its hidden field: `e.target.value` is the Markdown.parent '../main.hl'import MdEditor from './md-editor.hl'import { storeMdFiles } from '../../lib/uploads.hl'__title = 'Markdown editor · Hybriel components'static NL = ""String note = '# Hello' + NL + NL + 'Some **bold** and *italic* text with `code` and a [link](https://example.com).' + NL + NL + '- first' + NL + '- second'String summary = ''Number outsideN = 0// a GitHub pipe table (mission 004): alignment, an escaped pipe, bold and code in cells, a long row that scrolls on a phoneString 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.'View {mdEditorDemo {h1 { "Markdown editor" }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." }// a value that arrives from outside after the editor is built (a kept state, a push from another device): the editor shows itp { 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**' } }button { id = "md-stale" type = "button" "Hand the second editor its first text back" on click(e) { summary = '' } } }form { id = "md-form" method = "get" action = "/md-editor" on input(e) { emit demoValue(e) }MdEditor { name = "note" value = note }h2 { "Value of “note”" }pre { id = "md-value" note }MdEditor { name = "summary" value = summary placeholder = "A second editor, empty: type here…" }h2 { "Value of “summary”" }pre { id = "md-value-summary" summary }MdEditor { name = "plan" value = plan }h2 { "Value of “plan”" }pre { id = "md-value-plan" plan }p { button { type = "submit" "Send (posts both as Markdown)" } }}p { a { id = "readme" href = "/md-editor/README.md" "README (how to use it)" } }}}on demoValue(e) {if (e.target.name == 'note') { note = e.target.value }if (e.target.name == 'summary') { summary = e.target.value }if (e.target.name == 'plan') { plan = e.target.value }}// WHERE THE FILES GO IS THE APP'S DECISION: the editor sends dropped / pasted / chosen files here (`emit server mdUpload`), this site// keeps them for one day and answers the address of each file, in order (lib/uploads.hl storeMdFiles).on server mdUpload(files) { return storeMdFiles(files) }
Branches
Latest commits
- f661951ddate-picker: nest Style rules in the language's formmre
- 363577e6media-player: nest Style rules in the language's formmre
- 0b3fd8c9comments: nest Style rules in the language's formmre
- 67e043c8plugins/web/README.md from hybriel cb9e480dmre
- 519b56e9styles.hl: Style in the language's form (nested like the View, one declaration per line, bare @media)mre
- 29f63d01md-editor: Style in the language's form (nested like the View, one declaration per line, bare @media)mre
- 869f49c7files-upload: Style in the language's form (nested like the View, one declaration per line, bare @media)mre
- f60dab20month-view: Style in the language's form (nested like the View, one declaration per line, bare @media)mre
- 5b3c349aRe-vendor to Hybriel set day35 (cb9e480d): plugins core and web sources, README vendoring notemre
- 3449b117components: a startup error prints its message before exit 1 (hybriel#247)mre
- 59704ce1Merge branch 'n5b-pipes'mre
- 23b9164aMdEditor: a clipboard whose text is only the names or file:// paths of its files (a file manager copy) is about the files, as before; any other text wins (tickets#49); gate casesmre
- b0f1ec28MdEditor: a clipboard with text always pastes the text, also when a picture is on it too (a spreadsheet or office app), files on or off; a picture alone still goes to the files; real Ctrl+V gate tests/md-paste-files.mjs (tickets#49)mre
- ad4e929bMdEditor: pipe rows without a delimiter row are a table (first row = header, short rows padded, written back without an invented | --- | line) (notes#5)mre
- 4bd11128MdEditor: the Table button's empty table is written as a real pipe table (empty cells), so it survives the source switch, a save and a reload (notes#7)mre
- 7437e32bMdEditor draws its surface at once when claimed from server HTML: 1 ms mount animation, the first editor mounts all editors of the pagemre
- 5de0264cRe-vendor onto Hybriel master acaceaf3 (set-day27b): binary, lib and plugins; exit 1 on a startup fault; .gitignore binmre
- 79c77e7dMerge sb3-standby: components deploys through its standbymre
- c5442043components: no jobs switch needed in the standbymre
- 8d2fb24ccomponents: a standby container (port 45016, profile standby); deploy hands over through standby-swap.sh without a gapmre