gitoria

layouts

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit3aca2d7f3aca2d7fSync components from 8176eb1 with reviewed nested stylesmre3aca2d7f/components/code-editor/README.md

2.9 KB

  1. # Code editor
  2. A code field: the code is **coloured while you type**, line numbers follow, **Tab** indents and **Shift+Tab** outdents,
  3. **Ctrl+Z / Ctrl+Shift+Z** undo and redo. A port of custom-ide's CodeJar editor as a pure Hybriel component: no JavaScript
  4. of its own. Demo: `/code-editor`.
  5. Use it in a page:
  6. ```
  7. import CodeEditor from './code-editor.hl'
  8. form { method = "post" action = "/save"
  9. CodeEditor { name = "source" value = "let x = 1" language = "js" }
  10. }
  11. ```
  12. ## Files
  13. Copy `code-editor.hl` (one file; it has its own `Style`). Nothing else. Every colour is `var(--color-…, <base value>)`
  14. (the syntax colours use the palette tokens `--orange`, `--green-light`, `--yellow`, `--green-dark`): without them the code is
  15. black and the syntax greys (the base look: black, white, greys, no frames — root README "Look"); an app that declares the
  16. WorldAPI tokens (and its `--color-accent`) restyles it.
  17. ## Attributes
  18. | Attribute | Meaning |
  19. |---|---|
  20. | `name` | the field name the text posts under (default `code`) |
  21. | `value` | the start text |
  22. | `language` | `hybriel` (default), `js` (or `javascript`), `plain` (no colours) |
  23. | `spaces` | 0 (default): Tab writes a tab character; N: Tab writes N spaces |
  24. ## What it does
  25. - **Highlighting** while typing: comments (`//`, `/* */`), strings (`'` `"` `` ` ``), numbers, keywords, function names (a name
  26. before `(`), Capitalised names (types). The caret stays where it was.
  27. - **Line numbers** in a gutter that follows the number of lines (it scrolls sideways with the code).
  28. - **Tab / Shift+Tab**: at the caret a tab (or `spaces` spaces) is inserted / removed; with several lines selected every line is
  29. indented / outdented.
  30. - **Enter** keeps the indent of the line; after `(` `[` `{` it indents once more, and a closing bracket right behind the caret
  31. moves to its own line.
  32. - **Brackets and quotes** close themselves (a selection is wrapped); typing the closing character right before the same one
  33. steps over it; an apostrophe inside a word (`don't`) stays alone.
  34. - **Undo / redo**: Ctrl+Z, Ctrl+Shift+Z (or Ctrl+Y). The editor keeps its own history (snapshots of text and caret, 300 at
  35. most); typing within 300 ms is one step, Enter / Tab / a bracket / a paste are their own steps.
  36. - **Paste** is taken as plain text; the text is never treated as HTML.
  37. ## Reading the value
  38. The text is in a hidden `<input name>`, so it posts in a form. A change is announced with a bubbling DOM `input` event on that
  39. field (`e.target.name`, `e.target.value`); the demo shows it below each editor:
  40. ```
  41. form { on input(e) { emit gotCode(e) } … }
  42. on gotCode(e) { if (e.target.name == 'source') { source = e.target.value } }
  43. ```
  44. ## Not in it (custom-ide has more)
  45. Search, minimap, breadcrumbs, change bars, per-language grammars beyond the three above, read-only mode. Not tested: Firefox,
  46. Safari, touch, IME input (composition is left alone until it ends), very large files. Editing needs the page to be live
  47. (Hybriel has no mount event; the code appears when the page has loaded).

Branches

Latest commits

  • 3aca2d7fSync components from 8176eb1 with reviewed nested stylesmre
  • 87e4003dRe-vendor layouts to Hybriel set day35mre
  • d8628cfflayouts: a startup error prints its message before exit 1 (hybriel#247)mre
  • 180fd76elayouts: MdEditor from components 59704ce (text on the clipboard always pastes, a file manager copy still attaches; pipe rows; empty Table-button table; tickets#49, notes#5)mre
  • a3eda8afRe-vendor Hybriel master 7a684920 (binary 74ab3715): plugins whole, startup fault exits 1; files-upload gate 340/0mre
  • 025d5880WIP re-vendor Hybriel set-day27b (a9712e61, master f5ff97bf): plugins whole, startup fault exits 1; NOT deployable: files-upload emit refused (see .scratch/rv27-upload)mre
  • 42183a71Merge sb3-standby: layouts deploys through its standbymre
  • 408de1f2layouts: no jobs switch needed in the standbymre
  • 0b85f57elayouts: a standby container (port 45019, profile standby); deploy hands over through standby-swap.sh without a gapmre
  • 31e40b8bMerge dm3-media: range handling in the layouts media routemre
  • 856dcacbLayouts media route: read suffix ranges and ignore range lists and garbage, like the components route (the layouts copy still answered 416 for the last bytes)mre
  • ad5056eaMerge dm3-sync: components re-sync to c2834ddmre
  • 740e2abeRe-sync the components copy to c2834dd: media player fixes (state after a queue pick, cover-less audio, accessibility labels)mre
  • 7fe103bbMerge mp-player: the media player showcase pagemre
  • 7db43c4eMedia route: serve the showcase's media from committed files (storage/ is not in git)mre
  • f77b7d12Media player: re-sync components from 1c41293 (replay / forward 10 icons, play button surface on audio and video)mre
  • 40a9e69cMP: report, LOG linemre
  • 5b5dbf0fMedia player: the component from components.hybriel dd003e5 (sync-components), the showcase page /components/media-player with a queue, its media files served with ranges (lib/media.hl), theme rules (the seek bar, the queue's current item, the radii), the page in the overview listsmre
  • 9197159fTake components e54f83a: table lines and one-row desktop toolbar in the theme, Table button gates, a table in the md-editor demomre
  • e6322a44UX: report and LOG linemre