@tectra-ng/editor 0.0.1 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,111 @@
1
- # @tectra-ng/editor
1
+ # Editor
2
2
 
3
- Rich text editor for the tectra Angular UI kit. This placeholder reserves the name; install the version released together with `@tectra-ng/ui`.
3
+ ```bash
4
+ npm install @tectra-ng/editor
5
+ ```
6
+
7
+ Its own package: `tectra-ng` and `@tectra-ng/ui` do not include it, so apps without an editor do not carry the engine. It needs `@tectra-ng/ui` (and with it `core`, `themes`, `icons`) of the same version.
8
+
9
+ A rich text editor for descriptions, comments and reports. It writes clean HTML (or Quill 2 markup with `format="quill"`) and reads both, so text saved by Quill opens as it was. Toolbar presets or your own tool list, a menu over selected text, a `/` menu for blocks, links, colours, lists and checklists, tables, callouts, images (resize, drag) and video, `@` mentions, `:` emoji, Markdown shortcuts and smart typography, a character limit, drafts, a full view, an AI button and AI actions on the selection. Show saved text with `tx-editor-content` from `@tectra-ng/editor/content`.
10
+
11
+ ```html
12
+ <tx-editor [formControl]="description" placeholder="Describe the task" height="220px" />
13
+
14
+ <tx-editor toolbar="compact" [mentions]="findPeople" (mentionSelected)="notify($event)" [(html)]="comment" />
15
+
16
+ <tx-editor [toolbar]="[['bold', 'italic'], ['bulletList', 'link']]" format="quill" [maxLength]="2000" />
17
+ ```
18
+
19
+ The engine is the ProseMirror core (model, state, view, transform); everything above it — the schema, commands, keyboard, undo history, lists, Markdown shortcuts, autolinks and mentions — is part of the package. `@tectra-ng/ui` does not depend on it.
20
+
21
+ Tools: `table`, `callout`, `undo`, `redo`, `blockStyle`, `fontSize`, `bold`, `italic`, `underline`, `strike`, `code`, `subscript`, `superscript`, `textColor`, `highlight`, `bulletList`, `orderedList`, `taskList`, `outdent`, `indent`, `align`, `link`, `image`, `video`, `blockquote`, `codeBlock`, `horizontalRule`, `clearFormatting`.
22
+
23
+ ## Inputs
24
+ | Name | Description |
25
+ |---|---|
26
+ | html | Two-way: the HTML of the text; a form control works too |
27
+ | format | `html` (clean HTML) or `quill` (Quill 2 markup) for the value it writes; both are read |
28
+ | toolbar | `full`, `compact`, `minimal`, `none` or own groups of tools: `[['bold', 'italic'], ['link']]` |
29
+ | headingLevels | Heading levels in the text style menu; `full` offers 1–6, the others 1–2 |
30
+ | placeholder | Text shown while the editor is empty |
31
+ | readonly | Shows the text without editing; the toolbar is turned off |
32
+ | disabled | Turns the editor off |
33
+ | invalid | Red frame; follows the form control by default |
34
+ | height | Height of the text area, e.g. `220px`; it scrolls inside |
35
+ | minHeight | Minimum height of the text area |
36
+ | maxHeight | Maximum height; the area grows with the text until then |
37
+ | maxLength | Most characters; typing and pasting stop at the limit and the counter shows it |
38
+ | showCount | Shows the character counter without a limit |
39
+ | linkTarget | `_blank` (new tab, the default) or `_self` for new links |
40
+ | textColors | Text colour palette, `{ label, value }`; `label` may be a translation key |
41
+ | highlightColors | Highlight palette |
42
+ | imageUpload | `(file) => Promise<url>`; without it images are embedded as data URLs |
43
+ | maxImageSize | Largest image in bytes; a bigger one emits `imageRejected` |
44
+ | mentions | `(query) => items` or a Promise of them: turns on `@` mentions with a suggestion list |
45
+ | mentionTrigger | Character that starts a mention |
46
+ | selectionMenu | Shows the menu over selected text, links and tables |
47
+ | slashMenu | Typing `/` at the start of a line or after a space opens the block menu |
48
+ | emoji | Typing `:` and two letters suggests emoji |
49
+ | typography | Turns `--` into —, `->` into →, `...` into …, straight quotes into the locale's quotes; Backspace right after undoes it |
50
+ | draftKey | Keeps a draft under this key in the browser storage and restores it into an empty editor; `clearDraft()` after sending |
51
+ | aiActions | Actions for the AI button of the selection menu, `{ id, label, icon? }`; picking one emits `aiAction` |
52
+ | ai | Shows the AI button; it emits `aiRequested` |
53
+ | aiLabel | Label of the AI button |
54
+ | fullView | Two-way: the editor fills the window over a backdrop |
55
+ | fullViewButton | Shows the full view button (on with the `full` toolbar) |
56
+ | ariaLabel | Accessible name of the text area |
57
+ | ariaLabelledBy | Id of the element that names the text area |
58
+ | dt | Design tokens of this instance (`editor`); the text uses `editorContent` |
59
+ | pt | Classes and styles of the parts: `root`, `toolbar`, `tool`, `content`, `footer`, `bubble`, `suggestions` |
60
+ | ptOptions | How `pt` merges with the global pass-through |
61
+ | unstyled | Removes the tectra styles |
62
+
63
+ `focus()`, `clear()`, `clearDraft()`, `getHtml()`, `getText()` and `insertHtml(html)`; `editorView` is the ProseMirror view for own plugins and commands.
64
+
65
+ ## Outputs
66
+ | Name | Description |
67
+ |---|---|
68
+ | htmlChange | The HTML changed |
69
+ | fullViewChange | The full view was opened or closed |
70
+ | textChange | `{ html, text }` after every change |
71
+ | selectionChange | `{ from, to, empty, text }` |
72
+ | focused | The text area got focus |
73
+ | blurred | The text area lost focus |
74
+ | ready | The editor view was created |
75
+ | aiRequested | The AI button was pressed; emits the HTML |
76
+ | imageRejected | An image was not added: `{ file, reason: 'type' \| 'size', message }` |
77
+ | mentionSelected | A mention was picked from the list |
78
+ | aiAction | An AI action was picked for the selection: `{ action, text, html, replace }`; `replace` takes a string, HTML or an `AsyncIterable` of chunks that stream into the text; then Keep / Undo appear |
79
+ | draftRestored | A saved draft was put back into the editor; emits its HTML |
80
+
81
+ ## Slots
82
+ | Name | Description |
83
+ |---|---|
84
+ | txEditorToolbarEnd | Content at the end of the toolbar, before the AI and full view buttons |
85
+
86
+ ## Keyboard
87
+ | Key | Action |
88
+ |---|---|
89
+ | Ctrl / ⌘ + B, I, U | Bold, italic, underline |
90
+ | Ctrl / ⌘ + Shift + S | Strikethrough |
91
+ | Ctrl / ⌘ + E | Inline code |
92
+ | Ctrl / ⌘ + , / . | Subscript / superscript |
93
+ | Ctrl / ⌘ + K | Add or edit a link |
94
+ | Ctrl / ⌘ + Alt + 0 … 6 | Normal text, heading 1 … 6 |
95
+ | Ctrl / ⌘ + Shift + 7 / 8 / 9 | Numbered, bulleted, checklist |
96
+ | Ctrl / ⌘ + Shift + B | Quote |
97
+ | Ctrl / ⌘ + Alt + C | Code block |
98
+ | Ctrl / ⌘ + ] / [ | Indent / outdent |
99
+ | Tab / Shift + Tab | In a list: nest / lift the item; elsewhere moves focus |
100
+ | Ctrl / ⌘ + Z, Ctrl / ⌘ + Shift + Z | Undo, redo |
101
+ | Shift + Enter | Line break |
102
+ | Ctrl / ⌘ + Enter | Leave a code block |
103
+ | `#`–`######`, `-`, `1.`, `[ ]`, `>`, ```` ``` ````, `---` + space | Heading, list, checklist, quote, code block, divider |
104
+ | `**bold**`, `*italic*`, `~~strike~~`, `` `code` `` | Inline formats while typing |
105
+ | `/` | Block menu: type to filter, Up / Down, Enter |
106
+ | `:` + two letters | Emoji suggestions |
107
+ | Up / Down, Enter, Escape | In the mention, block and emoji lists: move, pick, close |
108
+ | Tab / Shift + Tab | In a table: next / previous cell; Tab in the last cell adds a row |
109
+ | Backspace | Right after a smart typography replacement: puts the typed characters back |
110
+ | Left / Right, Home / End | In the toolbar: move between the tools |
111
+ | Escape | Leaves the full view |
@@ -0,0 +1,30 @@
1
+ # Editor content
2
+
3
+ Shows saved rich text — clean HTML from `tx-editor` or Quill 2 markup — with the same typography as the editor. An own allowlist sanitizer keeps colours, alignment and indents and drops scripts, handlers and unsafe links; images open in a preview. The entry point does not load the editor engine.
4
+
5
+ ```html
6
+ <tx-editor-content [html]="comment.html" />
7
+ ```
8
+
9
+ `fromQuillHtml(html)` / `toEditorHtml(html)` turn Quill markup into clean HTML, `toQuillHtml(html)` does the opposite, `sanitizeEditorHtml(html)` cleans any HTML for display.
10
+
11
+ ## Inputs
12
+ | Name | Description |
13
+ |---|---|
14
+ | html | The saved HTML, clean or Quill |
15
+ | previewImages | Images open in a preview dialog on click |
16
+ | dt | Design tokens of this instance (`editorContent`) |
17
+ | pt | Classes and styles of the parts: `root`, `body` |
18
+ | ptOptions | How `pt` merges with the global pass-through |
19
+ | unstyled | Removes the tectra styles |
20
+
21
+ ## Outputs
22
+ | Name | Description |
23
+ |---|---|
24
+ | imageClick | An image was clicked: `{ originalEvent, src, alt }` |
25
+
26
+ ## Keyboard
27
+ | Key | Action |
28
+ |---|---|
29
+ | Tab | Moves through the links in the text |
30
+ | Escape | Closes the image preview |