gitoria

layouts

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf77b7d12f77b7d12Media player: re-sync components from 1c41293 (replay / forward 10 icons, play button surface on audio and video)mref77b7d12/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

  • 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
  • 58c2da6fUX: nav marker without bars; chat composer is one box (files-upload pick mode, showcase); comments state footer + closer reactions row; modal footer rule only for its own footer; gates for all of itmre
  • 956f107async components.hybriel 4922f9c: 44 px targets in month-view, date-picker, range-picker, pagination, modal, comments; names follow <html lang> (English default), UTC weekday fix; gate: 390 px target checks, 'edited' hit-area padding; comments showcase 'You are' is a labelled group (SY)mre
  • 49940371sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • 6f7bd392gate: the phone toolbar is two even rows (E2)mre
  • 3049c082sync components.hybriel 214c318: MdEditor on a phone, two even toolbar rows of 44 px targets, label 15 px, table head 16 px (E2)mre
  • b9a3f85fLOG: MLmre
  • 7979397creport ML-mobilemre
  • 85d2ed25gate: wordingmre
  • 98a311c0gate: 390 px checks for list rows, table word, edited tap target, code in titlesmre
  • 769b99d7theme: table cells keep a word whole, code in a title stays text-sized, 'edited' is a 44 px tap target on the phonemre
  • c36b7595list rows (notes, mail) stack their parts full width: the date no longer a one-letter column beside the titlemre
  • 02aa74aasync components.hybriel 134b4e3: MdEditor builds an editor put into the page at once, redraws a surface put in anew (F5, hybriel#211)mre
  • 268b1c87sync components.hybriel 6b0936a: the 'edited' foldable drops the theme's border and marginmre
  • c51d039fsync components.hybriel 8d79ff7: bubble hugs its content, quiet 'edited' label; gate checksmre
  • f4ad7eecsync components 9a: shared Icon (icons/icons.hl), md-editor toolbar icons + single focus ring (components f4-icons ba96735)mre