@docengine/editor 0.0.0-stage → 0.0.105
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 +112 -2
- package/dist/DocEnginePdfViewer.zip +0 -0
- package/dist/editor-lwc.css +7425 -0
- package/dist/editor-lwc.js +1595 -0
- package/dist/editor-lwc.js.map +1 -0
- package/dist/editor.js +89754 -0
- package/dist/pdf-viewer/viewer.html +40 -0
- package/dist/pdf-viewer/viewer.js +1 -0
- package/lib/.tsbuildinfo +1 -0
- package/lib/catalog/catalog-provider.d.ts +27 -0
- package/lib/catalog/catalog-provider.d.ts.map +1 -0
- package/lib/catalog/catalog-provider.js +88 -0
- package/lib/catalog/catalog-provider.js.map +1 -0
- package/lib/core/computed-formula.d.ts +3 -0
- package/lib/core/computed-formula.d.ts.map +1 -0
- package/lib/core/computed-formula.js +2 -0
- package/lib/core/computed-formula.js.map +1 -0
- package/lib/core/computed-formula.test.d.ts +2 -0
- package/lib/core/computed-formula.test.d.ts.map +1 -0
- package/lib/core/computed-formula.test.js +204 -0
- package/lib/core/computed-formula.test.js.map +1 -0
- package/lib/core/document-display-defaults.d.ts +2 -0
- package/lib/core/document-display-defaults.d.ts.map +1 -0
- package/lib/core/document-display-defaults.js +2 -0
- package/lib/core/document-display-defaults.js.map +1 -0
- package/lib/core/document-history.d.ts +23 -0
- package/lib/core/document-history.d.ts.map +1 -0
- package/lib/core/document-history.js +87 -0
- package/lib/core/document-history.js.map +1 -0
- package/lib/core/document-history.test.d.ts +2 -0
- package/lib/core/document-history.test.d.ts.map +1 -0
- package/lib/core/document-history.test.js +47 -0
- package/lib/core/document-history.test.js.map +1 -0
- package/lib/core/document-io.d.ts +2 -0
- package/lib/core/document-io.d.ts.map +1 -0
- package/lib/core/document-io.js +2 -0
- package/lib/core/document-io.js.map +1 -0
- package/lib/core/document-io.test.d.ts +2 -0
- package/lib/core/document-io.test.d.ts.map +1 -0
- package/lib/core/document-io.test.js +616 -0
- package/lib/core/document-io.test.js.map +1 -0
- package/lib/core/document-section-defaults.d.ts +27 -0
- package/lib/core/document-section-defaults.d.ts.map +1 -0
- package/lib/core/document-section-defaults.js +60 -0
- package/lib/core/document-section-defaults.js.map +1 -0
- package/lib/core/document-section-defaults.test.d.ts +2 -0
- package/lib/core/document-section-defaults.test.d.ts.map +1 -0
- package/lib/core/document-section-defaults.test.js +47 -0
- package/lib/core/document-section-defaults.test.js.map +1 -0
- package/lib/core/field-id.d.ts +2 -0
- package/lib/core/field-id.d.ts.map +1 -0
- package/lib/core/field-id.js +2 -0
- package/lib/core/field-id.js.map +1 -0
- package/lib/core/field-id.test.d.ts +2 -0
- package/lib/core/field-id.test.d.ts.map +1 -0
- package/lib/core/field-id.test.js +253 -0
- package/lib/core/field-id.test.js.map +1 -0
- package/lib/core/field-io/sectioned-document-io.d.ts +2 -0
- package/lib/core/field-io/sectioned-document-io.d.ts.map +1 -0
- package/lib/core/field-io/sectioned-document-io.js +2 -0
- package/lib/core/field-io/sectioned-document-io.js.map +1 -0
- package/lib/core/field-io/sectioned-document-io.test.d.ts +2 -0
- package/lib/core/field-io/sectioned-document-io.test.d.ts.map +1 -0
- package/lib/core/field-io/sectioned-document-io.test.js +511 -0
- package/lib/core/field-io/sectioned-document-io.test.js.map +1 -0
- package/lib/core/field-io/table-field-io.d.ts +2 -0
- package/lib/core/field-io/table-field-io.d.ts.map +1 -0
- package/lib/core/field-io/table-field-io.js +2 -0
- package/lib/core/field-io/table-field-io.js.map +1 -0
- package/lib/core/field-io/table-field-io.test.d.ts +2 -0
- package/lib/core/field-io/table-field-io.test.d.ts.map +1 -0
- package/lib/core/field-io/table-field-io.test.js +193 -0
- package/lib/core/field-io/table-field-io.test.js.map +1 -0
- package/lib/core/field-schemas.d.ts +2 -0
- package/lib/core/field-schemas.d.ts.map +1 -0
- package/lib/core/field-schemas.js +7 -0
- package/lib/core/field-schemas.js.map +1 -0
- package/lib/core/field-schemas.test.d.ts +2 -0
- package/lib/core/field-schemas.test.d.ts.map +1 -0
- package/lib/core/field-schemas.test.js +369 -0
- package/lib/core/field-schemas.test.js.map +1 -0
- package/lib/core/formula-field-index.d.ts +2 -0
- package/lib/core/formula-field-index.d.ts.map +1 -0
- package/lib/core/formula-field-index.js +2 -0
- package/lib/core/formula-field-index.js.map +1 -0
- package/lib/core/formula-field-index.test.d.ts +2 -0
- package/lib/core/formula-field-index.test.d.ts.map +1 -0
- package/lib/core/formula-field-index.test.js +110 -0
- package/lib/core/formula-field-index.test.js.map +1 -0
- package/lib/core/page-setup-styles.d.ts +69 -0
- package/lib/core/page-setup-styles.d.ts.map +1 -0
- package/lib/core/page-setup-styles.js +147 -0
- package/lib/core/page-setup-styles.js.map +1 -0
- package/lib/core/page-setup-styles.test.d.ts +2 -0
- package/lib/core/page-setup-styles.test.d.ts.map +1 -0
- package/lib/core/page-setup-styles.test.js +204 -0
- package/lib/core/page-setup-styles.test.js.map +1 -0
- package/lib/core/repeater-io.d.ts +2 -0
- package/lib/core/repeater-io.d.ts.map +1 -0
- package/lib/core/repeater-io.js +2 -0
- package/lib/core/repeater-io.js.map +1 -0
- package/lib/core/repeater-io.test.d.ts +2 -0
- package/lib/core/repeater-io.test.d.ts.map +1 -0
- package/lib/core/repeater-io.test.js +754 -0
- package/lib/core/repeater-io.test.js.map +1 -0
- package/lib/core/segment-tree.d.ts +2 -0
- package/lib/core/segment-tree.d.ts.map +1 -0
- package/lib/core/segment-tree.js +2 -0
- package/lib/core/segment-tree.js.map +1 -0
- package/lib/core/segment-tree.test.d.ts +2 -0
- package/lib/core/segment-tree.test.d.ts.map +1 -0
- package/lib/core/segment-tree.test.js +39 -0
- package/lib/core/segment-tree.test.js.map +1 -0
- package/lib/create-editor.d.ts +160 -0
- package/lib/create-editor.d.ts.map +1 -0
- package/lib/create-editor.js +3373 -0
- package/lib/create-editor.js.map +1 -0
- package/lib/design/collection-tree-picker.d.ts +17 -0
- package/lib/design/collection-tree-picker.d.ts.map +1 -0
- package/lib/design/collection-tree-picker.js +295 -0
- package/lib/design/collection-tree-picker.js.map +1 -0
- package/lib/design/collection-tree-picker.test.d.ts +2 -0
- package/lib/design/collection-tree-picker.test.d.ts.map +1 -0
- package/lib/design/collection-tree-picker.test.js +94 -0
- package/lib/design/collection-tree-picker.test.js.map +1 -0
- package/lib/design/design-mode.d.ts +3 -0
- package/lib/design/design-mode.d.ts.map +1 -0
- package/lib/design/design-mode.js +7 -0
- package/lib/design/design-mode.js.map +1 -0
- package/lib/design/design-shell.d.ts +16 -0
- package/lib/design/design-shell.d.ts.map +1 -0
- package/lib/design/design-shell.js +68 -0
- package/lib/design/design-shell.js.map +1 -0
- package/lib/design/display-style-form.d.ts +10 -0
- package/lib/design/display-style-form.d.ts.map +1 -0
- package/lib/design/display-style-form.js +182 -0
- package/lib/design/display-style-form.js.map +1 -0
- package/lib/design/display-style-form.test.d.ts +2 -0
- package/lib/design/display-style-form.test.d.ts.map +1 -0
- package/lib/design/display-style-form.test.js +137 -0
- package/lib/design/display-style-form.test.js.map +1 -0
- package/lib/design/field-highlight-form.d.ts +10 -0
- package/lib/design/field-highlight-form.d.ts.map +1 -0
- package/lib/design/field-highlight-form.js +160 -0
- package/lib/design/field-highlight-form.js.map +1 -0
- package/lib/design/field-highlight-form.test.d.ts +2 -0
- package/lib/design/field-highlight-form.test.d.ts.map +1 -0
- package/lib/design/field-highlight-form.test.js +58 -0
- package/lib/design/field-highlight-form.test.js.map +1 -0
- package/lib/design/field-palette.d.ts +55 -0
- package/lib/design/field-palette.d.ts.map +1 -0
- package/lib/design/field-palette.js +216 -0
- package/lib/design/field-palette.js.map +1 -0
- package/lib/design/field-palette.test.d.ts +2 -0
- package/lib/design/field-palette.test.d.ts.map +1 -0
- package/lib/design/field-palette.test.js +79 -0
- package/lib/design/field-palette.test.js.map +1 -0
- package/lib/design/formula-field-picker.d.ts +15 -0
- package/lib/design/formula-field-picker.d.ts.map +1 -0
- package/lib/design/formula-field-picker.js +170 -0
- package/lib/design/formula-field-picker.js.map +1 -0
- package/lib/design/formula-field-picker.test.d.ts +2 -0
- package/lib/design/formula-field-picker.test.d.ts.map +1 -0
- package/lib/design/formula-field-picker.test.js +136 -0
- package/lib/design/formula-field-picker.test.js.map +1 -0
- package/lib/design/palette-block-drop.d.ts +7 -0
- package/lib/design/palette-block-drop.d.ts.map +1 -0
- package/lib/design/palette-block-drop.js +62 -0
- package/lib/design/palette-block-drop.js.map +1 -0
- package/lib/design/properties-panel.d.ts +22 -0
- package/lib/design/properties-panel.d.ts.map +1 -0
- package/lib/design/properties-panel.js +848 -0
- package/lib/design/properties-panel.js.map +1 -0
- package/lib/design/schema-editor-controller.d.ts +22 -0
- package/lib/design/schema-editor-controller.d.ts.map +1 -0
- package/lib/design/schema-editor-controller.js +1033 -0
- package/lib/design/schema-editor-controller.js.map +1 -0
- package/lib/design/schema-editor-controller.test.d.ts +2 -0
- package/lib/design/schema-editor-controller.test.d.ts.map +1 -0
- package/lib/design/schema-editor-controller.test.js +259 -0
- package/lib/design/schema-editor-controller.test.js.map +1 -0
- package/lib/design/schema-editor-modal.d.ts +4 -0
- package/lib/design/schema-editor-modal.d.ts.map +1 -0
- package/lib/design/schema-editor-modal.js +68 -0
- package/lib/design/schema-editor-modal.js.map +1 -0
- package/lib/design/schema-items-designer-modal.d.ts +3 -0
- package/lib/design/schema-items-designer-modal.d.ts.map +1 -0
- package/lib/design/schema-items-designer-modal.js +187 -0
- package/lib/design/schema-items-designer-modal.js.map +1 -0
- package/lib/design/schema-items-designer.d.ts +20 -0
- package/lib/design/schema-items-designer.d.ts.map +1 -0
- package/lib/design/schema-items-designer.js +394 -0
- package/lib/design/schema-items-designer.js.map +1 -0
- package/lib/design/schema-items-designer.test.d.ts +2 -0
- package/lib/design/schema-items-designer.test.d.ts.map +1 -0
- package/lib/design/schema-items-designer.test.js +115 -0
- package/lib/design/schema-items-designer.test.js.map +1 -0
- package/lib/design/style-toolbar-shared.d.ts +53 -0
- package/lib/design/style-toolbar-shared.d.ts.map +1 -0
- package/lib/design/style-toolbar-shared.js +196 -0
- package/lib/design/style-toolbar-shared.js.map +1 -0
- package/lib/domain/ophthalmology/catalogs.d.ts +107 -0
- package/lib/domain/ophthalmology/catalogs.d.ts.map +1 -0
- package/lib/domain/ophthalmology/catalogs.js +65 -0
- package/lib/domain/ophthalmology/catalogs.js.map +1 -0
- package/lib/domain/ophthalmology/life-anamnesis-tree.d.ts +13 -0
- package/lib/domain/ophthalmology/life-anamnesis-tree.d.ts.map +1 -0
- package/lib/domain/ophthalmology/life-anamnesis-tree.js +44 -0
- package/lib/domain/ophthalmology/life-anamnesis-tree.js.map +1 -0
- package/lib/domain/ophthalmology/norm-options.d.ts +9 -0
- package/lib/domain/ophthalmology/norm-options.d.ts.map +1 -0
- package/lib/domain/ophthalmology/norm-options.js +24 -0
- package/lib/domain/ophthalmology/norm-options.js.map +1 -0
- package/lib/domain/ophthalmology/ophthalmology-complaints-tree.d.ts +13 -0
- package/lib/domain/ophthalmology/ophthalmology-complaints-tree.d.ts.map +1 -0
- package/lib/domain/ophthalmology/ophthalmology-complaints-tree.js +48 -0
- package/lib/domain/ophthalmology/ophthalmology-complaints-tree.js.map +1 -0
- package/lib/domain/ophthalmology/ophthalmology-diagnoses.d.ts +6 -0
- package/lib/domain/ophthalmology/ophthalmology-diagnoses.d.ts.map +1 -0
- package/lib/domain/ophthalmology/ophthalmology-diagnoses.js +13 -0
- package/lib/domain/ophthalmology/ophthalmology-diagnoses.js.map +1 -0
- package/lib/domain/ophthalmology/vision-values.d.ts +21 -0
- package/lib/domain/ophthalmology/vision-values.d.ts.map +1 -0
- package/lib/domain/ophthalmology/vision-values.js +55 -0
- package/lib/domain/ophthalmology/vision-values.js.map +1 -0
- package/lib/export/document-pdf.d.ts +20 -0
- package/lib/export/document-pdf.d.ts.map +1 -0
- package/lib/export/document-pdf.js +39 -0
- package/lib/export/document-pdf.js.map +1 -0
- package/lib/export/document-pdf.sf-stub.d.ts +13 -0
- package/lib/export/document-pdf.sf-stub.d.ts.map +1 -0
- package/lib/export/document-pdf.sf-stub.js +19 -0
- package/lib/export/document-pdf.sf-stub.js.map +1 -0
- package/lib/export/preview-export-options.d.ts +17 -0
- package/lib/export/preview-export-options.d.ts.map +1 -0
- package/lib/export/preview-export-options.js +28 -0
- package/lib/export/preview-export-options.js.map +1 -0
- package/lib/export/preview-html-document.d.ts +10 -0
- package/lib/export/preview-html-document.d.ts.map +1 -0
- package/lib/export/preview-html-document.js +29 -0
- package/lib/export/preview-html-document.js.map +1 -0
- package/lib/export/preview-html-styles.d.ts +10 -0
- package/lib/export/preview-html-styles.d.ts.map +1 -0
- package/lib/export/preview-html-styles.js +527 -0
- package/lib/export/preview-html-styles.js.map +1 -0
- package/lib/export/preview-html-styles.test.d.ts +2 -0
- package/lib/export/preview-html-styles.test.d.ts.map +1 -0
- package/lib/export/preview-html-styles.test.js +56 -0
- package/lib/export/preview-html-styles.test.js.map +1 -0
- package/lib/export/preview-pdf-mount.d.ts +14 -0
- package/lib/export/preview-pdf-mount.d.ts.map +1 -0
- package/lib/export/preview-pdf-mount.js +41 -0
- package/lib/export/preview-pdf-mount.js.map +1 -0
- package/lib/export/preview-pdf-parity.test.d.ts +2 -0
- package/lib/export/preview-pdf-parity.test.d.ts.map +1 -0
- package/lib/export/preview-pdf-parity.test.js +217 -0
- package/lib/export/preview-pdf-parity.test.js.map +1 -0
- package/lib/fields/barcode-encode.d.ts +33 -0
- package/lib/fields/barcode-encode.d.ts.map +1 -0
- package/lib/fields/barcode-encode.js +118 -0
- package/lib/fields/barcode-encode.js.map +1 -0
- package/lib/fields/barcode-encode.test.d.ts +2 -0
- package/lib/fields/barcode-encode.test.d.ts.map +1 -0
- package/lib/fields/barcode-encode.test.js +38 -0
- package/lib/fields/barcode-encode.test.js.map +1 -0
- package/lib/fields/collect-field-values.test.d.ts +2 -0
- package/lib/fields/collect-field-values.test.d.ts.map +1 -0
- package/lib/fields/collect-field-values.test.js +71 -0
- package/lib/fields/collect-field-values.test.js.map +1 -0
- package/lib/fields/columns-serialize.test.d.ts +2 -0
- package/lib/fields/columns-serialize.test.d.ts.map +1 -0
- package/lib/fields/columns-serialize.test.js +68 -0
- package/lib/fields/columns-serialize.test.js.map +1 -0
- package/lib/fields/cross-section-reposition.d.ts +19 -0
- package/lib/fields/cross-section-reposition.d.ts.map +1 -0
- package/lib/fields/cross-section-reposition.js +185 -0
- package/lib/fields/cross-section-reposition.js.map +1 -0
- package/lib/fields/cross-section-reposition.test.d.ts +2 -0
- package/lib/fields/cross-section-reposition.test.d.ts.map +1 -0
- package/lib/fields/cross-section-reposition.test.js +190 -0
- package/lib/fields/cross-section-reposition.test.js.map +1 -0
- package/lib/fields/document-preview.d.ts +10 -0
- package/lib/fields/document-preview.d.ts.map +1 -0
- package/lib/fields/document-preview.js +781 -0
- package/lib/fields/document-preview.js.map +1 -0
- package/lib/fields/document-preview.test.d.ts +2 -0
- package/lib/fields/document-preview.test.d.ts.map +1 -0
- package/lib/fields/document-preview.test.js +1433 -0
- package/lib/fields/document-preview.test.js.map +1 -0
- package/lib/fields/field-clipboard.d.ts +32 -0
- package/lib/fields/field-clipboard.d.ts.map +1 -0
- package/lib/fields/field-clipboard.js +642 -0
- package/lib/fields/field-clipboard.js.map +1 -0
- package/lib/fields/field-clipboard.test.d.ts +2 -0
- package/lib/fields/field-clipboard.test.d.ts.map +1 -0
- package/lib/fields/field-clipboard.test.js +281 -0
- package/lib/fields/field-clipboard.test.js.map +1 -0
- package/lib/fields/field-display-style.d.ts +76 -0
- package/lib/fields/field-display-style.d.ts.map +1 -0
- package/lib/fields/field-display-style.js +429 -0
- package/lib/fields/field-display-style.js.map +1 -0
- package/lib/fields/field-display-style.test.d.ts +2 -0
- package/lib/fields/field-display-style.test.d.ts.map +1 -0
- package/lib/fields/field-display-style.test.js +299 -0
- package/lib/fields/field-display-style.test.js.map +1 -0
- package/lib/fields/field-keyboard.d.ts +9 -0
- package/lib/fields/field-keyboard.d.ts.map +1 -0
- package/lib/fields/field-keyboard.js +1118 -0
- package/lib/fields/field-keyboard.js.map +1 -0
- package/lib/fields/field-keyboard.test.d.ts +2 -0
- package/lib/fields/field-keyboard.test.d.ts.map +1 -0
- package/lib/fields/field-keyboard.test.js +390 -0
- package/lib/fields/field-keyboard.test.js.map +1 -0
- package/lib/fields/field-selection.d.ts +12 -0
- package/lib/fields/field-selection.d.ts.map +1 -0
- package/lib/fields/field-selection.js +123 -0
- package/lib/fields/field-selection.js.map +1 -0
- package/lib/fields/field-selection.test.d.ts +2 -0
- package/lib/fields/field-selection.test.d.ts.map +1 -0
- package/lib/fields/field-selection.test.js +67 -0
- package/lib/fields/field-selection.test.js.map +1 -0
- package/lib/fields/field-token-drag.test.d.ts +2 -0
- package/lib/fields/field-token-drag.test.d.ts.map +1 -0
- package/lib/fields/field-token-drag.test.js +55 -0
- package/lib/fields/field-token-drag.test.js.map +1 -0
- package/lib/fields/fill-defaults.test.d.ts +2 -0
- package/lib/fields/fill-defaults.test.d.ts.map +1 -0
- package/lib/fields/fill-defaults.test.js +70 -0
- package/lib/fields/fill-defaults.test.js.map +1 -0
- package/lib/fields/fill-field-focus.d.ts +51 -0
- package/lib/fields/fill-field-focus.d.ts.map +1 -0
- package/lib/fields/fill-field-focus.js +230 -0
- package/lib/fields/fill-field-focus.js.map +1 -0
- package/lib/fields/fill-field-focus.test.d.ts +2 -0
- package/lib/fields/fill-field-focus.test.d.ts.map +1 -0
- package/lib/fields/fill-field-focus.test.js +201 -0
- package/lib/fields/fill-field-focus.test.js.map +1 -0
- package/lib/fields/handlers/builtins.d.ts +3 -0
- package/lib/fields/handlers/builtins.d.ts.map +1 -0
- package/lib/fields/handlers/builtins.js +869 -0
- package/lib/fields/handlers/builtins.js.map +1 -0
- package/lib/fields/handlers/index.d.ts +4 -0
- package/lib/fields/handlers/index.d.ts.map +1 -0
- package/lib/fields/handlers/index.js +5 -0
- package/lib/fields/handlers/index.js.map +1 -0
- package/lib/fields/handlers/registry.d.ts +27 -0
- package/lib/fields/handlers/registry.d.ts.map +1 -0
- package/lib/fields/handlers/registry.js +69 -0
- package/lib/fields/handlers/registry.js.map +1 -0
- package/lib/fields/handlers/registry.test.d.ts +2 -0
- package/lib/fields/handlers/registry.test.d.ts.map +1 -0
- package/lib/fields/handlers/registry.test.js +203 -0
- package/lib/fields/handlers/registry.test.js.map +1 -0
- package/lib/fields/handlers/schema-form-dom.d.ts +36 -0
- package/lib/fields/handlers/schema-form-dom.d.ts.map +1 -0
- package/lib/fields/handlers/schema-form-dom.js +114 -0
- package/lib/fields/handlers/schema-form-dom.js.map +1 -0
- package/lib/fields/heading-line-breaks.test.d.ts +2 -0
- package/lib/fields/heading-line-breaks.test.d.ts.map +1 -0
- package/lib/fields/heading-line-breaks.test.js +755 -0
- package/lib/fields/heading-line-breaks.test.js.map +1 -0
- package/lib/fields/inline-field-from-selection.test.d.ts +2 -0
- package/lib/fields/inline-field-from-selection.test.d.ts.map +1 -0
- package/lib/fields/inline-field-from-selection.test.js +185 -0
- package/lib/fields/inline-field-from-selection.test.js.map +1 -0
- package/lib/fields/inline-fields.d.ts +150 -0
- package/lib/fields/inline-fields.d.ts.map +1 -0
- package/lib/fields/inline-fields.js +3408 -0
- package/lib/fields/inline-fields.js.map +1 -0
- package/lib/fields/logical-display.d.ts +8 -0
- package/lib/fields/logical-display.d.ts.map +1 -0
- package/lib/fields/logical-display.js +29 -0
- package/lib/fields/logical-display.js.map +1 -0
- package/lib/fields/logical-display.test.d.ts +2 -0
- package/lib/fields/logical-display.test.d.ts.map +1 -0
- package/lib/fields/logical-display.test.js +31 -0
- package/lib/fields/logical-display.test.js.map +1 -0
- package/lib/fields/manual-field-values.d.ts +87 -0
- package/lib/fields/manual-field-values.d.ts.map +1 -0
- package/lib/fields/manual-field-values.js +189 -0
- package/lib/fields/manual-field-values.js.map +1 -0
- package/lib/fields/manual-field-values.test.d.ts +2 -0
- package/lib/fields/manual-field-values.test.d.ts.map +1 -0
- package/lib/fields/manual-field-values.test.js +84 -0
- package/lib/fields/manual-field-values.test.js.map +1 -0
- package/lib/fields/pivot-table-field.d.ts +25 -0
- package/lib/fields/pivot-table-field.d.ts.map +1 -0
- package/lib/fields/pivot-table-field.js +408 -0
- package/lib/fields/pivot-table-field.js.map +1 -0
- package/lib/fields/plain-text-newlines.test.d.ts +2 -0
- package/lib/fields/plain-text-newlines.test.d.ts.map +1 -0
- package/lib/fields/plain-text-newlines.test.js +40 -0
- package/lib/fields/plain-text-newlines.test.js.map +1 -0
- package/lib/fields/repeater-field.d.ts +10 -0
- package/lib/fields/repeater-field.d.ts.map +1 -0
- package/lib/fields/repeater-field.js +48 -0
- package/lib/fields/repeater-field.js.map +1 -0
- package/lib/fields/rich-text.d.ts +27 -0
- package/lib/fields/rich-text.d.ts.map +1 -0
- package/lib/fields/rich-text.js +984 -0
- package/lib/fields/rich-text.js.map +1 -0
- package/lib/fields/table-field.d.ts +57 -0
- package/lib/fields/table-field.d.ts.map +1 -0
- package/lib/fields/table-field.js +836 -0
- package/lib/fields/table-field.js.map +1 -0
- package/lib/fields/table-field.test.d.ts +2 -0
- package/lib/fields/table-field.test.d.ts.map +1 -0
- package/lib/fields/table-field.test.js +456 -0
- package/lib/fields/table-field.test.js.map +1 -0
- package/lib/fields/tree-paths.d.ts +5 -0
- package/lib/fields/tree-paths.d.ts.map +1 -0
- package/lib/fields/tree-paths.js +7 -0
- package/lib/fields/tree-paths.js.map +1 -0
- package/lib/fields/tree-selection.d.ts +9 -0
- package/lib/fields/tree-selection.d.ts.map +1 -0
- package/lib/fields/tree-selection.js +39 -0
- package/lib/fields/tree-selection.js.map +1 -0
- package/lib/fields/tree.d.ts +7 -0
- package/lib/fields/tree.d.ts.map +1 -0
- package/lib/fields/tree.js +7 -0
- package/lib/fields/tree.js.map +1 -0
- package/lib/fields/wire-columns-resize.d.ts +6 -0
- package/lib/fields/wire-columns-resize.d.ts.map +1 -0
- package/lib/fields/wire-columns-resize.js +130 -0
- package/lib/fields/wire-columns-resize.js.map +1 -0
- package/lib/fields/wire-columns-resize.test.d.ts +2 -0
- package/lib/fields/wire-columns-resize.test.d.ts.map +1 -0
- package/lib/fields/wire-columns-resize.test.js +38 -0
- package/lib/fields/wire-columns-resize.test.js.map +1 -0
- package/lib/fields/wire-editorjs-native-drop-guard.d.ts +34 -0
- package/lib/fields/wire-editorjs-native-drop-guard.d.ts.map +1 -0
- package/lib/fields/wire-editorjs-native-drop-guard.js +453 -0
- package/lib/fields/wire-editorjs-native-drop-guard.js.map +1 -0
- package/lib/fields/wire-editorjs-native-drop-guard.test.d.ts +2 -0
- package/lib/fields/wire-editorjs-native-drop-guard.test.d.ts.map +1 -0
- package/lib/fields/wire-editorjs-native-drop-guard.test.js +230 -0
- package/lib/fields/wire-editorjs-native-drop-guard.test.js.map +1 -0
- package/lib/fields/wire-table-column-reorder.d.ts +23 -0
- package/lib/fields/wire-table-column-reorder.d.ts.map +1 -0
- package/lib/fields/wire-table-column-reorder.js +207 -0
- package/lib/fields/wire-table-column-reorder.js.map +1 -0
- package/lib/fields/wire-table-column-reorder.test.d.ts +2 -0
- package/lib/fields/wire-table-column-reorder.test.d.ts.map +1 -0
- package/lib/fields/wire-table-column-reorder.test.js +133 -0
- package/lib/fields/wire-table-column-reorder.test.js.map +1 -0
- package/lib/fields/wire-table-column-resize.d.ts +118 -0
- package/lib/fields/wire-table-column-resize.d.ts.map +1 -0
- package/lib/fields/wire-table-column-resize.js +406 -0
- package/lib/fields/wire-table-column-resize.js.map +1 -0
- package/lib/fields/wire-table-column-resize.test.d.ts +2 -0
- package/lib/fields/wire-table-column-resize.test.d.ts.map +1 -0
- package/lib/fields/wire-table-column-resize.test.js +407 -0
- package/lib/fields/wire-table-column-resize.test.js.map +1 -0
- package/lib/index.d.ts +39 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +37 -0
- package/lib/index.js.map +1 -0
- package/lib/node.d.ts +20 -0
- package/lib/node.d.ts.map +1 -0
- package/lib/node.js +20 -0
- package/lib/node.js.map +1 -0
- package/lib/registry/registry-context.d.ts +6 -0
- package/lib/registry/registry-context.d.ts.map +1 -0
- package/lib/registry/registry-context.js +39 -0
- package/lib/registry/registry-context.js.map +1 -0
- package/lib/registry/schema-registry.d.ts +18 -0
- package/lib/registry/schema-registry.d.ts.map +1 -0
- package/lib/registry/schema-registry.js +67 -0
- package/lib/registry/schema-registry.js.map +1 -0
- package/lib/services/image-upload.d.ts +27 -0
- package/lib/services/image-upload.d.ts.map +1 -0
- package/lib/services/image-upload.js +159 -0
- package/lib/services/image-upload.js.map +1 -0
- package/lib/services/image-upload.test.d.ts +2 -0
- package/lib/services/image-upload.test.d.ts.map +1 -0
- package/lib/services/image-upload.test.js +141 -0
- package/lib/services/image-upload.test.js.map +1 -0
- package/lib/sf-entry.d.ts +5 -0
- package/lib/sf-entry.d.ts.map +1 -0
- package/lib/sf-entry.js +15 -0
- package/lib/sf-entry.js.map +1 -0
- package/lib/sf-pdf-viewer/main.d.ts +2 -0
- package/lib/sf-pdf-viewer/main.d.ts.map +1 -0
- package/lib/sf-pdf-viewer/main.js +57 -0
- package/lib/sf-pdf-viewer/main.js.map +1 -0
- package/lib/tools/document-section.d.ts +54 -0
- package/lib/tools/document-section.d.ts.map +1 -0
- package/lib/tools/document-section.js +591 -0
- package/lib/tools/document-section.js.map +1 -0
- package/lib/tools/template-block.d.ts +18 -0
- package/lib/tools/template-block.d.ts.map +1 -0
- package/lib/tools/template-block.js +243 -0
- package/lib/tools/template-block.js.map +1 -0
- package/lib/ui/action-icons.d.ts +10 -0
- package/lib/ui/action-icons.d.ts.map +1 -0
- package/lib/ui/action-icons.js +11 -0
- package/lib/ui/action-icons.js.map +1 -0
- package/lib/ui/document-actions.d.ts +12 -0
- package/lib/ui/document-actions.d.ts.map +1 -0
- package/lib/ui/document-actions.js +37 -0
- package/lib/ui/document-actions.js.map +1 -0
- package/lib/ui/drag-handle.d.ts +11 -0
- package/lib/ui/drag-handle.d.ts.map +1 -0
- package/lib/ui/drag-handle.js +38 -0
- package/lib/ui/drag-handle.js.map +1 -0
- package/lib/ui/existing-image-modal.d.ts +10 -0
- package/lib/ui/existing-image-modal.d.ts.map +1 -0
- package/lib/ui/existing-image-modal.js +153 -0
- package/lib/ui/existing-image-modal.js.map +1 -0
- package/lib/ui/field-form-modal.d.ts +33 -0
- package/lib/ui/field-form-modal.d.ts.map +1 -0
- package/lib/ui/field-form-modal.js +103 -0
- package/lib/ui/field-form-modal.js.map +1 -0
- package/lib/ui/field-form-modal.test.d.ts +2 -0
- package/lib/ui/field-form-modal.test.d.ts.map +1 -0
- package/lib/ui/field-form-modal.test.js +81 -0
- package/lib/ui/field-form-modal.test.js.map +1 -0
- package/lib/ui/field-mapping-badges.d.ts +9 -0
- package/lib/ui/field-mapping-badges.d.ts.map +1 -0
- package/lib/ui/field-mapping-badges.js +208 -0
- package/lib/ui/field-mapping-badges.js.map +1 -0
- package/lib/ui/field-mapping-badges.test.d.ts +2 -0
- package/lib/ui/field-mapping-badges.test.d.ts.map +1 -0
- package/lib/ui/field-mapping-badges.test.js +81 -0
- package/lib/ui/field-mapping-badges.test.js.map +1 -0
- package/lib/ui/field-mapping-modal-open.test.d.ts +2 -0
- package/lib/ui/field-mapping-modal-open.test.d.ts.map +1 -0
- package/lib/ui/field-mapping-modal-open.test.js +58 -0
- package/lib/ui/field-mapping-modal-open.test.js.map +1 -0
- package/lib/ui/field-mapping-modal.d.ts +4 -0
- package/lib/ui/field-mapping-modal.d.ts.map +1 -0
- package/lib/ui/field-mapping-modal.js +992 -0
- package/lib/ui/field-mapping-modal.js.map +1 -0
- package/lib/ui/filename-prompt.d.ts +6 -0
- package/lib/ui/filename-prompt.d.ts.map +1 -0
- package/lib/ui/filename-prompt.js +85 -0
- package/lib/ui/filename-prompt.js.map +1 -0
- package/lib/ui/format-icons.d.ts +23 -0
- package/lib/ui/format-icons.d.ts.map +1 -0
- package/lib/ui/format-icons.js +23 -0
- package/lib/ui/format-icons.js.map +1 -0
- package/lib/ui/html-text-modal.d.ts +6 -0
- package/lib/ui/html-text-modal.d.ts.map +1 -0
- package/lib/ui/html-text-modal.js +195 -0
- package/lib/ui/html-text-modal.js.map +1 -0
- package/lib/ui/image-modal.d.ts +6 -0
- package/lib/ui/image-modal.d.ts.map +1 -0
- package/lib/ui/image-modal.js +237 -0
- package/lib/ui/image-modal.js.map +1 -0
- package/lib/ui/integer-modal.d.ts +12 -0
- package/lib/ui/integer-modal.d.ts.map +1 -0
- package/lib/ui/integer-modal.js +71 -0
- package/lib/ui/integer-modal.js.map +1 -0
- package/lib/ui/list-modal.d.ts +6 -0
- package/lib/ui/list-modal.d.ts.map +1 -0
- package/lib/ui/list-modal.js +627 -0
- package/lib/ui/list-modal.js.map +1 -0
- package/lib/ui/list-modal.test.d.ts +2 -0
- package/lib/ui/list-modal.test.d.ts.map +1 -0
- package/lib/ui/list-modal.test.js +185 -0
- package/lib/ui/list-modal.test.js.map +1 -0
- package/lib/ui/logical-modal.d.ts +11 -0
- package/lib/ui/logical-modal.d.ts.map +1 -0
- package/lib/ui/logical-modal.js +104 -0
- package/lib/ui/logical-modal.js.map +1 -0
- package/lib/ui/mapping-drag-drop.d.ts +44 -0
- package/lib/ui/mapping-drag-drop.d.ts.map +1 -0
- package/lib/ui/mapping-drag-drop.js +339 -0
- package/lib/ui/mapping-drag-drop.js.map +1 -0
- package/lib/ui/mapping-drag-drop.test.d.ts +2 -0
- package/lib/ui/mapping-drag-drop.test.d.ts.map +1 -0
- package/lib/ui/mapping-drag-drop.test.js +47 -0
- package/lib/ui/mapping-drag-drop.test.js.map +1 -0
- package/lib/ui/mapping-result-helper.d.ts +130 -0
- package/lib/ui/mapping-result-helper.d.ts.map +1 -0
- package/lib/ui/mapping-result-helper.js +640 -0
- package/lib/ui/mapping-result-helper.js.map +1 -0
- package/lib/ui/mapping-result-helper.test.d.ts +2 -0
- package/lib/ui/mapping-result-helper.test.d.ts.map +1 -0
- package/lib/ui/mapping-result-helper.test.js +147 -0
- package/lib/ui/mapping-result-helper.test.js.map +1 -0
- package/lib/ui/modal-picker-keyboard.d.ts +12 -0
- package/lib/ui/modal-picker-keyboard.d.ts.map +1 -0
- package/lib/ui/modal-picker-keyboard.js +72 -0
- package/lib/ui/modal-picker-keyboard.js.map +1 -0
- package/lib/ui/modal-picker-keyboard.test.d.ts +2 -0
- package/lib/ui/modal-picker-keyboard.test.d.ts.map +1 -0
- package/lib/ui/modal-picker-keyboard.test.js +53 -0
- package/lib/ui/modal-picker-keyboard.test.js.map +1 -0
- package/lib/ui/modal-picker-pills.d.ts +2 -0
- package/lib/ui/modal-picker-pills.d.ts.map +1 -0
- package/lib/ui/modal-picker-pills.js +26 -0
- package/lib/ui/modal-picker-pills.js.map +1 -0
- package/lib/ui/notification.d.ts +2 -0
- package/lib/ui/notification.d.ts.map +1 -0
- package/lib/ui/notification.js +47 -0
- package/lib/ui/notification.js.map +1 -0
- package/lib/ui/palette-icons.d.ts +5 -0
- package/lib/ui/palette-icons.d.ts.map +1 -0
- package/lib/ui/palette-icons.js +28 -0
- package/lib/ui/palette-icons.js.map +1 -0
- package/lib/ui/pdf-canvas-preview.d.ts +11 -0
- package/lib/ui/pdf-canvas-preview.d.ts.map +1 -0
- package/lib/ui/pdf-canvas-preview.js +88 -0
- package/lib/ui/pdf-canvas-preview.js.map +1 -0
- package/lib/ui/preview-modal.d.ts +24 -0
- package/lib/ui/preview-modal.d.ts.map +1 -0
- package/lib/ui/preview-modal.js +536 -0
- package/lib/ui/preview-modal.js.map +1 -0
- package/lib/ui/recent-fill-colors.d.ts +21 -0
- package/lib/ui/recent-fill-colors.d.ts.map +1 -0
- package/lib/ui/recent-fill-colors.js +95 -0
- package/lib/ui/recent-fill-colors.js.map +1 -0
- package/lib/ui/recent-fill-colors.test.d.ts +2 -0
- package/lib/ui/recent-fill-colors.test.d.ts.map +1 -0
- package/lib/ui/recent-fill-colors.test.js +56 -0
- package/lib/ui/recent-fill-colors.test.js.map +1 -0
- package/lib/ui/repeater-editor-modal.d.ts +10 -0
- package/lib/ui/repeater-editor-modal.d.ts.map +1 -0
- package/lib/ui/repeater-editor-modal.js +124 -0
- package/lib/ui/repeater-editor-modal.js.map +1 -0
- package/lib/ui/rich-text-toolbar.d.ts +13 -0
- package/lib/ui/rich-text-toolbar.d.ts.map +1 -0
- package/lib/ui/rich-text-toolbar.js +670 -0
- package/lib/ui/rich-text-toolbar.js.map +1 -0
- package/lib/ui/rich-text-toolbar.test.d.ts +2 -0
- package/lib/ui/rich-text-toolbar.test.d.ts.map +1 -0
- package/lib/ui/rich-text-toolbar.test.js +167 -0
- package/lib/ui/rich-text-toolbar.test.js.map +1 -0
- package/lib/ui/signature-modal.d.ts +13 -0
- package/lib/ui/signature-modal.d.ts.map +1 -0
- package/lib/ui/signature-modal.js +219 -0
- package/lib/ui/signature-modal.js.map +1 -0
- package/lib/ui/source-path-canvas-drop.d.ts +121 -0
- package/lib/ui/source-path-canvas-drop.d.ts.map +1 -0
- package/lib/ui/source-path-canvas-drop.js +300 -0
- package/lib/ui/source-path-canvas-drop.js.map +1 -0
- package/lib/ui/source-path-canvas-drop.test.d.ts +2 -0
- package/lib/ui/source-path-canvas-drop.test.d.ts.map +1 -0
- package/lib/ui/source-path-canvas-drop.test.js +216 -0
- package/lib/ui/source-path-canvas-drop.test.js.map +1 -0
- package/lib/ui/source-schema-tree.d.ts +33 -0
- package/lib/ui/source-schema-tree.d.ts.map +1 -0
- package/lib/ui/source-schema-tree.js +322 -0
- package/lib/ui/source-schema-tree.js.map +1 -0
- package/lib/ui/text-modal.d.ts +13 -0
- package/lib/ui/text-modal.d.ts.map +1 -0
- package/lib/ui/text-modal.js +31 -0
- package/lib/ui/text-modal.js.map +1 -0
- package/lib/ui/tree-modal.d.ts +8 -0
- package/lib/ui/tree-modal.d.ts.map +1 -0
- package/lib/ui/tree-modal.js +586 -0
- package/lib/ui/tree-modal.js.map +1 -0
- package/lib/ui/tree-modal.test.d.ts +2 -0
- package/lib/ui/tree-modal.test.d.ts.map +1 -0
- package/lib/ui/tree-modal.test.js +390 -0
- package/lib/ui/tree-modal.test.js.map +1 -0
- package/lib/ui/wire-modal-escape.d.ts +13 -0
- package/lib/ui/wire-modal-escape.d.ts.map +1 -0
- package/lib/ui/wire-modal-escape.js +26 -0
- package/lib/ui/wire-modal-escape.js.map +1 -0
- package/lib/ui/wire-modal-escape.test.d.ts +2 -0
- package/lib/ui/wire-modal-escape.test.d.ts.map +1 -0
- package/lib/ui/wire-modal-escape.test.js +57 -0
- package/lib/ui/wire-modal-escape.test.js.map +1 -0
- package/lib/ui/wire-modal-focus-trap.test.d.ts +2 -0
- package/lib/ui/wire-modal-focus-trap.test.d.ts.map +1 -0
- package/lib/ui/wire-modal-focus-trap.test.js +264 -0
- package/lib/ui/wire-modal-focus-trap.test.js.map +1 -0
- package/lib/ui/wire-modal-move.d.ts +23 -0
- package/lib/ui/wire-modal-move.d.ts.map +1 -0
- package/lib/ui/wire-modal-move.js +179 -0
- package/lib/ui/wire-modal-move.js.map +1 -0
- package/lib/ui/wire-modal-move.test.d.ts +2 -0
- package/lib/ui/wire-modal-move.test.d.ts.map +1 -0
- package/lib/ui/wire-modal-move.test.js +84 -0
- package/lib/ui/wire-modal-move.test.js.map +1 -0
- package/lib/ui/wire-modal-palette.d.ts +56 -0
- package/lib/ui/wire-modal-palette.d.ts.map +1 -0
- package/lib/ui/wire-modal-palette.js +501 -0
- package/lib/ui/wire-modal-palette.js.map +1 -0
- package/lib/ui/wire-modal-resize.d.ts +27 -0
- package/lib/ui/wire-modal-resize.d.ts.map +1 -0
- package/lib/ui/wire-modal-resize.js +146 -0
- package/lib/ui/wire-modal-resize.js.map +1 -0
- package/lib/ui/wire-modal-resize.test.d.ts +2 -0
- package/lib/ui/wire-modal-resize.test.d.ts.map +1 -0
- package/lib/ui/wire-modal-resize.test.js +61 -0
- package/lib/ui/wire-modal-resize.test.js.map +1 -0
- package/lib/ui/wire-panel-splitter.d.ts +67 -0
- package/lib/ui/wire-panel-splitter.d.ts.map +1 -0
- package/lib/ui/wire-panel-splitter.js +361 -0
- package/lib/ui/wire-panel-splitter.js.map +1 -0
- package/lib/ui/wire-panel-splitter.test.d.ts +2 -0
- package/lib/ui/wire-panel-splitter.test.d.ts.map +1 -0
- package/lib/ui/wire-panel-splitter.test.js +152 -0
- package/lib/ui/wire-panel-splitter.test.js.map +1 -0
- package/lib/utils/export-filename.d.ts +24 -0
- package/lib/utils/export-filename.d.ts.map +1 -0
- package/lib/utils/export-filename.js +42 -0
- package/lib/utils/export-filename.js.map +1 -0
- package/lib/utils/export-filename.test.d.ts +2 -0
- package/lib/utils/export-filename.test.d.ts.map +1 -0
- package/lib/utils/export-filename.test.js +42 -0
- package/lib/utils/export-filename.test.js.map +1 -0
- package/lib/utils/print-document.d.ts +17 -0
- package/lib/utils/print-document.d.ts.map +1 -0
- package/lib/utils/print-document.js +132 -0
- package/lib/utils/print-document.js.map +1 -0
- package/lib/utils/save-blob.d.ts +9 -0
- package/lib/utils/save-blob.d.ts.map +1 -0
- package/lib/utils/save-blob.js +41 -0
- package/lib/utils/save-blob.js.map +1 -0
- package/lib/web-component.d.ts +6 -0
- package/lib/web-component.d.ts.map +1 -0
- package/lib/web-component.js +59 -0
- package/lib/web-component.js.map +1 -0
- package/package.json +61 -6
- package/src/catalog/catalog-provider.ts +91 -0
- package/src/core/computed-formula.test.ts +258 -0
- package/src/core/computed-formula.ts +18 -0
- package/src/core/document-display-defaults.ts +13 -0
- package/src/core/document-history.test.ts +54 -0
- package/src/core/document-history.ts +102 -0
- package/src/core/document-io.test.ts +739 -0
- package/src/core/document-io.ts +27 -0
- package/src/core/document-section-defaults.test.ts +56 -0
- package/src/core/document-section-defaults.ts +67 -0
- package/src/core/field-id.test.ts +299 -0
- package/src/core/field-id.ts +23 -0
- package/src/core/field-io/sectioned-document-io.test.ts +568 -0
- package/src/core/field-io/sectioned-document-io.ts +15 -0
- package/src/core/field-io/table-field-io.test.ts +242 -0
- package/src/core/field-io/table-field-io.ts +13 -0
- package/src/core/field-schemas.test.ts +472 -0
- package/src/core/field-schemas.ts +46 -0
- package/src/core/formula-field-index.test.ts +140 -0
- package/src/core/formula-field-index.ts +16 -0
- package/src/core/page-setup-styles.test.ts +274 -0
- package/src/core/page-setup-styles.ts +213 -0
- package/src/core/repeater-io.test.ts +899 -0
- package/src/core/repeater-io.ts +37 -0
- package/src/core/segment-tree.test.ts +41 -0
- package/src/core/segment-tree.ts +6 -0
- package/src/create-editor.ts +3848 -0
- package/src/design/collection-tree-picker.test.ts +105 -0
- package/src/design/collection-tree-picker.ts +340 -0
- package/src/design/design-mode.ts +7 -0
- package/src/design/design-shell.ts +76 -0
- package/src/design/display-style-form.test.ts +174 -0
- package/src/design/display-style-form.ts +217 -0
- package/src/design/field-highlight-form.test.ts +64 -0
- package/src/design/field-highlight-form.ts +169 -0
- package/src/design/field-palette.test.ts +97 -0
- package/src/design/field-palette.ts +250 -0
- package/src/design/formula-field-picker.test.ts +158 -0
- package/src/design/formula-field-picker.ts +189 -0
- package/src/design/palette-block-drop.ts +66 -0
- package/src/design/properties-panel.ts +900 -0
- package/src/design/schema-editor-controller.test.ts +296 -0
- package/src/design/schema-editor-controller.ts +1122 -0
- package/src/design/schema-editor-modal.ts +83 -0
- package/src/design/schema-items-designer-modal.ts +209 -0
- package/src/design/schema-items-designer.test.ts +148 -0
- package/src/design/schema-items-designer.ts +442 -0
- package/src/design/style-toolbar-shared.ts +218 -0
- package/src/dom-pragmatic.d.ts +83 -0
- package/src/domain/ophthalmology/catalogs.ts +72 -0
- package/src/domain/ophthalmology/life-anamnesis-tree.ts +43 -0
- package/src/domain/ophthalmology/norm-options.ts +24 -0
- package/src/domain/ophthalmology/ophthalmology-complaints-tree.ts +47 -0
- package/src/domain/ophthalmology/ophthalmology-diagnoses.ts +12 -0
- package/src/domain/ophthalmology/vision-values.ts +58 -0
- package/src/editorjs-shim.d.ts +2 -0
- package/src/export/document-pdf.sf-stub.ts +23 -0
- package/src/export/document-pdf.ts +44 -0
- package/src/export/preview-export-options.ts +29 -0
- package/src/export/preview-html-document.ts +34 -0
- package/src/export/preview-html-styles.test.ts +60 -0
- package/src/export/preview-html-styles.ts +551 -0
- package/src/export/preview-pdf-mount.ts +48 -0
- package/src/export/preview-pdf-parity.test.ts +237 -0
- package/src/fields/barcode-encode.test.ts +43 -0
- package/src/fields/barcode-encode.ts +147 -0
- package/src/fields/collect-field-values.test.ts +95 -0
- package/src/fields/columns-serialize.test.ts +75 -0
- package/src/fields/cross-section-reposition.test.ts +206 -0
- package/src/fields/cross-section-reposition.ts +214 -0
- package/src/fields/document-preview.test.ts +1621 -0
- package/src/fields/document-preview.ts +910 -0
- package/src/fields/field-clipboard.test.ts +312 -0
- package/src/fields/field-clipboard.ts +705 -0
- package/src/fields/field-display-style.test.ts +403 -0
- package/src/fields/field-display-style.ts +435 -0
- package/src/fields/field-keyboard.test.ts +446 -0
- package/src/fields/field-keyboard.ts +1281 -0
- package/src/fields/field-selection.test.ts +85 -0
- package/src/fields/field-selection.ts +137 -0
- package/src/fields/field-token-drag.test.ts +65 -0
- package/src/fields/fill-defaults.test.ts +89 -0
- package/src/fields/fill-field-focus.test.ts +239 -0
- package/src/fields/fill-field-focus.ts +249 -0
- package/src/fields/handlers/builtins.ts +879 -0
- package/src/fields/handlers/index.ts +16 -0
- package/src/fields/handlers/registry.test.ts +266 -0
- package/src/fields/handlers/registry.ts +88 -0
- package/src/fields/handlers/schema-form-dom.ts +135 -0
- package/src/fields/heading-line-breaks.test.ts +931 -0
- package/src/fields/inline-field-from-selection.test.ts +202 -0
- package/src/fields/inline-fields.ts +3760 -0
- package/src/fields/logical-display.test.ts +37 -0
- package/src/fields/logical-display.ts +29 -0
- package/src/fields/manual-field-values.test.ts +152 -0
- package/src/fields/manual-field-values.ts +207 -0
- package/src/fields/pivot-table-field.ts +458 -0
- package/src/fields/plain-text-newlines.test.ts +48 -0
- package/src/fields/repeater-field.ts +61 -0
- package/src/fields/rich-text.ts +1018 -0
- package/src/fields/table-field.test.ts +504 -0
- package/src/fields/table-field.ts +1026 -0
- package/src/fields/tree-paths.ts +6 -0
- package/src/fields/tree-selection.ts +50 -0
- package/src/fields/tree.ts +11 -0
- package/src/fields/wire-columns-resize.test.ts +40 -0
- package/src/fields/wire-columns-resize.ts +138 -0
- package/src/fields/wire-editorjs-native-drop-guard.test.ts +273 -0
- package/src/fields/wire-editorjs-native-drop-guard.ts +491 -0
- package/src/fields/wire-table-column-reorder.test.ts +163 -0
- package/src/fields/wire-table-column-reorder.ts +223 -0
- package/src/fields/wire-table-column-resize.test.ts +459 -0
- package/src/fields/wire-table-column-resize.ts +433 -0
- package/src/index.ts +287 -0
- package/src/node.ts +114 -0
- package/src/registry/registry-context.ts +36 -0
- package/src/registry/schema-registry.ts +80 -0
- package/src/services/image-upload.test.ts +180 -0
- package/src/services/image-upload.ts +185 -0
- package/src/sf-entry.ts +19 -0
- package/src/sf-pdf-viewer/main.ts +57 -0
- package/src/sf-pdf-viewer/viewer.html +40 -0
- package/src/styles/editor.css +5450 -0
- package/src/themes/bridge.css +1952 -0
- package/src/themes/prime.css +116 -0
- package/src/themes/slds.css +123 -0
- package/src/tools/document-section.ts +692 -0
- package/src/tools/template-block.ts +289 -0
- package/src/types.d.ts +1782 -0
- package/src/ui/action-icons.ts +13 -0
- package/src/ui/document-actions.ts +41 -0
- package/src/ui/drag-handle.ts +52 -0
- package/src/ui/existing-image-modal.ts +164 -0
- package/src/ui/field-form-modal.test.ts +92 -0
- package/src/ui/field-form-modal.ts +168 -0
- package/src/ui/field-mapping-badges.test.ts +93 -0
- package/src/ui/field-mapping-badges.ts +243 -0
- package/src/ui/field-mapping-modal-open.test.ts +72 -0
- package/src/ui/field-mapping-modal.ts +1277 -0
- package/src/ui/filename-prompt.ts +96 -0
- package/src/ui/format-icons.ts +42 -0
- package/src/ui/html-text-modal.ts +224 -0
- package/src/ui/image-modal.ts +264 -0
- package/src/ui/integer-modal.ts +76 -0
- package/src/ui/list-modal.test.ts +220 -0
- package/src/ui/list-modal.ts +701 -0
- package/src/ui/mapping-drag-drop.test.ts +61 -0
- package/src/ui/mapping-drag-drop.ts +382 -0
- package/src/ui/mapping-result-helper.test.ts +190 -0
- package/src/ui/mapping-result-helper.ts +707 -0
- package/src/ui/modal-picker-keyboard.test.ts +65 -0
- package/src/ui/modal-picker-keyboard.ts +87 -0
- package/src/ui/modal-picker-pills.ts +31 -0
- package/src/ui/notification.ts +54 -0
- package/src/ui/palette-icons.ts +64 -0
- package/src/ui/pdf-canvas-preview.ts +93 -0
- package/src/ui/preview-modal.ts +580 -0
- package/src/ui/recent-fill-colors.test.ts +66 -0
- package/src/ui/recent-fill-colors.ts +91 -0
- package/src/ui/repeater-editor-modal.ts +137 -0
- package/src/ui/rich-text-toolbar.test.ts +180 -0
- package/src/ui/rich-text-toolbar.ts +740 -0
- package/src/ui/signature-modal.ts +240 -0
- package/src/ui/source-path-canvas-drop.test.ts +256 -0
- package/src/ui/source-path-canvas-drop.ts +367 -0
- package/src/ui/source-schema-tree.ts +381 -0
- package/src/ui/text-modal.ts +37 -0
- package/src/ui/tree-modal.test.ts +484 -0
- package/src/ui/tree-modal.ts +682 -0
- package/src/ui/wire-modal-escape.test.ts +66 -0
- package/src/ui/wire-modal-escape.ts +23 -0
- package/src/ui/wire-modal-focus-trap.test.ts +307 -0
- package/src/ui/wire-modal-move.test.ts +107 -0
- package/src/ui/wire-modal-move.ts +201 -0
- package/src/ui/wire-modal-palette.ts +533 -0
- package/src/ui/wire-modal-resize.test.ts +76 -0
- package/src/ui/wire-modal-resize.ts +176 -0
- package/src/ui/wire-panel-splitter.test.ts +178 -0
- package/src/ui/wire-panel-splitter.ts +381 -0
- package/src/utils/export-filename.test.ts +54 -0
- package/src/utils/export-filename.ts +58 -0
- package/src/utils/print-document.ts +136 -0
- package/src/utils/save-blob.ts +40 -0
- package/src/web-component.ts +68 -0
|
@@ -0,0 +1,1018 @@
|
|
|
1
|
+
const ALLOWED_TAGS = new Set([
|
|
2
|
+
'B', 'STRONG', 'I', 'EM', 'U', 'S', 'STRIKE', 'SUB', 'SUP', 'BR', 'UL', 'OL', 'LI', 'SPAN', 'MARK', 'CODE', 'DIV',
|
|
3
|
+
'H1', 'H2', 'H3',
|
|
4
|
+
]);
|
|
5
|
+
|
|
6
|
+
const ALLOWED_STYLES = new Set([
|
|
7
|
+
'font-weight',
|
|
8
|
+
'font-style',
|
|
9
|
+
'text-decoration',
|
|
10
|
+
'text-decoration-line',
|
|
11
|
+
'font-family',
|
|
12
|
+
'font-size',
|
|
13
|
+
'text-align',
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
const ALLOWED_TEXT_ALIGN = new Set(['left', 'center', 'right', 'justify']);
|
|
17
|
+
|
|
18
|
+
const SIZE_UNIT_TO_PX = {
|
|
19
|
+
px: 1,
|
|
20
|
+
pt: 96 / 72,
|
|
21
|
+
em: 16,
|
|
22
|
+
rem: 16,
|
|
23
|
+
'%': 0.15,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function normalizeFontFamilyPart(part: any) {
|
|
27
|
+
let name = String(part ?? '').trim();
|
|
28
|
+
if (!name) return null;
|
|
29
|
+
if (/^['"].*['"]$/.test(name)) {
|
|
30
|
+
name = name.slice(1, -1).trim();
|
|
31
|
+
}
|
|
32
|
+
if (!name || !/^[\w\s\-'.]+$/i.test(name)) return null;
|
|
33
|
+
if (/\s/.test(name)) return `"${name.replace(/"/g, '')}"`;
|
|
34
|
+
return name;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function normalizeFontFamily(value: any) {
|
|
38
|
+
let trimmed = String(value ?? '').trim();
|
|
39
|
+
if (!trimmed || trimmed.length > 200) return null;
|
|
40
|
+
if (!/^[\w\s\-'",.]+$/i.test(trimmed)) return null;
|
|
41
|
+
|
|
42
|
+
if (/^['"].*['"]$/.test(trimmed)) {
|
|
43
|
+
trimmed = trimmed.slice(1, -1).trim();
|
|
44
|
+
if (!trimmed) return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (trimmed.includes(',')) {
|
|
48
|
+
const parts = trimmed.split(',').map((part: any) => normalizeFontFamilyPart(part));
|
|
49
|
+
if (parts.some((part: any) => !part)) return null;
|
|
50
|
+
return parts.join(', ');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return normalizeFontFamilyPart(trimmed);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function normalizeFontSize(value: any) {
|
|
57
|
+
const trimmed = String(value ?? '').trim();
|
|
58
|
+
if (!trimmed) return null;
|
|
59
|
+
|
|
60
|
+
const match = trimmed.match(/^([\d.]+)\s*(px|pt|em|rem|%)?$/i);
|
|
61
|
+
if (!match) return null;
|
|
62
|
+
|
|
63
|
+
const num = parseFloat(match[1]);
|
|
64
|
+
if (Number.isNaN(num)) return null;
|
|
65
|
+
|
|
66
|
+
const unit = (match[2] || 'px').toLowerCase();
|
|
67
|
+
const pxEquiv = num * ((SIZE_UNIT_TO_PX as any)[unit] ?? 1);
|
|
68
|
+
if (pxEquiv < 6 || pxEquiv > 96) return null;
|
|
69
|
+
|
|
70
|
+
return `${num}${unit}`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function buildSpanStyleAttr(styles: any) {
|
|
74
|
+
const parts = [];
|
|
75
|
+
if (styles.fontFamily) parts.push(`font-family: ${styles.fontFamily}`);
|
|
76
|
+
if (styles.fontSize) parts.push(`font-size: ${styles.fontSize}`);
|
|
77
|
+
return parts.join('; ');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function sanitizeStyleRule(prop: any, value: any) {
|
|
81
|
+
const p = prop.trim().toLowerCase();
|
|
82
|
+
const v = value.trim();
|
|
83
|
+
if (!v) return null;
|
|
84
|
+
|
|
85
|
+
if (p === 'font-family') {
|
|
86
|
+
const normalized = normalizeFontFamily(v);
|
|
87
|
+
return normalized ? `font-family: ${normalized}` : null;
|
|
88
|
+
}
|
|
89
|
+
if (p === 'font-size') {
|
|
90
|
+
const normalized = normalizeFontSize(v);
|
|
91
|
+
return normalized ? `font-size: ${normalized}` : null;
|
|
92
|
+
}
|
|
93
|
+
if (p === 'text-align') {
|
|
94
|
+
const align = v.toLowerCase();
|
|
95
|
+
return ALLOWED_TEXT_ALIGN.has(align) ? `text-align: ${align}` : null;
|
|
96
|
+
}
|
|
97
|
+
if (ALLOWED_STYLES.has(p)) return `${p}: ${v}`;
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function filterSpanStyle(styleValue: any) {
|
|
102
|
+
const safe = styleValue
|
|
103
|
+
.split(';')
|
|
104
|
+
.map((rule: any) => rule.trim())
|
|
105
|
+
.filter(Boolean)
|
|
106
|
+
.map((rule: any) => {
|
|
107
|
+
const colon = rule.indexOf(':');
|
|
108
|
+
if (colon === -1) return null;
|
|
109
|
+
const prop = rule.slice(0, colon).trim().toLowerCase();
|
|
110
|
+
if (prop === 'text-align') return null;
|
|
111
|
+
return sanitizeStyleRule(rule.slice(0, colon), rule.slice(colon + 1));
|
|
112
|
+
})
|
|
113
|
+
.filter(Boolean)
|
|
114
|
+
.join('; ');
|
|
115
|
+
return safe || null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function filterBlockStyle(styleValue: any) {
|
|
119
|
+
const safe = styleValue
|
|
120
|
+
.split(';')
|
|
121
|
+
.map((rule: any) => rule.trim())
|
|
122
|
+
.filter(Boolean)
|
|
123
|
+
.map((rule: any) => {
|
|
124
|
+
const colon = rule.indexOf(':');
|
|
125
|
+
if (colon === -1) return null;
|
|
126
|
+
const prop = rule.slice(0, colon).trim().toLowerCase();
|
|
127
|
+
if (prop !== 'text-align') return null;
|
|
128
|
+
return sanitizeStyleRule(prop, rule.slice(colon + 1));
|
|
129
|
+
})
|
|
130
|
+
.filter(Boolean)
|
|
131
|
+
.join('; ');
|
|
132
|
+
return safe || null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function getBlockTextAlign(styleValue: any) {
|
|
136
|
+
const style = filterBlockStyle(styleValue);
|
|
137
|
+
if (!style) return null;
|
|
138
|
+
const match = style.match(/text-align:\s*(\w+)/);
|
|
139
|
+
return match?.[1] ?? null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const HEADING_TAGS = new Set(['H1', 'H2', 'H3']);
|
|
143
|
+
|
|
144
|
+
export function isHeadingElement(node: any) {
|
|
145
|
+
return node?.nodeType === Node.ELEMENT_NODE && HEADING_TAGS.has(node.tagName);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function isAlignmentDiv(node: any) {
|
|
149
|
+
return (
|
|
150
|
+
node?.nodeType === Node.ELEMENT_NODE &&
|
|
151
|
+
node.tagName === 'DIV' &&
|
|
152
|
+
!!getBlockTextAlign(node.getAttribute('style') || '')
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function hoistMisnestedListItems(list: any) {
|
|
157
|
+
const misplaced = [...list.querySelectorAll('li')].filter(
|
|
158
|
+
(li: any) => li.parentElement !== list,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
for (const li of misplaced) {
|
|
162
|
+
let wrapper = li.parentElement;
|
|
163
|
+
while (wrapper && wrapper.parentElement !== list) {
|
|
164
|
+
wrapper = wrapper.parentElement;
|
|
165
|
+
}
|
|
166
|
+
list.insertBefore(li, wrapper ? wrapper.nextSibling : null);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
for (const child of [...list.children]) {
|
|
170
|
+
if (child.tagName === 'LI') continue;
|
|
171
|
+
const hasMeaningfulContent =
|
|
172
|
+
child.textContent.trim().length > 0 ||
|
|
173
|
+
!!child.querySelector('img, .field-token, br');
|
|
174
|
+
if (!hasMeaningfulContent) {
|
|
175
|
+
while (child.firstChild) {
|
|
176
|
+
list.insertBefore(child.firstChild, child);
|
|
177
|
+
}
|
|
178
|
+
child.remove();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Ensure list items are direct children of ul/ol after inline formatting commands. */
|
|
184
|
+
export function normalizeLists(root: any) {
|
|
185
|
+
if (!root?.querySelectorAll) return;
|
|
186
|
+
for (const list of root.querySelectorAll('ol, ul')) {
|
|
187
|
+
hoistMisnestedListItems(list);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function finishRichTextCommand(editable: any, ok: any) {
|
|
192
|
+
if (ok) normalizeLists(editable);
|
|
193
|
+
return ok;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function sanitizeHtml(html: any) {
|
|
197
|
+
if (!html) return '';
|
|
198
|
+
const doc = new DOMParser().parseFromString(html, 'text/html');
|
|
199
|
+
|
|
200
|
+
function clean(node: any) {
|
|
201
|
+
const children = [...node.childNodes];
|
|
202
|
+
for (const child of children) {
|
|
203
|
+
if (child.nodeType === Node.TEXT_NODE) continue;
|
|
204
|
+
|
|
205
|
+
if (child.nodeType !== Node.ELEMENT_NODE) {
|
|
206
|
+
child.remove();
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (!ALLOWED_TAGS.has(child.tagName)) {
|
|
211
|
+
clean(child);
|
|
212
|
+
if (LINE_BREAKING_BLOCK_TAGS.has(child.tagName)) {
|
|
213
|
+
unwrapPreservingLineBreak(node, child);
|
|
214
|
+
} else {
|
|
215
|
+
unwrapElement(child);
|
|
216
|
+
}
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (child.tagName === 'BR' && child.getAttribute('data-empty') === 'true') {
|
|
221
|
+
child.remove();
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
for (const attr of [...child.attributes]) {
|
|
226
|
+
if (child.tagName === 'SPAN' && attr.name === 'style') {
|
|
227
|
+
const safe = filterSpanStyle(attr.value);
|
|
228
|
+
if (safe) child.setAttribute('style', safe);
|
|
229
|
+
else child.removeAttribute('style');
|
|
230
|
+
} else if (
|
|
231
|
+
(child.tagName === 'DIV' || child.tagName === 'LI' || child.tagName === 'P') &&
|
|
232
|
+
attr.name === 'style'
|
|
233
|
+
) {
|
|
234
|
+
const safe = filterBlockStyle(attr.value);
|
|
235
|
+
if (safe) child.setAttribute('style', safe);
|
|
236
|
+
else child.removeAttribute('style');
|
|
237
|
+
} else if (child.tagName === 'DIV' && attr.name === 'class') {
|
|
238
|
+
const kept = String(attr.value || '')
|
|
239
|
+
.split(/\s+/)
|
|
240
|
+
.filter((c) => c === 'document-align' || c.startsWith('document-align--'))
|
|
241
|
+
.join(' ');
|
|
242
|
+
if (kept) child.setAttribute('class', kept);
|
|
243
|
+
else child.removeAttribute('class');
|
|
244
|
+
} else {
|
|
245
|
+
child.removeAttribute(attr.name);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (child.tagName === 'SPAN' && !child.attributes.length) {
|
|
250
|
+
clean(child);
|
|
251
|
+
unwrapElement(child);
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (child.tagName === 'DIV' && !child.attributes.length) {
|
|
256
|
+
clean(child);
|
|
257
|
+
unwrapPreservingLineBreak(node, child);
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
clean(child);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
clean(doc.body);
|
|
266
|
+
normalizeLists(doc.body);
|
|
267
|
+
return doc.body.innerHTML;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function isPlainTextHtml(html: any) {
|
|
271
|
+
const doc = new DOMParser().parseFromString(html, 'text/html');
|
|
272
|
+
return doc.body.childNodes.length === 1 && doc.body.firstChild?.nodeType === Node.TEXT_NODE;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export function appendHtmlToFragment(fragment: any, html: any) {
|
|
276
|
+
const wrap = document.createElement('div');
|
|
277
|
+
wrap.innerHTML = sanitizeHtml(plainTextNewlinesToBr(html));
|
|
278
|
+
while (wrap.firstChild) {
|
|
279
|
+
fragment.appendChild(wrap.firstChild);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Replace literal newlines in HTML text nodes with <br> so line breaks survive HTML rendering.
|
|
285
|
+
* @param {string} html
|
|
286
|
+
* @returns {string}
|
|
287
|
+
*/
|
|
288
|
+
export function plainTextNewlinesToBr(html: any) {
|
|
289
|
+
const value = String(html ?? '');
|
|
290
|
+
if (!value.includes('\n')) return value;
|
|
291
|
+
|
|
292
|
+
const wrap = document.createElement('div');
|
|
293
|
+
wrap.innerHTML = value;
|
|
294
|
+
|
|
295
|
+
function process(node: any) {
|
|
296
|
+
for (const child of [...node.childNodes]) {
|
|
297
|
+
if (child.nodeType === Node.TEXT_NODE) {
|
|
298
|
+
const text = child.textContent ?? '';
|
|
299
|
+
if (!text.includes('\n')) continue;
|
|
300
|
+
const frag = document.createDocumentFragment();
|
|
301
|
+
const pieces = text.split('\n');
|
|
302
|
+
pieces.forEach((piece: any, index: any) => {
|
|
303
|
+
if (piece) frag.appendChild(document.createTextNode(piece));
|
|
304
|
+
if (index < pieces.length - 1) frag.appendChild(document.createElement('br'));
|
|
305
|
+
});
|
|
306
|
+
child.parentNode?.replaceChild(frag, child);
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (child.nodeType === Node.ELEMENT_NODE) process(child);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
process(wrap);
|
|
314
|
+
return wrap.innerHTML;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export function isHtmlValueEmpty(html: any) {
|
|
318
|
+
const sanitized = sanitizeHtml(String(html ?? ''));
|
|
319
|
+
if (!sanitized.trim()) return true;
|
|
320
|
+
|
|
321
|
+
const doc = new DOMParser().parseFromString(sanitized, 'text/html');
|
|
322
|
+
const text = (doc.body.textContent ?? '').replace(/\u00a0/g, ' ').trim();
|
|
323
|
+
if (text) return false;
|
|
324
|
+
|
|
325
|
+
return !doc.body.querySelector('img, br, li, ul, ol');
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** Window for an editable node (supports iframe contenteditables). */
|
|
329
|
+
function ownerWindow(node: any): Window {
|
|
330
|
+
return (node?.ownerDocument?.defaultView as Window | null | undefined) ?? window;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function selectionFor(node: any): Selection | null {
|
|
334
|
+
return ownerWindow(node).getSelection();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export function saveSelection(container: any) {
|
|
338
|
+
const sel = selectionFor(container);
|
|
339
|
+
if (!sel?.rangeCount) return null;
|
|
340
|
+
const range = sel.getRangeAt(0);
|
|
341
|
+
if (!container?.contains(range.commonAncestorContainer)) return null;
|
|
342
|
+
return range.cloneRange();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export function restoreSelection(range: any) {
|
|
346
|
+
if (!range) return false;
|
|
347
|
+
const root = range?.commonAncestorContainer;
|
|
348
|
+
const sel = selectionFor(root?.nodeType === Node.TEXT_NODE ? root.parentNode : root) ?? window.getSelection();
|
|
349
|
+
sel!.removeAllRanges();
|
|
350
|
+
sel!.addRange(range);
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function rangeIntersectsNode(range: any, node: any) {
|
|
355
|
+
if (!range || !node) return false;
|
|
356
|
+
if (typeof range.intersectsNode === 'function') {
|
|
357
|
+
return range.intersectsNode(node);
|
|
358
|
+
}
|
|
359
|
+
let ancestor = range.commonAncestorContainer;
|
|
360
|
+
if (!ancestor) return false;
|
|
361
|
+
if (ancestor.nodeType === Node.TEXT_NODE) ancestor = ancestor.parentNode;
|
|
362
|
+
return ancestor.contains?.(node) ?? false;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function rangeIntersectsFieldToken(range: any, editable: any) {
|
|
366
|
+
for (const token of editable.querySelectorAll('.field-token')) {
|
|
367
|
+
if (rangeIntersectsNode(range, token)) return true;
|
|
368
|
+
}
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function isDocumentTableElement(node: any) {
|
|
373
|
+
return node?.nodeType === Node.ELEMENT_NODE && node.classList?.contains('document-table');
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function isTableFieldToken(token: any) {
|
|
377
|
+
return !!token?.closest?.('.document-table') || !!token?.classList?.contains('field-token--cell');
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function unwrapElement(el: any) {
|
|
381
|
+
const parent = el.parentNode;
|
|
382
|
+
if (!parent) return;
|
|
383
|
+
while (el.firstChild) {
|
|
384
|
+
parent.insertBefore(el.firstChild, el);
|
|
385
|
+
}
|
|
386
|
+
parent.removeChild(el);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const LINE_BREAKING_BLOCK_TAGS = new Set([
|
|
390
|
+
'DIV',
|
|
391
|
+
'P',
|
|
392
|
+
'BLOCKQUOTE',
|
|
393
|
+
'SECTION',
|
|
394
|
+
'ARTICLE',
|
|
395
|
+
'HEADER',
|
|
396
|
+
'FOOTER',
|
|
397
|
+
'PRE',
|
|
398
|
+
'ADDRESS',
|
|
399
|
+
'H1',
|
|
400
|
+
'H2',
|
|
401
|
+
'H3',
|
|
402
|
+
'H4',
|
|
403
|
+
'H5',
|
|
404
|
+
'H6',
|
|
405
|
+
]);
|
|
406
|
+
|
|
407
|
+
function previousMeaningfulSibling(child: any) {
|
|
408
|
+
let prev = child.previousSibling;
|
|
409
|
+
while (prev) {
|
|
410
|
+
if (prev.nodeType === Node.ELEMENT_NODE) return prev;
|
|
411
|
+
if (prev.nodeType === Node.TEXT_NODE && (prev.textContent ?? '').replace(/\u00a0/g, ' ').trim()) {
|
|
412
|
+
return prev;
|
|
413
|
+
}
|
|
414
|
+
prev = prev.previousSibling;
|
|
415
|
+
}
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** Unwrap a block so contenteditable line breaks become <br> instead of one inline string. */
|
|
420
|
+
function unwrapPreservingLineBreak(parent: any, child: any) {
|
|
421
|
+
const prev = previousMeaningfulSibling(child);
|
|
422
|
+
if (prev && prev.nodeName !== 'BR') {
|
|
423
|
+
parent.insertBefore(parent.ownerDocument.createElement('br'), child);
|
|
424
|
+
}
|
|
425
|
+
while (child.firstChild) {
|
|
426
|
+
parent.insertBefore(child.firstChild, child);
|
|
427
|
+
}
|
|
428
|
+
child.remove();
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function findAncestorTag(node: any, tagName: any, editable: any) {
|
|
432
|
+
let el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
|
433
|
+
while (el && el !== editable) {
|
|
434
|
+
if (el.tagName === tagName) return el;
|
|
435
|
+
el = el.parentElement;
|
|
436
|
+
}
|
|
437
|
+
return null;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function getActiveRange(editable: any, savedRange: any) {
|
|
441
|
+
if (!editable) return null;
|
|
442
|
+
editable.focus();
|
|
443
|
+
if (savedRange) restoreSelection(savedRange);
|
|
444
|
+
|
|
445
|
+
const sel = window.getSelection();
|
|
446
|
+
if (!sel?.rangeCount || sel.isCollapsed) return null;
|
|
447
|
+
|
|
448
|
+
const range = sel.getRangeAt(0);
|
|
449
|
+
if (!editable.contains(range.commonAncestorContainer)) return null;
|
|
450
|
+
if (rangeIntersectsFieldToken(range, editable)) return null;
|
|
451
|
+
|
|
452
|
+
return range;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export function applyInlineSpanStyle(editable: any, styles: any, savedRange: any) {
|
|
456
|
+
const styleAttr = buildSpanStyleAttr(styles);
|
|
457
|
+
if (!styleAttr) return false;
|
|
458
|
+
|
|
459
|
+
const range = getActiveRange(editable, savedRange);
|
|
460
|
+
if (!range) return false;
|
|
461
|
+
|
|
462
|
+
const el = document.createElement('span');
|
|
463
|
+
el.setAttribute('style', styleAttr);
|
|
464
|
+
|
|
465
|
+
try {
|
|
466
|
+
range.surroundContents(el);
|
|
467
|
+
} catch {
|
|
468
|
+
const contents = range.extractContents();
|
|
469
|
+
if (!contents.textContent && !contents.querySelector?.('img')) return false;
|
|
470
|
+
el.appendChild(contents);
|
|
471
|
+
range.insertNode(el);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const sel = window.getSelection();
|
|
475
|
+
sel!.removeAllRanges();
|
|
476
|
+
const newRange = document.createRange();
|
|
477
|
+
newRange.selectNodeContents(el);
|
|
478
|
+
sel!.addRange(newRange);
|
|
479
|
+
return true;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
export function applyFontFormatting(editable: any, { fontFamily, fontSize }: any, savedRange: any) {
|
|
483
|
+
const styles: any = {};
|
|
484
|
+
if (fontFamily) {
|
|
485
|
+
const normalized = normalizeFontFamily(fontFamily);
|
|
486
|
+
if (normalized) styles.fontFamily = normalized;
|
|
487
|
+
}
|
|
488
|
+
if (fontSize) {
|
|
489
|
+
const normalized = normalizeFontSize(fontSize);
|
|
490
|
+
if (normalized) styles.fontSize = normalized;
|
|
491
|
+
}
|
|
492
|
+
if (!styles.fontFamily && !styles.fontSize) return false;
|
|
493
|
+
return applyInlineSpanStyle(editable, styles, savedRange);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function clearFontStylesFromSelection(editable: any, savedRange: any) {
|
|
497
|
+
if (!editable) return;
|
|
498
|
+
editable.focus();
|
|
499
|
+
if (savedRange) restoreSelection(savedRange);
|
|
500
|
+
|
|
501
|
+
const sel = window.getSelection();
|
|
502
|
+
if (!sel?.rangeCount) return;
|
|
503
|
+
|
|
504
|
+
const range = sel.getRangeAt(0);
|
|
505
|
+
if (!editable.contains(range.commonAncestorContainer)) return;
|
|
506
|
+
|
|
507
|
+
for (const span of editable.querySelectorAll('span[style]')) {
|
|
508
|
+
if (!range.intersectsNode(span)) continue;
|
|
509
|
+
// Field tokens are styled spans — never strip or unwrap them as "formatting".
|
|
510
|
+
if (span.classList?.contains('field-token') || span.closest?.('.field-token')) continue;
|
|
511
|
+
|
|
512
|
+
const kept = (span.getAttribute('style') || '')
|
|
513
|
+
.split(';')
|
|
514
|
+
.map((rule: any) => rule.trim())
|
|
515
|
+
.filter(Boolean)
|
|
516
|
+
.map((rule: any) => {
|
|
517
|
+
const colon = rule.indexOf(':');
|
|
518
|
+
if (colon === -1) return null;
|
|
519
|
+
const prop = rule.slice(0, colon).trim().toLowerCase();
|
|
520
|
+
if (prop === 'font-family' || prop === 'font-size') return null;
|
|
521
|
+
return sanitizeStyleRule(rule.slice(0, colon), rule.slice(colon + 1));
|
|
522
|
+
})
|
|
523
|
+
.filter(Boolean)
|
|
524
|
+
.join('; ');
|
|
525
|
+
|
|
526
|
+
if (kept) span.setAttribute('style', kept);
|
|
527
|
+
else {
|
|
528
|
+
unwrapElement(span);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function clearAlignmentFromSelection(editable: any, savedRange: any) {
|
|
534
|
+
if (!editable) return;
|
|
535
|
+
editable.focus();
|
|
536
|
+
if (savedRange) restoreSelection(savedRange);
|
|
537
|
+
|
|
538
|
+
const sel = window.getSelection();
|
|
539
|
+
if (!sel?.rangeCount) return;
|
|
540
|
+
|
|
541
|
+
const range = sel.getRangeAt(0);
|
|
542
|
+
if (!editable.contains(range.commonAncestorContainer)) return;
|
|
543
|
+
|
|
544
|
+
for (const block of editable.querySelectorAll('div[style]')) {
|
|
545
|
+
if (!range.intersectsNode(block)) continue;
|
|
546
|
+
if (filterBlockStyle(block.getAttribute('style') || '')) {
|
|
547
|
+
unwrapElement(block);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function findAlignmentBlock(node: any, editable: any) {
|
|
553
|
+
let el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
|
554
|
+
while (el && el !== editable) {
|
|
555
|
+
if (isAlignmentDiv(el)) return el;
|
|
556
|
+
el = el.parentElement;
|
|
557
|
+
}
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function nodeContainsCaret(node: any, range: any) {
|
|
562
|
+
if (node === range.startContainer) return true;
|
|
563
|
+
if (node.nodeType === Node.ELEMENT_NODE) return node.contains(range.startContainer);
|
|
564
|
+
return false;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function isFieldTokenElement(node: any) {
|
|
568
|
+
return node?.nodeType === Node.ELEMENT_NODE && node.classList?.contains('field-token');
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Line range inside `container` (editable root, alignment div, or similar).
|
|
573
|
+
* Split on BR / heading / table boundaries — not the whole container as one line.
|
|
574
|
+
*/
|
|
575
|
+
function getLineRangeInContainer(container: any, range: any) {
|
|
576
|
+
const nodes = [...container.childNodes];
|
|
577
|
+
if (!nodes.length) return null;
|
|
578
|
+
|
|
579
|
+
let activeIndex = -1;
|
|
580
|
+
if (range.startContainer === container) {
|
|
581
|
+
activeIndex = Math.min(Math.max(range.startOffset, 0), nodes.length - 1);
|
|
582
|
+
} else {
|
|
583
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
584
|
+
if (nodeContainsCaret(nodes[i], range)) {
|
|
585
|
+
activeIndex = i;
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
if (activeIndex === -1) return null;
|
|
591
|
+
if (isDocumentTableElement(nodes[activeIndex])) return null;
|
|
592
|
+
|
|
593
|
+
let lineStart = activeIndex;
|
|
594
|
+
while (lineStart > 0 && nodes[lineStart - 1].nodeName !== 'BR') {
|
|
595
|
+
const prev = nodes[lineStart - 1];
|
|
596
|
+
if (HEADING_TAGS.has(prev.nodeName)) break;
|
|
597
|
+
if (isDocumentTableElement(prev)) break;
|
|
598
|
+
if (isAlignmentDiv(prev)) break;
|
|
599
|
+
lineStart -= 1;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
let lineEnd = activeIndex;
|
|
603
|
+
while (lineEnd < nodes.length - 1 && nodes[lineEnd].nodeName !== 'BR') {
|
|
604
|
+
const next = nodes[lineEnd + 1];
|
|
605
|
+
if (HEADING_TAGS.has(next.nodeName)) break;
|
|
606
|
+
if (isDocumentTableElement(next)) break;
|
|
607
|
+
if (isAlignmentDiv(next)) break;
|
|
608
|
+
lineEnd += 1;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
for (let i = lineStart; i <= lineEnd; i += 1) {
|
|
612
|
+
if (isDocumentTableElement(nodes[i])) return null;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
const doc = container.ownerDocument ?? document;
|
|
616
|
+
const lineRange = doc.createRange();
|
|
617
|
+
lineRange.setStartBefore(nodes[lineStart]);
|
|
618
|
+
if (nodes[lineEnd]?.nodeName === 'BR') {
|
|
619
|
+
lineRange.setEndBefore(nodes[lineEnd]);
|
|
620
|
+
} else {
|
|
621
|
+
lineRange.setEndAfter(nodes[lineEnd]);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
return lineRange.collapsed ? null : lineRange;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
function getTopLevelLineRange(editable: any, range: any) {
|
|
628
|
+
return getLineRangeInContainer(editable, range);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/** Nearest block that owns "lines" for alignment (LI, align div, or editable). */
|
|
632
|
+
function getAlignmentLineRoot(node: any, editable: any) {
|
|
633
|
+
let el = node?.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
|
634
|
+
while (el && el !== editable) {
|
|
635
|
+
if (el.tagName === 'LI') return el;
|
|
636
|
+
if (isAlignmentDiv(el)) return el;
|
|
637
|
+
if (isHeadingElement(el)) return el;
|
|
638
|
+
el = el.parentElement;
|
|
639
|
+
}
|
|
640
|
+
return editable;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function selectionCoversElement(range: any, el: any) {
|
|
644
|
+
if (!range || !el) return false;
|
|
645
|
+
// Test / incomplete Range mocks: only full selectNodeContents-style ranges cover.
|
|
646
|
+
if (typeof range.compareBoundaryPoints !== 'function') {
|
|
647
|
+
return (
|
|
648
|
+
range.startContainer === el &&
|
|
649
|
+
range.endContainer === el &&
|
|
650
|
+
range.startOffset === 0 &&
|
|
651
|
+
range.endOffset === el.childNodes.length
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
try {
|
|
655
|
+
const doc = el.ownerDocument ?? document;
|
|
656
|
+
const full = doc.createRange();
|
|
657
|
+
full.selectNodeContents(el);
|
|
658
|
+
return (
|
|
659
|
+
range.compareBoundaryPoints(Range.START_TO_START, full) <= 0 &&
|
|
660
|
+
range.compareBoundaryPoints(Range.END_TO_END, full) >= 0
|
|
661
|
+
);
|
|
662
|
+
} catch {
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
function applyAlignmentToElement(el: any, alignment: any) {
|
|
668
|
+
if (!el) return false;
|
|
669
|
+
el.style.textAlign = alignment;
|
|
670
|
+
if (el.tagName === 'DIV') {
|
|
671
|
+
setAlignmentDivClass(el, alignment);
|
|
672
|
+
el.setAttribute('style', `text-align: ${alignment}`);
|
|
673
|
+
} else {
|
|
674
|
+
el.setAttribute('style', `text-align: ${alignment}`);
|
|
675
|
+
}
|
|
676
|
+
return true;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
function setAlignmentDivClass(div: any, alignment: any) {
|
|
680
|
+
div.classList.add('document-align');
|
|
681
|
+
for (const side of ALLOWED_TEXT_ALIGN) {
|
|
682
|
+
div.classList.toggle(`document-align--${side}`, side === alignment);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function getFieldTokenFromRange(editable: any, range: any) {
|
|
687
|
+
let el = range.startContainer;
|
|
688
|
+
if (el.nodeType === Node.TEXT_NODE) el = el.parentElement;
|
|
689
|
+
const token = el?.closest?.('.field-token');
|
|
690
|
+
return token && editable.contains(token) ? token : null;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
export function applyAlignmentToFieldToken(token: any, alignment: any) {
|
|
694
|
+
if (!token || isTableFieldToken(token)) return false;
|
|
695
|
+
|
|
696
|
+
const parent = token.parentElement;
|
|
697
|
+
if (isAlignmentDiv(parent)) {
|
|
698
|
+
parent.style.textAlign = alignment;
|
|
699
|
+
setAlignmentDivClass(parent, alignment);
|
|
700
|
+
return true;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
const div = document.createElement('div');
|
|
704
|
+
setAlignmentDivClass(div, alignment);
|
|
705
|
+
div.setAttribute('style', `text-align: ${alignment}`);
|
|
706
|
+
token.parentNode.insertBefore(div, token);
|
|
707
|
+
div.appendChild(token);
|
|
708
|
+
return true;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function wrapRangeInAlignmentDiv(range: any, alignment: any) {
|
|
712
|
+
const div = document.createElement('div');
|
|
713
|
+
setAlignmentDivClass(div, alignment);
|
|
714
|
+
div.setAttribute('style', `text-align: ${alignment}`);
|
|
715
|
+
|
|
716
|
+
const insertParent =
|
|
717
|
+
range.startContainer?.nodeType === Node.ELEMENT_NODE
|
|
718
|
+
? range.startContainer
|
|
719
|
+
: range.startContainer?.parentNode;
|
|
720
|
+
const insertOffset = range.startOffset ?? 0;
|
|
721
|
+
|
|
722
|
+
const contents = range.extractContents();
|
|
723
|
+
// Tables stay as top-level blocks — never nest them in an align wrapper.
|
|
724
|
+
const extractedTables = [...(contents.querySelectorAll?.('.document-table') ?? [])];
|
|
725
|
+
for (const table of extractedTables) {
|
|
726
|
+
table.remove();
|
|
727
|
+
}
|
|
728
|
+
// linkedom DocumentFragment.textContent can be null — fall back to child text.
|
|
729
|
+
const contentText = String(
|
|
730
|
+
contents.textContent ??
|
|
731
|
+
[...(contents.childNodes ?? [])].map((n: any) => n.textContent ?? '').join(''),
|
|
732
|
+
);
|
|
733
|
+
if (!contentText.trim() && !contents.querySelector?.('.field-token, img, br')) {
|
|
734
|
+
for (const table of extractedTables) {
|
|
735
|
+
if (insertParent) {
|
|
736
|
+
const ref = insertParent.childNodes[insertOffset] ?? null;
|
|
737
|
+
insertParent.insertBefore(table, ref);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return null;
|
|
741
|
+
}
|
|
742
|
+
div.appendChild(contents);
|
|
743
|
+
|
|
744
|
+
try {
|
|
745
|
+
range.insertNode(div);
|
|
746
|
+
} catch {
|
|
747
|
+
// linkedom (and some edge ranges) detach the live range after extractContents.
|
|
748
|
+
if (!insertParent) return null;
|
|
749
|
+
const ref = insertParent.childNodes[insertOffset] ?? null;
|
|
750
|
+
insertParent.insertBefore(div, ref);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
let insertAfter = div;
|
|
754
|
+
for (const table of extractedTables) {
|
|
755
|
+
insertAfter.after(table);
|
|
756
|
+
insertAfter = table;
|
|
757
|
+
}
|
|
758
|
+
return div;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
export function applyBlockAlignment(editable: any, alignment: any, savedRange: any) {
|
|
762
|
+
if (!editable || !ALLOWED_TEXT_ALIGN.has(alignment)) return false;
|
|
763
|
+
editable.focus();
|
|
764
|
+
if (savedRange) restoreSelection(savedRange);
|
|
765
|
+
|
|
766
|
+
const sel = selectionFor(editable) ?? window.getSelection();
|
|
767
|
+
if (!sel?.rangeCount) return false;
|
|
768
|
+
let range = sel.getRangeAt(0);
|
|
769
|
+
if (!editable.contains(range.commonAncestorContainer)) return false;
|
|
770
|
+
|
|
771
|
+
// List items: align the LI only — not a wrapper around the whole editor.
|
|
772
|
+
let startEl: any =
|
|
773
|
+
range.startContainer?.nodeType === Node.TEXT_NODE
|
|
774
|
+
? range.startContainer.parentElement
|
|
775
|
+
: range.startContainer;
|
|
776
|
+
const li =
|
|
777
|
+
startEl?.nodeType === Node.ELEMENT_NODE
|
|
778
|
+
? (startEl.closest?.('li') as HTMLElement | null)
|
|
779
|
+
: null;
|
|
780
|
+
if (li && editable.contains(li)) {
|
|
781
|
+
const endNode =
|
|
782
|
+
range.endContainer?.nodeType === Node.TEXT_NODE
|
|
783
|
+
? range.endContainer.parentNode
|
|
784
|
+
: range.endContainer;
|
|
785
|
+
const endInLi = range.collapsed || !!(endNode && li.contains(endNode));
|
|
786
|
+
if (endInLi) {
|
|
787
|
+
return applyAlignmentToElement(li, alignment);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
if (range.collapsed) {
|
|
792
|
+
const selectedTokens = [...editable.querySelectorAll('.field-token--selected')].filter(
|
|
793
|
+
(token: any) => !isTableFieldToken(token),
|
|
794
|
+
);
|
|
795
|
+
if (selectedTokens.length) {
|
|
796
|
+
let applied = false;
|
|
797
|
+
for (const token of selectedTokens) {
|
|
798
|
+
if (applyAlignmentToFieldToken(token, alignment)) applied = true;
|
|
799
|
+
}
|
|
800
|
+
return applied;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
const fieldToken = getFieldTokenFromRange(editable, range);
|
|
804
|
+
if (fieldToken && !isTableFieldToken(fieldToken)) {
|
|
805
|
+
return applyAlignmentToFieldToken(fieldToken, alignment);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// Align the current line only — never retarget a multi-line ancestor div.
|
|
809
|
+
const lineRoot = getAlignmentLineRoot(range.startContainer, editable);
|
|
810
|
+
const lineRange = getLineRangeInContainer(lineRoot, range);
|
|
811
|
+
if (!lineRange) return false;
|
|
812
|
+
|
|
813
|
+
if (isAlignmentDiv(lineRoot) && selectionCoversElement(lineRange, lineRoot)) {
|
|
814
|
+
return applyAlignmentToElement(lineRoot, alignment);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
return !!wrapRangeInAlignmentDiv(lineRange, alignment);
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// Non-collapsed: only update an existing align block when the selection is the whole block.
|
|
821
|
+
const existingBlock = findAlignmentBlock(range.commonAncestorContainer, editable);
|
|
822
|
+
if (
|
|
823
|
+
existingBlock &&
|
|
824
|
+
!existingBlock.querySelector?.('.document-table') &&
|
|
825
|
+
selectionCoversElement(range, existingBlock)
|
|
826
|
+
) {
|
|
827
|
+
return applyAlignmentToElement(existingBlock, alignment);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// Selected content may include fields; tables are excluded from the wrap.
|
|
831
|
+
return !!wrapRangeInAlignmentDiv(range, alignment);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
function collectHeadingsInRange(range: any, editable: any) {
|
|
835
|
+
return [...editable.querySelectorAll('h1, h2, h3')].filter((heading: any) =>
|
|
836
|
+
rangeIntersectsNode(range, heading),
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
function findOutermostHeading(range: any, editable: any) {
|
|
841
|
+
const headings = collectHeadingsInRange(range, editable);
|
|
842
|
+
if (!headings.length) return null;
|
|
843
|
+
return (
|
|
844
|
+
headings.find((heading: any) =>
|
|
845
|
+
!headings.some((other: any) => other !== heading && other.contains(heading)),
|
|
846
|
+
) ?? headings[0]
|
|
847
|
+
);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
function flattenHeadingsInRange(range: any, editable: any) {
|
|
851
|
+
const headings = collectHeadingsInRange(range, editable);
|
|
852
|
+
headings.sort((a: any, b: any) => {
|
|
853
|
+
if (a.contains(b)) return 1;
|
|
854
|
+
if (b.contains(a)) return -1;
|
|
855
|
+
return 0;
|
|
856
|
+
});
|
|
857
|
+
for (const heading of headings) {
|
|
858
|
+
if (heading.isConnected) unwrapElement(heading);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
function replaceElementTag(el: any, tagName: any) {
|
|
863
|
+
if (el.tagName === tagName) return el;
|
|
864
|
+
const replacement = document.createElement(tagName);
|
|
865
|
+
while (el.firstChild) {
|
|
866
|
+
replacement.appendChild(el.firstChild);
|
|
867
|
+
}
|
|
868
|
+
el.parentNode.replaceChild(replacement, el);
|
|
869
|
+
return replacement;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
function wrapRangeInHeading(range: any, tagName: any) {
|
|
873
|
+
const heading = document.createElement(tagName);
|
|
874
|
+
const contents = range.extractContents();
|
|
875
|
+
if (!contents.textContent && !contents.querySelector?.('.field-token, img, br')) return null;
|
|
876
|
+
heading.appendChild(contents);
|
|
877
|
+
range.insertNode(heading);
|
|
878
|
+
return heading;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
function clearHeadingsFromSelection(editable: any, savedRange: any) {
|
|
882
|
+
if (!editable) return;
|
|
883
|
+
editable.focus();
|
|
884
|
+
if (savedRange) restoreSelection(savedRange);
|
|
885
|
+
|
|
886
|
+
const sel = window.getSelection();
|
|
887
|
+
if (!sel?.rangeCount) return;
|
|
888
|
+
|
|
889
|
+
const range = sel.getRangeAt(0);
|
|
890
|
+
if (!editable.contains(range.commonAncestorContainer)) return;
|
|
891
|
+
|
|
892
|
+
for (const heading of editable.querySelectorAll('h1, h2, h3')) {
|
|
893
|
+
if (!rangeIntersectsNode(range, heading)) continue;
|
|
894
|
+
unwrapElement(heading);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
export function applyBlockHeading(editable: any, level: any, savedRange: any) {
|
|
899
|
+
if (!editable || level < 1 || level > 3) return false;
|
|
900
|
+
const tagName = `H${level}`;
|
|
901
|
+
|
|
902
|
+
editable.focus();
|
|
903
|
+
if (savedRange) restoreSelection(savedRange);
|
|
904
|
+
|
|
905
|
+
const sel = window.getSelection();
|
|
906
|
+
if (!sel?.rangeCount) return false;
|
|
907
|
+
let range = sel.getRangeAt(0);
|
|
908
|
+
if (!editable.contains(range.commonAncestorContainer)) return false;
|
|
909
|
+
|
|
910
|
+
if (range.collapsed) {
|
|
911
|
+
if (rangeIntersectsFieldToken(range, editable)) return false;
|
|
912
|
+
|
|
913
|
+
const lineRange = getTopLevelLineRange(editable, range);
|
|
914
|
+
if (!lineRange) return false;
|
|
915
|
+
range = lineRange;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
if (rangeIntersectsFieldToken(range, editable)) return false;
|
|
919
|
+
|
|
920
|
+
const outermostHeading = findOutermostHeading(range, editable);
|
|
921
|
+
if (outermostHeading) {
|
|
922
|
+
if (outermostHeading.tagName === tagName) {
|
|
923
|
+
flattenHeadingsInRange(range, editable);
|
|
924
|
+
} else {
|
|
925
|
+
for (const inner of [...outermostHeading.querySelectorAll('h1, h2, h3')]) {
|
|
926
|
+
unwrapElement(inner);
|
|
927
|
+
}
|
|
928
|
+
replaceElementTag(outermostHeading, tagName);
|
|
929
|
+
}
|
|
930
|
+
return true;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
flattenHeadingsInRange(range, editable);
|
|
934
|
+
return !!wrapRangeInHeading(range, tagName);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
export function toggleInlineTag(editable: any, tagName: any, savedRange: any) {
|
|
938
|
+
if (!editable) return false;
|
|
939
|
+
editable.focus();
|
|
940
|
+
if (savedRange) restoreSelection(savedRange);
|
|
941
|
+
|
|
942
|
+
const sel = window.getSelection();
|
|
943
|
+
if (!sel?.rangeCount || sel.isCollapsed) return false;
|
|
944
|
+
|
|
945
|
+
const range = sel.getRangeAt(0);
|
|
946
|
+
if (!editable.contains(range.commonAncestorContainer)) return false;
|
|
947
|
+
if (rangeIntersectsFieldToken(range, editable)) return false;
|
|
948
|
+
|
|
949
|
+
const existing = findAncestorTag(range.commonAncestorContainer, tagName, editable);
|
|
950
|
+
if (existing) {
|
|
951
|
+
unwrapElement(existing);
|
|
952
|
+
return true;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
const el = document.createElement(tagName);
|
|
956
|
+
try {
|
|
957
|
+
range.surroundContents(el);
|
|
958
|
+
} catch {
|
|
959
|
+
const contents = range.extractContents();
|
|
960
|
+
if (!contents.textContent && !contents.querySelector?.('img')) return false;
|
|
961
|
+
el.appendChild(contents);
|
|
962
|
+
range.insertNode(el);
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
sel.removeAllRanges();
|
|
966
|
+
const newRange = document.createRange();
|
|
967
|
+
newRange.selectNodeContents(el);
|
|
968
|
+
sel.addRange(newRange);
|
|
969
|
+
return true;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
export function execRichTextCommand(command: any, editable: any, savedRange: any) {
|
|
973
|
+
if (!editable) return false;
|
|
974
|
+
editable.focus();
|
|
975
|
+
if (savedRange) restoreSelection(savedRange);
|
|
976
|
+
|
|
977
|
+
if (command === 'mark') {
|
|
978
|
+
return finishRichTextCommand(editable, toggleInlineTag(editable, 'MARK', null));
|
|
979
|
+
}
|
|
980
|
+
if (command === 'inlineCode') {
|
|
981
|
+
return finishRichTextCommand(editable, toggleInlineTag(editable, 'CODE', null));
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
if (command === 'removeFormat') {
|
|
985
|
+
const sel = window.getSelection();
|
|
986
|
+
const range = sel?.rangeCount ? sel.getRangeAt(0) : null;
|
|
987
|
+
// Browser removeFormat unwraps spans and destroys field tokens in the selection.
|
|
988
|
+
if (!range || !rangeIntersectsFieldToken(range, editable)) {
|
|
989
|
+
document.execCommand('styleWithCSS', false, false as any);
|
|
990
|
+
document.execCommand('removeFormat', false, null as any);
|
|
991
|
+
}
|
|
992
|
+
clearFontStylesFromSelection(editable, null);
|
|
993
|
+
clearAlignmentFromSelection(editable, null);
|
|
994
|
+
clearHeadingsFromSelection(editable, null);
|
|
995
|
+
return finishRichTextCommand(editable, true);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
const headingLevel = ({ heading1: 1, heading2: 2, heading3: 3 } as any)[command];
|
|
999
|
+
if (headingLevel) {
|
|
1000
|
+
return finishRichTextCommand(
|
|
1001
|
+
editable,
|
|
1002
|
+
applyBlockHeading(editable, headingLevel, savedRange),
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
const alignment = ({ justifyLeft: 'left', justifyCenter: 'center', justifyRight: 'right' } as any)[command];
|
|
1007
|
+
if (alignment) {
|
|
1008
|
+
return finishRichTextCommand(editable, applyBlockAlignment(editable, alignment, null));
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
const inlineTag = ({ bold: 'B', italic: 'I', underline: 'U', strikeThrough: 'S' } as any)[command];
|
|
1012
|
+
if (inlineTag) {
|
|
1013
|
+
return finishRichTextCommand(editable, toggleInlineTag(editable, inlineTag, savedRange));
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
document.execCommand('styleWithCSS', false, false as any);
|
|
1017
|
+
return finishRichTextCommand(editable, document.execCommand(command, false, null as any));
|
|
1018
|
+
}
|