@nldd/design-system 0.11.0 → 0.13.0
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/custom-elements.json +2726 -617
- package/dist/components/actions/button-group/button-group.d.ts +4 -3
- package/dist/components/actions/button-group/button-group.d.ts.map +1 -1
- package/dist/components/actions/button-group/button-group.js +4 -3
- package/dist/components/actions/button-group/button-group.js.map +1 -1
- package/dist/components/actions/button-group/button-group.styles.d.ts.map +1 -1
- package/dist/components/actions/button-group/button-group.styles.js +6 -6
- package/dist/components/actions/button-group/button-group.styles.js.map +1 -1
- package/dist/components/actions/menu/menu.d.ts.map +1 -1
- package/dist/components/actions/menu/menu.js +3 -0
- package/dist/components/actions/menu/menu.js.map +1 -1
- package/dist/components/components.js +21704 -19266
- package/dist/components/content/avatar/avatar.d.ts +2 -1
- package/dist/components/content/avatar/avatar.d.ts.map +1 -1
- package/dist/components/content/avatar/avatar.js +12 -1
- package/dist/components/content/avatar/avatar.js.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.d.ts +30 -2
- package/dist/components/content/avatar-group/avatar-group.d.ts.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.i18n.d.ts +1 -0
- package/dist/components/content/avatar-group/avatar-group.i18n.d.ts.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.i18n.js +1 -0
- package/dist/components/content/avatar-group/avatar-group.i18n.js.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.js +96 -7
- package/dist/components/content/avatar-group/avatar-group.js.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.styles.d.ts.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.styles.js +35 -1
- package/dist/components/content/avatar-group/avatar-group.styles.js.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.template.d.ts +1 -0
- package/dist/components/content/avatar-group/avatar-group.template.d.ts.map +1 -1
- package/dist/components/content/avatar-group/avatar-group.template.js +52 -29
- package/dist/components/content/avatar-group/avatar-group.template.js.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.d.ts +14 -1
- package/dist/components/content/code-viewer/code-viewer.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.diff.d.ts +40 -0
- package/dist/components/content/code-viewer/code-viewer.diff.d.ts.map +1 -0
- package/dist/components/content/code-viewer/code-viewer.diff.js +261 -0
- package/dist/components/content/code-viewer/code-viewer.diff.js.map +1 -0
- package/dist/components/content/code-viewer/code-viewer.i18n.d.ts +5 -0
- package/dist/components/content/code-viewer/code-viewer.i18n.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.i18n.js +9 -0
- package/dist/components/content/code-viewer/code-viewer.i18n.js.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.js +98 -6
- package/dist/components/content/code-viewer/code-viewer.js.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.styles.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.styles.js +180 -14
- package/dist/components/content/code-viewer/code-viewer.styles.js.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.template.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.template.js +5 -4
- package/dist/components/content/code-viewer/code-viewer.template.js.map +1 -1
- package/dist/components/content/icon/icon-aliases.d.ts.map +1 -1
- package/dist/components/content/icon/icon-aliases.js +32 -4
- package/dist/components/content/icon/icon-aliases.js.map +1 -1
- package/dist/components/content/icon/icon-gallery-status.d.ts.map +1 -1
- package/dist/components/content/icon/icon-gallery-status.js +19 -0
- package/dist/components/content/icon/icon-gallery-status.js.map +1 -1
- package/dist/components/content/icon/icon-registry.d.ts.map +1 -1
- package/dist/components/content/icon/icon-registry.js +19 -4
- package/dist/components/content/icon/icon-registry.js.map +1 -1
- package/dist/components/content/rich-text/rich-text.d.ts +10 -0
- package/dist/components/content/rich-text/rich-text.d.ts.map +1 -1
- package/dist/components/content/rich-text/rich-text.js +10 -0
- package/dist/components/content/rich-text/rich-text.js.map +1 -1
- package/dist/components/content/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/content/tooltip/tooltip.js +2 -0
- package/dist/components/content/tooltip/tooltip.js.map +1 -1
- package/dist/components/{dist-Bo5Jeyfn.js → dist-B5E3q-ea.js} +2 -1
- package/dist/components/{dist-DbNhCpS5.js → dist-BFw_yEMS.js} +2 -1
- package/dist/components/{dist-DnZmcpbQ.js → dist-BNLAXAyO.js} +2 -1
- package/dist/components/{dist-DkqAbJH8.js → dist-BOVSVPSz.js} +1 -1
- package/dist/components/{dist-Ch3gNAuT.js → dist-BPB3rWnd.js} +2 -1
- package/dist/components/{dist-Bud_7w5g.js → dist-BWlUmyq3.js} +34 -2869
- package/dist/components/dist-CC8oiVtm.js +366 -0
- package/dist/components/dist-COKR0tYU.js +2860 -0
- package/dist/components/{dist-CaxHkqR2.js → dist-Co-tsc9S.js} +4 -3
- package/dist/components/{dist-iC2RTM0V.js → dist-D_9ZyZ5v.js} +3 -2
- package/dist/components/{dist-BB5mlo7D.js → dist-Dn9pjiud.js} +3 -2
- package/dist/components/{dist-B2QcygzG.js → dist-Dz28se9B.js} +2 -1
- package/dist/components/{dist-CA0yDFIt.js → dist-IPm8ilWf.js} +3 -2
- package/dist/components/{icon-zNX9A6d3.js → icon-BJHKWhY5.js} +39 -8
- package/dist/components/{icon-button-Cntrg4_E.js → icon-button-DhBIq6lN.js} +75 -2
- package/dist/components/inputs/code-editor/code-editor.d.ts +4 -54
- package/dist/components/inputs/code-editor/code-editor.d.ts.map +1 -1
- package/dist/components/inputs/code-editor/code-editor.js +22 -262
- package/dist/components/inputs/code-editor/code-editor.js.map +1 -1
- package/dist/components/inputs/code-editor/code-editor.styles.d.ts.map +1 -1
- package/dist/components/inputs/code-editor/code-editor.styles.js +43 -6
- package/dist/components/inputs/code-editor/code-editor.styles.js.map +1 -1
- package/dist/components/inputs/date-picker/date-picker.d.ts +2 -2
- package/dist/components/inputs/date-picker/date-picker.i18n.d.ts +1 -1
- package/dist/components/inputs/date-picker/date-picker.i18n.js +1 -1
- package/dist/components/inputs/date-picker/date-picker.i18n.js.map +1 -1
- package/dist/components/inputs/date-picker/date-picker.template.js +1 -1
- package/dist/components/inputs/date-picker/date-picker.template.js.map +1 -1
- package/dist/components/inputs/file-field/file-field.d.ts +86 -10
- package/dist/components/inputs/file-field/file-field.d.ts.map +1 -1
- package/dist/components/inputs/file-field/file-field.drop.d.ts +34 -0
- package/dist/components/inputs/file-field/file-field.drop.d.ts.map +1 -0
- package/dist/components/inputs/file-field/file-field.drop.js +176 -0
- package/dist/components/inputs/file-field/file-field.drop.js.map +1 -0
- package/dist/components/inputs/file-field/file-field.i18n.d.ts +20 -1
- package/dist/components/inputs/file-field/file-field.i18n.d.ts.map +1 -1
- package/dist/components/inputs/file-field/file-field.i18n.js +20 -1
- package/dist/components/inputs/file-field/file-field.i18n.js.map +1 -1
- package/dist/components/inputs/file-field/file-field.js +283 -15
- package/dist/components/inputs/file-field/file-field.js.map +1 -1
- package/dist/components/inputs/file-field/file-field.styles.d.ts.map +1 -1
- package/dist/components/inputs/file-field/file-field.styles.js +245 -10
- package/dist/components/inputs/file-field/file-field.styles.js.map +1 -1
- package/dist/components/inputs/file-field/file-field.template.d.ts +1 -0
- package/dist/components/inputs/file-field/file-field.template.d.ts.map +1 -1
- package/dist/components/inputs/file-field/file-field.template.js +167 -28
- package/dist/components/inputs/file-field/file-field.template.js.map +1 -1
- package/dist/components/inputs/file-field/file-field.truncate.d.ts +22 -0
- package/dist/components/inputs/file-field/file-field.truncate.d.ts.map +1 -0
- package/dist/components/inputs/file-field/file-field.truncate.js +62 -0
- package/dist/components/inputs/file-field/file-field.truncate.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.js +9 -7
- package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.annotations.js +1 -1
- package/dist/components/inputs/text-editor/text-editor.annotations.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.clipboard.d.ts +16 -0
- package/dist/components/inputs/text-editor/text-editor.clipboard.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.clipboard.js +50 -0
- package/dist/components/inputs/text-editor/text-editor.clipboard.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.code-copy.d.ts +10 -0
- package/dist/components/inputs/text-editor/text-editor.code-copy.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.code-copy.js +141 -0
- package/dist/components/inputs/text-editor/text-editor.code-copy.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.commands.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.commands.js +31 -58
- package/dist/components/inputs/text-editor/text-editor.commands.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.d.ts +17 -64
- package/dist/components/inputs/text-editor/text-editor.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.drag.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.drag.js +2 -1
- package/dist/components/inputs/text-editor/text-editor.drag.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.focus-selection.d.ts +3 -0
- package/dist/components/inputs/text-editor/text-editor.focus-selection.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.focus-selection.js +55 -0
- package/dist/components/inputs/text-editor/text-editor.focus-selection.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.hidden-syntax.d.ts +6 -0
- package/dist/components/inputs/text-editor/text-editor.hidden-syntax.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.hidden-syntax.js +305 -0
- package/dist/components/inputs/text-editor/text-editor.hidden-syntax.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.i18n.d.ts +5 -0
- package/dist/components/inputs/text-editor/text-editor.i18n.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.i18n.js +7 -0
- package/dist/components/inputs/text-editor/text-editor.i18n.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.js +126 -315
- package/dist/components/inputs/text-editor/text-editor.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.keymap.d.ts +6 -0
- package/dist/components/inputs/text-editor/text-editor.keymap.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.keymap.js +38 -0
- package/dist/components/inputs/text-editor/text-editor.keymap.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.links.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.links.js +11 -9
- package/dist/components/inputs/text-editor/text-editor.links.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.markdown.d.ts +1 -17
- package/dist/components/inputs/text-editor/text-editor.markdown.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.markdown.js +32 -188
- package/dist/components/inputs/text-editor/text-editor.markdown.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.mention.d.ts +52 -0
- package/dist/components/inputs/text-editor/text-editor.mention.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.mention.js +186 -0
- package/dist/components/inputs/text-editor/text-editor.mention.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.mentions.d.ts +0 -16
- package/dist/components/inputs/text-editor/text-editor.mentions.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.mentions.js +1 -41
- package/dist/components/inputs/text-editor/text-editor.mentions.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.selection.d.ts +13 -0
- package/dist/components/inputs/text-editor/text-editor.selection.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.selection.js +72 -0
- package/dist/components/inputs/text-editor/text-editor.selection.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.spellcheck.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.spellcheck.js +4 -6
- package/dist/components/inputs/text-editor/text-editor.spellcheck.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.styles.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.styles.js +301 -60
- package/dist/components/inputs/text-editor/text-editor.styles.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.syntax.d.ts +22 -0
- package/dist/components/inputs/text-editor/text-editor.syntax.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.syntax.js +44 -0
- package/dist/components/inputs/text-editor/text-editor.syntax.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.tasks.d.ts +17 -0
- package/dist/components/inputs/text-editor/text-editor.tasks.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.tasks.js +109 -0
- package/dist/components/inputs/text-editor/text-editor.tasks.js.map +1 -0
- package/dist/components/layout/page-sections/hero/hero-corner.styles.d.ts.map +1 -1
- package/dist/components/layout/page-sections/hero/hero-corner.styles.js +61 -0
- package/dist/components/layout/page-sections/hero/hero-corner.styles.js.map +1 -1
- package/dist/components/layout/page-sections/hero/hero.d.ts +1 -1
- package/dist/components/layout/page-sections/hero/hero.js +1 -1
- package/dist/components/layout/popover/popover.d.ts +6 -0
- package/dist/components/layout/popover/popover.d.ts.map +1 -1
- package/dist/components/layout/popover/popover.js +16 -0
- package/dist/components/layout/popover/popover.js.map +1 -1
- package/dist/components/layout/popover/popover.styles.d.ts.map +1 -1
- package/dist/components/layout/popover/popover.styles.js +13 -0
- package/dist/components/layout/popover/popover.styles.js.map +1 -1
- package/dist/components/navigation/document-tab-bar/document-tab-bar.d.ts.map +1 -1
- package/dist/components/navigation/document-tab-bar/document-tab-bar.js +5 -0
- package/dist/components/navigation/document-tab-bar/document-tab-bar.js.map +1 -1
- package/dist/components/navigation/menu-bar/menu-bar.d.ts.map +1 -1
- package/dist/components/navigation/menu-bar/menu-bar.js +2 -0
- package/dist/components/navigation/menu-bar/menu-bar.js.map +1 -1
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts.map +1 -1
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js +3 -0
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js.map +1 -1
- package/dist/components/status-and-feedback/banner/banner.d.ts +1 -1
- package/dist/components/status-and-feedback/banner/banner.js +2 -2
- package/dist/components/status-and-feedback/banner/banner.js.map +1 -1
- package/dist/components/status-and-feedback/notification/notification.d.ts +3 -2
- package/dist/components/status-and-feedback/notification/notification.d.ts.map +1 -1
- package/dist/components/status-and-feedback/notification/notification.js +9 -4
- package/dist/components/status-and-feedback/notification/notification.js.map +1 -1
- package/dist/components/status-and-feedback/notification/notification.styles.d.ts.map +1 -1
- package/dist/components/status-and-feedback/notification/notification.styles.js +18 -0
- package/dist/components/status-and-feedback/notification/notification.styles.js.map +1 -1
- package/dist/components/status-and-feedback/notification/notifications-area.d.ts.map +1 -1
- package/dist/components/status-and-feedback/notification/notifications-area.js +14 -0
- package/dist/components/status-and-feedback/notification/notifications-area.js.map +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.i18n.d.ts +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.i18n.js +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.i18n.js.map +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.js +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.js.map +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.i18n.d.ts +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.i18n.js +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.i18n.js.map +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.js +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.js.map +1 -1
- package/dist/css/rich-text.css +61 -1
- package/dist/css/themes/donkergeel.css +12 -3
- package/dist/css/themes/geel.css +12 -3
- package/dist/css/themes.css +24 -6
- package/dist/css/variables.css +16 -10
- package/dist/nldd.min.js +2217 -1329
- package/dist/translations/en-US.d.ts.map +1 -1
- package/dist/translations/en-US.js +34 -4
- package/dist/translations/en-US.js.map +1 -1
- package/dist/translations/fy.d.ts.map +1 -1
- package/dist/translations/fy.js +29 -4
- package/dist/translations/fy.js.map +1 -1
- package/dist/translations/nl.generated.d.ts +34 -4
- package/dist/translations/nl.generated.d.ts.map +1 -1
- package/dist/translations/pap-AW.d.ts.map +1 -1
- package/dist/translations/pap-AW.js +29 -4
- package/dist/translations/pap-AW.js.map +1 -1
- package/dist/translations/pap-CW.d.ts.map +1 -1
- package/dist/translations/pap-CW.js +29 -4
- package/dist/translations/pap-CW.js.map +1 -1
- package/dist/types/vue.d.ts +43 -39
- package/dist/utilities/carried-context.d.ts +20 -0
- package/dist/utilities/carried-context.d.ts.map +1 -0
- package/dist/utilities/carried-context.js +76 -0
- package/dist/utilities/carried-context.js.map +1 -0
- package/dist/utilities/codemirror/codemirror-input.d.ts +90 -0
- package/dist/utilities/codemirror/codemirror-input.d.ts.map +1 -0
- package/dist/utilities/codemirror/codemirror-input.js +250 -0
- package/dist/utilities/codemirror/codemirror-input.js.map +1 -0
- package/dist/utilities/codemirror/languages.d.ts +5 -1
- package/dist/utilities/codemirror/languages.d.ts.map +1 -1
- package/dist/utilities/codemirror/languages.js +21 -1
- package/dist/utilities/codemirror/languages.js.map +1 -1
- package/dist/utilities/dismiss-from-title-bar.d.ts +1 -1
- package/dist/utilities/dismiss-from-title-bar.js +1 -1
- package/package.json +2 -1
|
@@ -24,7 +24,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
24
24
|
* setHeading/setList for picker-style "set" semantics), reads the active formats
|
|
25
25
|
* with getState(), listens to the nldd-text-editor-state event to render toggle
|
|
26
26
|
* states, and forwards padding clicks with focusFromPoint(). Cmd/Ctrl+B/I/E/K are
|
|
27
|
-
* bound out of the box.
|
|
27
|
+
* bound out of the box.
|
|
28
|
+
*
|
|
29
|
+
* With `syntax="hidden"` a task item (`- [ ]`, `- [x]`) reads as a box in the
|
|
30
|
+
* place of its bullet, and like every other mark shows its markdown on the line
|
|
31
|
+
* the caret is on. A click on the box checks or unchecks it without moving the
|
|
32
|
+
* caret. Cmd/Ctrl+Enter does the same for the tasks on the lines of the
|
|
33
|
+
* selection, in both syntax modes. The box is no tab stop: Tab leaves the
|
|
34
|
+
* editor. A screen reader reads "Taak, open" or "Taak, afgerond" in its place.
|
|
35
|
+
*
|
|
36
|
+
* A code block that names its language after the backticks is highlighted in
|
|
37
|
+
* it, as in nldd-code-viewer; the grammar loads with the first such block. Its
|
|
38
|
+
* opening line is the head of the block, with a "Kopieer" button at the right
|
|
39
|
+
* edge that copies the code without its fences and says "Gekopieerd" or
|
|
40
|
+
* "Kopiëren mislukt", as the code viewer does. In an editable editor the button
|
|
41
|
+
* is no tab stop (select and copy is the keyboard route); read-only or disabled
|
|
42
|
+
* it can be focused. Without a secure context there is no button. Commands keep focus on the editor. An inline toggle wraps
|
|
28
43
|
* the selected text (whitespace at its edges stays outside the markers), unwraps
|
|
29
44
|
* a run the caret is in, and with the caret at the very end of a run steps out
|
|
30
45
|
* of it. Bold that a typed space has broken (`**woord **`) keeps its styling
|
|
@@ -33,8 +48,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
33
48
|
* text) writes at the same clean offsets getSelection() reads. An @-mention typeahead
|
|
34
49
|
* (mentionSource) collapses to an atomic token, further typeahead lists on their
|
|
35
50
|
* own trigger (typeaheads) write what you tell them to, and a W3C-style annotation overlay
|
|
36
|
-
* (annotations) marks ranges with a
|
|
37
|
-
*
|
|
51
|
+
* (annotations) marks ranges with a light tint and a count badge without touching
|
|
52
|
+
* the underlying text.
|
|
53
|
+
*
|
|
54
|
+
* To show the value, render the markdown into nldd-rich-text, which uses the
|
|
55
|
+
* same type, bold and code as the editor. A mention is stored as
|
|
56
|
+
* `[@Name](user:id)`: turn it into `<a href="…" data-mention>Name</a>` (or a
|
|
57
|
+
* `span` when there is no page for the person), without the `@`. A link reads
|
|
58
|
+
* as the same token there; a span keeps the color and the icon without the tint.
|
|
38
59
|
*
|
|
39
60
|
* @element nldd-text-editor
|
|
40
61
|
*
|
|
@@ -50,6 +71,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
50
71
|
* @attr {number} rows - Minimum visible rows (the floor in every resize mode). Default: 6.
|
|
51
72
|
* @attr {string} resize - 'none' (fixed) | 'vertical' (drag) | 'auto' (grow, default)
|
|
52
73
|
* @attr {string} appearance - 'simple' (default, bare) | 'input-field' (framed surface)
|
|
74
|
+
* @attr {string} syntax - 'visible' (default): every formatting mark stays in view, dimmed, a bullet as the character you typed (`-`, `*` or `+`). 'hidden': the marks of bold, italic, strikethrough, inline code, links and the `#` of a heading are hidden and come back where the caret or the selection touches that construct, so the text reads closer to the result while what you edit is still the markdown. A bullet reads as a dot, and shows its character on the line the caret is on. A quote reads as a line on the left; with the caret anywhere in it, its `>` marks show instead, in the same place. A `---` line reads as a divider until the caret is on it, and a code block loses its closing ``` line until the caret is in it, since its own tint and edge already say what it is. Its opening line stays as the head of the block, with only the backticks hidden: the language as a label on the left, the copy button on the right. The numbers of a numbered list stay, in the color of the text: they are content. Read-only and disabled hide every mark, which makes a clean read view. The value is plain markdown either way.
|
|
53
75
|
* @attr {string} accessible-label - Accessible label forwarded to the editor. Set automatically by nldd-form-field.
|
|
54
76
|
*
|
|
55
77
|
* @prop {MentionSource} mentionSource - Consumer-supplied @-mention candidate source (property only). Without it, @-typeahead is inert.
|
|
@@ -58,7 +80,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
58
80
|
* @prop {Typeahead[]} typeaheads - Your own typeahead lists next to the @-mention (property only): each a trigger character (`#`, `:`, `/`), a `source` that returns candidates for the text typed after it, an optional `query` (a regular expression for what may follow the trigger, such as a space in a full name), an optional `emptyText` (what to say when there are no candidates, instead of the translated default) and an optional `insert` that decides what a choice writes (by default the trigger, the text and a space). Lists on one trigger are merged in order. A candidate is `{ id, text, supportingText? }` and can carry an `avatar` (its row then takes two lines, the supporting text under the text), an `icon` or a `symbol` for its row.
|
|
59
81
|
* @attr {boolean} annotatable - Enable the annotation overlay (off by default). Annotations only render when this is set.
|
|
60
82
|
* @prop {Annotation[]} annotations - Consumer-supplied annotation overlay (property only). Anchored by offset and mapped through edits; the text stays clean. Requires `annotatable`. Assign a NEW array to apply changes (Lit dirty-checks by identity, so in-place mutation like `.push()` won't re-render): `editor.annotations = [...editor.annotations, next]`.
|
|
61
|
-
* @attr {object} translations - Override the editor's assistive-tech strings (the open-in-new-tab link badge
|
|
83
|
+
* @attr {object} translations - Override the editor's assistive-tech strings (the open-in-new-tab link badge, the annotation count badge, the label of a task's box and the copy button of a code block). Unset keys fall back to Dutch.
|
|
62
84
|
* @attr {boolean} invalid - Marks the control as invalid. Announced with aria-invalid; nothing is drawn for it.
|
|
63
85
|
*
|
|
64
86
|
* @fires input - When the content changes (detail: { value })
|
|
@@ -69,52 +91,46 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
69
91
|
* @fires nldd-text-editor-annotation-click - When an annotation's count badge is clicked (detail: { ids: string[], rect: DOMRect }); rect is the badge's viewport box so a consumer can anchor its own note UI to it
|
|
70
92
|
*/
|
|
71
93
|
import { relabel } from './text-editor.labels.js';
|
|
72
|
-
import { LitElement } from 'lit';
|
|
73
94
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
74
|
-
import { FormAssociated } from '../../../utilities/form-associated-mixin.js';
|
|
75
95
|
import { reflectNonDefault } from '../../../utilities/reflect-non-default.js';
|
|
76
|
-
import { EditorView,
|
|
77
|
-
import { Compartment,
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
96
|
+
import { EditorView, drawSelection, dropCursor } from '@codemirror/view';
|
|
97
|
+
import { Compartment, Prec, Transaction } from '@codemirror/state';
|
|
98
|
+
import { history, undo as cmUndo, redo as cmRedo, undoDepth, redoDepth } from '@codemirror/commands';
|
|
99
|
+
import { NLDDCodeMirrorInput } from '../../../utilities/codemirror/codemirror-input.js';
|
|
80
100
|
import { nlddCodeMirrorTheme } from '../../../utilities/codemirror/theme.js';
|
|
81
|
-
import { markdownEditing
|
|
82
|
-
import {
|
|
101
|
+
import { markdownEditing } from './text-editor.markdown.js';
|
|
102
|
+
import { mentionInsert, mentionToken, mentionRangeAt } from './text-editor.mention.js';
|
|
103
|
+
import { typeaheads as typeaheadExtension, } from './text-editor.mentions.js';
|
|
83
104
|
import { repairHeldEmphasis } from './text-editor.emphasis.js';
|
|
84
|
-
import { spellcheck
|
|
85
|
-
import { annotations as annotationExtension, setAnnotations,
|
|
105
|
+
import { spellcheck } from './text-editor.spellcheck.js';
|
|
106
|
+
import { annotations as annotationExtension, setAnnotations, currentAnnotations } from './text-editor.annotations.js';
|
|
107
|
+
import { AnnotationClipboard } from './text-editor.clipboard.js';
|
|
108
|
+
import { textEditorKeymap } from './text-editor.keymap.js';
|
|
86
109
|
import { orderedListRenumber } from './text-editor.ordered-list.js';
|
|
87
110
|
import { dragToMove, dragMovePlugin } from './text-editor.drag.js';
|
|
88
111
|
import { linkOpenBadge } from './text-editor.links.js';
|
|
89
112
|
import { stableCursor } from './text-editor.cursor.js';
|
|
90
|
-
import {
|
|
113
|
+
import { focusSelectionGuard } from './text-editor.focus-selection.js';
|
|
114
|
+
import { hiddenSyntax } from './text-editor.hidden-syntax.js';
|
|
115
|
+
import { lineHighSelection } from './text-editor.selection.js';
|
|
116
|
+
import { toggleInlineWrap, indentListItems as cmIndentListItems, outdentListItems as cmOutdentListItems, canIndentListItem as cmCanIndent, canOutdentListItem as cmCanOutdent, toggleHeading as cmToggleHeading, setHeading as cmSetHeading, toggleBulletList as cmToggleBulletList, toggleTaskList as cmToggleTaskList, setList as cmSetList, toggleQuote as cmToggleQuote, toggleLink as cmToggleLink, toggleCodeBlock as cmToggleCodeBlock, readActiveFormats, EMPTY_FORMATS, } from './text-editor.commands.js';
|
|
91
117
|
import { textEditorStyles } from './text-editor.styles.js';
|
|
92
118
|
import { textEditorTemplate } from './text-editor.template.js';
|
|
93
119
|
import { stripSentinels, docToClean, cleanToDoc, sentinelPositions } from './text-editor.annotation-sentinels.js';
|
|
94
120
|
import { nlddTextEditorTranslations } from './text-editor.i18n.js';
|
|
95
|
-
import { DescribedBy } from '../../../utilities/described-by-mixin.js';
|
|
96
121
|
import { translate } from '../../../utilities/translations.js';
|
|
122
|
+
import { tasks } from './text-editor.tasks.js';
|
|
123
|
+
import { codeCopy } from './text-editor.code-copy.js';
|
|
97
124
|
export { DEFAULT_TYPEAHEAD_QUERY } from './text-editor.mentions.js';
|
|
98
|
-
let NLDDTextEditor = class NLDDTextEditor extends
|
|
125
|
+
let NLDDTextEditor = class NLDDTextEditor extends NLDDCodeMirrorInput {
|
|
99
126
|
constructor() {
|
|
100
127
|
super(...arguments);
|
|
101
|
-
this._initialValue = '';
|
|
102
|
-
this._valueAtFocus = '';
|
|
103
|
-
this._accessibleLabelWarned = false;
|
|
104
|
-
this.value = '';
|
|
105
|
-
this.inputId = '';
|
|
106
|
-
this.placeholder = '';
|
|
107
|
-
this.disabled = false;
|
|
108
|
-
this.name = '';
|
|
109
|
-
this.readonly = false;
|
|
110
|
-
this.required = false;
|
|
111
128
|
/** Turns spellchecking off. On by default, without code, URLs and mentions. */
|
|
112
129
|
this.noSpellcheck = false;
|
|
113
130
|
this.wrap = true;
|
|
114
|
-
this.rows = 6;
|
|
115
131
|
this.resize = 'auto';
|
|
116
132
|
this.appearance = 'simple';
|
|
117
|
-
this.
|
|
133
|
+
this.syntax = 'visible';
|
|
118
134
|
/** Your own typeahead lists next to the @-mention, each on its own trigger
|
|
119
135
|
* character. Property only. Read on every keystroke, so a new array takes
|
|
120
136
|
* effect at once. */
|
|
@@ -152,42 +168,20 @@ let NLDDTextEditor = class NLDDTextEditor extends DescribedBy(FormAssociated(NLD
|
|
|
152
168
|
* open-in-new-tab link badge and the annotation count badge). Unset keys fall
|
|
153
169
|
* back to Dutch. */
|
|
154
170
|
this.translations = {};
|
|
155
|
-
this.
|
|
171
|
+
this.rowsProperty = '--_text-editor-rows';
|
|
156
172
|
this._wrapCompartment = new Compartment();
|
|
157
|
-
this._placeholderCompartment = new Compartment();
|
|
158
|
-
this._attrsCompartment = new Compartment();
|
|
159
173
|
this._spellcheckCompartment = new Compartment();
|
|
160
174
|
this._historyCompartment = new Compartment();
|
|
161
|
-
|
|
162
|
-
* Marks the control as invalid.
|
|
163
|
-
*
|
|
164
|
-
* Announced and not drawn. What is wrong belongs in an
|
|
165
|
-
* nldd-validation-list, in words: a red ring around a single
|
|
166
|
-
* checkbox or radio would say the option is wrong, while it is the question
|
|
167
|
-
* that is unanswered. `aria-invalid` still goes on the control, because
|
|
168
|
-
* choosing not to show something is not a reason to keep quiet about it.
|
|
169
|
-
*/
|
|
170
|
-
this.invalid = false;
|
|
175
|
+
this._syntaxCompartment = new Compartment();
|
|
171
176
|
this._labels = null;
|
|
172
|
-
/**
|
|
173
|
-
|
|
174
|
-
this._cutBuffer = null;
|
|
177
|
+
/** Carries the annotations of a cut along to a paste of the same text. */
|
|
178
|
+
this._clipboard = new AnnotationClipboard();
|
|
175
179
|
/** The last state handed out, to keep from repeating it. The event drives a
|
|
176
180
|
* toolbar's toggles, and moving the caret within one paragraph leaves every
|
|
177
181
|
* one of them where it was: a consumer would re-render its whole bar on every
|
|
178
182
|
* arrow key for nothing. */
|
|
179
183
|
this._lastState = null;
|
|
180
184
|
/* # Internals */
|
|
181
|
-
this._onScrollerPointerDown = (event) => {
|
|
182
|
-
if (event.target !== this.view?.scrollDOM)
|
|
183
|
-
return;
|
|
184
|
-
// No caret to move on a read-only/disabled view — leave the press alone, like
|
|
185
|
-
// the drag path (which early-returns on state.readOnly).
|
|
186
|
-
if (this.view.state.readOnly)
|
|
187
|
-
return;
|
|
188
|
-
this.focusFromPoint(event.clientX, event.clientY);
|
|
189
|
-
event.preventDefault();
|
|
190
|
-
};
|
|
191
185
|
this._onMentionPointerDown = (event) => {
|
|
192
186
|
const token = event.target?.closest?.('.cm-md-mention-token');
|
|
193
187
|
if (!token || !this.view)
|
|
@@ -244,6 +238,9 @@ let NLDDTextEditor = class NLDDTextEditor extends DescribedBy(FormAssociated(NLD
|
|
|
244
238
|
'components.text-editor.annotation-count-label',
|
|
245
239
|
'components.text-editor.annotation-singular-lowercase',
|
|
246
240
|
'components.text-editor.annotation-plural-lowercase',
|
|
241
|
+
'components.text-editor.task-open-label',
|
|
242
|
+
'components.text-editor.task-done-label',
|
|
243
|
+
'components.text-editor.code-copy-action',
|
|
247
244
|
].map((key) => this._t(key)).join('\n');
|
|
248
245
|
}
|
|
249
246
|
buildExtensions() {
|
|
@@ -269,62 +266,40 @@ let NLDDTextEditor = class NLDDTextEditor extends DescribedBy(FormAssociated(NLD
|
|
|
269
266
|
// Prec.highest so the badge nests inside a heading/bold run and scales with
|
|
270
267
|
// it, like the mention and annotation, instead of staying at the base size.
|
|
271
268
|
Prec.highest(linkOpenBadge((url) => this._t('components.text-editor.open-in-new-tab-label', { url }))),
|
|
269
|
+
// A copy button on the head of each code block. See text-editor.code-copy.ts.
|
|
270
|
+
codeCopy({
|
|
271
|
+
copy: () => this._t('components.text-editor.code-copy-action'),
|
|
272
|
+
success: () => this._t('components.text-editor.code-copy-success-text'),
|
|
273
|
+
failure: () => this._t('components.text-editor.code-copy-failure-text'),
|
|
274
|
+
}),
|
|
275
|
+
// Checking a task by click and Cmd/Ctrl+Enter. See text-editor.tasks.ts.
|
|
276
|
+
tasks({
|
|
277
|
+
open: () => this._t('components.text-editor.task-open-label'),
|
|
278
|
+
done: () => this._t('components.text-editor.task-done-label'),
|
|
279
|
+
}),
|
|
272
280
|
this._historyCompartment.of(history()),
|
|
273
281
|
drawSelection(),
|
|
282
|
+
// As tall as the line, like the tokens. See text-editor.selection.ts.
|
|
283
|
+
lineHighSelection,
|
|
274
284
|
// Draws the caret in drawSelection's place, on a side that does not depend on
|
|
275
285
|
// the direction it arrived from unless that direction means something (a
|
|
276
286
|
// widget, a line wrap). See text-editor.cursor.ts.
|
|
277
287
|
stableCursor,
|
|
288
|
+
// Safari can stretch the selection to the start when focus comes back
|
|
289
|
+
// from a toolbar. See text-editor.focus-selection.ts.
|
|
290
|
+
focusSelectionGuard(),
|
|
278
291
|
dropCursor(),
|
|
279
292
|
dragToMove,
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
// marker is backspaced. Falls through (returns false) off a list marker.
|
|
283
|
-
Prec.highest(keymap.of([{ key: 'Backspace', run: clearListMarkerBackward }])),
|
|
284
|
-
keymap.of([
|
|
285
|
-
{ key: 'Mod-b', run: (view) => { toggleInlineWrap(view, '**', 'StrongEmphasis'); return true; } },
|
|
286
|
-
{ key: 'Mod-i', run: (view) => { toggleInlineWrap(view, '*', 'Emphasis'); return true; } },
|
|
287
|
-
{ key: 'Mod-e', run: (view) => { toggleInlineWrap(view, '`', 'InlineCode'); return true; } },
|
|
288
|
-
{ key: 'Mod-k', run: (view) => { cmToggleLink(view); return true; } },
|
|
289
|
-
// A mention deletes in two steps: the first Backspace/Delete next to it
|
|
290
|
-
// selects the whole token, the second removes it.
|
|
291
|
-
{ key: 'Backspace', run: (view) => this._selectMentionBeforeDelete(view, -1) },
|
|
292
|
-
{ key: 'Delete', run: (view) => this._selectMentionBeforeDelete(view, 1) },
|
|
293
|
-
// Cmd/Ctrl+] and +[ nest and un-nest list items. defaultKeymap binds them
|
|
294
|
-
// to indentMore/indentLess, whose four-space indent turns plain text into
|
|
295
|
-
// an indented code block. Consumed here in every case: off a list item
|
|
296
|
-
// they do nothing, which beats a code block nobody asked for.
|
|
297
|
-
{ key: 'Mod-]', run: (view) => { cmIndentListItems(view); return true; } },
|
|
298
|
-
{ key: 'Mod-[', run: (view) => { cmOutdentListItems(view); return true; } },
|
|
299
|
-
// The browser deletes where the editor has nothing to add, so the
|
|
300
|
-
// spelling marks on the line stay (see leaveDeletionToBrowser).
|
|
301
|
-
{ key: 'Backspace', run: (view) => !leaveDeletionToBrowser(view, 'Backspace') && deleteCharBackward(view), shift: deleteCharBackward },
|
|
302
|
-
{ key: 'Delete', run: (view) => !leaveDeletionToBrowser(view, 'Delete') && deleteCharForward(view) },
|
|
303
|
-
...defaultKeymap.filter((binding) => binding.key !== 'Backspace' && binding.key !== 'Delete'),
|
|
304
|
-
...historyKeymap,
|
|
305
|
-
]),
|
|
306
|
-
this._placeholderCompartment.of(this._placeholderExtension()),
|
|
293
|
+
textEditorKeymap,
|
|
294
|
+
...this.inputExtensions(),
|
|
307
295
|
this._wrapCompartment.of(this.wrap ? EditorView.lineWrapping : []),
|
|
308
|
-
this._editableCompartment.of(this._editableExtension()),
|
|
309
|
-
this._attrsCompartment.of(this._attrsExtension()),
|
|
310
296
|
this._spellcheckCompartment.of(this.noSpellcheck ? [] : spellcheck()),
|
|
297
|
+
this._syntaxCompartment.of(this.syntax === 'hidden' ? hiddenSyntax() : []),
|
|
311
298
|
EditorView.updateListener.of((u) => {
|
|
312
|
-
if (u.docChanged)
|
|
313
|
-
this._onDocChanged();
|
|
314
299
|
if (u.docChanged || u.selectionSet)
|
|
315
300
|
this._emitState();
|
|
316
301
|
}),
|
|
317
302
|
EditorView.domEventHandlers({
|
|
318
|
-
focus: () => {
|
|
319
|
-
this._valueAtFocus = this.value;
|
|
320
|
-
},
|
|
321
|
-
blur: (_event, view) => {
|
|
322
|
-
// An emphasis held together while it was being typed is closed
|
|
323
|
-
// properly first, so the committed value renders the way it looked.
|
|
324
|
-
repairHeldEmphasis(view);
|
|
325
|
-
if (this.value !== this._valueAtFocus)
|
|
326
|
-
this._emitChange();
|
|
327
|
-
},
|
|
328
303
|
// Triple-click selects the whole paragraph (the doc line), like macOS.
|
|
329
304
|
// CM's own triple-click stops at the visual line, which under wrapping is
|
|
330
305
|
// just one wrapped row.
|
|
@@ -342,35 +317,24 @@ let NLDDTextEditor = class NLDDTextEditor extends DescribedBy(FormAssociated(NLD
|
|
|
342
317
|
// Native Cmd/Ctrl+X/C/V go through these DOM events, not the toolbar's
|
|
343
318
|
// methods, so mirror the annotation-carrying logic here too.
|
|
344
319
|
cut: (_event, view) => {
|
|
345
|
-
|
|
346
|
-
this._cutBuffer = from === to
|
|
347
|
-
? null
|
|
348
|
-
: { text: stripSentinels(view.state.sliceDoc(from, to)), anns: this._annotationsInSelection() };
|
|
320
|
+
this._clipboard.rememberCut(view);
|
|
349
321
|
return false; // let CodeMirror perform the actual cut (clipboard + delete)
|
|
350
322
|
},
|
|
351
323
|
copy: () => {
|
|
352
|
-
this.
|
|
324
|
+
this._clipboard.forget();
|
|
353
325
|
return false;
|
|
354
326
|
},
|
|
355
|
-
paste: (event) => {
|
|
327
|
+
paste: (event, view) => {
|
|
356
328
|
const raw = event.clipboardData?.getData('text/plain');
|
|
357
329
|
if (raw === undefined)
|
|
358
330
|
return false; // no clipboard data — let CodeMirror handle it
|
|
359
|
-
this.
|
|
331
|
+
this._clipboard.paste(view, raw);
|
|
360
332
|
event.preventDefault();
|
|
361
333
|
return true;
|
|
362
334
|
},
|
|
363
335
|
}),
|
|
364
336
|
];
|
|
365
337
|
}
|
|
366
|
-
_editableExtension() {
|
|
367
|
-
const editable = !this.disabled;
|
|
368
|
-
const readOnly = this.disabled || this.readonly;
|
|
369
|
-
return [EditorView.editable.of(editable), EditorState.readOnly.of(readOnly)];
|
|
370
|
-
}
|
|
371
|
-
_placeholderExtension() {
|
|
372
|
-
return this.placeholder ? cmPlaceholder(this.placeholder) : [];
|
|
373
|
-
}
|
|
374
338
|
/**
|
|
375
339
|
* A browser checks text when it changes, not when `spellcheck` does: turned
|
|
376
340
|
* off, the red underlines stayed until the text under them was edited, and
|
|
@@ -387,34 +351,30 @@ let NLDDTextEditor = class NLDDTextEditor extends DescribedBy(FormAssociated(NLD
|
|
|
387
351
|
if (focused)
|
|
388
352
|
view.focus();
|
|
389
353
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
this.mountEditor(stripSentinels(this.value));
|
|
409
|
-
this.onEditorMounted();
|
|
354
|
+
// Autocorrect and autocapitalize follow the user's own settings, as on an
|
|
355
|
+
// <input> or a <textarea>, also with no-spellcheck: CodeMirror's "off" is
|
|
356
|
+
// not what a text field does. And with them off, CodeMirror turns the
|
|
357
|
+
// period macOS puts after a double space back into a space by writing the
|
|
358
|
+
// line anew, which cost the spelling marks on it.
|
|
359
|
+
contentAttributes() {
|
|
360
|
+
return { autocorrect: 'on', autocapitalize: 'sentences' };
|
|
361
|
+
}
|
|
362
|
+
/** The document carries annotation sentinels; the value never does. A value
|
|
363
|
+
* that carries one (text round-tripped through another editor) hands it
|
|
364
|
+
* back stripped, too. */
|
|
365
|
+
docToValue(doc) {
|
|
366
|
+
return stripSentinels(doc);
|
|
367
|
+
}
|
|
368
|
+
/** An emphasis held together while it was being typed is closed properly
|
|
369
|
+
* first, so the committed value renders the way it looked. */
|
|
370
|
+
beforeChangeCheck(view) {
|
|
371
|
+
repairHeldEmphasis(view);
|
|
410
372
|
}
|
|
411
373
|
/* Runs on the initial mount and on every re-mount after a detach/reattach
|
|
412
374
|
* (e.g. Vue <KeepAlive>): the view — with its scroller and content DOM — is
|
|
413
375
|
* rebuilt, so the click forwarders and annotation state must be (re)applied. */
|
|
414
376
|
onEditorMounted() {
|
|
415
|
-
|
|
416
|
-
// place a caret; forward it to the nearest line.
|
|
417
|
-
this.view?.scrollDOM.addEventListener('pointerdown', this._onScrollerPointerDown);
|
|
377
|
+
super.onEditorMounted();
|
|
418
378
|
// Clicking a mention selects the whole token (capture, to beat CM's own
|
|
419
379
|
// caret placement).
|
|
420
380
|
this.view?.contentDOM.addEventListener('pointerdown', this._onMentionPointerDown, true);
|
|
@@ -422,55 +382,36 @@ let NLDDTextEditor = class NLDDTextEditor extends DescribedBy(FormAssociated(NLD
|
|
|
422
382
|
// the tinted text itself stays plain-clickable for caret placement.
|
|
423
383
|
this.view?.contentDOM.addEventListener('click', this._onAnnotationBadgeClick);
|
|
424
384
|
this._syncAnnotations();
|
|
425
|
-
this.commitFormValue();
|
|
426
|
-
this._checkAccessibleLabel();
|
|
427
385
|
// Emit one state snapshot on mount so a consumer's toolbar initializes to the
|
|
428
386
|
// real state (e.g. undo/redo disabled with no history yet) instead of its
|
|
429
387
|
// default, without waiting for the first edit or selection change.
|
|
430
388
|
this._emitState();
|
|
431
389
|
}
|
|
432
390
|
updated(changed) {
|
|
433
|
-
|
|
434
|
-
|
|
391
|
+
super.updated(changed);
|
|
392
|
+
if (!this.view)
|
|
393
|
+
return;
|
|
394
|
+
// A render after setTranslations() or a new `translations`: the labels
|
|
395
|
+
// drawn inside the document follow when their text changed.
|
|
396
|
+
const labels = this._labelSignature();
|
|
397
|
+
if (labels !== this._labels) {
|
|
398
|
+
if (this._labels !== null)
|
|
399
|
+
this.view.dispatch({ effects: relabel.of(null) });
|
|
400
|
+
this._labels = labels;
|
|
435
401
|
}
|
|
436
|
-
if (
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
// which would strip the sentinels the filter then re-adds (caret churn).
|
|
449
|
-
if (stripSentinels(this.doc) !== this.value)
|
|
450
|
-
this.setDoc(stripSentinels(this.value));
|
|
451
|
-
this.commitFormValue();
|
|
452
|
-
}
|
|
453
|
-
if (changed.has('disabled') || changed.has('readonly')) {
|
|
454
|
-
this.reconfigure(this._editableCompartment, this._editableExtension());
|
|
455
|
-
}
|
|
456
|
-
if (changed.has('wrap')) {
|
|
457
|
-
this.reconfigure(this._wrapCompartment, this.wrap ? EditorView.lineWrapping : []);
|
|
458
|
-
}
|
|
459
|
-
if (changed.has('placeholder')) {
|
|
460
|
-
this.reconfigure(this._placeholderCompartment, this._placeholderExtension());
|
|
461
|
-
}
|
|
462
|
-
if (changed.has('accessibleLabel') || changed.has('inputId')) {
|
|
463
|
-
this.reconfigure(this._attrsCompartment, this._attrsExtension());
|
|
464
|
-
}
|
|
465
|
-
if (changed.has('noSpellcheck')) {
|
|
466
|
-
this.reconfigure(this._spellcheckCompartment, this.noSpellcheck ? [] : spellcheck());
|
|
467
|
-
this._redrawForSpellcheck();
|
|
468
|
-
}
|
|
469
|
-
if (changed.has('annotations') || changed.has('annotatable')) {
|
|
470
|
-
this._syncAnnotations();
|
|
471
|
-
}
|
|
402
|
+
if (changed.has('wrap')) {
|
|
403
|
+
this.reconfigure(this._wrapCompartment, this.wrap ? EditorView.lineWrapping : []);
|
|
404
|
+
}
|
|
405
|
+
if (changed.has('syntax')) {
|
|
406
|
+
this.reconfigure(this._syntaxCompartment, this.syntax === 'hidden' ? hiddenSyntax() : []);
|
|
407
|
+
}
|
|
408
|
+
if (changed.has('noSpellcheck')) {
|
|
409
|
+
this.reconfigure(this._spellcheckCompartment, this.noSpellcheck ? [] : spellcheck());
|
|
410
|
+
this._redrawForSpellcheck();
|
|
411
|
+
}
|
|
412
|
+
if (changed.has('annotations') || changed.has('annotatable')) {
|
|
413
|
+
this._syncAnnotations();
|
|
472
414
|
}
|
|
473
|
-
this._checkAccessibleLabel();
|
|
474
415
|
}
|
|
475
416
|
_syncAnnotations() {
|
|
476
417
|
// Annotations only render when the consumer opts in via `annotatable`.
|
|
@@ -482,20 +423,6 @@ let NLDDTextEditor = class NLDDTextEditor extends DescribedBy(FormAssociated(NLD
|
|
|
482
423
|
annotations: Transaction.addToHistory.of(false),
|
|
483
424
|
});
|
|
484
425
|
}
|
|
485
|
-
// Two-step mention deletion: select the token on the first key, remove on the
|
|
486
|
-
// second. dir -1 = Backspace (token ends at the caret), +1 = Delete (starts).
|
|
487
|
-
_selectMentionBeforeDelete(view, dir) {
|
|
488
|
-
const sel = view.state.selection.main;
|
|
489
|
-
// A non-empty selection (e.g. an already-selected mention) → let the default
|
|
490
|
-
// command delete it.
|
|
491
|
-
if (!sel.empty)
|
|
492
|
-
return false;
|
|
493
|
-
const range = dir < 0 ? mentionRangeEndingAt(view.state, sel.head) : mentionRangeStartingAt(view.state, sel.head);
|
|
494
|
-
if (!range)
|
|
495
|
-
return false; // not next to a mention → normal backspace/delete
|
|
496
|
-
view.dispatch({ selection: { anchor: range.from, head: range.to } });
|
|
497
|
-
return true;
|
|
498
|
-
}
|
|
499
426
|
/* # Headless command API */
|
|
500
427
|
toggleBold() {
|
|
501
428
|
if (this.view)
|
|
@@ -590,31 +517,15 @@ let NLDDTextEditor = class NLDDTextEditor extends DescribedBy(FormAssociated(NLD
|
|
|
590
517
|
view.dispatch({ effects: this._historyCompartment.reconfigure(history()) });
|
|
591
518
|
this._emitState();
|
|
592
519
|
}
|
|
593
|
-
/** The annotations lying fully inside the current selection, offset relative to
|
|
594
|
-
* the selection's clean start. */
|
|
595
|
-
_annotationsInSelection() {
|
|
596
|
-
if (!this.view)
|
|
597
|
-
return [];
|
|
598
|
-
const { from, to } = this.view.state.selection.main;
|
|
599
|
-
const doc = this.view.state.doc.toString();
|
|
600
|
-
const cleanFrom = docToClean(doc, from);
|
|
601
|
-
const cleanTo = docToClean(doc, to);
|
|
602
|
-
return currentAnnotations(this.view.state)
|
|
603
|
-
.filter((a) => a.from >= cleanFrom && a.to <= cleanTo)
|
|
604
|
-
.map((a) => ({ id: a.id, from: a.from - cleanFrom, to: a.to - cleanFrom }));
|
|
605
|
-
}
|
|
606
520
|
/** Copy the current selection to the clipboard, sentinel-free. No-op when the
|
|
607
521
|
* selection is empty or the clipboard is unavailable (e.g. permission denied). */
|
|
608
522
|
async copy() {
|
|
609
523
|
if (!this.view)
|
|
610
524
|
return;
|
|
611
|
-
|
|
612
|
-
if (from === to)
|
|
525
|
+
if (this.view.state.selection.main.empty)
|
|
613
526
|
return;
|
|
614
|
-
const text =
|
|
615
|
-
|
|
616
|
-
// bleed onto the next paste.
|
|
617
|
-
this._cutBuffer = null;
|
|
527
|
+
const text = this._clipboard.selectedText(this.view);
|
|
528
|
+
this._clipboard.forget();
|
|
618
529
|
try {
|
|
619
530
|
await navigator.clipboard.writeText(text);
|
|
620
531
|
}
|
|
@@ -629,11 +540,10 @@ let NLDDTextEditor = class NLDDTextEditor extends DescribedBy(FormAssociated(NLD
|
|
|
629
540
|
// Cut mutates (it removes the selection), so it's a no-op on a read-only editor.
|
|
630
541
|
if (!this.view || this.view.state.readOnly)
|
|
631
542
|
return;
|
|
632
|
-
|
|
633
|
-
if (from === to)
|
|
543
|
+
if (this.view.state.selection.main.empty)
|
|
634
544
|
return;
|
|
635
|
-
const text =
|
|
636
|
-
this.
|
|
545
|
+
const text = this._clipboard.selectedText(this.view);
|
|
546
|
+
this._clipboard.rememberCut(this.view);
|
|
637
547
|
try {
|
|
638
548
|
await navigator.clipboard.writeText(text);
|
|
639
549
|
}
|
|
@@ -657,7 +567,8 @@ let NLDDTextEditor = class NLDDTextEditor extends DescribedBy(FormAssociated(NLD
|
|
|
657
567
|
catch {
|
|
658
568
|
return; /* clipboard blocked */
|
|
659
569
|
}
|
|
660
|
-
this.
|
|
570
|
+
if (this.view)
|
|
571
|
+
this._clipboard.paste(this.view, raw);
|
|
661
572
|
this.view?.focus();
|
|
662
573
|
}
|
|
663
574
|
/** Puts `text` at the caret, in place of the selection when there is one, and
|
|
@@ -695,29 +606,6 @@ let NLDDTextEditor = class NLDDTextEditor extends DescribedBy(FormAssociated(NLD
|
|
|
695
606
|
});
|
|
696
607
|
this.view.focus();
|
|
697
608
|
}
|
|
698
|
-
/** Insert `text` at the selection, re-attaching the cut annotations when it matches
|
|
699
|
-
* a cut made in this editor (a move, one-shot). Shared by the toolbar's paste()
|
|
700
|
-
* and the native Cmd/Ctrl+V handler. */
|
|
701
|
-
_pasteText(text) {
|
|
702
|
-
// Paste mutates; refuse it on a read-only editor (covers the toolbar paste()
|
|
703
|
-
// and the native Cmd/Ctrl+V handler that both funnel through here).
|
|
704
|
-
if (!this.view || !text || this.view.state.readOnly)
|
|
705
|
-
return;
|
|
706
|
-
const buffer = this._cutBuffer;
|
|
707
|
-
// Normalize line endings on both sides: a Windows/other-app clipboard may hand
|
|
708
|
-
// back CRLF where the cut buffer holds LF, and an exact compare would then miss
|
|
709
|
-
// the match and silently drop the carried annotations.
|
|
710
|
-
const sameText = (a, b) => a.replace(/\r\n/g, '\n') === b.replace(/\r\n/g, '\n');
|
|
711
|
-
const carry = !!(buffer && sameText(buffer.text, text) && buffer.anns.length > 0);
|
|
712
|
-
const at = docToClean(this.view.state.doc.toString(), this.view.state.selection.main.from);
|
|
713
|
-
// input.paste, like CodeMirror's own paste: history groups it as one step and
|
|
714
|
-
// a transaction filter can tell a paste from typing.
|
|
715
|
-
const spec = { ...this.view.state.replaceSelection(text), userEvent: 'input.paste' };
|
|
716
|
-
this.view.dispatch(carry ? { ...spec, effects: pasteAnnotations.of({ at, anns: buffer.anns }) } : spec);
|
|
717
|
-
// One-shot: a second paste of the same cut would duplicate the ids, so drop it.
|
|
718
|
-
if (carry)
|
|
719
|
-
this._cutBuffer = null;
|
|
720
|
-
}
|
|
721
609
|
/** Escape hatch: run a command by name, so a toolbar can carry the name in its
|
|
722
610
|
* markup instead of a method reference. Every method above is reachable.
|
|
723
611
|
*
|
|
@@ -894,91 +782,17 @@ let NLDDTextEditor = class NLDDTextEditor extends DescribedBy(FormAssociated(NLD
|
|
|
894
782
|
composed: true,
|
|
895
783
|
}));
|
|
896
784
|
}
|
|
897
|
-
_onDocChanged() {
|
|
898
|
-
// The document carries annotation sentinels; the exposed value never does.
|
|
899
|
-
const text = stripSentinels(this.doc);
|
|
900
|
-
if (text === this.value)
|
|
901
|
-
return;
|
|
902
|
-
this.value = text;
|
|
903
|
-
this.commitFormValue();
|
|
904
|
-
this.dispatchEvent(new CustomEvent('input', {
|
|
905
|
-
detail: { value: text },
|
|
906
|
-
bubbles: true,
|
|
907
|
-
composed: true,
|
|
908
|
-
}));
|
|
909
|
-
}
|
|
910
|
-
_emitChange() {
|
|
911
|
-
this.commitFormValue();
|
|
912
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
913
|
-
detail: { value: this.value },
|
|
914
|
-
bubbles: true,
|
|
915
|
-
composed: true,
|
|
916
|
-
}));
|
|
917
|
-
}
|
|
918
|
-
_checkAccessibleLabel() {
|
|
919
|
-
if (this._accessibleLabelWarned)
|
|
920
|
-
return;
|
|
921
|
-
if (this.accessibleLabel || this.inputId)
|
|
922
|
-
return;
|
|
923
|
-
this._accessibleLabelWarned = true;
|
|
924
|
-
console.warn('<nldd-text-editor>: No accessible-label or input-id provided. Use nldd-form-field for labeled usage, or set accessible-label for screen reader accessibility (WCAG SC 4.1.2).');
|
|
925
|
-
}
|
|
926
|
-
formValue() {
|
|
927
|
-
return this.value;
|
|
928
|
-
}
|
|
929
|
-
formResetCallback() {
|
|
930
|
-
this.value = this._initialValue;
|
|
931
|
-
}
|
|
932
|
-
formStateRestoreCallback(state) {
|
|
933
|
-
if (typeof state === 'string')
|
|
934
|
-
this.value = state;
|
|
935
|
-
}
|
|
936
|
-
/** CodeMirror builds the textbox; the host is only its container. */
|
|
937
|
-
describedTarget() {
|
|
938
|
-
return this.shadowRoot?.querySelector('.cm-content') ?? null;
|
|
939
|
-
}
|
|
940
785
|
render() {
|
|
941
786
|
return textEditorTemplate(this);
|
|
942
787
|
}
|
|
943
788
|
};
|
|
944
|
-
NLDDTextEditor.shadowRootOptions = {
|
|
945
|
-
...LitElement.shadowRootOptions,
|
|
946
|
-
delegatesFocus: true,
|
|
947
|
-
};
|
|
948
789
|
NLDDTextEditor.styles = textEditorStyles;
|
|
949
|
-
/** Says this is the control an nldd-form-field is about, so the field can
|
|
950
|
-
* find it, name it and move focus into it. See nldd-form-field. */
|
|
951
|
-
NLDDTextEditor.isFormInput = true;
|
|
952
|
-
__decorate([
|
|
953
|
-
property({ type: String })
|
|
954
|
-
], NLDDTextEditor.prototype, "value", void 0);
|
|
955
|
-
__decorate([
|
|
956
|
-
property({ type: String, attribute: 'input-id' })
|
|
957
|
-
], NLDDTextEditor.prototype, "inputId", void 0);
|
|
958
|
-
__decorate([
|
|
959
|
-
property({ reflect: true, converter: reflectNonDefault('') })
|
|
960
|
-
], NLDDTextEditor.prototype, "placeholder", void 0);
|
|
961
|
-
__decorate([
|
|
962
|
-
property({ type: Boolean, reflect: true })
|
|
963
|
-
], NLDDTextEditor.prototype, "disabled", void 0);
|
|
964
|
-
__decorate([
|
|
965
|
-
property({ reflect: true, converter: reflectNonDefault('') })
|
|
966
|
-
], NLDDTextEditor.prototype, "name", void 0);
|
|
967
|
-
__decorate([
|
|
968
|
-
property({ type: Boolean, reflect: true })
|
|
969
|
-
], NLDDTextEditor.prototype, "readonly", void 0);
|
|
970
|
-
__decorate([
|
|
971
|
-
property({ type: Boolean, reflect: true })
|
|
972
|
-
], NLDDTextEditor.prototype, "required", void 0);
|
|
973
790
|
__decorate([
|
|
974
791
|
property({ type: Boolean, reflect: true, attribute: 'no-spellcheck' })
|
|
975
792
|
], NLDDTextEditor.prototype, "noSpellcheck", void 0);
|
|
976
793
|
__decorate([
|
|
977
794
|
property({ type: Boolean, reflect: true })
|
|
978
795
|
], NLDDTextEditor.prototype, "wrap", void 0);
|
|
979
|
-
__decorate([
|
|
980
|
-
property({ type: Number })
|
|
981
|
-
], NLDDTextEditor.prototype, "rows", void 0);
|
|
982
796
|
__decorate([
|
|
983
797
|
property({ reflect: true, converter: reflectNonDefault('auto') })
|
|
984
798
|
], NLDDTextEditor.prototype, "resize", void 0);
|
|
@@ -986,8 +800,8 @@ __decorate([
|
|
|
986
800
|
property({ reflect: true, converter: reflectNonDefault('simple') })
|
|
987
801
|
], NLDDTextEditor.prototype, "appearance", void 0);
|
|
988
802
|
__decorate([
|
|
989
|
-
property({
|
|
990
|
-
], NLDDTextEditor.prototype, "
|
|
803
|
+
property({ reflect: true, converter: reflectNonDefault('visible') })
|
|
804
|
+
], NLDDTextEditor.prototype, "syntax", void 0);
|
|
991
805
|
__decorate([
|
|
992
806
|
property({ attribute: false })
|
|
993
807
|
], NLDDTextEditor.prototype, "mentionSource", void 0);
|
|
@@ -1012,9 +826,6 @@ __decorate([
|
|
|
1012
826
|
__decorate([
|
|
1013
827
|
query('.text-editor')
|
|
1014
828
|
], NLDDTextEditor.prototype, "_container", void 0);
|
|
1015
|
-
__decorate([
|
|
1016
|
-
property({ type: Boolean, reflect: true })
|
|
1017
|
-
], NLDDTextEditor.prototype, "invalid", void 0);
|
|
1018
829
|
NLDDTextEditor = __decorate([
|
|
1019
830
|
customElement('nldd-text-editor')
|
|
1020
831
|
], NLDDTextEditor);
|