@aquera/nile-elements 1.9.7 → 1.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/{index-249de90a.esm.js → index-289706c7.esm.js} +1 -1
- package/dist/{index-df196058.cjs.js → index-d7e6f1c6.cjs.js} +2 -2
- package/dist/index-d7e6f1c6.cjs.js.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1587 -1276
- package/dist/katex-44476ab4.esm.js +1 -0
- package/dist/katex-f4186f87.cjs.js +2 -0
- package/dist/katex-f4186f87.cjs.js.map +1 -0
- package/dist/nile-color-picker/index.cjs.js +1 -1
- package/dist/nile-color-picker/index.esm.js +1 -1
- package/dist/nile-color-picker/nile-color-picker.cjs.js +1 -1
- package/dist/nile-color-picker/nile-color-picker.cjs.js.map +1 -1
- package/dist/nile-color-picker/nile-color-picker.esm.js +1 -1
- package/dist/nile-select/virtual-scroll-helper.cjs.js +1 -1
- package/dist/nile-select/virtual-scroll-helper.cjs.js.map +1 -1
- package/dist/nile-select/virtual-scroll-helper.esm.js +52 -44
- package/dist/nile-virtual-select/renderer.cjs.js +1 -1
- package/dist/nile-virtual-select/renderer.cjs.js.map +1 -1
- package/dist/nile-virtual-select/renderer.esm.js +23 -22
- package/dist/nile-wysiwyg-editor/engine/commands.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/commands.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/commands.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/create-state.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/inputrules.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/keymap.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/keymap.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embeds.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embeds.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embeds.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/math-view.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/math-view.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/math-view.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/style-block-view.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/style-block-view.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/style-block-view.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/tables.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/sanitize.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/sanitize.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/sanitize.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/schema.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/schema.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/schema.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/selection-state.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/math/katex-renderer.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/math/katex-renderer.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/math/katex-renderer.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.esm.js +22 -3
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.esm.js +7 -6
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.esm.js +33 -54
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.esm.js +83 -95
- package/dist/nile-wysiwyg-editor/types.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/types.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/types.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-item.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/bubble-item.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/bubble-item.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.esm.js +23 -15
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.esm.js +3 -3
- package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-panel.esm.js +2 -2
- package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/math-panel.esm.js +0 -3
- package/dist/nile-wysiwyg-editor/ui/preview.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/preview.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/preview.esm.js +8 -0
- package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/source-view.esm.js +225 -24
- package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/suggest-list.esm.js +9 -9
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.esm.js +115 -13
- package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-menu.esm.js +13 -12
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-color-picker/nile-color-picker.d.ts +1 -0
- package/dist/src/nile-color-picker/nile-color-picker.js +1 -0
- package/dist/src/nile-color-picker/nile-color-picker.js.map +1 -1
- package/dist/src/nile-select/virtual-scroll-helper.js +9 -1
- package/dist/src/nile-select/virtual-scroll-helper.js.map +1 -1
- package/dist/src/nile-virtual-select/renderer.js +1 -0
- package/dist/src/nile-virtual-select/renderer.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/index.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/index.js +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/index.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embed-view.js +3 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embed-view.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.d.ts +19 -4
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.js +23 -18
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.d.ts +8 -3
- package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.js +41 -4
- package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/plugins/style-block-view.d.ts +17 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/style-block-view.js +174 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/style-block-view.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.js +33 -2
- package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/pm.test.js +49 -8
- package/dist/src/nile-wysiwyg-editor/engine/pm.test.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/sanitize.d.ts +12 -0
- package/dist/src/nile-wysiwyg-editor/engine/sanitize.js +76 -8
- package/dist/src/nile-wysiwyg-editor/engine/sanitize.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/schema.d.ts +2 -0
- package/dist/src/nile-wysiwyg-editor/engine/schema.js +154 -2
- package/dist/src/nile-wysiwyg-editor/engine/schema.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/index.d.ts +5 -0
- package/dist/src/nile-wysiwyg-editor/index.js +3 -0
- package/dist/src/nile-wysiwyg-editor/index.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/math/katex-renderer.d.ts +38 -0
- package/dist/src/nile-wysiwyg-editor/math/katex-renderer.js +40 -0
- package/dist/src/nile-wysiwyg-editor/math/katex-renderer.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js +22 -3
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.d.ts +36 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js +125 -8
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.js +5 -2
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.d.ts +2 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.js +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.d.ts +55 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.js +79 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.js +33 -54
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.d.ts +50 -2
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.js +158 -102
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/types.d.ts +4 -2
- package/dist/src/nile-wysiwyg-editor/types.js +2 -2
- package/dist/src/nile-wysiwyg-editor/types.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/bubble-item.d.ts +48 -0
- package/dist/src/nile-wysiwyg-editor/ui/bubble-item.js +69 -0
- package/dist/src/nile-wysiwyg-editor/ui/bubble-item.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.d.ts +17 -2
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js +128 -35
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.d.ts +2 -1
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js +4 -3
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/math-panel.js +0 -3
- package/dist/src/nile-wysiwyg-editor/ui/math-panel.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/preview.d.ts +20 -0
- package/dist/src/nile-wysiwyg-editor/ui/preview.js +44 -0
- package/dist/src/nile-wysiwyg-editor/ui/preview.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/source-view.d.ts +35 -3
- package/dist/src/nile-wysiwyg-editor/ui/source-view.js +337 -24
- package/dist/src/nile-wysiwyg-editor/ui/source-view.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js +9 -0
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.d.ts +13 -2
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js +166 -10
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.js +10 -8
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/xml-25c4108a.esm.js +1 -0
- package/dist/xml-90fd974e.cjs.js +2 -0
- package/dist/xml-90fd974e.cjs.js.map +1 -0
- package/package.json +2 -1
- package/rollup.config.js +1 -0
- package/src/index.ts +8 -0
- package/src/nile-color-picker/nile-color-picker.ts +1 -0
- package/src/nile-select/virtual-scroll-helper.ts +9 -1
- package/src/nile-virtual-select/renderer.ts +1 -1
- package/src/nile-wysiwyg-editor/engine/index.ts +1 -0
- package/src/nile-wysiwyg-editor/engine/plugins/embed-view.ts +3 -0
- package/src/nile-wysiwyg-editor/engine/plugins/embeds.ts +26 -20
- package/src/nile-wysiwyg-editor/engine/plugins/math-view.ts +45 -4
- package/src/nile-wysiwyg-editor/engine/plugins/style-block-view.ts +178 -0
- package/src/nile-wysiwyg-editor/engine/plugins/tables.ts +34 -2
- package/src/nile-wysiwyg-editor/engine/pm.test.ts +58 -8
- package/src/nile-wysiwyg-editor/engine/sanitize.ts +71 -8
- package/src/nile-wysiwyg-editor/engine/schema.ts +158 -7
- package/src/nile-wysiwyg-editor/index.ts +5 -0
- package/src/nile-wysiwyg-editor/math/katex-renderer.ts +59 -0
- package/src/nile-wysiwyg-editor/math/katex.d.ts +17 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.ts +22 -3
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.ts +5 -2
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.ts +142 -7
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.ts +2 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.ts +68 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.ts +33 -54
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.ts +202 -108
- package/src/nile-wysiwyg-editor/types.ts +6 -4
- package/src/nile-wysiwyg-editor/ui/bubble-item.ts +60 -0
- package/src/nile-wysiwyg-editor/ui/bubble-menu.ts +147 -40
- package/src/nile-wysiwyg-editor/ui/embed-panel.ts +4 -3
- package/src/nile-wysiwyg-editor/ui/math-panel.ts +0 -3
- package/src/nile-wysiwyg-editor/ui/preview.ts +42 -0
- package/src/nile-wysiwyg-editor/ui/source-view.ts +339 -31
- package/src/nile-wysiwyg-editor/ui/suggest-list.ts +10 -0
- package/src/nile-wysiwyg-editor/ui/table-grid-picker.ts +160 -10
- package/src/nile-wysiwyg-editor/ui/table-menu.ts +10 -8
- package/vscode-html-custom-data.json +75 -6
- package/dist/index-df196058.cjs.js.map +0 -1
|
@@ -1,8 +1,83 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html, css } from 'lit';
|
|
2
|
+
import { html, css, nothing } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
4
|
import NileElement from '../../internal/nile-element';
|
|
5
5
|
import { renderGlyph } from '../../internal/glyph';
|
|
6
|
+
import '../../nile-lite-tooltip/nile-lite-tooltip';
|
|
7
|
+
/**
|
|
8
|
+
* Registry of controls addressable by `<nile-wysiwyg-bubble-item name="…">`.
|
|
9
|
+
* Icons/labels mirror the main toolbar so both surfaces look identical.
|
|
10
|
+
*/
|
|
11
|
+
const BUBBLE_ITEMS = {
|
|
12
|
+
bold: { command: 'bold', label: 'Bold', icon: 'format_bold', active: s => s.bold },
|
|
13
|
+
italic: { command: 'italic', label: 'Italic', icon: 'format_italic', active: s => s.italic },
|
|
14
|
+
underline: {
|
|
15
|
+
command: 'underline',
|
|
16
|
+
label: 'Underline',
|
|
17
|
+
icon: 'format_underline',
|
|
18
|
+
active: s => s.underline,
|
|
19
|
+
},
|
|
20
|
+
strike: {
|
|
21
|
+
command: 'strike',
|
|
22
|
+
label: 'Strikethrough',
|
|
23
|
+
icon: 'ng-strikethrough',
|
|
24
|
+
active: s => s.strike,
|
|
25
|
+
},
|
|
26
|
+
code: { command: 'code', label: 'Inline code', icon: 'ng-code', active: s => s.code },
|
|
27
|
+
subscript: {
|
|
28
|
+
command: 'subscript',
|
|
29
|
+
label: 'Subscript',
|
|
30
|
+
icon: 'ng-subscript',
|
|
31
|
+
active: s => s.subscript,
|
|
32
|
+
},
|
|
33
|
+
superscript: {
|
|
34
|
+
command: 'superscript',
|
|
35
|
+
label: 'Superscript',
|
|
36
|
+
icon: 'ng-superscript',
|
|
37
|
+
active: s => s.superscript,
|
|
38
|
+
},
|
|
39
|
+
link: { command: 'openLink', label: 'Link', icon: 'link_2', active: s => s.linkActive },
|
|
40
|
+
bulletList: {
|
|
41
|
+
command: 'bulletList',
|
|
42
|
+
label: 'Bulleted list',
|
|
43
|
+
icon: 'format_list_bulleted',
|
|
44
|
+
active: s => s.inBulletList,
|
|
45
|
+
},
|
|
46
|
+
orderedList: {
|
|
47
|
+
command: 'orderedList',
|
|
48
|
+
label: 'Numbered list',
|
|
49
|
+
icon: 'format_list_numbered',
|
|
50
|
+
active: s => s.inOrderedList,
|
|
51
|
+
},
|
|
52
|
+
alignLeft: {
|
|
53
|
+
command: 'align',
|
|
54
|
+
label: 'Align left',
|
|
55
|
+
icon: 'format_align_left',
|
|
56
|
+
attrs: { align: 'left' },
|
|
57
|
+
active: s => s.align === 'left',
|
|
58
|
+
},
|
|
59
|
+
alignCenter: {
|
|
60
|
+
command: 'align',
|
|
61
|
+
label: 'Align center',
|
|
62
|
+
icon: 'format_align_middle',
|
|
63
|
+
attrs: { align: 'center' },
|
|
64
|
+
active: s => s.align === 'center',
|
|
65
|
+
},
|
|
66
|
+
alignRight: {
|
|
67
|
+
command: 'align',
|
|
68
|
+
label: 'Align right',
|
|
69
|
+
icon: 'format_align_right',
|
|
70
|
+
attrs: { align: 'right' },
|
|
71
|
+
active: s => s.align === 'right',
|
|
72
|
+
},
|
|
73
|
+
clearFormatting: {
|
|
74
|
+
command: 'clearFormatting',
|
|
75
|
+
label: 'Clear formatting',
|
|
76
|
+
icon: 'format_clear',
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
/** Built-in default when no `<nile-wysiwyg-bubble-item>` children are authored. */
|
|
80
|
+
const DEFAULT_BUBBLE = ['bold', 'italic', 'underline', 'strike', 'link'];
|
|
6
81
|
/**
|
|
7
82
|
* Balloon toolbar shown over non-empty selections. The host owns positioning
|
|
8
83
|
* (absolute left/top) and visibility; commands bubble up as
|
|
@@ -12,29 +87,6 @@ let NileWysiwygBubbleMenu = class NileWysiwygBubbleMenu extends NileElement {
|
|
|
12
87
|
constructor() {
|
|
13
88
|
super(...arguments);
|
|
14
89
|
this.open = false;
|
|
15
|
-
/** Same icon set as the main toolbar, so both surfaces look identical. */
|
|
16
|
-
this.items = [
|
|
17
|
-
{ name: 'bold', label: 'Bold', icon: 'format_bold', active: s => s.bold },
|
|
18
|
-
{ name: 'italic', label: 'Italic', icon: 'format_italic', active: s => s.italic },
|
|
19
|
-
{
|
|
20
|
-
name: 'underline',
|
|
21
|
-
label: 'Underline',
|
|
22
|
-
icon: 'format_underline',
|
|
23
|
-
active: s => s.underline,
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: 'strike',
|
|
27
|
-
label: 'Strikethrough',
|
|
28
|
-
icon: 'ng-strikethrough',
|
|
29
|
-
active: s => s.strike,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: 'openLink',
|
|
33
|
-
label: 'Link',
|
|
34
|
-
icon: 'link_2',
|
|
35
|
-
active: s => s.linkActive,
|
|
36
|
-
},
|
|
37
|
-
];
|
|
38
90
|
}
|
|
39
91
|
static get styles() {
|
|
40
92
|
return [
|
|
@@ -90,27 +142,65 @@ let NileWysiwygBubbleMenu = class NileWysiwygBubbleMenu extends NileElement {
|
|
|
90
142
|
background: var(--nile-colors-primary-50, var(--ng-componentcolors-utility-blue-50, #eff4ff));
|
|
91
143
|
color: var(--nile-colors-primary-700, var(--ng-componentcolors-utility-blue-700, #1d4ed8));
|
|
92
144
|
}
|
|
145
|
+
|
|
146
|
+
.divider {
|
|
147
|
+
align-self: stretch;
|
|
148
|
+
width: 1px;
|
|
149
|
+
margin: 3px 2px;
|
|
150
|
+
background: var(--nile-colors-neutral-300, #e4e7ec);
|
|
151
|
+
}
|
|
93
152
|
`,
|
|
94
153
|
];
|
|
95
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* True when this instance is an author's declarative `<nile-wysiwyg-bubble-menu>`
|
|
157
|
+
* container in an editor's light DOM (holding `<nile-wysiwyg-bubble-item>`
|
|
158
|
+
* children). It renders nothing — the editor reads the items and renders the
|
|
159
|
+
* real bubble menu in its own shadow DOM. The editor's internal instance
|
|
160
|
+
* lives in a shadow root, so `closest` never matches it.
|
|
161
|
+
*/
|
|
162
|
+
get isAuthoringContainer() {
|
|
163
|
+
return !!this.closest('nile-wysiwyg-editor');
|
|
164
|
+
}
|
|
96
165
|
render() {
|
|
166
|
+
if (this.isAuthoringContainer)
|
|
167
|
+
return html ``;
|
|
97
168
|
const state = this.toolbarState;
|
|
169
|
+
const entries = this.items && this.items.length
|
|
170
|
+
? this.items
|
|
171
|
+
: DEFAULT_BUBBLE.map(name => ({ name }));
|
|
98
172
|
return html `
|
|
99
173
|
<div class="bubble" part="bubble-menu" @mousedown=${(e) => e.preventDefault()}>
|
|
100
|
-
${
|
|
101
|
-
<button
|
|
102
|
-
type="button"
|
|
103
|
-
title=${item.label}
|
|
104
|
-
aria-label=${item.label}
|
|
105
|
-
?data-active=${state ? item.active(state) : false}
|
|
106
|
-
@click=${() => this.emit('wysiwyg-command', { name: item.name })}
|
|
107
|
-
>
|
|
108
|
-
${renderGlyph(item.icon, 16)}
|
|
109
|
-
</button>
|
|
110
|
-
`)}
|
|
174
|
+
${entries.map(entry => this.renderEntry(entry, state))}
|
|
111
175
|
</div>
|
|
112
176
|
`;
|
|
113
177
|
}
|
|
178
|
+
renderEntry(entry, state) {
|
|
179
|
+
if (entry.name === '|') {
|
|
180
|
+
return html `<span class="divider" part="bubble-divider"></span>`;
|
|
181
|
+
}
|
|
182
|
+
const base = BUBBLE_ITEMS[entry.name];
|
|
183
|
+
const label = entry.label || base?.label || entry.name;
|
|
184
|
+
const icon = entry.icon || base?.icon;
|
|
185
|
+
// Unknown command with no icon to draw → nothing to render.
|
|
186
|
+
if (!icon)
|
|
187
|
+
return nothing;
|
|
188
|
+
const command = base?.command ?? entry.name;
|
|
189
|
+
const attrs = base?.attrs;
|
|
190
|
+
const isActive = base?.active && state ? base.active(state) : false;
|
|
191
|
+
return html `
|
|
192
|
+
<nile-lite-tooltip content=${label} placement="top">
|
|
193
|
+
<button
|
|
194
|
+
type="button"
|
|
195
|
+
aria-label=${label}
|
|
196
|
+
?data-active=${isActive}
|
|
197
|
+
@click=${() => this.emit('wysiwyg-command', attrs ? { name: command, attrs } : { name: command })}
|
|
198
|
+
>
|
|
199
|
+
${renderGlyph(icon, 16)}
|
|
200
|
+
</button>
|
|
201
|
+
</nile-lite-tooltip>
|
|
202
|
+
`;
|
|
203
|
+
}
|
|
114
204
|
};
|
|
115
205
|
__decorate([
|
|
116
206
|
property({ type: Boolean, reflect: true })
|
|
@@ -118,6 +208,9 @@ __decorate([
|
|
|
118
208
|
__decorate([
|
|
119
209
|
property({ attribute: false })
|
|
120
210
|
], NileWysiwygBubbleMenu.prototype, "toolbarState", void 0);
|
|
211
|
+
__decorate([
|
|
212
|
+
property({ attribute: false })
|
|
213
|
+
], NileWysiwygBubbleMenu.prototype, "items", void 0);
|
|
121
214
|
NileWysiwygBubbleMenu = __decorate([
|
|
122
215
|
customElement('nile-wysiwyg-bubble-menu')
|
|
123
216
|
], NileWysiwygBubbleMenu);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bubble-menu.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/ui/bubble-menu.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,WAAW,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAYnD;;;;GAIG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,WAAW;IAA/C;;QACuC,SAA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CAAC,KAAK;6BACR,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;uBACxC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;;gBAE9D,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;;WAE/B,CACF;;KAEJ,CAAC;IACJ,CAAC;CACF,CAAA;AA1G6C;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAAc;AAEzB;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2DAA6B;AAHjD,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CA2GjC","sourcesContent":["import { html, css, TemplateResult, CSSResultArray } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport NileElement from '../../internal/nile-element';\nimport { renderGlyph } from '../../internal/glyph';\nimport type { ToolbarState } from '../engine/selection-state';\nimport type { WysiwygCommandDetail } from '../types';\n\ninterface BubbleItem {\n name: WysiwygCommandDetail['name'];\n label: string;\n /** nile-glyph icon name (ng-* names are stroke-drawn). */\n icon: string;\n active: (state: ToolbarState) => boolean;\n}\n\n/**\n * Balloon toolbar shown over non-empty selections. The host owns positioning\n * (absolute left/top) and visibility; commands bubble up as\n * `wysiwyg-command` events, same contract as the main toolbar.\n */\n@customElement('nile-wysiwyg-bubble-menu')\nexport class NileWysiwygBubbleMenu extends NileElement {\n @property({ type: Boolean, reflect: true }) open = false;\n\n @property({ attribute: false }) toolbarState?: ToolbarState;\n\n public static get styles(): CSSResultArray {\n return [\n css`\n :host {\n font-family: var(\n --nile-font-family-sans-serif,\n var(--ng-font-family-body, system-ui, -apple-system, sans-serif)\n );\n position: absolute;\n z-index: 15;\n display: none;\n }\n\n :host([open]) {\n display: block;\n }\n\n .bubble {\n display: flex;\n gap: 2px;\n padding: 4px;\n background: var(--nile-wysiwyg-popover-bg, #ffffff);\n border: 1px solid\n var(--nile-wysiwyg-border-color, var(--nile-colors-neutral-400, #d0d5dd));\n border-radius: var(--nile-wysiwyg-radius, 8px);\n box-shadow: var(\n --nile-wysiwyg-popover-shadow,\n 0 4px 12px rgba(16, 24, 40, 0.12)\n );\n }\n\n button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 26px;\n height: 26px;\n border: none;\n border-radius: 5px;\n background: transparent;\n cursor: pointer;\n font-size: 13px;\n font-weight: 600;\n color: var(--nile-colors-neutral-700, #344054);\n }\n\n button:hover {\n background: var(--nile-colors-neutral-100, #f2f4f7);\n }\n\n button[data-active] {\n background: var(--nile-colors-primary-50, var(--ng-componentcolors-utility-blue-50, #eff4ff));\n color: var(--nile-colors-primary-700, var(--ng-componentcolors-utility-blue-700, #1d4ed8));\n }\n `,\n ];\n }\n\n /** Same icon set as the main toolbar, so both surfaces look identical. */\n private items: BubbleItem[] = [\n { name: 'bold', label: 'Bold', icon: 'format_bold', active: s => s.bold },\n { name: 'italic', label: 'Italic', icon: 'format_italic', active: s => s.italic },\n {\n name: 'underline',\n label: 'Underline',\n icon: 'format_underline',\n active: s => s.underline,\n },\n {\n name: 'strike',\n label: 'Strikethrough',\n icon: 'ng-strikethrough',\n active: s => s.strike,\n },\n {\n name: 'openLink',\n label: 'Link',\n icon: 'link_2',\n active: s => s.linkActive,\n },\n ];\n\n public render(): TemplateResult {\n const state = this.toolbarState;\n return html`\n <div class=\"bubble\" part=\"bubble-menu\" @mousedown=${(e: Event) => e.preventDefault()}>\n ${this.items.map(\n item => html`\n <button\n type=\"button\"\n title=${item.label}\n aria-label=${item.label}\n ?data-active=${state ? item.active(state) : false}\n @click=${() => this.emit('wysiwyg-command', { name: item.name })}\n >\n ${renderGlyph(item.icon, 16)}\n </button>\n `\n )}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-wysiwyg-bubble-menu': NileWysiwygBubbleMenu;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bubble-menu.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/ui/bubble-menu.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAkC,OAAO,EAAE,MAAM,KAAK,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,WAAW,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInD,OAAO,2CAA2C,CAAC;AAcnD;;;GAGG;AACH,MAAM,YAAY,GAA8B;IAC9C,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE;IAClF,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE;IAC5F,SAAS,EAAE;QACT,OAAO,EAAE,WAAW;QACpB,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;KACzB;IACD,MAAM,EAAE;QACN,OAAO,EAAE,QAAQ;QACjB,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM;KACtB;IACD,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CA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C;CACF,CAAA;AAnI6C;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAAc;AAEzB;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2DAA6B;AAO5B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDAA+B;AAVnD,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CAoIjC","sourcesContent":["import { html, css, TemplateResult, CSSResultArray, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport NileElement from '../../internal/nile-element';\nimport { renderGlyph } from '../../internal/glyph';\nimport type { ToolbarState } from '../engine/selection-state';\nimport type { WysiwygCommandDetail } from '../types';\nimport type { AuthoredToolbarItem } from '../nile-wysiwyg-toolbar/nile-wysiwyg-toolbar';\nimport '../../nile-lite-tooltip/nile-lite-tooltip';\n\n/** A control the bubble menu knows how to render, keyed by its authored name. */\ninterface BubbleDef {\n /** The command dispatched on click. */\n command: WysiwygCommandDetail['name'];\n label: string;\n /** nile-glyph icon name (ng-* names are stroke-drawn). */\n icon: string;\n /** Static attrs sent with the command (e.g. alignment direction). */\n attrs?: WysiwygCommandDetail['attrs'];\n active?: (state: ToolbarState) => boolean;\n}\n\n/**\n * Registry of controls addressable by `<nile-wysiwyg-bubble-item name=\"…\">`.\n * Icons/labels mirror the main toolbar so both surfaces look identical.\n */\nconst BUBBLE_ITEMS: Record<string, BubbleDef> = {\n bold: { command: 'bold', label: 'Bold', icon: 'format_bold', active: s => s.bold },\n italic: { command: 'italic', label: 'Italic', icon: 'format_italic', active: s => s.italic },\n underline: {\n command: 'underline',\n label: 'Underline',\n icon: 'format_underline',\n active: s => s.underline,\n },\n strike: {\n command: 'strike',\n label: 'Strikethrough',\n icon: 'ng-strikethrough',\n active: s => s.strike,\n },\n code: { command: 'code', label: 'Inline code', icon: 'ng-code', active: s => s.code },\n subscript: {\n command: 'subscript',\n label: 'Subscript',\n icon: 'ng-subscript',\n active: s => s.subscript,\n },\n superscript: {\n command: 'superscript',\n label: 'Superscript',\n icon: 'ng-superscript',\n active: s => s.superscript,\n },\n link: { command: 'openLink', label: 'Link', icon: 'link_2', active: s => s.linkActive },\n bulletList: {\n command: 'bulletList',\n label: 'Bulleted list',\n icon: 'format_list_bulleted',\n active: s => s.inBulletList,\n },\n orderedList: {\n command: 'orderedList',\n label: 'Numbered list',\n icon: 'format_list_numbered',\n active: s => s.inOrderedList,\n },\n alignLeft: {\n command: 'align',\n label: 'Align left',\n icon: 'format_align_left',\n attrs: { align: 'left' },\n active: s => s.align === 'left',\n },\n alignCenter: {\n command: 'align',\n label: 'Align center',\n icon: 'format_align_middle',\n attrs: { align: 'center' },\n active: s => s.align === 'center',\n },\n alignRight: {\n command: 'align',\n label: 'Align right',\n icon: 'format_align_right',\n attrs: { align: 'right' },\n active: s => s.align === 'right',\n },\n clearFormatting: {\n command: 'clearFormatting',\n label: 'Clear formatting',\n icon: 'format_clear',\n },\n};\n\n/** Built-in default when no `<nile-wysiwyg-bubble-item>` children are authored. */\nconst DEFAULT_BUBBLE = ['bold', 'italic', 'underline', 'strike', 'link'];\n\n/**\n * Balloon toolbar shown over non-empty selections. The host owns positioning\n * (absolute left/top) and visibility; commands bubble up as\n * `wysiwyg-command` events, same contract as the main toolbar.\n */\n@customElement('nile-wysiwyg-bubble-menu')\nexport class NileWysiwygBubbleMenu extends NileElement {\n @property({ type: Boolean, reflect: true }) open = false;\n\n @property({ attribute: false }) toolbarState?: ToolbarState;\n\n /**\n * Structured item list authored in light DOM (from\n * `<nile-wysiwyg-bubble-item>` children). `'|'` is a separator. Falls back to\n * {@link DEFAULT_BUBBLE} when empty.\n */\n @property({ attribute: false }) items?: AuthoredToolbarItem[];\n\n public static get styles(): CSSResultArray {\n return [\n css`\n :host {\n font-family: var(\n --nile-font-family-sans-serif,\n var(--ng-font-family-body, system-ui, -apple-system, sans-serif)\n );\n position: absolute;\n z-index: 15;\n display: none;\n }\n\n :host([open]) {\n display: block;\n }\n\n .bubble {\n display: flex;\n gap: 2px;\n padding: 4px;\n background: var(--nile-wysiwyg-popover-bg, #ffffff);\n border: 1px solid\n var(--nile-wysiwyg-border-color, var(--nile-colors-neutral-400, #d0d5dd));\n border-radius: var(--nile-wysiwyg-radius, 8px);\n box-shadow: var(\n --nile-wysiwyg-popover-shadow,\n 0 4px 12px rgba(16, 24, 40, 0.12)\n );\n }\n\n button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 26px;\n height: 26px;\n border: none;\n border-radius: 5px;\n background: transparent;\n cursor: pointer;\n font-size: 13px;\n font-weight: 600;\n color: var(--nile-colors-neutral-700, #344054);\n }\n\n button:hover {\n background: var(--nile-colors-neutral-100, #f2f4f7);\n }\n\n button[data-active] {\n background: var(--nile-colors-primary-50, var(--ng-componentcolors-utility-blue-50, #eff4ff));\n color: var(--nile-colors-primary-700, var(--ng-componentcolors-utility-blue-700, #1d4ed8));\n }\n\n .divider {\n align-self: stretch;\n width: 1px;\n margin: 3px 2px;\n background: var(--nile-colors-neutral-300, #e4e7ec);\n }\n `,\n ];\n }\n\n /**\n * True when this instance is an author's declarative `<nile-wysiwyg-bubble-menu>`\n * container in an editor's light DOM (holding `<nile-wysiwyg-bubble-item>`\n * children). It renders nothing — the editor reads the items and renders the\n * real bubble menu in its own shadow DOM. The editor's internal instance\n * lives in a shadow root, so `closest` never matches it.\n */\n private get isAuthoringContainer(): boolean {\n return !!this.closest('nile-wysiwyg-editor');\n }\n\n public render(): TemplateResult {\n if (this.isAuthoringContainer) return html``;\n\n const state = this.toolbarState;\n const entries: AuthoredToolbarItem[] =\n this.items && this.items.length\n ? this.items\n : DEFAULT_BUBBLE.map(name => ({ name }));\n return html`\n <div class=\"bubble\" part=\"bubble-menu\" @mousedown=${(e: Event) => e.preventDefault()}>\n ${entries.map(entry => this.renderEntry(entry, state))}\n </div>\n `;\n }\n\n private renderEntry(\n entry: AuthoredToolbarItem,\n state?: ToolbarState\n ): TemplateResult | typeof nothing {\n if (entry.name === '|') {\n return html`<span class=\"divider\" part=\"bubble-divider\"></span>`;\n }\n const base = BUBBLE_ITEMS[entry.name];\n const label = entry.label || base?.label || entry.name;\n const icon = entry.icon || base?.icon;\n // Unknown command with no icon to draw → nothing to render.\n if (!icon) return nothing;\n const command = base?.command ?? (entry.name as WysiwygCommandDetail['name']);\n const attrs = base?.attrs;\n const isActive = base?.active && state ? base.active(state) : false;\n return html`\n <nile-lite-tooltip content=${label} placement=\"top\">\n <button\n type=\"button\"\n aria-label=${label}\n ?data-active=${isActive}\n @click=${() =>\n this.emit('wysiwyg-command', attrs ? { name: command, attrs } : { name: command })}\n >\n ${renderGlyph(icon, 16)}\n </button>\n </nile-lite-tooltip>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-wysiwyg-bubble-menu': NileWysiwygBubbleMenu;\n }\n}\n"]}
|
|
@@ -3,7 +3,8 @@ import NileElement from '../../internal/nile-element';
|
|
|
3
3
|
import '../../nile-input/index';
|
|
4
4
|
import '../../nile-button/index';
|
|
5
5
|
/**
|
|
6
|
-
* Floating embed-insert panel: paste
|
|
6
|
+
* Floating embed-insert panel: paste any https:// link (YouTube/Vimeo/Loom
|
|
7
|
+
* are auto-formatted; anything else embeds as a sandboxed iframe). Styled to
|
|
7
8
|
* match the image panel (nile-input + nile-button). Emits
|
|
8
9
|
* `wysiwyg-embed-apply` detail: { src, provider } and `wysiwyg-embed-cancel`.
|
|
9
10
|
*/
|
|
@@ -6,7 +6,8 @@ import { toEmbedUrl } from '../engine/plugins/embeds';
|
|
|
6
6
|
import '../../nile-input/index';
|
|
7
7
|
import '../../nile-button/index';
|
|
8
8
|
/**
|
|
9
|
-
* Floating embed-insert panel: paste
|
|
9
|
+
* Floating embed-insert panel: paste any https:// link (YouTube/Vimeo/Loom
|
|
10
|
+
* are auto-formatted; anything else embeds as a sandboxed iframe). Styled to
|
|
10
11
|
* match the image panel (nile-input + nile-button). Emits
|
|
11
12
|
* `wysiwyg-embed-apply` detail: { src, provider } and `wysiwyg-embed-cancel`.
|
|
12
13
|
*/
|
|
@@ -90,7 +91,7 @@ let NileWysiwygEmbedPanel = class NileWysiwygEmbedPanel extends NileElement {
|
|
|
90
91
|
handleSubmit() {
|
|
91
92
|
const target = toEmbedUrl(this.urlValue.trim());
|
|
92
93
|
if (!target) {
|
|
93
|
-
this.error = '
|
|
94
|
+
this.error = 'Enter a valid https:// URL.';
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
96
97
|
this.error = '';
|
|
@@ -119,7 +120,7 @@ let NileWysiwygEmbedPanel = class NileWysiwygEmbedPanel extends NileElement {
|
|
|
119
120
|
|
|
120
121
|
${this.error
|
|
121
122
|
? html `<span class="error" part="error">${this.error}</span>`
|
|
122
|
-
: html `<span class="hint">
|
|
123
|
+
: html `<span class="hint">Add any link to it</span>`}
|
|
123
124
|
|
|
124
125
|
<div class="actions">
|
|
125
126
|
<nile-button variant="primary" @click=${() => this.handleSubmit()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed-panel.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/ui/embed-panel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,WAAW,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AAEjC
|
|
1
|
+
{"version":3,"file":"embed-panel.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/ui/embed-panel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AA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;YAC3C,OAAO;QACT,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAEO,aAAa,CAAC,KAAoB;QACxC,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC3B,KAAK,CAAC,eAAe,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACpC,CAAC;aAAM,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;YACjC,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,KAAK,CAAC,eAAe,EAAE,CAAC;YACxB,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAA;6DAC8C,IAAI,CAAC,aAAa;;;;mBAI5D,IAAI,CAAC,QAAQ;wBACR,IAAI,CAAC,KAAK;;;UAGxB,IAAI,CAAC,KAAK;YACV,CAAC,CAAC,IAAI,CAAA,oCAAoC,IAAI,CAAC,KAAK,SAAS;YAC7D,CAAC,CAAC,IAAI,CAAA,8CAA8C;;;kDAGZ,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE;;;;;KAKtE,CAAC;IACJ,CAAC;CACF,CAAA;AA1H6C;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAAc;AAExC;IAAhB,KAAK,EAAE;uDAAuB;AACd;IAAhB,KAAK,EAAE;oDAAoB;AAJjB,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CA2HjC","sourcesContent":["import { html, css, TemplateResult, CSSResultArray } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport NileElement from '../../internal/nile-element';\nimport { toEmbedUrl } from '../engine/plugins/embeds';\nimport '../../nile-input/index';\nimport '../../nile-button/index';\n\n/**\n * Floating embed-insert panel: paste any https:// link (YouTube/Vimeo/Loom\n * are auto-formatted; anything else embeds as a sandboxed iframe). Styled to\n * match the image panel (nile-input + nile-button). Emits\n * `wysiwyg-embed-apply` detail: { src, provider } and `wysiwyg-embed-cancel`.\n */\n@customElement('nile-wysiwyg-embed-panel')\nexport class NileWysiwygEmbedPanel extends NileElement {\n @property({ type: Boolean, reflect: true }) open = false;\n\n @state() private urlValue = '';\n @state() private error = '';\n\n public static get styles(): CSSResultArray {\n return [\n css`\n :host {\n font-family: var(\n --nile-font-family-sans-serif,\n var(--ng-font-family-body, system-ui, -apple-system, sans-serif)\n );\n position: absolute;\n z-index: 20;\n display: none;\n }\n\n :host([open]) {\n display: block;\n }\n\n .embed-panel {\n display: flex;\n flex-direction: column;\n gap: 12px;\n min-width: 340px;\n max-width: 420px;\n padding: 12px;\n background: var(--nile-wysiwyg-popover-bg, #ffffff);\n border: 1px solid var(--nile-colors-neutral-400, #d0d5dd);\n border-radius: 8px;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);\n font-size: 13px;\n }\n\n nile-input {\n width: 100%;\n }\n\n .hint {\n font-size: 12px;\n color: var(--nile-colors-neutral-500, #98a2b3);\n }\n\n .error {\n font-size: 12px;\n color: var(--nile-colors-danger-600, #d92d20);\n }\n\n .actions {\n display: flex;\n justify-content: flex-end;\n align-items: center;\n gap: 8px;\n width: 100%;\n }\n `,\n ];\n }\n\n public focusInput(): void {\n this.updateComplete.then(() => {\n const input = this.shadowRoot?.querySelector('nile-input') as HTMLElement | null;\n input?.focus();\n });\n }\n\n /** Clears the field. */\n public reset(): void {\n this.urlValue = '';\n this.error = '';\n }\n\n private onUrl(event: CustomEvent): void {\n this.urlValue = (event.detail?.value ?? '') as string;\n this.error = '';\n }\n\n private handleSubmit(): void {\n const target = toEmbedUrl(this.urlValue.trim());\n if (!target) {\n this.error = 'Enter a valid https:// URL.';\n return;\n }\n this.error = '';\n this.emit('wysiwyg-embed-apply', target);\n }\n\n private handleKeydown(event: KeyboardEvent): void {\n if (event.key === 'Escape') {\n event.stopPropagation();\n this.emit('wysiwyg-embed-cancel');\n } else if (event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n this.handleSubmit();\n }\n }\n\n public render(): TemplateResult {\n return html`\n <div class=\"embed-panel\" part=\"embed-panel\" @keydown=${this.handleKeydown}>\n <nile-input\n label=\"Video URL\"\n placeholder=\"https://www.youtube.com/watch?v=…\"\n .value=${this.urlValue}\n @nile-input=${this.onUrl}\n ></nile-input>\n\n ${this.error\n ? html`<span class=\"error\" part=\"error\">${this.error}</span>`\n : html`<span class=\"hint\">Add any link to it</span>`}\n\n <div class=\"actions\">\n <nile-button variant=\"primary\" @click=${() => this.handleSubmit()}\n >Embed</nile-button\n >\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-wysiwyg-embed-panel': NileWysiwygEmbedPanel;\n }\n}\n"]}
|
|
@@ -143,9 +143,6 @@ let NileWysiwygMathPanel = class NileWysiwygMathPanel extends NileElement {
|
|
|
143
143
|
</nile-button-toggle-group>
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
|
-
<span class="hint"
|
|
147
|
-
>LaTeX is stored as-is; rendering uses your math renderer if configured.</span
|
|
148
|
-
>
|
|
149
146
|
|
|
150
147
|
<div class="actions">
|
|
151
148
|
<nile-button variant="primary" @click=${() => this.handleSubmit()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math-panel.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/ui/math-panel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,WAAW,MAAM,6BAA6B,CAAC;AACtD,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBA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CAAC,CAAC,CAAC,QAAQ,CAAC;QACjE,CAAC;;;;;;;;;kDASqC,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE;;;;;KAKtE,CAAC;IACJ,CAAC;CACF,CAAA;AA/I6C;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAAc;AAExC;IAAhB,KAAK,EAAE;wDAAyB;AAChB;IAAhB,KAAK,EAAE;qDAAgD;AAJ7C,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CAgJhC","sourcesContent":["import { html, css, TemplateResult, CSSResultArray } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport NileElement from '../../internal/nile-element';\nimport '../../nile-input/index';\nimport '../../nile-button/index';\nimport '../../nile-button-toggle-group/index';\nimport '../../nile-button-toggle/index';\n\n/**\n * Floating math-insert panel: enter a LaTeX expression. Styled to match the\n * image/embed panels (nile-input + nile-button). Emits `wysiwyg-math-apply`\n * detail: { latex, display } and `wysiwyg-math-cancel`. Rendering of the\n * formula itself is the host's job (via a mathRenderer).\n */\n@customElement('nile-wysiwyg-math-panel')\nexport class NileWysiwygMathPanel extends NileElement {\n @property({ type: Boolean, reflect: true }) open = false;\n\n @state() private latexValue = '';\n @state() private display: 'inline' | 'block' = 'inline';\n\n public static get styles(): CSSResultArray {\n return [\n css`\n :host {\n font-family: var(\n --nile-font-family-sans-serif,\n var(--ng-font-family-body, system-ui, -apple-system, sans-serif)\n );\n position: absolute;\n z-index: 20;\n display: none;\n }\n\n :host([open]) {\n display: block;\n }\n\n .math-panel {\n display: flex;\n flex-direction: column;\n gap: 12px;\n min-width: 340px;\n max-width: 420px;\n padding: 12px;\n background: var(--nile-wysiwyg-popover-bg, #ffffff);\n border: 1px solid var(--nile-colors-neutral-400, #d0d5dd);\n border-radius: 8px;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);\n font-size: 13px;\n }\n\n nile-input {\n width: 100%;\n }\n\n /* Keep the LaTeX field monospaced. */\n nile-input::part(input) {\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n }\n\n .display-row {\n display: flex;\n align-items: center;\n gap: 10px;\n }\n\n .display-label {\n color: var(--nile-colors-neutral-700, #344054);\n }\n\n .hint {\n font-size: 12px;\n color: var(--nile-colors-neutral-500, #98a2b3);\n }\n\n .actions {\n display: flex;\n justify-content: flex-end;\n align-items: center;\n gap: 8px;\n width: 100%;\n }\n `,\n ];\n }\n\n /** Opens with an optional initial value (editing an existing formula). */\n public focusInput(initial = ''): void {\n this.latexValue = initial;\n this.updateComplete.then(() => {\n const input = this.shadowRoot?.querySelector('nile-input') as HTMLElement | null;\n input?.focus();\n });\n }\n\n /** Clears the field. */\n public reset(): void {\n this.latexValue = '';\n this.display = 'inline';\n }\n\n private onLatex(event: CustomEvent): void {\n this.latexValue = (event.detail?.value ?? '') as string;\n }\n\n private handleSubmit(): void {\n const latex = this.latexValue.trim();\n if (!latex) {\n this.emit('wysiwyg-math-cancel');\n return;\n }\n this.emit('wysiwyg-math-apply', { latex, display: this.display });\n }\n\n private handleKeydown(event: KeyboardEvent): void {\n if (event.key === 'Escape') {\n event.stopPropagation();\n this.emit('wysiwyg-math-cancel');\n } else if (event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n this.handleSubmit();\n }\n }\n\n public render(): TemplateResult {\n return html`\n <div class=\"math-panel\" part=\"math-panel\" @keydown=${this.handleKeydown}>\n <nile-input\n label=\"LaTeX expression\"\n placeholder=\"e.g. \\\\frac{a}{b} = c^2\"\n .value=${this.latexValue}\n @nile-input=${this.onLatex}\n ></nile-input>\n\n <div class=\"display-row\">\n <span class=\"display-label\">Display</span>\n <nile-button-toggle-group\n class=\"toggle\"\n .value=${this.display}\n @nile-change=${(e: CustomEvent) => {\n this.display = e.detail.value === 'block' ? 'block' : 'inline';\n }}\n >\n <nile-button-toggle value=\"inline\">Inline</nile-button-toggle>\n <nile-button-toggle value=\"block\">Block</nile-button-toggle>\n </nile-button-toggle-group>\n </div>\n\n\n <div class=\"actions\">\n <nile-button variant=\"primary\" @click=${() => this.handleSubmit()}\n >Insert</nile-button\n >\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-wysiwyg-math-panel': NileWysiwygMathPanel;\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LitElement, TemplateResult, CSSResultArray } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Renders sanitized document HTML inside its OWN shadow root. Any author
|
|
4
|
+
* `<style>` block in the content is therefore scoped to this element and
|
|
5
|
+
* cannot leak into the surrounding source-view / editor chrome (which lives in
|
|
6
|
+
* a different shadow root). Reuses the editor's content styles so the render
|
|
7
|
+
* matches the live editor. The content wrapper is an `<article>`, not a
|
|
8
|
+
* `<div>`, so a blanket `div { … }` rule doesn't paint the wrapper itself.
|
|
9
|
+
*/
|
|
10
|
+
export declare class NileWysiwygPreview extends LitElement {
|
|
11
|
+
/** Sanitized HTML to render (already run through sanitizeHtml). */
|
|
12
|
+
content: string;
|
|
13
|
+
static get styles(): CSSResultArray;
|
|
14
|
+
render(): TemplateResult;
|
|
15
|
+
}
|
|
16
|
+
declare global {
|
|
17
|
+
interface HTMLElementTagNameMap {
|
|
18
|
+
'nile-wysiwyg-preview': NileWysiwygPreview;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, html, css } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
5
|
+
import { styles as editorStyles } from '../nile-wysiwyg-editor.css';
|
|
6
|
+
/**
|
|
7
|
+
* Renders sanitized document HTML inside its OWN shadow root. Any author
|
|
8
|
+
* `<style>` block in the content is therefore scoped to this element and
|
|
9
|
+
* cannot leak into the surrounding source-view / editor chrome (which lives in
|
|
10
|
+
* a different shadow root). Reuses the editor's content styles so the render
|
|
11
|
+
* matches the live editor. The content wrapper is an `<article>`, not a
|
|
12
|
+
* `<div>`, so a blanket `div { … }` rule doesn't paint the wrapper itself.
|
|
13
|
+
*/
|
|
14
|
+
let NileWysiwygPreview = class NileWysiwygPreview extends LitElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
/** Sanitized HTML to render (already run through sanitizeHtml). */
|
|
18
|
+
this.content = '';
|
|
19
|
+
}
|
|
20
|
+
static get styles() {
|
|
21
|
+
return [
|
|
22
|
+
editorStyles,
|
|
23
|
+
css `
|
|
24
|
+
:host {
|
|
25
|
+
display: block;
|
|
26
|
+
}
|
|
27
|
+
.ProseMirror {
|
|
28
|
+
min-height: 0;
|
|
29
|
+
}
|
|
30
|
+
`,
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
return html `<article class="ProseMirror">${unsafeHTML(this.content)}</article>`;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
__decorate([
|
|
38
|
+
property({ type: String })
|
|
39
|
+
], NileWysiwygPreview.prototype, "content", void 0);
|
|
40
|
+
NileWysiwygPreview = __decorate([
|
|
41
|
+
customElement('nile-wysiwyg-preview')
|
|
42
|
+
], NileWysiwygPreview);
|
|
43
|
+
export { NileWysiwygPreview };
|
|
44
|
+
//# sourceMappingURL=preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/ui/preview.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;;;;;GAOG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IAA3C;;QACL,mEAAmE;QACvC,YAAO,GAAG,EAAE,CAAC;IAmB3C,CAAC;IAjBQ,MAAM,KAAK,MAAM;QACtB,OAAO;YACL,YAAY;YACZ,GAAG,CAAA;;;;;;;OAOF;SACF,CAAC;IACJ,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAA,gCAAgC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;IAClF,CAAC;CACF,CAAA;AAnB6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAc;AAF9B,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CAqB9B","sourcesContent":["import { LitElement, html, css, TemplateResult, CSSResultArray } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\nimport { styles as editorStyles } from '../nile-wysiwyg-editor.css';\n\n/**\n * Renders sanitized document HTML inside its OWN shadow root. Any author\n * `<style>` block in the content is therefore scoped to this element and\n * cannot leak into the surrounding source-view / editor chrome (which lives in\n * a different shadow root). Reuses the editor's content styles so the render\n * matches the live editor. The content wrapper is an `<article>`, not a\n * `<div>`, so a blanket `div { … }` rule doesn't paint the wrapper itself.\n */\n@customElement('nile-wysiwyg-preview')\nexport class NileWysiwygPreview extends LitElement {\n /** Sanitized HTML to render (already run through sanitizeHtml). */\n @property({ type: String }) content = '';\n\n public static get styles(): CSSResultArray {\n return [\n editorStyles,\n css`\n :host {\n display: block;\n }\n .ProseMirror {\n min-height: 0;\n }\n `,\n ];\n }\n\n public render(): TemplateResult {\n return html`<article class=\"ProseMirror\">${unsafeHTML(this.content)}</article>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-wysiwyg-preview': NileWysiwygPreview;\n }\n}\n"]}
|
|
@@ -1,15 +1,47 @@
|
|
|
1
1
|
import { TemplateResult, CSSResultArray } from 'lit';
|
|
2
2
|
import NileElement from '../../internal/nile-element';
|
|
3
|
+
import './preview';
|
|
3
4
|
/**
|
|
4
|
-
* Raw HTML source editing mode.
|
|
5
|
-
*
|
|
5
|
+
* Raw HTML source editing mode. A split view: the raw HTML on the left, a
|
|
6
|
+
* live rendered preview on the right, with a draggable divider between them
|
|
7
|
+
* and a resizable body. The preview runs the same sanitizer the host applies
|
|
8
|
+
* on the way back, so what you see is what the document becomes. Emits
|
|
6
9
|
* `wysiwyg-source-apply` detail: { html } and `wysiwyg-source-cancel`.
|
|
10
|
+
*
|
|
11
|
+
* The code pane is a lightweight editor: a real `<textarea>` for input, with a
|
|
12
|
+
* highlight.js-coloured layer painted behind it and a synced line-number
|
|
13
|
+
* gutter. No heavyweight code-editor dependency.
|
|
7
14
|
*/
|
|
8
15
|
export declare class NileWysiwygSourceView extends NileElement {
|
|
9
16
|
value: string;
|
|
10
|
-
textarea
|
|
17
|
+
private textarea?;
|
|
18
|
+
private highlightEl?;
|
|
19
|
+
private linenosEl?;
|
|
20
|
+
private bodyEl?;
|
|
21
|
+
/** Current source text, drives the live preview, highlight and gutter. */
|
|
22
|
+
private draft;
|
|
23
|
+
/**
|
|
24
|
+
* Fraction of the body width given to the code pane (the rest is preview).
|
|
25
|
+
* Clamped while dragging the divider.
|
|
26
|
+
*/
|
|
27
|
+
private splitRatio;
|
|
28
|
+
/** Whether the divider is currently being dragged. */
|
|
29
|
+
private splitDragging;
|
|
11
30
|
static get styles(): CSSResultArray;
|
|
31
|
+
protected willUpdate(changed: Map<string, unknown>): void;
|
|
32
|
+
/** The current (possibly edited) source text — what "Done" would apply. */
|
|
33
|
+
get currentValue(): string;
|
|
12
34
|
focusInput(): void;
|
|
35
|
+
/** highlight.js-coloured HTML for the current draft (falls back to escaped). */
|
|
36
|
+
private get highlighted();
|
|
37
|
+
private get lineCount();
|
|
38
|
+
/** Begins a pointer-driven resize of the split divider. */
|
|
39
|
+
private startSplitDrag;
|
|
40
|
+
/** Resets the divider to a 50/50 layout (double-click affordance). */
|
|
41
|
+
private resetSplit;
|
|
42
|
+
private onInput;
|
|
43
|
+
/** Keeps the highlight layer and line-number gutter aligned with scroll. */
|
|
44
|
+
private onScroll;
|
|
13
45
|
render(): TemplateResult;
|
|
14
46
|
}
|
|
15
47
|
declare global {
|