@nldd/design-system 0.8.64 → 0.8.65
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/dist/components/actions/button/button.d.ts.map +1 -1
- package/dist/components/actions/button/button.js +7 -6
- package/dist/components/actions/button/button.js.map +1 -1
- package/dist/components/actions/button/button.styles.d.ts.map +1 -1
- package/dist/components/actions/button/button.styles.js +9 -5
- package/dist/components/actions/button/button.styles.js.map +1 -1
- package/dist/components/actions/button-bar/button-bar.d.ts.map +1 -1
- package/dist/components/actions/button-bar/button-bar.js +3 -2
- package/dist/components/actions/button-bar/button-bar.js.map +1 -1
- package/dist/components/actions/button-group/button-group.d.ts.map +1 -1
- package/dist/components/actions/button-group/button-group.js +3 -2
- package/dist/components/actions/button-group/button-group.js.map +1 -1
- package/dist/components/actions/icon-button/icon-button.d.ts +4 -0
- package/dist/components/actions/icon-button/icon-button.d.ts.map +1 -1
- package/dist/components/actions/icon-button/icon-button.js +13 -5
- package/dist/components/actions/icon-button/icon-button.js.map +1 -1
- package/dist/components/actions/icon-button/icon-button.styles.d.ts.map +1 -1
- package/dist/components/actions/icon-button/icon-button.styles.js +15 -10
- package/dist/components/actions/icon-button/icon-button.styles.js.map +1 -1
- package/dist/components/actions/icon-button/icon-button.template.d.ts.map +1 -1
- package/dist/components/actions/icon-button/icon-button.template.js +2 -0
- package/dist/components/actions/icon-button/icon-button.template.js.map +1 -1
- package/dist/components/actions/menu/menu.d.ts +1 -0
- package/dist/components/actions/menu/menu.d.ts.map +1 -1
- package/dist/components/actions/menu/menu.js +33 -15
- package/dist/components/actions/menu/menu.js.map +1 -1
- package/dist/components/actions/menu/menu.styles.d.ts.map +1 -1
- package/dist/components/actions/menu/menu.styles.js +8 -0
- package/dist/components/actions/menu/menu.styles.js.map +1 -1
- package/dist/components/actions/split-button/split-button.d.ts.map +1 -1
- package/dist/components/actions/split-button/split-button.js +5 -4
- package/dist/components/actions/split-button/split-button.js.map +1 -1
- package/dist/components/actions/toolbar/toolbar.d.ts +11 -0
- package/dist/components/actions/toolbar/toolbar.d.ts.map +1 -1
- package/dist/components/actions/toolbar/toolbar.js +112 -40
- package/dist/components/actions/toolbar/toolbar.js.map +1 -1
- package/dist/components/actions/toolbar/toolbar.styles.d.ts.map +1 -1
- package/dist/components/actions/toolbar/toolbar.styles.js +3 -12
- package/dist/components/actions/toolbar/toolbar.styles.js.map +1 -1
- package/dist/components/components.js +104 -102
- package/dist/components/content/blockquote/blockquote.styles.d.ts.map +1 -1
- package/dist/components/content/blockquote/blockquote.styles.js +0 -3
- package/dist/components/content/blockquote/blockquote.styles.js.map +1 -1
- package/dist/components/content/byline/byline.d.ts.map +1 -1
- package/dist/components/content/byline/byline.js +3 -2
- package/dist/components/content/byline/byline.js.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.d.ts +24 -64
- package/dist/components/content/code-viewer/code-viewer.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.js +239 -156
- 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 +33 -92
- 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 +10 -29
- 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 +22 -1
- package/dist/components/content/icon/icon-aliases.js.map +1 -1
- package/dist/components/content/icon/icon-registry.d.ts.map +1 -1
- package/dist/components/content/icon/icon-registry.js +18 -0
- package/dist/components/content/icon/icon-registry.js.map +1 -1
- package/dist/components/content/icon/icon.d.ts.map +1 -1
- package/dist/components/content/icon/icon.js +3 -2
- package/dist/components/content/icon/icon.js.map +1 -1
- package/dist/components/content/image/image.d.ts.map +1 -1
- package/dist/components/content/image/image.js +7 -6
- package/dist/components/content/image/image.js.map +1 -1
- package/dist/components/content/image/image.styles.d.ts.map +1 -1
- package/dist/components/content/image/image.styles.js +2 -6
- package/dist/components/content/image/image.styles.js.map +1 -1
- package/dist/components/content/keyboard-shortcut/keyboard-shortcut.d.ts.map +1 -1
- package/dist/components/content/keyboard-shortcut/keyboard-shortcut.js +8 -7
- package/dist/components/content/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/dist/components/content/keyboard-shortcut/keyboard-shortcut.styles.d.ts.map +1 -1
- package/dist/components/content/keyboard-shortcut/keyboard-shortcut.styles.js +5 -1
- package/dist/components/content/keyboard-shortcut/keyboard-shortcut.styles.js.map +1 -1
- package/dist/components/content/rich-text/rich-text.d.ts.map +1 -1
- package/dist/components/content/rich-text/rich-text.js +3 -2
- package/dist/components/content/rich-text/rich-text.js.map +1 -1
- package/dist/components/content/tag/tag.d.ts.map +1 -1
- package/dist/components/content/tag/tag.js +5 -4
- package/dist/components/content/tag/tag.js.map +1 -1
- package/dist/components/content/title/title.d.ts.map +1 -1
- package/dist/components/content/title/title.js +2 -1
- package/dist/components/content/title/title.js.map +1 -1
- package/dist/components/content/token/token.d.ts +70 -0
- package/dist/components/content/token/token.d.ts.map +1 -0
- package/dist/components/content/token/token.js +170 -0
- package/dist/components/content/token/token.js.map +1 -0
- package/dist/components/content/token/token.styles.d.ts.map +1 -0
- package/dist/components/content/token/token.styles.js +122 -0
- package/dist/components/content/token/token.styles.js.map +1 -0
- package/dist/components/content/token/token.template.d.ts +6 -0
- package/dist/components/content/token/token.template.d.ts.map +1 -0
- package/dist/components/content/token/token.template.js +47 -0
- package/dist/components/content/token/token.template.js.map +1 -0
- package/dist/components/content/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/content/tooltip/tooltip.js +14 -5
- package/dist/components/content/tooltip/tooltip.js.map +1 -1
- package/dist/components/content/tooltip/tooltip.styles.d.ts.map +1 -1
- package/dist/components/content/tooltip/tooltip.styles.js +11 -0
- package/dist/components/content/tooltip/tooltip.styles.js.map +1 -1
- package/dist/components/gherkin-DhZlEZiy.js +115 -0
- package/dist/components/index-BI4lrehT.js +66595 -0
- package/dist/components/index-BcdqzZql.js +703 -0
- package/dist/components/index-BlMqctke.js +81 -0
- package/dist/components/index-BseMFLNF.js +688 -0
- package/dist/components/index-ChjtFo6I.js +177 -0
- package/dist/components/index-D3NSlPL5.js +405 -0
- package/dist/components/index-D7B3n3QJ.js +384 -0
- package/dist/components/index.d.ts +20 -18
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +20 -18
- package/dist/components/index.js.map +1 -1
- package/dist/components/inputs/code-editor/code-editor.d.ts +58 -29
- package/dist/components/inputs/code-editor/code-editor.d.ts.map +1 -1
- package/dist/components/inputs/code-editor/code-editor.js +241 -52
- 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 +58 -46
- package/dist/components/inputs/code-editor/code-editor.styles.js.map +1 -1
- package/dist/components/inputs/code-editor/code-editor.template.d.ts +1 -1
- package/dist/components/inputs/code-editor/code-editor.template.d.ts.map +1 -1
- package/dist/components/inputs/code-editor/code-editor.template.js +5 -22
- package/dist/components/inputs/code-editor/code-editor.template.js.map +1 -1
- package/dist/components/inputs/combo-box/combo-box.d.ts +15 -4
- package/dist/components/inputs/combo-box/combo-box.d.ts.map +1 -1
- package/dist/components/inputs/combo-box/combo-box.js +53 -9
- package/dist/components/inputs/combo-box/combo-box.js.map +1 -1
- package/dist/components/inputs/dropdown/dropdown.d.ts.map +1 -1
- package/dist/components/inputs/dropdown/dropdown.js +2 -1
- package/dist/components/inputs/dropdown/dropdown.js.map +1 -1
- package/dist/components/inputs/multi-line-text-field/multi-line-text-field.d.ts +1 -1
- package/dist/components/inputs/multi-line-text-field/multi-line-text-field.d.ts.map +1 -1
- package/dist/components/inputs/multi-line-text-field/multi-line-text-field.js +6 -5
- package/dist/components/inputs/multi-line-text-field/multi-line-text-field.js.map +1 -1
- package/dist/components/inputs/multi-line-text-field/multi-line-text-field.styles.d.ts.map +1 -1
- package/dist/components/inputs/multi-line-text-field/multi-line-text-field.styles.js +8 -11
- package/dist/components/inputs/multi-line-text-field/multi-line-text-field.styles.js.map +1 -1
- package/dist/components/inputs/number-field/number-field.d.ts.map +1 -1
- package/dist/components/inputs/number-field/number-field.js +2 -1
- package/dist/components/inputs/number-field/number-field.js.map +1 -1
- package/dist/components/inputs/password-field/password-field.d.ts.map +1 -1
- package/dist/components/inputs/password-field/password-field.js +3 -2
- package/dist/components/inputs/password-field/password-field.js.map +1 -1
- package/dist/components/inputs/radio-button-group/radio-button-group.js +1 -1
- package/dist/components/inputs/radio-button-group/radio-button-group.js.map +1 -1
- package/dist/components/inputs/search-field/search-field.d.ts.map +1 -1
- package/dist/components/inputs/search-field/search-field.js +2 -1
- package/dist/components/inputs/search-field/search-field.js.map +1 -1
- package/dist/components/inputs/segmented-control/segmented-control.d.ts +1 -1
- package/dist/components/inputs/segmented-control/segmented-control.d.ts.map +1 -1
- package/dist/components/inputs/segmented-control/segmented-control.js +10 -9
- package/dist/components/inputs/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/inputs/segmented-control/segmented-control.styles.d.ts.map +1 -1
- package/dist/components/inputs/segmented-control/segmented-control.styles.js +70 -36
- package/dist/components/inputs/segmented-control/segmented-control.styles.js.map +1 -1
- package/dist/components/inputs/stepper/stepper.d.ts.map +1 -1
- package/dist/components/inputs/stepper/stepper.js +2 -1
- package/dist/components/inputs/stepper/stepper.js.map +1 -1
- package/dist/components/inputs/switch/switch.d.ts.map +1 -1
- package/dist/components/inputs/switch/switch.js +2 -1
- package/dist/components/inputs/switch/switch.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.d.ts +51 -0
- package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.js +148 -0
- package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.annotations.d.ts +47 -0
- package/dist/components/inputs/text-editor/text-editor.annotations.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.annotations.js +327 -0
- package/dist/components/inputs/text-editor/text-editor.annotations.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.caret.d.ts +13 -0
- package/dist/components/inputs/text-editor/text-editor.caret.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.caret.js +27 -0
- package/dist/components/inputs/text-editor/text-editor.caret.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.commands.d.ts +61 -0
- package/dist/components/inputs/text-editor/text-editor.commands.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.commands.js +376 -0
- package/dist/components/inputs/text-editor/text-editor.commands.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.d.ts +241 -0
- package/dist/components/inputs/text-editor/text-editor.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.drag.d.ts +30 -0
- package/dist/components/inputs/text-editor/text-editor.drag.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.drag.js +231 -0
- package/dist/components/inputs/text-editor/text-editor.drag.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.i18n.d.ts +8 -0
- package/dist/components/inputs/text-editor/text-editor.i18n.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.i18n.js +13 -0
- package/dist/components/inputs/text-editor/text-editor.i18n.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.js +782 -0
- package/dist/components/inputs/text-editor/text-editor.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.links.d.ts +18 -0
- package/dist/components/inputs/text-editor/text-editor.links.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.links.js +147 -0
- package/dist/components/inputs/text-editor/text-editor.links.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.markdown.d.ts +20 -0
- package/dist/components/inputs/text-editor/text-editor.markdown.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.markdown.js +372 -0
- package/dist/components/inputs/text-editor/text-editor.markdown.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.mentions.d.ts +32 -0
- package/dist/components/inputs/text-editor/text-editor.mentions.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.mentions.js +153 -0
- package/dist/components/inputs/text-editor/text-editor.mentions.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.ordered-list.d.ts +12 -0
- package/dist/components/inputs/text-editor/text-editor.ordered-list.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.ordered-list.js +85 -0
- package/dist/components/inputs/text-editor/text-editor.ordered-list.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.styles.d.ts +2 -0
- package/dist/components/inputs/text-editor/text-editor.styles.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.styles.js +592 -0
- package/dist/components/inputs/text-editor/text-editor.styles.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.template.d.ts +4 -0
- package/dist/components/inputs/text-editor/text-editor.template.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.template.js +7 -0
- package/dist/components/inputs/text-editor/text-editor.template.js.map +1 -0
- package/dist/components/inputs/text-field/text-field.d.ts.map +1 -1
- package/dist/components/inputs/text-field/text-field.js +3 -2
- package/dist/components/inputs/text-field/text-field.js.map +1 -1
- package/dist/components/inputs/toggle-button/toggle-button.d.ts.map +1 -1
- package/dist/components/inputs/toggle-button/toggle-button.js +4 -3
- package/dist/components/inputs/toggle-button/toggle-button.js.map +1 -1
- package/dist/components/inputs/toggle-button/toggle-button.styles.d.ts.map +1 -1
- package/dist/components/inputs/toggle-button/toggle-button.styles.js +14 -10
- package/dist/components/inputs/toggle-button/toggle-button.styles.js.map +1 -1
- package/dist/components/inputs/toggle-button-group/toggle-button-group.d.ts +1 -1
- package/dist/components/inputs/toggle-button-group/toggle-button-group.d.ts.map +1 -1
- package/dist/components/inputs/toggle-button-group/toggle-button-group.js +5 -4
- package/dist/components/inputs/toggle-button-group/toggle-button-group.js.map +1 -1
- package/dist/components/inputs/token-field/token-field.d.ts +257 -0
- package/dist/components/inputs/token-field/token-field.d.ts.map +1 -0
- package/dist/components/inputs/token-field/token-field.i18n.d.ts +9 -0
- package/dist/components/inputs/token-field/token-field.i18n.d.ts.map +1 -0
- package/dist/components/inputs/token-field/token-field.i18n.js +8 -0
- package/dist/components/inputs/token-field/token-field.i18n.js.map +1 -0
- package/dist/components/inputs/token-field/token-field.js +877 -0
- package/dist/components/inputs/token-field/token-field.js.map +1 -0
- package/dist/components/inputs/token-field/token-field.styles.d.ts +2 -0
- package/dist/components/inputs/token-field/token-field.styles.d.ts.map +1 -0
- package/dist/components/inputs/token-field/token-field.styles.js +194 -0
- package/dist/components/inputs/token-field/token-field.styles.js.map +1 -0
- package/dist/components/inputs/token-field/token-field.template.d.ts +8 -0
- package/dist/components/inputs/token-field/token-field.template.d.ts.map +1 -0
- package/dist/components/inputs/token-field/token-field.template.js +136 -0
- package/dist/components/inputs/token-field/token-field.template.js.map +1 -0
- package/dist/components/layout/app-view/app-view.d.ts.map +1 -1
- package/dist/components/layout/app-view/app-view.js +2 -1
- package/dist/components/layout/app-view/app-view.js.map +1 -1
- package/dist/components/layout/box/box.d.ts.map +1 -1
- package/dist/components/layout/box/box.js +2 -1
- package/dist/components/layout/box/box.js.map +1 -1
- package/dist/components/layout/box/box.styles.d.ts.map +1 -1
- package/dist/components/layout/box/box.styles.js +1 -6
- package/dist/components/layout/box/box.styles.js.map +1 -1
- package/dist/components/layout/collection/collection.d.ts +5 -0
- package/dist/components/layout/collection/collection.d.ts.map +1 -1
- package/dist/components/layout/collection/collection.js +17 -1
- package/dist/components/layout/collection/collection.js.map +1 -1
- package/dist/components/layout/collection/collection.styles.d.ts.map +1 -1
- package/dist/components/layout/collection/collection.styles.js +18 -17
- package/dist/components/layout/collection/collection.styles.js.map +1 -1
- package/dist/components/layout/page-footer/page-footer.d.ts.map +1 -1
- package/dist/components/layout/page-footer/page-footer.js +2 -1
- package/dist/components/layout/page-footer/page-footer.js.map +1 -1
- package/dist/components/layout/page-sections/hero/hero.d.ts +7 -23
- package/dist/components/layout/page-sections/hero/hero.d.ts.map +1 -1
- package/dist/components/layout/page-sections/hero/hero.js +12 -73
- package/dist/components/layout/page-sections/hero/hero.js.map +1 -1
- package/dist/components/layout/page-sections/hero/hero.styles.d.ts.map +1 -1
- package/dist/components/layout/page-sections/hero/hero.styles.js +13 -159
- package/dist/components/layout/page-sections/hero/hero.styles.js.map +1 -1
- package/dist/components/layout/popover/popover.d.ts +1 -0
- package/dist/components/layout/popover/popover.d.ts.map +1 -1
- package/dist/components/layout/popover/popover.js +14 -1
- 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 +11 -0
- package/dist/components/layout/popover/popover.styles.js.map +1 -1
- package/dist/components/layout/sheet/sheet.d.ts +1 -1
- package/dist/components/layout/sheet/sheet.d.ts.map +1 -1
- package/dist/components/layout/sheet/sheet.js +16 -6
- package/dist/components/layout/sheet/sheet.js.map +1 -1
- package/dist/components/layout/sheet/sheet.styles.d.ts.map +1 -1
- package/dist/components/layout/sheet/sheet.styles.js +60 -83
- package/dist/components/layout/sheet/sheet.styles.js.map +1 -1
- package/dist/components/layout/spacer/spacer.d.ts.map +1 -1
- package/dist/components/layout/spacer/spacer.js +2 -1
- package/dist/components/layout/spacer/spacer.js.map +1 -1
- package/dist/components/layout/spacer/spacer.styles.d.ts.map +1 -1
- package/dist/components/layout/spacer/spacer.styles.js +0 -1
- package/dist/components/layout/spacer/spacer.styles.js.map +1 -1
- package/dist/components/layout/split-views/split-view-divider/split-view-divider.d.ts.map +1 -1
- package/dist/components/layout/split-views/split-view-divider/split-view-divider.js +2 -1
- package/dist/components/layout/split-views/split-view-divider/split-view-divider.js.map +1 -1
- package/dist/components/layout/split-views/split-view-divider/split-view-divider.styles.js +10 -10
- package/dist/components/layout/window/window.d.ts.map +1 -1
- package/dist/components/layout/window/window.js +11 -2
- package/dist/components/layout/window/window.js.map +1 -1
- package/dist/components/lists-and-tables/cells/cell/cell.d.ts.map +1 -1
- package/dist/components/lists-and-tables/cells/cell/cell.js +4 -3
- package/dist/components/lists-and-tables/cells/cell/cell.js.map +1 -1
- package/dist/components/lists-and-tables/cells/description-cell/description-cell.d.ts.map +1 -1
- package/dist/components/lists-and-tables/cells/description-cell/description-cell.js +3 -2
- package/dist/components/lists-and-tables/cells/description-cell/description-cell.js.map +1 -1
- package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.d.ts.map +1 -1
- package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.js +2 -1
- package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.js.map +1 -1
- package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.d.ts.map +1 -1
- package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.js +3 -2
- package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.js.map +1 -1
- package/dist/components/lists-and-tables/cells/text-cell/text-cell.d.ts.map +1 -1
- package/dist/components/lists-and-tables/cells/text-cell/text-cell.js +10 -9
- package/dist/components/lists-and-tables/cells/text-cell/text-cell.js.map +1 -1
- package/dist/components/lists-and-tables/cells/timeline-track-cell/timeline-track-cell.d.ts.map +1 -1
- package/dist/components/lists-and-tables/cells/timeline-track-cell/timeline-track-cell.js +3 -2
- package/dist/components/lists-and-tables/cells/timeline-track-cell/timeline-track-cell.js.map +1 -1
- package/dist/components/lists-and-tables/cells/title-cell/title-cell.d.ts.map +1 -1
- package/dist/components/lists-and-tables/cells/title-cell/title-cell.js +9 -8
- package/dist/components/lists-and-tables/cells/title-cell/title-cell.js.map +1 -1
- package/dist/components/lists-and-tables/list/list.d.ts.map +1 -1
- package/dist/components/lists-and-tables/list/list.js +5 -4
- package/dist/components/lists-and-tables/list/list.js.map +1 -1
- package/dist/components/lists-and-tables/list/list.styles.d.ts.map +1 -1
- package/dist/components/lists-and-tables/list/list.styles.js +3 -2
- package/dist/components/lists-and-tables/list/list.styles.js.map +1 -1
- package/dist/components/lists-and-tables/list-item/list-item.d.ts.map +1 -1
- package/dist/components/lists-and-tables/list-item/list-item.js +2 -1
- package/dist/components/lists-and-tables/list-item/list-item.js.map +1 -1
- package/dist/components/lists-and-tables/table/table.d.ts.map +1 -1
- package/dist/components/lists-and-tables/table/table.js +4 -3
- package/dist/components/lists-and-tables/table/table.js.map +1 -1
- package/dist/components/navigation/breadcrumbs/breadcrumbs.d.ts.map +1 -1
- package/dist/components/navigation/breadcrumbs/breadcrumbs.js +2 -1
- package/dist/components/navigation/breadcrumbs/breadcrumbs.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 -4
- package/dist/components/navigation/document-tab-bar/document-tab-bar.js.map +1 -1
- package/dist/components/navigation/link/link.d.ts.map +1 -1
- package/dist/components/navigation/link/link.js +2 -1
- package/dist/components/navigation/link/link.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 -1
- package/dist/components/navigation/menu-bar/menu-bar.js.map +1 -1
- package/dist/components/navigation/menu-bar-item/menu-bar-item.d.ts.map +1 -1
- package/dist/components/navigation/menu-bar-item/menu-bar-item.js +4 -3
- package/dist/components/navigation/menu-bar-item/menu-bar-item.js.map +1 -1
- package/dist/components/navigation/skip-link/skip-link.d.ts.map +1 -1
- package/dist/components/navigation/skip-link/skip-link.js +2 -1
- package/dist/components/navigation/skip-link/skip-link.js.map +1 -1
- package/dist/components/navigation/tab-bar/tab-bar.d.ts +7 -0
- package/dist/components/navigation/tab-bar/tab-bar.d.ts.map +1 -1
- package/dist/components/navigation/tab-bar/tab-bar.js +31 -5
- package/dist/components/navigation/tab-bar/tab-bar.js.map +1 -1
- package/dist/components/navigation/tab-bar/tab-bar.styles.d.ts.map +1 -1
- package/dist/components/navigation/tab-bar/tab-bar.styles.js +74 -78
- package/dist/components/navigation/tab-bar/tab-bar.styles.js.map +1 -1
- package/dist/components/navigation/tab-bar/tab-bar.template.d.ts.map +1 -1
- package/dist/components/navigation/tab-bar/tab-bar.template.js +8 -1
- package/dist/components/navigation/tab-bar/tab-bar.template.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 +7 -6
- package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js.map +1 -1
- package/dist/components/navigation/top-title-bar/top-title-bar.d.ts.map +1 -1
- package/dist/components/navigation/top-title-bar/top-title-bar.js +5 -4
- package/dist/components/navigation/top-title-bar/top-title-bar.js.map +1 -1
- package/dist/components/shell-BlsXDxCn.js +222 -0
- package/dist/components/status-and-feedback/activity-indicator/activity-indicator.d.ts.map +1 -1
- package/dist/components/status-and-feedback/activity-indicator/activity-indicator.js +4 -3
- package/dist/components/status-and-feedback/activity-indicator/activity-indicator.js.map +1 -1
- package/dist/components/status-and-feedback/activity-indicator/activity-indicator.styles.d.ts.map +1 -1
- package/dist/components/status-and-feedback/activity-indicator/activity-indicator.styles.js +0 -1
- package/dist/components/status-and-feedback/activity-indicator/activity-indicator.styles.js.map +1 -1
- package/dist/components/status-and-feedback/badge/badge.d.ts.map +1 -1
- package/dist/components/status-and-feedback/badge/badge.js +4 -3
- package/dist/components/status-and-feedback/badge/badge.js.map +1 -1
- package/dist/components/status-and-feedback/banner/banner.d.ts +0 -1
- package/dist/components/status-and-feedback/banner/banner.d.ts.map +1 -1
- package/dist/components/status-and-feedback/banner/banner.js +13 -13
- package/dist/components/status-and-feedback/banner/banner.js.map +1 -1
- package/dist/components/status-and-feedback/inline-dialog/inline-dialog.d.ts.map +1 -1
- package/dist/components/status-and-feedback/inline-dialog/inline-dialog.js +5 -4
- package/dist/components/status-and-feedback/inline-dialog/inline-dialog.js.map +1 -1
- package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.d.ts +1 -0
- package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.d.ts.map +1 -1
- package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.js +35 -4
- package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.js.map +1 -1
- package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.styles.d.ts.map +1 -1
- package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.styles.js +11 -0
- package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.styles.js.map +1 -1
- package/dist/components/status-and-feedback/modal-dialog/modal-dialog.d.ts.map +1 -1
- package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js +4 -3
- package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js.map +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.d.ts.map +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.js +9 -8
- package/dist/components/status-and-feedback/progress-bar/progress-bar.js.map +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.styles.d.ts.map +1 -1
- package/dist/components/status-and-feedback/progress-bar/progress-bar.styles.js +0 -6
- package/dist/components/status-and-feedback/progress-bar/progress-bar.styles.js.map +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.d.ts.map +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.js +8 -7
- package/dist/components/status-and-feedback/progress-circle/progress-circle.js.map +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.styles.d.ts.map +1 -1
- package/dist/components/status-and-feedback/progress-circle/progress-circle.styles.js +0 -2
- package/dist/components/status-and-feedback/progress-circle/progress-circle.styles.js.map +1 -1
- package/dist/components/status-and-feedback/status-bar/status-bar.d.ts.map +1 -1
- package/dist/components/status-and-feedback/status-bar/status-bar.js +3 -2
- package/dist/components/status-and-feedback/status-bar/status-bar.js.map +1 -1
- package/dist/components/toml-BOuWGMcf.js +76 -0
- package/dist/css/fouc.css +30 -0
- package/dist/css/global.css +1 -0
- package/dist/css/rich-text.css +0 -5
- package/dist/css/settings.css +25 -10
- package/dist/utilities/codemirror/codemirror-element.d.ts +66 -0
- package/dist/utilities/codemirror/codemirror-element.d.ts.map +1 -0
- package/dist/utilities/codemirror/codemirror-element.js +121 -0
- package/dist/utilities/codemirror/codemirror-element.js.map +1 -0
- package/dist/utilities/codemirror/languages.d.ts +4 -0
- package/dist/utilities/codemirror/languages.d.ts.map +1 -0
- package/dist/utilities/codemirror/languages.js +39 -0
- package/dist/utilities/codemirror/languages.js.map +1 -0
- package/dist/utilities/codemirror/theme.d.ts +4 -0
- package/dist/utilities/codemirror/theme.d.ts.map +1 -0
- package/dist/utilities/codemirror/theme.js +84 -0
- package/dist/utilities/codemirror/theme.js.map +1 -0
- package/dist/utilities/dismiss-from-title-bar.d.ts +19 -0
- package/dist/utilities/dismiss-from-title-bar.d.ts.map +1 -0
- package/dist/utilities/dismiss-from-title-bar.js +21 -0
- package/dist/utilities/dismiss-from-title-bar.js.map +1 -0
- package/dist/utilities/reflect-non-default.d.ts +30 -0
- package/dist/utilities/reflect-non-default.d.ts.map +1 -0
- package/dist/utilities/reflect-non-default.js +34 -0
- package/dist/utilities/reflect-non-default.js.map +1 -0
- package/package.json +92 -68
- package/dist/components/index-BNhqNvDd.js +0 -36784
- package/dist/components/inputs/token/token.d.ts +0 -42
- package/dist/components/inputs/token/token.d.ts.map +0 -1
- package/dist/components/inputs/token/token.js +0 -86
- package/dist/components/inputs/token/token.js.map +0 -1
- package/dist/components/inputs/token/token.styles.d.ts.map +0 -1
- package/dist/components/inputs/token/token.styles.js +0 -142
- package/dist/components/inputs/token/token.styles.js.map +0 -1
- package/dist/components/inputs/token/token.template.d.ts +0 -4
- package/dist/components/inputs/token/token.template.d.ts.map +0 -1
- package/dist/components/inputs/token/token.template.js +0 -41
- package/dist/components/inputs/token/token.template.js.map +0 -1
- package/dist/components/prism-bash-vbqaw3JR.js +0 -226
- package/dist/components/prism-css-B93tXdOU.js +0 -59
- package/dist/components/prism-gherkin-CMPYyXOQ.js +0 -82
- package/dist/components/prism-javascript-DeC_17Pw.js +0 -140
- package/dist/components/prism-json-DIMpow89.js +0 -25
- package/dist/components/prism-markdown-D-uFBkiz.js +0 -339
- package/dist/components/prism-markup-DfJYPYHA.js +0 -177
- package/dist/components/prism-python--N285k7w.js +0 -99
- package/dist/components/prism-rust-Cnm1tSdo.js +0 -157
- package/dist/components/prism-sql-BGqCBMyJ.js +0 -33
- package/dist/components/prism-toml-Ubdq-a5x.js +0 -45
- package/dist/components/prism-typescript-BPJAiB1s.js +0 -87
- package/dist/components/prism-yaml-DO0f9pf6.js +0 -71
- /package/dist/components/{inputs → content}/token/token.styles.d.ts +0 -0
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Nederlandse Digitale Dienst Text Editor Component (Lit + TypeScript)
|
|
9
|
+
*
|
|
10
|
+
* A hybrid markdown editor built on CodeMirror 6 (via NLDDCodeMirrorElement):
|
|
11
|
+
* the document stays plain markdown text, but formatting is shown inline (bold
|
|
12
|
+
* is bold, headings are larger, links are coloured) while the syntax markers
|
|
13
|
+
* stay visible, only dimmed — the iA Writer / Kirby approach. No WYSIWYG tree,
|
|
14
|
+
* so the data stays portable.
|
|
15
|
+
*
|
|
16
|
+
* Default `variant="simple"` is bare (no frame, no focus ring) for use inside
|
|
17
|
+
* a composition (e.g. a message field) that owns its chrome and focus; the
|
|
18
|
+
* caret is a prominent accent. `variant="input-field"` adds a framed surface + focus
|
|
19
|
+
* ring. `font` is `sans` (default, best for prose) or `mono`.
|
|
20
|
+
*
|
|
21
|
+
* Headless: there is no built-in toolbar. A consumer drives formatting via the
|
|
22
|
+
* command methods (toggleBold/toggleItalic/toggleInlineCode/toggleStrikethrough/
|
|
23
|
+
* toggleHeading/toggleBulletList/toggleQuote/toggleLink/runCommand to toggle, and
|
|
24
|
+
* setHeading/setList for picker-style "set" semantics), reads the active formats
|
|
25
|
+
* with getState(), listens to the nldd-text-editor-state event to render toggle
|
|
26
|
+
* states, and forwards padding clicks with focusFromPoint(). Cmd/Ctrl+B/I/E/K are
|
|
27
|
+
* bound out of the box. Commands keep focus on the editor. An @-mention typeahead
|
|
28
|
+
* (mentionSource) collapses to an atomic token, and a W3C-style annotation overlay
|
|
29
|
+
* (annotations) marks ranges with a dashed underline, light tint and a count badge
|
|
30
|
+
* without touching the underlying text.
|
|
31
|
+
*
|
|
32
|
+
* @element nldd-text-editor
|
|
33
|
+
*
|
|
34
|
+
* @attr {string} value - Editor content (markdown)
|
|
35
|
+
* @attr {string} placeholder - Placeholder text shown while empty
|
|
36
|
+
* @attr {string} input-id - Sets the id on the editable element. Set automatically by nldd-form-field.
|
|
37
|
+
* @attr {boolean} disabled - Disabled state
|
|
38
|
+
* @attr {string} name - Field name for form submission
|
|
39
|
+
* @attr {boolean} readonly - Readonly state (focusable and selectable, not editable)
|
|
40
|
+
* @attr {boolean} required - Required state
|
|
41
|
+
* @attr {boolean} wrap - Wrap long lines (default true; prose wraps)
|
|
42
|
+
* @attr {number} rows - Minimum visible rows (the floor in every resize mode). Default: 6.
|
|
43
|
+
* @attr {string} resize - 'none' (fixed) | 'vertical' (drag) | 'auto' (grow, default)
|
|
44
|
+
* @attr {string} variant - 'simple' (default, bare) | 'input-field' (framed surface)
|
|
45
|
+
* @attr {string} font - 'sans' (default) | 'mono'
|
|
46
|
+
* @attr {string} accessible-label - Accessible label forwarded to the editor. Set automatically by nldd-form-field.
|
|
47
|
+
*
|
|
48
|
+
* @prop {MentionSource} mentionSource - Consumer-supplied @-mention candidate source (property only). Without it, @-typeahead is inert.
|
|
49
|
+
* @attr {boolean} annotatable - Enable the annotation overlay (off by default). Annotations only render when this is set.
|
|
50
|
+
* @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]`.
|
|
51
|
+
* @attr {object} translations - Override the editor's assistive-tech strings (the open-in-new-tab link badge and the annotation count badge). Unset keys fall back to Dutch.
|
|
52
|
+
*
|
|
53
|
+
* @fires input - When the content changes (detail: { value })
|
|
54
|
+
* @fires change - When the content is committed on blur (detail: { value })
|
|
55
|
+
* @fires nldd-text-editor-state - When the selection or content changes (detail: TextEditorState), for toolbar toggle state
|
|
56
|
+
* @fires nldd-text-editor-mention - When an @-mention is inserted (detail: MentionInsertedDetail with id, label, from, to)
|
|
57
|
+
* @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
|
|
58
|
+
*/
|
|
59
|
+
import { LitElement } from 'lit';
|
|
60
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
61
|
+
import { reflectNonDefault } from '../../../utilities/reflect-non-default.js';
|
|
62
|
+
import { EditorView, keymap, drawSelection, dropCursor, placeholder as cmPlaceholder, } from '@codemirror/view';
|
|
63
|
+
import { Compartment, EditorState, Prec, Transaction } from '@codemirror/state';
|
|
64
|
+
import { defaultKeymap, history, historyKeymap, indentLess, undo as cmUndo, redo as cmRedo, undoDepth, redoDepth } from '@codemirror/commands';
|
|
65
|
+
import { NLDDCodeMirrorElement } from '../../../utilities/codemirror/codemirror-element.js';
|
|
66
|
+
import { nlddCodeMirrorTheme } from '../../../utilities/codemirror/theme.js';
|
|
67
|
+
import { markdownEditing, mentionRangeAt, mentionRangeEndingAt, mentionRangeStartingAt } from './text-editor.markdown.js';
|
|
68
|
+
import { mentions } from './text-editor.mentions.js';
|
|
69
|
+
import { annotations as annotationExtension, setAnnotations, pasteAnnotations, currentAnnotations } from './text-editor.annotations.js';
|
|
70
|
+
import { orderedListRenumber } from './text-editor.ordered-list.js';
|
|
71
|
+
import { dragToMove, dragMovePlugin } from './text-editor.drag.js';
|
|
72
|
+
import { linkOpenBadge } from './text-editor.links.js';
|
|
73
|
+
import { toggleInlineWrap, indentListItems as cmIndentListItems, canIndentListItem as cmCanIndent, canOutdentListItem as cmCanOutdent, toggleHeading as cmToggleHeading, setHeading as cmSetHeading, toggleBulletList as cmToggleBulletList, setList as cmSetList, toggleQuote as cmToggleQuote, toggleLink as cmToggleLink, toggleCodeBlock as cmToggleCodeBlock, clearListMarkerBackward, readActiveFormats, EMPTY_FORMATS, } from './text-editor.commands.js';
|
|
74
|
+
import { textEditorStyles } from './text-editor.styles.js';
|
|
75
|
+
import { textEditorTemplate } from './text-editor.template.js';
|
|
76
|
+
import { stripSentinels, docToClean } from './text-editor.annotation-sentinels.js';
|
|
77
|
+
import { nlddTextEditorTranslations } from './text-editor.i18n.js';
|
|
78
|
+
let NLDDTextEditor = class NLDDTextEditor extends NLDDCodeMirrorElement {
|
|
79
|
+
constructor() {
|
|
80
|
+
super(...arguments);
|
|
81
|
+
this._internals = this.attachInternals();
|
|
82
|
+
this._initialValue = '';
|
|
83
|
+
this._valueAtFocus = '';
|
|
84
|
+
this._accessibleLabelWarned = false;
|
|
85
|
+
this.value = '';
|
|
86
|
+
this.inputId = '';
|
|
87
|
+
this.placeholder = '';
|
|
88
|
+
this.disabled = false;
|
|
89
|
+
this.name = '';
|
|
90
|
+
this.readonly = false;
|
|
91
|
+
this.required = false;
|
|
92
|
+
this.wrap = true;
|
|
93
|
+
this.rows = 6;
|
|
94
|
+
this.resize = 'auto';
|
|
95
|
+
this.variant = 'simple';
|
|
96
|
+
this.font = 'sans';
|
|
97
|
+
this.accessibleLabel = '';
|
|
98
|
+
/** Whether the annotation overlay is enabled. Off by default; set the
|
|
99
|
+
* `annotatable` attribute to turn it on (so the comment affordance and the
|
|
100
|
+
* overlay only appear when the consumer opts in). */
|
|
101
|
+
this.annotatable = false;
|
|
102
|
+
/** Consumer-supplied annotations (W3C-style overlay). Property only (set via
|
|
103
|
+
* JS). Render only when `annotatable` is on. The text stays clean; these
|
|
104
|
+
* render as a light tint and a count badge, anchored by offset and mapped
|
|
105
|
+
* through edits.
|
|
106
|
+
*
|
|
107
|
+
* IMPORTANT: assign a NEW array to apply changes. Lit dirty-checks this
|
|
108
|
+
* property by identity, so mutating the existing array in place
|
|
109
|
+
* (`editor.annotations.push(next)`, `editor.annotations[0].end = 9`, …) does
|
|
110
|
+
* NOT trigger a re-render. Always replace it:
|
|
111
|
+
* `editor.annotations = [...editor.annotations, next]`. */
|
|
112
|
+
this.annotations = [];
|
|
113
|
+
/** Override translation keys for the editor's assistive-tech strings (the
|
|
114
|
+
* open-in-new-tab link badge and the annotation count badge). Unset keys fall
|
|
115
|
+
* back to Dutch. */
|
|
116
|
+
this.translations = {};
|
|
117
|
+
this._editableCompartment = new Compartment();
|
|
118
|
+
this._wrapCompartment = new Compartment();
|
|
119
|
+
this._placeholderCompartment = new Compartment();
|
|
120
|
+
this._attrsCompartment = new Compartment();
|
|
121
|
+
this._historyCompartment = new Compartment();
|
|
122
|
+
/** Text and annotations of the last cut, so a same-editor paste can move the
|
|
123
|
+
* annotations along with their text. Cleared by copy and by a matching paste. */
|
|
124
|
+
this._cutBuffer = null;
|
|
125
|
+
/* # Internals */
|
|
126
|
+
this._onScrollerPointerDown = (event) => {
|
|
127
|
+
if (event.target !== this.view?.scrollDOM)
|
|
128
|
+
return;
|
|
129
|
+
// No caret to move on a read-only/disabled view — leave the press alone, like
|
|
130
|
+
// the drag path (which early-returns on state.readOnly).
|
|
131
|
+
if (this.view.state.readOnly)
|
|
132
|
+
return;
|
|
133
|
+
this.focusFromPoint(event.clientX, event.clientY);
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
};
|
|
136
|
+
this._onMentionPointerDown = (event) => {
|
|
137
|
+
const token = event.target?.closest?.('.cm-md-mention-token');
|
|
138
|
+
if (!token || !this.view)
|
|
139
|
+
return;
|
|
140
|
+
// Don't dispatch a selection on a read-only/disabled view — matches the drag
|
|
141
|
+
// path, which guards its selection change on state.readOnly.
|
|
142
|
+
if (this.view.state.readOnly)
|
|
143
|
+
return;
|
|
144
|
+
const range = mentionRangeAt(this.view.state, this.view.posAtDOM(token));
|
|
145
|
+
if (!range)
|
|
146
|
+
return;
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
event.stopPropagation();
|
|
149
|
+
this.view.dispatch({ selection: { anchor: range.from, head: range.to } });
|
|
150
|
+
this.view.focus();
|
|
151
|
+
// Hand off to the drag machinery: a plain release keeps the mention selected,
|
|
152
|
+
// dragging past the threshold moves the whole token. Left button, no modifiers.
|
|
153
|
+
if (event.button === 0 && !event.shiftKey && !event.altKey && !event.metaKey && !event.ctrlKey) {
|
|
154
|
+
this.view.plugin(dragMovePlugin)?.startFor(event, range.from, range.to);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
/** A click on an annotation's count badge emits nldd-text-editor-annotation-click
|
|
158
|
+
* with the id(s) it covers (a merged badge carries several) and the badge's
|
|
159
|
+
* viewport rect, so the consumer can anchor its own note UI to the badge. The
|
|
160
|
+
* tinted text stays plain-clickable for caret placement. */
|
|
161
|
+
this._onAnnotationBadgeClick = (event) => {
|
|
162
|
+
const badge = event.target?.closest?.('.cm-annotation-badge');
|
|
163
|
+
if (!badge)
|
|
164
|
+
return;
|
|
165
|
+
const ids = (badge.dataset.annotations ?? '').split(' ').filter(Boolean);
|
|
166
|
+
if (!ids.length)
|
|
167
|
+
return;
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
this.dispatchEvent(new CustomEvent('nldd-text-editor-annotation-click', {
|
|
170
|
+
detail: { ids, rect: badge.getBoundingClientRect() },
|
|
171
|
+
bubbles: true,
|
|
172
|
+
composed: true,
|
|
173
|
+
}));
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
getEditorParent() {
|
|
177
|
+
return this._container;
|
|
178
|
+
}
|
|
179
|
+
/** Resolve a translation key, applying `{name}` placeholder substitution from
|
|
180
|
+
* `vars`. Consumer overrides via `translations` win; unset keys fall back to the
|
|
181
|
+
* Dutch defaults. */
|
|
182
|
+
_t(key, vars) {
|
|
183
|
+
let str = this.translations[key] ?? nlddTextEditorTranslations[key];
|
|
184
|
+
if (vars) {
|
|
185
|
+
for (const [k, v] of Object.entries(vars)) {
|
|
186
|
+
str = str.split(`{${k}}`).join(String(v));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return str;
|
|
190
|
+
}
|
|
191
|
+
buildExtensions() {
|
|
192
|
+
return [
|
|
193
|
+
nlddCodeMirrorTheme,
|
|
194
|
+
markdownEditing,
|
|
195
|
+
mentions(() => this.mentionSource, (detail) => this._emitMention(detail)),
|
|
196
|
+
// Prec.low so this transaction filter runs *before* the annotation filter
|
|
197
|
+
// (filters run low-precedence first), letting the annotation map through the
|
|
198
|
+
// renumber changes too — otherwise a marker growing from 1 to 11 drifts a
|
|
199
|
+
// token on that line.
|
|
200
|
+
Prec.low(orderedListRenumber),
|
|
201
|
+
// The label fns read `this._t` lazily, so a newly rendered badge always uses
|
|
202
|
+
// the current `translations`; overriding them before mount localizes the
|
|
203
|
+
// assistive-tech strings.
|
|
204
|
+
annotationExtension((count, quote) => this._t('components.text-editor.annotation-count-label', {
|
|
205
|
+
count,
|
|
206
|
+
noun: this._t(count === 1
|
|
207
|
+
? 'components.text-editor.annotation-singular-lowercase'
|
|
208
|
+
: 'components.text-editor.annotation-plural-lowercase'),
|
|
209
|
+
quote,
|
|
210
|
+
})),
|
|
211
|
+
// Prec.highest so the badge nests inside a heading/bold run and scales with
|
|
212
|
+
// it, like the mention and annotation, instead of staying at the base size.
|
|
213
|
+
Prec.highest(linkOpenBadge((url) => this._t('components.text-editor.open-in-new-tab-label', { url }))),
|
|
214
|
+
this._historyCompartment.of(history()),
|
|
215
|
+
drawSelection(),
|
|
216
|
+
dropCursor(),
|
|
217
|
+
dragToMove,
|
|
218
|
+
// Prec.highest so this beats the markdown language's deleteMarkupBackward,
|
|
219
|
+
// which would otherwise leave alignment whitespace when a non-first list
|
|
220
|
+
// marker is backspaced. Falls through (returns false) off a list marker.
|
|
221
|
+
Prec.highest(keymap.of([{ key: 'Backspace', run: clearListMarkerBackward }])),
|
|
222
|
+
keymap.of([
|
|
223
|
+
{ key: 'Mod-b', run: (view) => { toggleInlineWrap(view, '**', 'StrongEmphasis'); return true; } },
|
|
224
|
+
{ key: 'Mod-i', run: (view) => { toggleInlineWrap(view, '*', 'Emphasis'); return true; } },
|
|
225
|
+
{ key: 'Mod-e', run: (view) => { toggleInlineWrap(view, '`', 'InlineCode'); return true; } },
|
|
226
|
+
{ key: 'Mod-k', run: (view) => { cmToggleLink(view); return true; } },
|
|
227
|
+
// A mention deletes in two steps: the first Backspace/Delete next to it
|
|
228
|
+
// selects the whole token, the second removes it.
|
|
229
|
+
{ key: 'Backspace', run: (view) => this._selectMentionBeforeDelete(view, -1) },
|
|
230
|
+
{ key: 'Delete', run: (view) => this._selectMentionBeforeDelete(view, 1) },
|
|
231
|
+
...defaultKeymap,
|
|
232
|
+
...historyKeymap,
|
|
233
|
+
]),
|
|
234
|
+
this._placeholderCompartment.of(this._placeholderExtension()),
|
|
235
|
+
this._wrapCompartment.of(this.wrap ? EditorView.lineWrapping : []),
|
|
236
|
+
this._editableCompartment.of(this._editableExtension()),
|
|
237
|
+
this._attrsCompartment.of(this._attrsExtension()),
|
|
238
|
+
EditorView.updateListener.of((u) => {
|
|
239
|
+
if (u.docChanged)
|
|
240
|
+
this._onDocChanged();
|
|
241
|
+
if (u.docChanged || u.selectionSet)
|
|
242
|
+
this._emitState();
|
|
243
|
+
}),
|
|
244
|
+
EditorView.domEventHandlers({
|
|
245
|
+
focus: () => {
|
|
246
|
+
this._valueAtFocus = this.value;
|
|
247
|
+
},
|
|
248
|
+
blur: () => {
|
|
249
|
+
if (this.value !== this._valueAtFocus)
|
|
250
|
+
this._emitChange();
|
|
251
|
+
},
|
|
252
|
+
// Triple-click selects the whole paragraph (the doc line), like macOS.
|
|
253
|
+
// CM's own triple-click stops at the visual line, which under wrapping is
|
|
254
|
+
// just one wrapped row.
|
|
255
|
+
mousedown: (event, view) => {
|
|
256
|
+
if (event.detail < 3)
|
|
257
|
+
return false;
|
|
258
|
+
const pos = view.posAtCoords({ x: event.clientX, y: event.clientY });
|
|
259
|
+
if (pos === null)
|
|
260
|
+
return false;
|
|
261
|
+
const line = view.state.doc.lineAt(pos);
|
|
262
|
+
view.dispatch({ selection: { anchor: line.from, head: line.to } });
|
|
263
|
+
event.preventDefault();
|
|
264
|
+
return true;
|
|
265
|
+
},
|
|
266
|
+
// Native Cmd/Ctrl+X/C/V go through these DOM events, not the toolbar's
|
|
267
|
+
// methods, so mirror the annotation-carrying logic here too.
|
|
268
|
+
cut: (_event, view) => {
|
|
269
|
+
const { from, to } = view.state.selection.main;
|
|
270
|
+
this._cutBuffer = from === to
|
|
271
|
+
? null
|
|
272
|
+
: { text: stripSentinels(view.state.sliceDoc(from, to)), anns: this._annotationsInSelection() };
|
|
273
|
+
return false; // let CodeMirror perform the actual cut (clipboard + delete)
|
|
274
|
+
},
|
|
275
|
+
copy: () => {
|
|
276
|
+
this._cutBuffer = null; // a plain copy must not carry a pending cut's annotations
|
|
277
|
+
return false;
|
|
278
|
+
},
|
|
279
|
+
paste: (event) => {
|
|
280
|
+
const raw = event.clipboardData?.getData('text/plain');
|
|
281
|
+
if (raw === undefined)
|
|
282
|
+
return false; // no clipboard data — let CodeMirror handle it
|
|
283
|
+
this._pasteText(stripSentinels(raw));
|
|
284
|
+
event.preventDefault();
|
|
285
|
+
return true;
|
|
286
|
+
},
|
|
287
|
+
}),
|
|
288
|
+
];
|
|
289
|
+
}
|
|
290
|
+
_editableExtension() {
|
|
291
|
+
const editable = !this.disabled;
|
|
292
|
+
const readOnly = this.disabled || this.readonly;
|
|
293
|
+
return [EditorView.editable.of(editable), EditorState.readOnly.of(readOnly)];
|
|
294
|
+
}
|
|
295
|
+
_placeholderExtension() {
|
|
296
|
+
return this.placeholder ? cmPlaceholder(this.placeholder) : [];
|
|
297
|
+
}
|
|
298
|
+
_attrsExtension() {
|
|
299
|
+
const attrs = {};
|
|
300
|
+
if (this.accessibleLabel)
|
|
301
|
+
attrs['aria-label'] = this.accessibleLabel;
|
|
302
|
+
if (this.inputId)
|
|
303
|
+
attrs['id'] = this.inputId;
|
|
304
|
+
return EditorView.contentAttributes.of(attrs);
|
|
305
|
+
}
|
|
306
|
+
firstUpdated() {
|
|
307
|
+
this._initialValue = this.value;
|
|
308
|
+
this.style.setProperty('--_rows', String(this.rows));
|
|
309
|
+
this.mountEditor(this.value);
|
|
310
|
+
this.onEditorMounted();
|
|
311
|
+
}
|
|
312
|
+
/* Runs on the initial mount and on every re-mount after a detach/reattach
|
|
313
|
+
* (e.g. Vue <KeepAlive>): the view — with its scroller and content DOM — is
|
|
314
|
+
* rebuilt, so the click forwarders and annotation state must be (re)applied. */
|
|
315
|
+
onEditorMounted() {
|
|
316
|
+
// A press on the scroller's own padding (outside .cm-content) doesn't
|
|
317
|
+
// place a caret; forward it to the nearest line.
|
|
318
|
+
this.view?.scrollDOM.addEventListener('pointerdown', this._onScrollerPointerDown);
|
|
319
|
+
// Clicking a mention selects the whole token (capture, to beat CM's own
|
|
320
|
+
// caret placement).
|
|
321
|
+
this.view?.contentDOM.addEventListener('pointerdown', this._onMentionPointerDown, true);
|
|
322
|
+
// Clicking an annotation's count badge opens it (the consumer decides how);
|
|
323
|
+
// the tinted text itself stays plain-clickable for caret placement.
|
|
324
|
+
this.view?.contentDOM.addEventListener('click', this._onAnnotationBadgeClick);
|
|
325
|
+
this._syncAnnotations();
|
|
326
|
+
this._internals.setFormValue(this.doc);
|
|
327
|
+
this._checkAccessibleLabel();
|
|
328
|
+
// Emit one state snapshot on mount so a consumer's toolbar initialises to the
|
|
329
|
+
// real state (e.g. undo/redo disabled with no history yet) instead of its
|
|
330
|
+
// default, without waiting for the first edit or selection change.
|
|
331
|
+
this._emitState();
|
|
332
|
+
}
|
|
333
|
+
updated(changed) {
|
|
334
|
+
if (changed.has('rows')) {
|
|
335
|
+
this.style.setProperty('--_rows', String(this.rows));
|
|
336
|
+
}
|
|
337
|
+
if (this.view) {
|
|
338
|
+
if (changed.has('value')) {
|
|
339
|
+
// Only push an external value change into the document; a value that just
|
|
340
|
+
// mirrors the current (sentinel-stripped) doc must not trigger a rewrite,
|
|
341
|
+
// which would strip the sentinels the filter then re-adds (caret churn).
|
|
342
|
+
if (stripSentinels(this.doc) !== this.value)
|
|
343
|
+
this.setDoc(this.value);
|
|
344
|
+
this._internals.setFormValue(this.value);
|
|
345
|
+
}
|
|
346
|
+
if (changed.has('disabled') || changed.has('readonly')) {
|
|
347
|
+
this.reconfigure(this._editableCompartment, this._editableExtension());
|
|
348
|
+
}
|
|
349
|
+
if (changed.has('wrap')) {
|
|
350
|
+
this.reconfigure(this._wrapCompartment, this.wrap ? EditorView.lineWrapping : []);
|
|
351
|
+
}
|
|
352
|
+
if (changed.has('placeholder')) {
|
|
353
|
+
this.reconfigure(this._placeholderCompartment, this._placeholderExtension());
|
|
354
|
+
}
|
|
355
|
+
if (changed.has('accessibleLabel') || changed.has('inputId')) {
|
|
356
|
+
this.reconfigure(this._attrsCompartment, this._attrsExtension());
|
|
357
|
+
}
|
|
358
|
+
if (changed.has('annotations') || changed.has('annotatable')) {
|
|
359
|
+
this._syncAnnotations();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
this._checkAccessibleLabel();
|
|
363
|
+
}
|
|
364
|
+
_syncAnnotations() {
|
|
365
|
+
// Annotations only render when the consumer opts in via `annotatable`.
|
|
366
|
+
// addToHistory:false keeps this consumer-driven re-anchoring (and the sentinel
|
|
367
|
+
// changes the filter appends) out of the text-edit undo stack — otherwise the
|
|
368
|
+
// first undo after load would strip the annotations instead of a real edit.
|
|
369
|
+
this.view?.dispatch({
|
|
370
|
+
effects: setAnnotations.of(this.annotatable ? this.annotations : []),
|
|
371
|
+
annotations: Transaction.addToHistory.of(false),
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
// Two-step mention deletion: select the token on the first key, remove on the
|
|
375
|
+
// second. dir -1 = Backspace (token ends at the caret), +1 = Delete (starts).
|
|
376
|
+
_selectMentionBeforeDelete(view, dir) {
|
|
377
|
+
const sel = view.state.selection.main;
|
|
378
|
+
// A non-empty selection (e.g. an already-selected mention) → let the default
|
|
379
|
+
// command delete it.
|
|
380
|
+
if (!sel.empty)
|
|
381
|
+
return false;
|
|
382
|
+
const range = dir < 0 ? mentionRangeEndingAt(view.state, sel.head) : mentionRangeStartingAt(view.state, sel.head);
|
|
383
|
+
if (!range)
|
|
384
|
+
return false; // not next to a mention → normal backspace/delete
|
|
385
|
+
view.dispatch({ selection: { anchor: range.from, head: range.to } });
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
/* # Headless command API */
|
|
389
|
+
toggleBold() {
|
|
390
|
+
if (this.view)
|
|
391
|
+
toggleInlineWrap(this.view, '**', 'StrongEmphasis');
|
|
392
|
+
}
|
|
393
|
+
toggleItalic() {
|
|
394
|
+
if (this.view)
|
|
395
|
+
toggleInlineWrap(this.view, '*', 'Emphasis');
|
|
396
|
+
}
|
|
397
|
+
toggleInlineCode() {
|
|
398
|
+
if (this.view)
|
|
399
|
+
toggleInlineWrap(this.view, '`', 'InlineCode');
|
|
400
|
+
}
|
|
401
|
+
toggleStrikethrough() {
|
|
402
|
+
if (this.view)
|
|
403
|
+
toggleInlineWrap(this.view, '~~', 'Strikethrough');
|
|
404
|
+
}
|
|
405
|
+
toggleHeading(level) {
|
|
406
|
+
if (this.view)
|
|
407
|
+
cmToggleHeading(this.view, level);
|
|
408
|
+
}
|
|
409
|
+
/** Set the block to a heading level (0 = paragraph) without toggling — for a
|
|
410
|
+
* picker where choosing a level always applies it. */
|
|
411
|
+
setHeading(level) {
|
|
412
|
+
if (this.view)
|
|
413
|
+
cmSetHeading(this.view, level);
|
|
414
|
+
}
|
|
415
|
+
toggleBulletList() {
|
|
416
|
+
if (this.view)
|
|
417
|
+
cmToggleBulletList(this.view);
|
|
418
|
+
}
|
|
419
|
+
/** Set the list type, replacing any existing list ('none' strips it) — for an
|
|
420
|
+
* exclusive list picker. */
|
|
421
|
+
setList(type) {
|
|
422
|
+
if (this.view)
|
|
423
|
+
cmSetList(this.view, type);
|
|
424
|
+
}
|
|
425
|
+
toggleQuote() {
|
|
426
|
+
if (this.view)
|
|
427
|
+
cmToggleQuote(this.view);
|
|
428
|
+
}
|
|
429
|
+
toggleLink(href = '') {
|
|
430
|
+
if (this.view)
|
|
431
|
+
cmToggleLink(this.view, href);
|
|
432
|
+
}
|
|
433
|
+
toggleCodeBlock() {
|
|
434
|
+
if (this.view)
|
|
435
|
+
cmToggleCodeBlock(this.view);
|
|
436
|
+
}
|
|
437
|
+
/** Nest the selected list item(s) under the preceding item at the same level.
|
|
438
|
+
* Only list items move, and only as far as that parent's content column — so a
|
|
439
|
+
* first or standalone item can't be over-indented into an indented code block. */
|
|
440
|
+
indent() {
|
|
441
|
+
if (this.view)
|
|
442
|
+
cmIndentListItems(this.view);
|
|
443
|
+
}
|
|
444
|
+
/** Decrease the leading indentation of the selected lines. */
|
|
445
|
+
outdent() {
|
|
446
|
+
if (this.view) {
|
|
447
|
+
indentLess(this.view);
|
|
448
|
+
this.view.focus();
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
/** Undo the last change. History is built in, so Cmd/Ctrl+Z works too. */
|
|
452
|
+
undo() {
|
|
453
|
+
if (this.view) {
|
|
454
|
+
cmUndo(this.view);
|
|
455
|
+
this.view.focus();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
/** Redo the last undone change (Cmd/Ctrl+Shift+Z / Ctrl+Y also work). */
|
|
459
|
+
redo() {
|
|
460
|
+
if (this.view) {
|
|
461
|
+
cmRedo(this.view);
|
|
462
|
+
this.view.focus();
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
/** Drop the undo/redo history, leaving the document untouched. Use after a
|
|
466
|
+
* consumer-driven discard so a later undo can't step back into the
|
|
467
|
+
* thrown-away edits. Reconfiguring the history compartment off and back on
|
|
468
|
+
* re-initialises it with empty stacks. */
|
|
469
|
+
clearHistory() {
|
|
470
|
+
const view = this.view;
|
|
471
|
+
if (!view)
|
|
472
|
+
return;
|
|
473
|
+
view.dispatch({ effects: this._historyCompartment.reconfigure([]) });
|
|
474
|
+
view.dispatch({ effects: this._historyCompartment.reconfigure(history()) });
|
|
475
|
+
this._emitState();
|
|
476
|
+
}
|
|
477
|
+
/** The annotations lying fully inside the current selection, offset relative to
|
|
478
|
+
* the selection's clean start. */
|
|
479
|
+
_annotationsInSelection() {
|
|
480
|
+
if (!this.view)
|
|
481
|
+
return [];
|
|
482
|
+
const { from, to } = this.view.state.selection.main;
|
|
483
|
+
const doc = this.view.state.doc.toString();
|
|
484
|
+
const cleanFrom = docToClean(doc, from);
|
|
485
|
+
const cleanTo = docToClean(doc, to);
|
|
486
|
+
return currentAnnotations(this.view.state)
|
|
487
|
+
.filter((a) => a.from >= cleanFrom && a.to <= cleanTo)
|
|
488
|
+
.map((a) => ({ id: a.id, from: a.from - cleanFrom, to: a.to - cleanFrom }));
|
|
489
|
+
}
|
|
490
|
+
/** Copy the current selection to the clipboard, sentinel-free. No-op when the
|
|
491
|
+
* selection is empty or the clipboard is unavailable (e.g. permission denied). */
|
|
492
|
+
async copy() {
|
|
493
|
+
if (!this.view)
|
|
494
|
+
return;
|
|
495
|
+
const { from, to } = this.view.state.selection.main;
|
|
496
|
+
if (from === to)
|
|
497
|
+
return;
|
|
498
|
+
const text = stripSentinels(this.view.state.sliceDoc(from, to));
|
|
499
|
+
// A copy is a plain-text copy: forget any pending cut so its annotations don't
|
|
500
|
+
// bleed onto the next paste.
|
|
501
|
+
this._cutBuffer = null;
|
|
502
|
+
try {
|
|
503
|
+
await navigator.clipboard.writeText(text);
|
|
504
|
+
}
|
|
505
|
+
catch { /* clipboard blocked */ }
|
|
506
|
+
// The await can outlive the element (disconnect destroys the view), so guard.
|
|
507
|
+
this.view?.focus();
|
|
508
|
+
}
|
|
509
|
+
/** Cut the current selection to the clipboard and remove it from the document.
|
|
510
|
+
* Its annotations are remembered so a paste back into this editor moves them
|
|
511
|
+
* along. No-op when the selection is empty. */
|
|
512
|
+
async cut() {
|
|
513
|
+
// Cut mutates (it removes the selection), so it's a no-op on a read-only editor.
|
|
514
|
+
if (!this.view || this.view.state.readOnly)
|
|
515
|
+
return;
|
|
516
|
+
const { from, to } = this.view.state.selection.main;
|
|
517
|
+
if (from === to)
|
|
518
|
+
return;
|
|
519
|
+
const text = stripSentinels(this.view.state.sliceDoc(from, to));
|
|
520
|
+
this._cutBuffer = { text, anns: this._annotationsInSelection() };
|
|
521
|
+
try {
|
|
522
|
+
await navigator.clipboard.writeText(text);
|
|
523
|
+
}
|
|
524
|
+
catch { /* clipboard blocked */ }
|
|
525
|
+
if (!this.view)
|
|
526
|
+
return;
|
|
527
|
+
this.view.dispatch(this.view.state.replaceSelection(''));
|
|
528
|
+
this.view.focus();
|
|
529
|
+
}
|
|
530
|
+
/** Paste clipboard text at the caret, replacing any selection. Sentinels that
|
|
531
|
+
* rode in from another editor are stripped. When the text matches a cut made in
|
|
532
|
+
* this editor, its annotations travel with it (a move); otherwise it's plain
|
|
533
|
+
* text. No-op when the clipboard is empty or unreadable. */
|
|
534
|
+
async paste() {
|
|
535
|
+
if (!this.view)
|
|
536
|
+
return;
|
|
537
|
+
let raw = '';
|
|
538
|
+
try {
|
|
539
|
+
raw = await navigator.clipboard.readText();
|
|
540
|
+
}
|
|
541
|
+
catch {
|
|
542
|
+
return; /* clipboard blocked */
|
|
543
|
+
}
|
|
544
|
+
this._pasteText(stripSentinels(raw));
|
|
545
|
+
this.view?.focus();
|
|
546
|
+
}
|
|
547
|
+
/** Insert `text` at the selection, re-attaching the cut annotations when it matches
|
|
548
|
+
* a cut made in this editor (a move, one-shot). Shared by the toolbar's paste()
|
|
549
|
+
* and the native Cmd/Ctrl+V handler. */
|
|
550
|
+
_pasteText(text) {
|
|
551
|
+
// Paste mutates; refuse it on a read-only editor (covers the toolbar paste()
|
|
552
|
+
// and the native Cmd/Ctrl+V handler that both funnel through here).
|
|
553
|
+
if (!this.view || !text || this.view.state.readOnly)
|
|
554
|
+
return;
|
|
555
|
+
const buffer = this._cutBuffer;
|
|
556
|
+
// Normalize line endings on both sides: a Windows/other-app clipboard may hand
|
|
557
|
+
// back CRLF where the cut buffer holds LF, and an exact compare would then miss
|
|
558
|
+
// the match and silently drop the carried annotations.
|
|
559
|
+
const sameText = (a, b) => a.replace(/\r\n/g, '\n') === b.replace(/\r\n/g, '\n');
|
|
560
|
+
const carry = !!(buffer && sameText(buffer.text, text) && buffer.anns.length > 0);
|
|
561
|
+
const at = docToClean(this.view.state.doc.toString(), this.view.state.selection.main.from);
|
|
562
|
+
const spec = this.view.state.replaceSelection(text);
|
|
563
|
+
this.view.dispatch(carry ? { ...spec, effects: pasteAnnotations.of({ at, anns: buffer.anns }) } : spec);
|
|
564
|
+
// One-shot: a second paste of the same cut would duplicate the ids, so drop it.
|
|
565
|
+
if (carry)
|
|
566
|
+
this._cutBuffer = null;
|
|
567
|
+
}
|
|
568
|
+
/** Escape hatch: run a command by name (bold, italic, inlineCode,
|
|
569
|
+
* strikethrough, bulletList, quote, heading [payload: level], link
|
|
570
|
+
* [payload: href], copy, cut, paste). */
|
|
571
|
+
runCommand(name, payload) {
|
|
572
|
+
switch (name) {
|
|
573
|
+
case 'bold':
|
|
574
|
+
this.toggleBold();
|
|
575
|
+
break;
|
|
576
|
+
case 'italic':
|
|
577
|
+
this.toggleItalic();
|
|
578
|
+
break;
|
|
579
|
+
case 'inlineCode':
|
|
580
|
+
this.toggleInlineCode();
|
|
581
|
+
break;
|
|
582
|
+
case 'strikethrough':
|
|
583
|
+
this.toggleStrikethrough();
|
|
584
|
+
break;
|
|
585
|
+
case 'bulletList':
|
|
586
|
+
this.toggleBulletList();
|
|
587
|
+
break;
|
|
588
|
+
case 'quote':
|
|
589
|
+
this.toggleQuote();
|
|
590
|
+
break;
|
|
591
|
+
case 'heading':
|
|
592
|
+
this.toggleHeading((typeof payload === 'number' ? payload : 1));
|
|
593
|
+
break;
|
|
594
|
+
case 'link':
|
|
595
|
+
this.toggleLink(typeof payload === 'string' ? payload : '');
|
|
596
|
+
break;
|
|
597
|
+
case 'copy':
|
|
598
|
+
void this.copy();
|
|
599
|
+
break;
|
|
600
|
+
case 'cut':
|
|
601
|
+
void this.cut();
|
|
602
|
+
break;
|
|
603
|
+
case 'paste':
|
|
604
|
+
void this.paste();
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
/** The formats active at the current selection (drives a toolbar's state). */
|
|
609
|
+
getState() {
|
|
610
|
+
return {
|
|
611
|
+
active: this.view ? readActiveFormats(this.view) : { ...EMPTY_FORMATS },
|
|
612
|
+
empty: this.view ? this.view.state.selection.main.empty : true,
|
|
613
|
+
canIndent: this.view ? cmCanIndent(this.view) : false,
|
|
614
|
+
canOutdent: this.view ? cmCanOutdent(this.view) : false,
|
|
615
|
+
canUndo: this.view ? undoDepth(this.view.state) > 0 : false,
|
|
616
|
+
canRedo: this.view ? redoDepth(this.view.state) > 0 : false,
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
/** The current selection in CLEAN (annotation-sentinel-free) coordinates plus
|
|
620
|
+
* the quoted text — the anchor a consumer needs to attach a new annotation to
|
|
621
|
+
* the selection (e.g. from a toolbar "comment" button). `empty` mirrors
|
|
622
|
+
* getState().empty for gating that button.
|
|
623
|
+
*
|
|
624
|
+
* `rect` is the selection's bounding box in viewport coordinates (or the
|
|
625
|
+
* caret box when empty), so a consumer can anchor a popover to the selected
|
|
626
|
+
* text itself instead of to its own button. Use it as a Floating UI virtual
|
|
627
|
+
* anchor: `{ getBoundingClientRect: () => rect, contextElement: editorEl }`.
|
|
628
|
+
* It is computed from CodeMirror's layout, so it is correct even when the
|
|
629
|
+
* editor is not focused (clicking a toolbar button blurs the editor but the
|
|
630
|
+
* selection state survives). `null` when there is no view or the selection
|
|
631
|
+
* is scrolled out of sight. */
|
|
632
|
+
getSelection() {
|
|
633
|
+
const view = this.view;
|
|
634
|
+
if (!view)
|
|
635
|
+
return { start: 0, end: 0, quote: '', empty: true, rect: null };
|
|
636
|
+
const doc = view.state.doc.toString();
|
|
637
|
+
const sel = view.state.selection.main;
|
|
638
|
+
const start = docToClean(doc, sel.from);
|
|
639
|
+
const end = docToClean(doc, sel.to);
|
|
640
|
+
const a = view.coordsAtPos(sel.from);
|
|
641
|
+
const b = view.coordsAtPos(sel.to);
|
|
642
|
+
const rect = a && b
|
|
643
|
+
? new DOMRect(Math.min(a.left, b.left), Math.min(a.top, b.top), Math.max(a.right, b.right) - Math.min(a.left, b.left), Math.max(a.bottom, b.bottom) - Math.min(a.top, b.top))
|
|
644
|
+
: null;
|
|
645
|
+
return { start, end, quote: stripSentinels(doc).slice(start, end), empty: sel.empty, rect };
|
|
646
|
+
}
|
|
647
|
+
/** The annotations currently in the editor, in CLEAN coordinates, each quote
|
|
648
|
+
* re-sliced from the current text — so a consumer can persist positions that
|
|
649
|
+
* moved with edits (read this on save, then write the anchors back). */
|
|
650
|
+
getAnnotations() {
|
|
651
|
+
const view = this.view;
|
|
652
|
+
if (!view)
|
|
653
|
+
return [];
|
|
654
|
+
const clean = stripSentinels(view.state.doc.toString());
|
|
655
|
+
return currentAnnotations(view.state).map((a) => ({
|
|
656
|
+
id: a.id,
|
|
657
|
+
start: a.from,
|
|
658
|
+
end: a.to,
|
|
659
|
+
quote: clean.slice(a.from, a.to),
|
|
660
|
+
}));
|
|
661
|
+
}
|
|
662
|
+
_emitState() {
|
|
663
|
+
this.dispatchEvent(new CustomEvent('nldd-text-editor-state', {
|
|
664
|
+
detail: this.getState(),
|
|
665
|
+
bubbles: true,
|
|
666
|
+
composed: true,
|
|
667
|
+
}));
|
|
668
|
+
}
|
|
669
|
+
_emitMention(detail) {
|
|
670
|
+
this.dispatchEvent(new CustomEvent('nldd-text-editor-mention', {
|
|
671
|
+
detail,
|
|
672
|
+
bubbles: true,
|
|
673
|
+
composed: true,
|
|
674
|
+
}));
|
|
675
|
+
}
|
|
676
|
+
_onDocChanged() {
|
|
677
|
+
// The document carries annotation sentinels; the exposed value never does.
|
|
678
|
+
const text = stripSentinels(this.doc);
|
|
679
|
+
if (text === this.value)
|
|
680
|
+
return;
|
|
681
|
+
this.value = text;
|
|
682
|
+
this._internals.setFormValue(text);
|
|
683
|
+
this.dispatchEvent(new CustomEvent('input', {
|
|
684
|
+
detail: { value: text },
|
|
685
|
+
bubbles: true,
|
|
686
|
+
composed: true,
|
|
687
|
+
}));
|
|
688
|
+
}
|
|
689
|
+
_emitChange() {
|
|
690
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
691
|
+
detail: { value: this.value },
|
|
692
|
+
bubbles: true,
|
|
693
|
+
composed: true,
|
|
694
|
+
}));
|
|
695
|
+
}
|
|
696
|
+
_checkAccessibleLabel() {
|
|
697
|
+
if (this._accessibleLabelWarned)
|
|
698
|
+
return;
|
|
699
|
+
if (this.accessibleLabel || this.inputId)
|
|
700
|
+
return;
|
|
701
|
+
this._accessibleLabelWarned = true;
|
|
702
|
+
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).');
|
|
703
|
+
}
|
|
704
|
+
formResetCallback() {
|
|
705
|
+
this.value = this._initialValue;
|
|
706
|
+
}
|
|
707
|
+
formDisabledCallback(disabled) {
|
|
708
|
+
this.disabled = disabled;
|
|
709
|
+
}
|
|
710
|
+
formStateRestoreCallback(state) {
|
|
711
|
+
if (typeof state === 'string')
|
|
712
|
+
this.value = state;
|
|
713
|
+
}
|
|
714
|
+
render() {
|
|
715
|
+
return textEditorTemplate(this);
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
NLDDTextEditor.formAssociated = true;
|
|
719
|
+
NLDDTextEditor.shadowRootOptions = {
|
|
720
|
+
...LitElement.shadowRootOptions,
|
|
721
|
+
delegatesFocus: true,
|
|
722
|
+
};
|
|
723
|
+
NLDDTextEditor.styles = textEditorStyles;
|
|
724
|
+
__decorate([
|
|
725
|
+
property({ type: String })
|
|
726
|
+
], NLDDTextEditor.prototype, "value", void 0);
|
|
727
|
+
__decorate([
|
|
728
|
+
property({ type: String, attribute: 'input-id' })
|
|
729
|
+
], NLDDTextEditor.prototype, "inputId", void 0);
|
|
730
|
+
__decorate([
|
|
731
|
+
property({ reflect: true, converter: reflectNonDefault('') })
|
|
732
|
+
], NLDDTextEditor.prototype, "placeholder", void 0);
|
|
733
|
+
__decorate([
|
|
734
|
+
property({ type: Boolean, reflect: true })
|
|
735
|
+
], NLDDTextEditor.prototype, "disabled", void 0);
|
|
736
|
+
__decorate([
|
|
737
|
+
property({ type: String, reflect: true })
|
|
738
|
+
], NLDDTextEditor.prototype, "name", void 0);
|
|
739
|
+
__decorate([
|
|
740
|
+
property({ type: Boolean, reflect: true })
|
|
741
|
+
], NLDDTextEditor.prototype, "readonly", void 0);
|
|
742
|
+
__decorate([
|
|
743
|
+
property({ type: Boolean, reflect: true })
|
|
744
|
+
], NLDDTextEditor.prototype, "required", void 0);
|
|
745
|
+
__decorate([
|
|
746
|
+
property({ type: Boolean, reflect: true })
|
|
747
|
+
], NLDDTextEditor.prototype, "wrap", void 0);
|
|
748
|
+
__decorate([
|
|
749
|
+
property({ type: Number })
|
|
750
|
+
], NLDDTextEditor.prototype, "rows", void 0);
|
|
751
|
+
__decorate([
|
|
752
|
+
property({ reflect: true, converter: reflectNonDefault('auto') })
|
|
753
|
+
], NLDDTextEditor.prototype, "resize", void 0);
|
|
754
|
+
__decorate([
|
|
755
|
+
property({ reflect: true, converter: reflectNonDefault('simple') })
|
|
756
|
+
], NLDDTextEditor.prototype, "variant", void 0);
|
|
757
|
+
__decorate([
|
|
758
|
+
property({ reflect: true, converter: reflectNonDefault('sans') })
|
|
759
|
+
], NLDDTextEditor.prototype, "font", void 0);
|
|
760
|
+
__decorate([
|
|
761
|
+
property({ type: String, attribute: 'accessible-label' })
|
|
762
|
+
], NLDDTextEditor.prototype, "accessibleLabel", void 0);
|
|
763
|
+
__decorate([
|
|
764
|
+
property({ attribute: false })
|
|
765
|
+
], NLDDTextEditor.prototype, "mentionSource", void 0);
|
|
766
|
+
__decorate([
|
|
767
|
+
property({ type: Boolean, reflect: true })
|
|
768
|
+
], NLDDTextEditor.prototype, "annotatable", void 0);
|
|
769
|
+
__decorate([
|
|
770
|
+
property({ attribute: false })
|
|
771
|
+
], NLDDTextEditor.prototype, "annotations", void 0);
|
|
772
|
+
__decorate([
|
|
773
|
+
property({ type: Object })
|
|
774
|
+
], NLDDTextEditor.prototype, "translations", void 0);
|
|
775
|
+
__decorate([
|
|
776
|
+
query('.text-editor')
|
|
777
|
+
], NLDDTextEditor.prototype, "_container", void 0);
|
|
778
|
+
NLDDTextEditor = __decorate([
|
|
779
|
+
customElement('nldd-text-editor')
|
|
780
|
+
], NLDDTextEditor);
|
|
781
|
+
export { NLDDTextEditor };
|
|
782
|
+
//# sourceMappingURL=text-editor.js.map
|