gitoria

components

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit79c77e7d79c77e7dMerge sb3-standby: components deploys through its standbymre79c77e7d/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

  • 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
  • c2834dd3Merge mr-fixes: media player state after a queue pick, Range handling, cover-less audio, accessibility labelsmre
  • 354fe3c6Media player: audio without a cover starts and shows its time (the mount tick sits on the seek bar, which every item has); the speed button names the current speed, the seek slider says its time in words; a gate page for the first render on cover-less audio and a fourth demo queue item without a covermre
  • ee4aee1eMedia player: a new queue item shows its own speed, mute, play state and time and starts when asked, also for two videos in a row; the media route reads suffix ranges and ignores range lists and garbage instead of answering 500; stronger gate checks (the 10 percent drag, the played bar, the queue tap)mre
  • 9a4f9b31Merge mp-player: media served from the committed filesmre
  • ab96e686Media route: serve the demo's media from the committed files in components/media-player (storage/ is not in git, the deploy gate found no files)mre
  • b2980734Merge mp-player: the media player (components/media-player), its demo and the media iconsmre
  • 1c41293eMediaPlayer: back / forward 10 s as replay / forward 10 icons (circular arrow with a 10), the play button keeps its surface background on audio and video, the media route's range end is a letmre
  • 9e1ab228MP: report, LOG line, STATUS entrymre
  • dd003e5dMediaPlayer: audio and video in one phone-first player (components/media-player), its demo /media-player with a queue, the media icons in components/icons, the demo's media files served with ranges (lib/media.hl), 35 gate checksmre
  • e54f83adMdEditor: text typed before the editor is built is kept (the build takes it in once, the input handler no longer writes it to the field first), tickets#35mre
  • 8c920932gate: the 11 old drop-zone checks now test the one-box pick mode (drop anywhere in the box, Choose files button inside it, no drop zone)mre
  • 626de199MdEditor: copy and cut put the selection's Markdown on the clipboard, a clipboard with HTML only pastes its text, gate checks for copy, cut and paste (components#20)mre
  • 5228126dUX: components synced from the tickets/layouts UX mission (comments: State select in the footer and button words; files-upload: one-box pick mode; modal: footer rule for its own footer). WIP: the gate's #18 pick-mode checks still expect the old drop zone (11 fail), see the UX2 reportmre
  • 0a9216fbMdEditor: a Table button in the toolbar, a typed pipe row fills the cells, tables take the page theme's look; gate checks updated for 12 toolbar buttonsmre
  • f9d405c8comments: reactions row half as far from its comment (creator 2026-10-24: 'half this distance please'); the 44 px tap targets staymre
  • 4922f9cfsessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • 0355975areports/MC-mobile.md, LOG, STATUS (MC)mre