@lyads/visual-editor 0.0.0-stage → 1.0.1
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/CHANGELOG.md +15 -0
- package/LICENSE +201 -0
- package/NOTICE +8 -0
- package/README.md +135 -2
- package/THIRD_PARTY_NOTICES.md +21259 -0
- package/dist/application/block-placement.d.ts +30 -0
- package/dist/application/block-session.d.ts +135 -0
- package/dist/application/content-service.d.ts +73 -0
- package/dist/application/document-commands.d.ts +51 -0
- package/dist/application/document-metadata.d.ts +30 -0
- package/dist/application/document-presentation.d.ts +35 -0
- package/dist/application/email-insertion.d.ts +76 -0
- package/dist/application/host.d.ts +36 -0
- package/dist/application/image-link.d.ts +36 -0
- package/dist/application/section-layout.d.ts +25 -0
- package/dist/application/session.d.ts +128 -0
- package/dist/assets/browser-worker-D56tNvnb.js +1014 -0
- package/dist/assets/browser-worker-D56tNvnb.js.map +1 -0
- package/dist/block-controller-RjYGvOcn.js +2468 -0
- package/dist/block-controller-RjYGvOcn.js.map +1 -0
- package/dist/block-factory-C5oHi4Fm.js +5397 -0
- package/dist/block-factory-C5oHi4Fm.js.map +1 -0
- package/dist/blocks/block-checks.d.ts +34 -0
- package/dist/blocks/block-inspector.d.ts +55 -0
- package/dist/blocks/block-output.d.ts +28 -0
- package/dist/blocks/block-type.d.ts +124 -0
- package/dist/blocks/content-guard.d.ts +52 -0
- package/dist/blocks/conversion.d.ts +22 -0
- package/dist/blocks/definitions.d.ts +43 -0
- package/dist/blocks/device-styles.d.ts +31 -0
- package/dist/blocks/email-generator.d.ts +22 -0
- package/dist/blocks/email-preview.d.ts +23 -0
- package/dist/blocks/email-renderer.d.ts +20 -0
- package/dist/blocks/fields.d.ts +34 -0
- package/dist/blocks/page-generator.d.ts +16 -0
- package/dist/blocks/render-context.d.ts +58 -0
- package/dist/blocks/styles.d.ts +54 -0
- package/dist/blocks/types/embed.d.ts +40 -0
- package/dist/blocks/types/layout.d.ts +41 -0
- package/dist/blocks/types/media.d.ts +53 -0
- package/dist/blocks/types/structure.d.ts +44 -0
- package/dist/blocks/types/text.d.ts +88 -0
- package/dist/blocks/values.d.ts +64 -0
- package/dist/browser.js +69 -0
- package/dist/browser.js.map +1 -0
- package/dist/canvas-runtime/action-bar.d.ts +19 -0
- package/dist/canvas-runtime/auto-scroll.d.ts +10 -0
- package/dist/canvas-runtime/block-drag.d.ts +29 -0
- package/dist/canvas-runtime/bridge.d.ts +6 -0
- package/dist/canvas-runtime/context.d.ts +53 -0
- package/dist/canvas-runtime/document-sync.d.ts +21 -0
- package/dist/canvas-runtime/drop-targets.d.ts +34 -0
- package/dist/canvas-runtime/embed-markers.d.ts +15 -0
- package/dist/canvas-runtime/file-guard.d.ts +12 -0
- package/dist/canvas-runtime/image-tools.d.ts +31 -0
- package/dist/canvas-runtime/keyboard.d.ts +18 -0
- package/dist/canvas-runtime/main.d.ts +1 -0
- package/dist/canvas-runtime/messages.d.ts +26 -0
- package/dist/canvas-runtime/morph.d.ts +21 -0
- package/dist/canvas-runtime/navigation.d.ts +29 -0
- package/dist/canvas-runtime/overlay.d.ts +15 -0
- package/dist/canvas-runtime/pointer-intents.d.ts +14 -0
- package/dist/canvas-runtime/selection-layer.d.ts +16 -0
- package/dist/canvas-runtime/shared/shortcuts.d.ts +27 -0
- package/dist/canvas-runtime/text-editor.d.ts +55 -0
- package/dist/canvas-runtime/text-session.d.ts +39 -0
- package/dist/canvas-runtime/variable-marks.d.ts +20 -0
- package/dist/canvas-runtime/viewport.d.ts +10 -0
- package/dist/codecs/css.d.ts +74 -0
- package/dist/codecs/html.d.ts +81 -0
- package/dist/compilation/browser-compiler.d.ts +14 -0
- package/dist/compilation/browser-worker.d.ts +1 -0
- package/dist/compilation/compile-lanes.d.ts +18 -0
- package/dist/compilation/generated-mjml.d.ts +25 -0
- package/dist/compilation/guard.d.ts +40 -0
- package/dist/compilation/node-compiler.d.ts +17 -0
- package/dist/compilation/node-worker.d.ts +1 -0
- package/dist/composition/block-factory.d.ts +84 -0
- package/dist/composition/browser.d.ts +48 -0
- package/dist/composition/factory.d.ts +48 -0
- package/dist/composition/server.d.ts +43 -0
- package/dist/core/any-document.d.ts +16 -0
- package/dist/core/block-document.d.ts +215 -0
- package/dist/core/budget.d.ts +32 -0
- package/dist/core/canvas-contract.d.ts +29 -0
- package/dist/core/canvas-layout.d.ts +66 -0
- package/dist/core/catalog.d.ts +35 -0
- package/dist/core/document-presentation.d.ts +21 -0
- package/dist/core/document.d.ts +99 -0
- package/dist/core/history.d.ts +26 -0
- package/dist/core/html-content-model.d.ts +32 -0
- package/dist/core/html-escape.d.ts +2 -0
- package/dist/core/rich-text-format.d.ts +14 -0
- package/dist/core/rich-text-markup.d.ts +28 -0
- package/dist/core/section-layout.d.ts +83 -0
- package/dist/generated-mjml-CtzE-f3v.js +1235 -0
- package/dist/generated-mjml-CtzE-f3v.js.map +1 -0
- package/dist/identity-CJHb6l9N.js +13759 -0
- package/dist/identity-CJHb6l9N.js.map +1 -0
- package/dist/renderers/canvas-bridge.d.ts +75 -0
- package/dist/renderers/canvas-icons.d.ts +1 -0
- package/dist/renderers/canvas-runtime.generated.d.ts +3 -0
- package/dist/renderers/element-source.d.ts +13 -0
- package/dist/renderers/email-renderer.d.ts +14 -0
- package/dist/renderers/marked-preview.d.ts +34 -0
- package/dist/renderers/markup-tree.d.ts +36 -0
- package/dist/renderers/page-renderer.d.ts +15 -0
- package/dist/renderers/preview-document.d.ts +39 -0
- package/dist/renderers/preview-frame.d.ts +102 -0
- package/dist/renderers/section-scaffold.d.ts +16 -0
- package/dist/renderers/selection-preview.d.ts +47 -0
- package/dist/rich-text/command-executor.d.ts +26 -0
- package/dist/rich-text/commands.d.ts +36 -0
- package/dist/rich-text/document-builder.d.ts +52 -0
- package/dist/rich-text/formatting.d.ts +17 -0
- package/dist/rich-text/projection-export.d.ts +17 -0
- package/dist/rich-text/projection-rules.d.ts +13 -0
- package/dist/rich-text/schema.d.ts +50 -0
- package/dist/rich-text/whitespace.d.ts +7 -0
- package/dist/security/bounded-parser.d.ts +18 -0
- package/dist/security/conditional-comment.d.ts +30 -0
- package/dist/security/content-inventory.d.ts +78 -0
- package/dist/security/email-sanitizer.d.ts +36 -0
- package/dist/security/identity.d.ts +6 -0
- package/dist/security/markup-rules.d.ts +31 -0
- package/dist/security/policy.d.ts +61 -0
- package/dist/security/preview-message.d.ts +317 -0
- package/dist/security/rich-text-projection.d.ts +19 -0
- package/dist/security/sha256.d.ts +6 -0
- package/dist/security/source-markup.d.ts +53 -0
- package/dist/security/text-presentation.d.ts +19 -0
- package/dist/security/url-policy.d.ts +23 -0
- package/dist/server-worker.js +17 -0
- package/dist/server-worker.js.map +1 -0
- package/dist/server.js +79 -0
- package/dist/server.js.map +1 -0
- package/dist/templates/blank-email.d.ts +6 -0
- package/dist/templates/blocks/catalog.d.ts +31 -0
- package/dist/templates/catalog.d.ts +31 -0
- package/dist/visual-editor.css +2 -0
- package/dist/vue/block-controller.d.ts +106 -0
- package/dist/vue/block-workbench.d.ts +70 -0
- package/dist/vue/canvas/canvas-theme.d.ts +8 -0
- package/dist/vue/canvas/file-drop.d.ts +38 -0
- package/dist/vue/canvas/frame-window.d.ts +26 -0
- package/dist/vue/canvas/inline-text.d.ts +98 -0
- package/dist/vue/canvas/palette-drag.d.ts +55 -0
- package/dist/vue/canvas/piece-requests.d.ts +48 -0
- package/dist/vue/canvas/strip-reserve.d.ts +14 -0
- package/dist/vue/canvas-content-label.d.ts +5 -0
- package/dist/vue/components/BlockVisualEditor.vue.d.ts +44 -0
- package/dist/vue/components/CanvasSurface.vue.d.ts +11 -0
- package/dist/vue/components/CodeEditor.vue.d.ts +22 -0
- package/dist/vue/components/EditorBlockMenus.vue.d.ts +3 -0
- package/dist/vue/components/EditorBlockPalette.vue.d.ts +3 -0
- package/dist/vue/components/EditorDiagnostics.vue.d.ts +3 -0
- package/dist/vue/components/EditorDialogs.vue.d.ts +16 -0
- package/dist/vue/components/EditorDocumentMetadata.vue.d.ts +3 -0
- package/dist/vue/components/EditorDocumentStyles.vue.d.ts +15 -0
- package/dist/vue/components/EditorImageSizeControls.vue.d.ts +23 -0
- package/dist/vue/components/EditorLayoutControls.vue.d.ts +16 -0
- package/dist/vue/components/EditorLeftPanel.vue.d.ts +3 -0
- package/dist/vue/components/EditorNoticeIndicator.vue.d.ts +3 -0
- package/dist/vue/components/EditorPreview.vue.d.ts +8 -0
- package/dist/vue/components/EditorProperties.vue.d.ts +14 -0
- package/dist/vue/components/EditorRichTextControls.vue.d.ts +25 -0
- package/dist/vue/components/EditorSelectionPath.vue.d.ts +11 -0
- package/dist/vue/components/EditorShortcutHelp.vue.d.ts +3 -0
- package/dist/vue/components/EditorSourcePane.vue.d.ts +3 -0
- package/dist/vue/components/EditorStructureTree.vue.d.ts +3 -0
- package/dist/vue/components/EditorTemplateGallery.vue.d.ts +15 -0
- package/dist/vue/components/EditorTopBar.vue.d.ts +33 -0
- package/dist/vue/components/RichTextEditor.vue.d.ts +47 -0
- package/dist/vue/components/SelectionPreviewFrame.vue.d.ts +212 -0
- package/dist/vue/components/VisualEditor.vue.d.ts +53 -0
- package/dist/vue/components/blocks/BlockCanvas.vue.d.ts +15 -0
- package/dist/vue/components/blocks/BlockFieldControl.vue.d.ts +39 -0
- package/dist/vue/components/blocks/BlockGlobalStyles.vue.d.ts +3 -0
- package/dist/vue/components/blocks/BlockPalette.vue.d.ts +6 -0
- package/dist/vue/components/blocks/BlockProperties.vue.d.ts +5 -0
- package/dist/vue/components/blocks/BlockReview.vue.d.ts +5 -0
- package/dist/vue/components/properties/EditorPropertyAdvanced.vue.d.ts +8 -0
- package/dist/vue/components/properties/EditorPropertyContent.vue.d.ts +13 -0
- package/dist/vue/components/properties/EditorPropertyStyle.vue.d.ts +8 -0
- package/dist/vue/components/ui/EditorAnchoredMenu.vue.d.ts +36 -0
- package/dist/vue/components/ui/EditorBadge.vue.d.ts +18 -0
- package/dist/vue/components/ui/EditorButton.vue.d.ts +28 -0
- package/dist/vue/components/ui/EditorCheckbox.vue.d.ts +13 -0
- package/dist/vue/components/ui/EditorColorInput.vue.d.ts +27 -0
- package/dist/vue/components/ui/EditorConfirmDialog.vue.d.ts +35 -0
- package/dist/vue/components/ui/EditorContextMenu.vue.d.ts +27 -0
- package/dist/vue/components/ui/EditorContextPopover.vue.d.ts +33 -0
- package/dist/vue/components/ui/EditorEmpty.vue.d.ts +8 -0
- package/dist/vue/components/ui/EditorField.vue.d.ts +24 -0
- package/dist/vue/components/ui/EditorGroup.vue.d.ts +16 -0
- package/dist/vue/components/ui/EditorIcon.vue.d.ts +6 -0
- package/dist/vue/components/ui/EditorIconButton.vue.d.ts +19 -0
- package/dist/vue/components/ui/EditorInput.vue.d.ts +41 -0
- package/dist/vue/components/ui/EditorKeys.vue.d.ts +6 -0
- package/dist/vue/components/ui/EditorMeasurement.vue.d.ts +34 -0
- package/dist/vue/components/ui/EditorMenu.vue.d.ts +56 -0
- package/dist/vue/components/ui/EditorNotice.vue.d.ts +30 -0
- package/dist/vue/components/ui/EditorPropertyGroup.vue.d.ts +22 -0
- package/dist/vue/components/ui/EditorRecoveryDialog.vue.d.ts +23 -0
- package/dist/vue/components/ui/EditorScrollArea.vue.d.ts +13 -0
- package/dist/vue/components/ui/EditorSelect.vue.d.ts +25 -0
- package/dist/vue/components/ui/EditorSeparator.vue.d.ts +8 -0
- package/dist/vue/components/ui/EditorSidePanel.vue.d.ts +26 -0
- package/dist/vue/components/ui/EditorSwitch.vue.d.ts +12 -0
- package/dist/vue/components/ui/EditorTabs.vue.d.ts +28 -0
- package/dist/vue/components/ui/EditorTemplatePreview.vue.d.ts +9 -0
- package/dist/vue/components/ui/EditorTextToolbar.vue.d.ts +16 -0
- package/dist/vue/components/ui/EditorTree.vue.d.ts +37 -0
- package/dist/vue/components/ui/EditorUiProvider.vue.d.ts +13 -0
- package/dist/vue/components/ui/EditorVariablePicker.vue.d.ts +20 -0
- package/dist/vue/components/ui/color-style-value.d.ts +9 -0
- package/dist/vue/components/ui/composition-dismissal.d.ts +1 -0
- package/dist/vue/components/ui/editor-dialog-focus.d.ts +6 -0
- package/dist/vue/components/ui/numeric-style-value.d.ts +15 -0
- package/dist/vue/controller.d.ts +115 -0
- package/dist/vue/font-options.d.ts +6 -0
- package/dist/vue/icon-data.d.ts +233 -0
- package/dist/vue/icons.d.ts +5 -0
- package/dist/vue/locale.d.ts +7 -0
- package/dist/vue/outline.d.ts +26 -0
- package/dist/vue/projection-key.d.ts +7 -0
- package/dist/vue/properties/selection-properties.d.ts +40 -0
- package/dist/vue/properties/style-fields.d.ts +30 -0
- package/dist/vue/public.d.ts +14 -0
- package/dist/vue/recovery.d.ts +30 -0
- package/dist/vue/responsive-panel.d.ts +1 -0
- package/dist/vue/rich-text-commands.d.ts +29 -0
- package/dist/vue/services/block-command-definitions.d.ts +14 -0
- package/dist/vue/services/block-commands.d.ts +114 -0
- package/dist/vue/services/block-menu.d.ts +12 -0
- package/dist/vue/services/block-palette.d.ts +21 -0
- package/dist/vue/services/block-presentation.d.ts +16 -0
- package/dist/vue/services/diagnostic-groups.d.ts +25 -0
- package/dist/vue/services/image-requests.d.ts +80 -0
- package/dist/vue/services/live-change.d.ts +26 -0
- package/dist/vue/services/property-commands.d.ts +28 -0
- package/dist/vue/services/saved-blocks.d.ts +32 -0
- package/dist/vue/services/selection-path.d.ts +20 -0
- package/dist/vue/services/shortcuts.d.ts +39 -0
- package/dist/vue/services/structure-tree.d.ts +38 -0
- package/dist/vue/services/template-application.d.ts +33 -0
- package/dist/vue/services/tree-drag.d.ts +28 -0
- package/dist/vue/session/blocks.d.ts +44 -0
- package/dist/vue/session/guard.d.ts +13 -0
- package/dist/vue/session/structure.d.ts +36 -0
- package/dist/vue/session/text.d.ts +23 -0
- package/dist/vue/session/transfer.d.ts +23 -0
- package/dist/vue/theme.d.ts +20 -0
- package/dist/vue/variables.d.ts +21 -0
- package/dist/vue/workbench.d.ts +100 -0
- package/dist/vue.js +71418 -0
- package/dist/vue.js.map +1 -0
- package/package.json +125 -4
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EditorDocumentData, SourceInput } from '../core/document';
|
|
2
|
+
/**
|
|
3
|
+
* Finds the exact stretch of the exported source which one element occupies. Editing an element
|
|
4
|
+
* as HTML replaces only that stretch: everything else keeps its original bytes, and the result is
|
|
5
|
+
* imported through the ordinary validation like any other source.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ElementSourceMap {
|
|
8
|
+
/** The markup of one element as it stands in the source, or undefined when it has none. */
|
|
9
|
+
read(document: EditorDocumentData, source: SourceInput, id: string): string | undefined;
|
|
10
|
+
/** The whole source with one element replaced by `html`. */
|
|
11
|
+
replace(document: EditorDocumentData, source: SourceInput, id: string, html: string): SourceInput | undefined;
|
|
12
|
+
private locate;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EditorDocumentData, SourceInput } from '../core/document';
|
|
2
|
+
import type { DocumentOutputCodec, DocumentOutputPolicy } from './page-renderer';
|
|
3
|
+
export interface MjmlCompilerPort {
|
|
4
|
+
compile(source: string): Promise<string>;
|
|
5
|
+
}
|
|
6
|
+
/** MJML is for creating supported content; imported HTML is never recompiled. */
|
|
7
|
+
export declare class MjmlEmailRenderer {
|
|
8
|
+
private readonly codec;
|
|
9
|
+
private readonly policy;
|
|
10
|
+
private readonly compiler;
|
|
11
|
+
constructor(codec: DocumentOutputCodec, policy: DocumentOutputPolicy, compiler: MjmlCompilerPort);
|
|
12
|
+
render(document: EditorDocumentData): SourceInput;
|
|
13
|
+
createSource(mjml: string): Promise<SourceInput>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DocumentKind, SourceInput } from '../core/document';
|
|
2
|
+
import type { SecureIdentifier } from '../security/identity';
|
|
3
|
+
import type { CanvasBridgeRegion } from './canvas-bridge';
|
|
4
|
+
import type { PreviewFrameDocument, PreviewFrameOptions, SelectionPreview, SelectionPreviewSource } from './preview-frame';
|
|
5
|
+
/**
|
|
6
|
+
* The preview of a block piece (schema 2) for the editing frame: the output of the generators
|
|
7
|
+
* in preview mode, already marked with `data-visual-editor-node` and
|
|
8
|
+
* `data-visual-editor-edit-node`, and the regions of its blocks.
|
|
9
|
+
*/
|
|
10
|
+
export interface BlockPreviewInput {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly revision: number;
|
|
13
|
+
readonly kind: DocumentKind;
|
|
14
|
+
readonly source: SourceInput;
|
|
15
|
+
readonly regions: readonly CanvasBridgeRegion[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Builds the frame document of a block piece and keeps the marks the generators wrote. A mark
|
|
19
|
+
* is kept only for a block of the piece, once per block, and an edit mark only for an editable
|
|
20
|
+
* block, inside its own selectable element; every other reserved attribute is removed. The
|
|
21
|
+
* content rules of the blocks already refuse those attributes in free HTML: this is the second
|
|
22
|
+
* barrier, so markup of the author can never pose as a block.
|
|
23
|
+
*/
|
|
24
|
+
export declare class MarkedPreviewRenderer implements SelectionPreviewSource<BlockPreviewInput> {
|
|
25
|
+
private readonly frame;
|
|
26
|
+
private readonly identifiers;
|
|
27
|
+
constructor(frame: PreviewFrameDocument, identifiers: SecureIdentifier);
|
|
28
|
+
build(input: BlockPreviewInput, selectionLabel: string, options?: PreviewFrameOptions): SelectionPreview;
|
|
29
|
+
update(input: BlockPreviewInput, selectionLabel: string, current: Pick<SelectionPreview, 'nonce'>, options?: PreviewFrameOptions): SelectionPreview;
|
|
30
|
+
private render;
|
|
31
|
+
/** Validates the marks in document order; returns the ids of the blocks and texts found. */
|
|
32
|
+
private keepMarks;
|
|
33
|
+
private attribute;
|
|
34
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { DefaultTreeAdapterMap } from 'parse5';
|
|
2
|
+
import type { DocumentNode } from '../core/document';
|
|
3
|
+
export type MarkupElement = DefaultTreeAdapterMap['element'];
|
|
4
|
+
export type MarkupParent = DefaultTreeAdapterMap['parentNode'];
|
|
5
|
+
export interface DocumentParts {
|
|
6
|
+
readonly root?: MarkupElement;
|
|
7
|
+
readonly head?: MarkupElement;
|
|
8
|
+
/** Absent in a page made of frames, which has a `frameset` where the body would be. */
|
|
9
|
+
readonly body?: MarkupElement;
|
|
10
|
+
readonly frameset?: MarkupElement;
|
|
11
|
+
}
|
|
12
|
+
/** The elements every parsed document has, wherever the source wrote or implied them. */
|
|
13
|
+
export declare function documentParts(document: DefaultTreeAdapterMap['document']): DocumentParts;
|
|
14
|
+
/** The children a walk follows: the content of a template stands where its children would. */
|
|
15
|
+
export declare function markupChildren(node: MarkupParent): readonly DefaultTreeAdapterMap['childNode'][];
|
|
16
|
+
/** Removes every attribute reserved to the editor below `root`, template contents included. */
|
|
17
|
+
export declare function stripReservedAttributes(root: MarkupParent): void;
|
|
18
|
+
/** Elements of the document which a parser shows as elements of the piece, in document order. */
|
|
19
|
+
export declare function canonicalElements(nodes: readonly DocumentNode[]): DocumentNode[];
|
|
20
|
+
export interface AlignmentVisitor {
|
|
21
|
+
/** Every element of the HTML tree, infrastructure included, before it is matched. */
|
|
22
|
+
element?(element: MarkupElement): void;
|
|
23
|
+
/**
|
|
24
|
+
* An element of the markup and the node of the document it stands for. `island` is an inline
|
|
25
|
+
* SVG or MathML: one node of the document, whose inside is never walked. Return `false` to end
|
|
26
|
+
* the walk there.
|
|
27
|
+
*/
|
|
28
|
+
match(element: MarkupElement, node: DocumentNode, island: boolean): boolean | void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The one rule which pairs the markup a parser reads with the nodes of the document: the same
|
|
32
|
+
* elements in the same order, skipping what every document has (`html`, `head`, `body`, `style`,
|
|
33
|
+
* `meta`, `title`) and never going inside foreign content, which the document keeps as source.
|
|
34
|
+
* Returns how many nodes were paired, or undefined when markup and document disagree.
|
|
35
|
+
*/
|
|
36
|
+
export declare function alignElements(root: MarkupParent, canonical: readonly DocumentNode[], visitor: AlignmentVisitor): number | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EditorDocument, EditorDocumentData, SourceInput } from '../core/document';
|
|
2
|
+
export interface DocumentOutputCodec {
|
|
3
|
+
export(document: EditorDocumentData): SourceInput;
|
|
4
|
+
}
|
|
5
|
+
export interface DocumentOutputPolicy {
|
|
6
|
+
/** An `EditorDocument` was validated when it was built; its content is checked again. */
|
|
7
|
+
assertSafe(document: EditorDocumentData | EditorDocument): void;
|
|
8
|
+
}
|
|
9
|
+
/** Serializes the canonical page rather than rebuilding it from recognized blocks. */
|
|
10
|
+
export declare class PageRenderer {
|
|
11
|
+
private readonly codec;
|
|
12
|
+
private readonly policy;
|
|
13
|
+
constructor(codec: DocumentOutputCodec, policy: DocumentOutputPolicy);
|
|
14
|
+
render(document: EditorDocumentData): SourceInput;
|
|
15
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DocumentKind, EditorDocumentData, ImportResult, SourceInput } from '../core/document';
|
|
2
|
+
import type { DocumentOutputPolicy } from './page-renderer';
|
|
3
|
+
export interface SourceValidationCodec {
|
|
4
|
+
import(source: SourceInput, kind: DocumentKind): ImportResult;
|
|
5
|
+
/** Read without touching the preservation cache of the documents being edited. */
|
|
6
|
+
inspect?(source: SourceInput, kind: DocumentKind): ImportResult;
|
|
7
|
+
/** Needed when the rules of the kind changed what the given source parses to. */
|
|
8
|
+
export?(document: EditorDocumentData): SourceInput;
|
|
9
|
+
}
|
|
10
|
+
export interface HtmlAssemblyPort {
|
|
11
|
+
build(source: SourceInput, kind: DocumentKind, preview?: boolean): string;
|
|
12
|
+
}
|
|
13
|
+
/** Produces a complete portable file from an already policy-validated source. */
|
|
14
|
+
export declare class HtmlDocumentAssembler {
|
|
15
|
+
#private;
|
|
16
|
+
private readonly codec;
|
|
17
|
+
private readonly policy;
|
|
18
|
+
constructor(codec: SourceValidationCodec, policy: DocumentOutputPolicy, imageOrigins?: readonly string[]);
|
|
19
|
+
build(source: SourceInput, kind: DocumentKind, preview?: boolean): string;
|
|
20
|
+
/**
|
|
21
|
+
* Changes only the copy shown in the editor, never the document. A policy written by the
|
|
22
|
+
* author cannot stand next to the editor's (it could neither loosen it nor break the
|
|
23
|
+
* editing script), a refresh would navigate the frame away, and a base would redirect
|
|
24
|
+
* every relative reference. The elements which stay keep their place in the tree.
|
|
25
|
+
*
|
|
26
|
+
* The content of `noscript` is text to a parser with scripting and markup to one without: the
|
|
27
|
+
* editing frame reads it the first way, the plain preview and the parser which reconciles a
|
|
28
|
+
* revision read it the second. It is read here as markup, given the same treatment, cleared
|
|
29
|
+
* of every attribute reserved to the editor and written back as text.
|
|
30
|
+
*/
|
|
31
|
+
private neutralize;
|
|
32
|
+
private noscript;
|
|
33
|
+
}
|
|
34
|
+
/** Sandbox remains mandatory even with CSP; no user markup reaches the host DOM. */
|
|
35
|
+
export declare class PreviewDocument {
|
|
36
|
+
private readonly assembler;
|
|
37
|
+
constructor(assembler: HtmlAssemblyPort);
|
|
38
|
+
build(source: SourceInput, kind: DocumentKind): string;
|
|
39
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { DefaultTreeAdapterMap } from 'parse5';
|
|
2
|
+
import * as v from 'valibot';
|
|
3
|
+
import type { DocumentKind, SourceInput } from '../core/document';
|
|
4
|
+
import type { CanvasBridgeLabels, CanvasBridgeRegion, CanvasBridgeTheme } from './canvas-bridge';
|
|
5
|
+
import type { MarkupElement } from './markup-tree';
|
|
6
|
+
import type { HtmlAssemblyPort } from './preview-document';
|
|
7
|
+
export interface SelectionPreview {
|
|
8
|
+
readonly html: string;
|
|
9
|
+
/**
|
|
10
|
+
* The secret of the message protocol of this window. It only exists inside the text of the
|
|
11
|
+
* runtime script, never in an attribute, and has no part in the CSP, which authorizes that
|
|
12
|
+
* script by the digest of its text. The name is the one the protocol always used.
|
|
13
|
+
*/
|
|
14
|
+
readonly nonce: string;
|
|
15
|
+
readonly revision: number;
|
|
16
|
+
readonly nodeIds: readonly string[];
|
|
17
|
+
readonly regions: readonly CanvasBridgeRegion[];
|
|
18
|
+
readonly readOnly: boolean;
|
|
19
|
+
/** Test mode: only then does the host accept fidelity reports from the frame. */
|
|
20
|
+
readonly diagnostics: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Options every preview of the editing frame takes, whatever document it shows. */
|
|
23
|
+
export interface PreviewFrameOptions {
|
|
24
|
+
readonly readOnly?: boolean;
|
|
25
|
+
readonly labels?: CanvasBridgeLabels;
|
|
26
|
+
readonly title?: string;
|
|
27
|
+
readonly lang?: string;
|
|
28
|
+
/** Test mode of the frame runtime; never enabled by a document. */
|
|
29
|
+
readonly diagnostics?: boolean;
|
|
30
|
+
/** Colors of the host shell for the controls drawn over the piece. */
|
|
31
|
+
readonly theme?: CanvasBridgeTheme;
|
|
32
|
+
/** False: the host opens no block menu, so the frame never asks for one. */
|
|
33
|
+
readonly menu?: false;
|
|
34
|
+
/** Friendly names of the variables of the host by key (at most 500, names up to 200). */
|
|
35
|
+
readonly variables?: Readonly<Record<string, string>>;
|
|
36
|
+
}
|
|
37
|
+
/** What the editing frame asks of the renderer of its document: a new window or a revision. */
|
|
38
|
+
export interface SelectionPreviewSource<D extends {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly revision: number;
|
|
41
|
+
}> {
|
|
42
|
+
build(document: D, selectionLabel: string, options?: PreviewFrameOptions): SelectionPreview;
|
|
43
|
+
update(document: D, selectionLabel: string, current: Pick<SelectionPreview, 'nonce'>, options?: PreviewFrameOptions): SelectionPreview;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One document bound to its renderer, as the editing frame takes it: the frame only knows the
|
|
47
|
+
* identity of what it shows and asks for a new window or the next revision. A new renderer
|
|
48
|
+
* means a new window.
|
|
49
|
+
*/
|
|
50
|
+
export interface FramePreviewSource {
|
|
51
|
+
readonly id: string;
|
|
52
|
+
readonly revision: number;
|
|
53
|
+
readonly renderer: object;
|
|
54
|
+
build(selectionLabel: string, options?: PreviewFrameOptions): SelectionPreview;
|
|
55
|
+
update(selectionLabel: string, current: Pick<SelectionPreview, 'nonce'>, options?: PreviewFrameOptions): SelectionPreview;
|
|
56
|
+
}
|
|
57
|
+
export declare function framePreview<D extends {
|
|
58
|
+
readonly id: string;
|
|
59
|
+
readonly revision: number;
|
|
60
|
+
}>(renderer: SelectionPreviewSource<D>, document: D): FramePreviewSource;
|
|
61
|
+
/** Only plain color values and a bounded radius ever reach the style of the controls. */
|
|
62
|
+
export declare const previewThemeSchema: v.StrictObjectSchema<{
|
|
63
|
+
readonly accent: v.ExactOptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 80, undefined>, v.CheckAction<string, undefined>]>, undefined>;
|
|
64
|
+
readonly contrast: v.ExactOptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 80, undefined>, v.CheckAction<string, undefined>]>, undefined>;
|
|
65
|
+
readonly surface: v.ExactOptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 80, undefined>, v.CheckAction<string, undefined>]>, undefined>;
|
|
66
|
+
readonly text: v.ExactOptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 80, undefined>, v.CheckAction<string, undefined>]>, undefined>;
|
|
67
|
+
readonly border: v.ExactOptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 80, undefined>, v.CheckAction<string, undefined>]>, undefined>;
|
|
68
|
+
readonly radius: v.ExactOptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 24, undefined>]>, undefined>;
|
|
69
|
+
}, undefined>;
|
|
70
|
+
/** The page is made of frames: it has no body to edit in the piece, only its source. */
|
|
71
|
+
export declare const PREVIEW_FRAMESET = "PREVIEW_FRAMESET";
|
|
72
|
+
/** Normalizes optional DOM metadata; strict public options are validated separately. */
|
|
73
|
+
export declare function normalizePreviewLanguage(value: string | undefined): string | undefined;
|
|
74
|
+
/** An opened frame document: the parsed tree and the parts the renderers mark. */
|
|
75
|
+
export interface OpenedPreview {
|
|
76
|
+
readonly parsed: DefaultTreeAdapterMap['document'];
|
|
77
|
+
readonly head: MarkupElement;
|
|
78
|
+
readonly body: MarkupElement;
|
|
79
|
+
readonly hostLanguage: string;
|
|
80
|
+
readonly labels: CanvasBridgeLabels;
|
|
81
|
+
readonly theme: CanvasBridgeTheme | undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The parts of an editing-frame document every renderer shares: the assembled copy with its
|
|
85
|
+
* CSP, the language and title, the selection style and the single runtime script authorized by
|
|
86
|
+
* the digest of its text. What marks the blocks is the renderer's own.
|
|
87
|
+
*/
|
|
88
|
+
export declare class PreviewFrameDocument {
|
|
89
|
+
#private;
|
|
90
|
+
private readonly assembler;
|
|
91
|
+
constructor(assembler: HtmlAssemblyPort);
|
|
92
|
+
open(source: SourceInput, kind: DocumentKind, selectionLabel: string, options: PreviewFrameOptions): OpenedPreview;
|
|
93
|
+
/** Adds the selection style and, for a new window, the runtime; serializes the result. */
|
|
94
|
+
close(opened: OpenedPreview, preview: {
|
|
95
|
+
readonly revision: number;
|
|
96
|
+
readonly regions: readonly CanvasBridgeRegion[];
|
|
97
|
+
readonly nodeIds: readonly string[];
|
|
98
|
+
readonly token: string;
|
|
99
|
+
readonly executable: boolean;
|
|
100
|
+
}, options: PreviewFrameOptions): SelectionPreview;
|
|
101
|
+
private uniformLabels;
|
|
102
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SectionScaffoldPort } from '../application/section-layout';
|
|
2
|
+
import type { SectionLayoutProjection, SectionLayoutSettings } from '../core/section-layout';
|
|
3
|
+
import type { SourceInput } from '../core/document';
|
|
4
|
+
import type { CssDocumentCodec } from '../codecs/css';
|
|
5
|
+
import { MjmlEmailRenderer } from './email-renderer';
|
|
6
|
+
/** Generates only an empty MJML layout shell. Existing column HTML is transplanted by application. */
|
|
7
|
+
export declare class MjmlSectionScaffold implements SectionScaffoldPort {
|
|
8
|
+
private readonly renderer;
|
|
9
|
+
private readonly styles;
|
|
10
|
+
constructor(renderer: MjmlEmailRenderer, styles: Pick<CssDocumentCodec, 'inspect' | 'readDeclarations'>);
|
|
11
|
+
create(settings: SectionLayoutSettings, original: SectionLayoutProjection): Promise<SourceInput>;
|
|
12
|
+
supports(projection: SectionLayoutProjection): boolean;
|
|
13
|
+
private geometry;
|
|
14
|
+
private layoutComment;
|
|
15
|
+
private layoutTag;
|
|
16
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { EditorDocumentData } from '../core/document';
|
|
2
|
+
import type { DocumentOutputCodec, DocumentOutputPolicy } from './page-renderer';
|
|
3
|
+
import type { HtmlAssemblyPort } from './preview-document';
|
|
4
|
+
import { CanvasLayout } from '../core/canvas-layout';
|
|
5
|
+
import { BlockCatalog } from '../core/catalog';
|
|
6
|
+
import type { CanvasRegion } from '../core/canvas-layout';
|
|
7
|
+
import type { SourceInput } from '../core/document';
|
|
8
|
+
import type { PreviewFrameOptions, SelectionPreview, SelectionPreviewSource } from './preview-frame';
|
|
9
|
+
import type { BlockPreviewInput } from './marked-preview';
|
|
10
|
+
export { framePreview, normalizePreviewLanguage, previewThemeSchema, PREVIEW_FRAMESET, } from './preview-frame';
|
|
11
|
+
export type { FramePreviewSource, PreviewFrameOptions, SelectionPreview, SelectionPreviewSource, } from './preview-frame';
|
|
12
|
+
export type { BlockPreviewInput } from './marked-preview';
|
|
13
|
+
export interface SelectionPreviewOptions extends PreviewFrameOptions {
|
|
14
|
+
/** Friendly name of each selectable block, in the language of the host shell. */
|
|
15
|
+
readonly describe?: (region: CanvasRegion) => string | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** Instruments logical regions after validating the complete untrusted document. */
|
|
18
|
+
export declare class SelectionPreviewRenderer implements SelectionPreviewSource<EditorDocumentData> {
|
|
19
|
+
#private;
|
|
20
|
+
private readonly codec;
|
|
21
|
+
private readonly policy;
|
|
22
|
+
private readonly assembler;
|
|
23
|
+
/**
|
|
24
|
+
* The previews of block pieces (schema 2). Their markup comes from the generators already
|
|
25
|
+
* marked; this path keeps those marks, only for blocks of the piece and once each, instead
|
|
26
|
+
* of deriving them from an HTML document.
|
|
27
|
+
*/
|
|
28
|
+
readonly blocks: SelectionPreviewSource<BlockPreviewInput>;
|
|
29
|
+
constructor(codec: DocumentOutputCodec, policy: DocumentOutputPolicy, assembler: HtmlAssemblyPort,
|
|
30
|
+
/** The catalog and the layout of the editor it serves; its own when used alone. */
|
|
31
|
+
structure?: {
|
|
32
|
+
readonly catalog?: BlockCatalog;
|
|
33
|
+
readonly layout?: CanvasLayout;
|
|
34
|
+
});
|
|
35
|
+
/** The markup one element has in the exported source, for editing it as HTML. */
|
|
36
|
+
elementSource(document: EditorDocumentData, id: string): string | undefined;
|
|
37
|
+
/** The exported source with one element replaced; it still has to be imported and validated. */
|
|
38
|
+
replaceElementSource(document: EditorDocumentData, id: string, html: string): SourceInput | undefined;
|
|
39
|
+
/** A complete preview for a new window: a fresh protocol secret, CSP and the runtime script. */
|
|
40
|
+
build(document: EditorDocumentData, selectionLabel: string, options?: SelectionPreviewOptions): SelectionPreview;
|
|
41
|
+
/**
|
|
42
|
+
* The next revision for a window which is already running: same secret, no script. The frame
|
|
43
|
+
* runtime reconciles this markup over what it shows instead of reloading.
|
|
44
|
+
*/
|
|
45
|
+
update(document: EditorDocumentData, selectionLabel: string, current: Pick<SelectionPreview, 'nonce'>, options?: SelectionPreviewOptions): SelectionPreview;
|
|
46
|
+
private render;
|
|
47
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
import type { Mark as ProseMirrorMark } from '@tiptap/pm/model';
|
|
3
|
+
import type { RichTextCommandName, RichTextCommandState, RichTextStyleName } from './commands';
|
|
4
|
+
import { RichTextFormatting } from './formatting';
|
|
5
|
+
export interface RichTextRange {
|
|
6
|
+
readonly from: number;
|
|
7
|
+
readonly to: number;
|
|
8
|
+
}
|
|
9
|
+
/** Resolves the value a text run shows when the person gave it no style of their own. */
|
|
10
|
+
export type RichTextInheritedStyle = (marks: readonly ProseMirrorMark[], position: number) => Partial<Record<RichTextStyleName, string>>;
|
|
11
|
+
/** Applies the closed command vocabulary to an editor; values are validated by the caller. */
|
|
12
|
+
export declare class RichTextCommandExecutor {
|
|
13
|
+
private readonly formatting;
|
|
14
|
+
private readonly focus;
|
|
15
|
+
/**
|
|
16
|
+
* @param focus Whether a command also takes the keyboard. The editor inside the preview
|
|
17
|
+
* frame never does: its commands come from controls which must keep the focus they have.
|
|
18
|
+
*/
|
|
19
|
+
constructor(formatting?: RichTextFormatting, focus?: boolean);
|
|
20
|
+
run(editor: Editor, command: RichTextCommandName, value?: string | null, range?: RichTextRange): boolean;
|
|
21
|
+
private clamp;
|
|
22
|
+
}
|
|
23
|
+
/** Reads what the controls show: active formats, the styles of the selection and history. */
|
|
24
|
+
export declare class RichTextStateReader {
|
|
25
|
+
read(editor: Editor, ready: boolean, normalize?: (style: RichTextStyleName, value: string) => string, inherited?: RichTextInheritedStyle): RichTextCommandState;
|
|
26
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Closed vocabulary shared by the host controls, the message policy and the frame runtime. */
|
|
2
|
+
export declare const RICH_TEXT_COMMANDS: readonly ["bold", "italic", "underline", "strike", "superscript", "subscript", "bulletList", "orderedList", "color", "backgroundColor", "fontFamily", "fontSize", "lineHeight", "clearFormatting", "setLink", "unsetLink", "insertText", "undo", "redo", "finish", "cancel"];
|
|
3
|
+
export type RichTextCommandName = (typeof RICH_TEXT_COMMANDS)[number];
|
|
4
|
+
export declare const RICH_TEXT_TOGGLES: readonly ["bold", "italic", "underline", "strike", "superscript", "subscript", "bulletList", "orderedList"];
|
|
5
|
+
export type RichTextToggleName = (typeof RICH_TEXT_TOGGLES)[number];
|
|
6
|
+
export declare const RICH_TEXT_STYLES: readonly ["color", "backgroundColor", "fontFamily", "fontSize", "lineHeight"];
|
|
7
|
+
export type RichTextStyleName = (typeof RICH_TEXT_STYLES)[number];
|
|
8
|
+
/** Commands which carry a value. `null` clears a style; every other command takes none. */
|
|
9
|
+
export declare const RICH_TEXT_VALUE_COMMANDS: readonly RichTextCommandName[];
|
|
10
|
+
export declare const RICH_TEXT_LIMITS: Readonly<{
|
|
11
|
+
commandValue: 2048;
|
|
12
|
+
insertedText: 1024;
|
|
13
|
+
styleValue: 200;
|
|
14
|
+
}>;
|
|
15
|
+
export interface RichTextStyleState {
|
|
16
|
+
readonly value: string;
|
|
17
|
+
readonly own: boolean;
|
|
18
|
+
readonly mixed: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface RichTextCommandState {
|
|
21
|
+
/** A caret or selection exists, so commands have a target. */
|
|
22
|
+
readonly ready: boolean;
|
|
23
|
+
readonly marks: readonly RichTextToggleName[];
|
|
24
|
+
readonly styles: Readonly<Record<RichTextStyleName, RichTextStyleState>>;
|
|
25
|
+
readonly link: boolean;
|
|
26
|
+
readonly href: string;
|
|
27
|
+
readonly empty: boolean;
|
|
28
|
+
readonly canUndo: boolean;
|
|
29
|
+
readonly canRedo: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function emptyRichTextState(): RichTextCommandState;
|
|
32
|
+
/** One command surface for the local panel editor and the editor inside the preview frame. */
|
|
33
|
+
export interface RichTextCommands {
|
|
34
|
+
readonly state: RichTextCommandState;
|
|
35
|
+
run(command: RichTextCommandName, value?: string | null): boolean;
|
|
36
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { RichTextProjectionRules } from './projection-rules';
|
|
2
|
+
/** Source markup seen without a DOM: a document node or an element of the preview frame. */
|
|
3
|
+
export interface RichTextSourceNode {
|
|
4
|
+
readonly type: 'text' | 'element' | 'other';
|
|
5
|
+
readonly text?: string;
|
|
6
|
+
readonly tag?: string;
|
|
7
|
+
/** Present only when the element must be restored from its source node. */
|
|
8
|
+
readonly origin?: string;
|
|
9
|
+
readonly attributes?: Readonly<Record<string, string>>;
|
|
10
|
+
readonly children?: readonly RichTextSourceNode[];
|
|
11
|
+
}
|
|
12
|
+
export interface RichTextJsonMark {
|
|
13
|
+
type: string;
|
|
14
|
+
attrs?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface RichTextJsonNode {
|
|
17
|
+
type: string;
|
|
18
|
+
attrs?: Record<string, unknown>;
|
|
19
|
+
content?: RichTextJsonNode[];
|
|
20
|
+
marks?: RichTextJsonMark[];
|
|
21
|
+
text?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RichTextBuildOptions {
|
|
24
|
+
/** Mark names of the schema, outermost first: the only nesting the editor can render. */
|
|
25
|
+
readonly markOrder: readonly string[];
|
|
26
|
+
/** The block collapses white space, so source spacing at its edges is not content. */
|
|
27
|
+
readonly collapse: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Builds the editor document straight from source markup, so mounting over the real element
|
|
31
|
+
* keeps loose text loose and every source tag and attribute available to the rendered view.
|
|
32
|
+
* Markup whose nesting the schema cannot reproduce is refused instead of being rearranged.
|
|
33
|
+
*/
|
|
34
|
+
export declare class RichTextDocumentBuilder {
|
|
35
|
+
#private;
|
|
36
|
+
private readonly rules;
|
|
37
|
+
constructor(rules?: RichTextProjectionRules);
|
|
38
|
+
/** Returns undefined for markup the editor cannot represent faithfully. */
|
|
39
|
+
build(children: readonly RichTextSourceNode[], allowBlocks: boolean, options: RichTextBuildOptions): RichTextJsonNode | undefined;
|
|
40
|
+
private visit;
|
|
41
|
+
private origin;
|
|
42
|
+
/** A span which wraps another mark must be rendered outside it. */
|
|
43
|
+
private wraps;
|
|
44
|
+
private nest;
|
|
45
|
+
private inline;
|
|
46
|
+
/** Inline content of one block, with collapsible edge spacing and a final break set aside. */
|
|
47
|
+
private textblock;
|
|
48
|
+
private paragraph;
|
|
49
|
+
private blocks;
|
|
50
|
+
private block;
|
|
51
|
+
private item;
|
|
52
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Mark } from '@tiptap/core';
|
|
2
|
+
import type { Editor, Extensions } from '@tiptap/core';
|
|
3
|
+
import type { Transaction } from '@tiptap/pm/state';
|
|
4
|
+
import type { RichTextFormat } from '../core/rich-text-format';
|
|
5
|
+
/** Keeps preservation provenance independent from removable semantic marks. */
|
|
6
|
+
export declare class RichTextFormatting {
|
|
7
|
+
styleExtensions(): Extensions;
|
|
8
|
+
markName(format: RichTextFormat): string;
|
|
9
|
+
markNames(): readonly string[];
|
|
10
|
+
extensions(): readonly Mark[];
|
|
11
|
+
toggle(editor: Editor, format: Exclude<RichTextFormat, 'link'>, focus?: boolean): boolean;
|
|
12
|
+
removeLink(editor: Editor, focus?: boolean): boolean;
|
|
13
|
+
/** The source tag and attributes travel with the origin wherever the schema declares them. */
|
|
14
|
+
private carried;
|
|
15
|
+
preserve(tr: Transaction, format: RichTextFormat): boolean;
|
|
16
|
+
restore(tr: Transaction, format: RichTextFormat): boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Node as ProseMirrorNode, Schema } from '@tiptap/pm/model';
|
|
2
|
+
/**
|
|
3
|
+
* Serializes an editor document to the rich-text projection without a DOM: allowlisted tags,
|
|
4
|
+
* the origin marker and the styles the person applied. Source attributes never leave with it.
|
|
5
|
+
*/
|
|
6
|
+
export declare class RichTextProjectionExporter {
|
|
7
|
+
#private;
|
|
8
|
+
/** Captures the projection specs; construct it before the schema gains a faithful view. */
|
|
9
|
+
constructor(schema: Schema);
|
|
10
|
+
export(document: ProseMirrorNode): string;
|
|
11
|
+
/** The text of a block, with the source spacing and terminal break the editor set aside. */
|
|
12
|
+
private text;
|
|
13
|
+
private blocks;
|
|
14
|
+
private node;
|
|
15
|
+
private inline;
|
|
16
|
+
private compile;
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which source markup the rich-text projection understands and when an element must carry its
|
|
3
|
+
* origin, so the host projection and the editor inside the preview frame agree on one answer.
|
|
4
|
+
*/
|
|
5
|
+
export declare class RichTextProjectionRules {
|
|
6
|
+
isInline(tag: string): boolean;
|
|
7
|
+
isBlock(tag: string): boolean;
|
|
8
|
+
supports(tag: string): boolean;
|
|
9
|
+
canonicalTag(tag: string): string;
|
|
10
|
+
semanticAttributes(tag: string): readonly string[];
|
|
11
|
+
/** The element keeps attributes or a tag which only its source node can restore. */
|
|
12
|
+
needsOrigin(tag: string, attributeNames: readonly string[]): boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Extensions } from '@tiptap/core';
|
|
2
|
+
import type { Schema } from '@tiptap/pm/model';
|
|
3
|
+
import { RichTextFormatting } from './formatting';
|
|
4
|
+
export declare const RICH_TEXT_RAW_ATTRIBUTE = "raw";
|
|
5
|
+
export declare const RICH_TEXT_IMPLICIT_ATTRIBUTE = "implicit";
|
|
6
|
+
/** Collapsible source spacing and a terminal line break around the text of a block. */
|
|
7
|
+
export declare const RICH_TEXT_EDGE_ATTRIBUTE = "edge";
|
|
8
|
+
/** A source span which wraps other marks; the plain preserved span is always the innermost. */
|
|
9
|
+
export declare const RICH_TEXT_OUTER_SPAN = "preservedOuterSpan";
|
|
10
|
+
export interface RichTextEdge {
|
|
11
|
+
readonly lead: string;
|
|
12
|
+
readonly tail: string;
|
|
13
|
+
readonly br: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function isRichTextEdge(value: unknown): value is RichTextEdge;
|
|
16
|
+
/** Marks the element which the frame runtime renders for a source node with an origin. */
|
|
17
|
+
export declare const RICH_TEXT_VIEW_ORIGIN_ATTRIBUTE = "data-visual-editor-text-origin";
|
|
18
|
+
/** A neutral block for loose text between blocks; it never matches author selectors by tag. */
|
|
19
|
+
export declare const RICH_TEXT_IMPLICIT_TAG = "visual-editor-line";
|
|
20
|
+
export interface RichTextRaw {
|
|
21
|
+
readonly tag: string;
|
|
22
|
+
readonly attrs: Readonly<Record<string, string>>;
|
|
23
|
+
}
|
|
24
|
+
export interface RichTextSchemaOptions {
|
|
25
|
+
/**
|
|
26
|
+
* `paragraph` and `block+` are the projection documents of the panel editor. `inline*` puts the
|
|
27
|
+
* text directly in the mounted element, so a heading or a link gains no inner paragraph.
|
|
28
|
+
*/
|
|
29
|
+
readonly content: 'paragraph' | 'block+' | 'inline*';
|
|
30
|
+
readonly links: boolean;
|
|
31
|
+
readonly isAllowedUri: (value: string) => boolean;
|
|
32
|
+
/** Keeps source tags and attributes in the rendered view. Only for the real element. */
|
|
33
|
+
readonly fidelity?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function isRichTextRaw(value: unknown): value is RichTextRaw;
|
|
36
|
+
/** The single rich-text schema definition of the panel editor and of the frame runtime. */
|
|
37
|
+
export declare class RichTextSchema {
|
|
38
|
+
readonly formatting: RichTextFormatting;
|
|
39
|
+
private readonly formats;
|
|
40
|
+
extensions(options: RichTextSchemaOptions): Extensions;
|
|
41
|
+
/**
|
|
42
|
+
* Makes the rendered view reuse the source tag and attributes of every node with an origin.
|
|
43
|
+
* Capture the projection specs (RichTextProjectionExporter) before calling this.
|
|
44
|
+
*/
|
|
45
|
+
applyFidelity(schema: Schema): void;
|
|
46
|
+
private faithful;
|
|
47
|
+
/** Outermost mark of the schema, so a source span can keep wrapping a link or a bold. */
|
|
48
|
+
private outerSpan;
|
|
49
|
+
private fidelityExtension;
|
|
50
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DOMParser } from '@tiptap/pm/model';
|
|
2
|
+
import type { ParseOptions, Schema, Slice } from '@tiptap/pm/model';
|
|
3
|
+
/** Keeps clipboard parsing on the schema's parser while preserving authored spacing. */
|
|
4
|
+
export declare class RichTextWhitespaceParser extends DOMParser {
|
|
5
|
+
constructor(schema: Schema);
|
|
6
|
+
parseSlice(dom: Node, options?: ParseOptions): Slice;
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DefaultTreeAdapterMap, ParserOptions } from 'parse5';
|
|
2
|
+
type Options = Omit<ParserOptions<DefaultTreeAdapterMap>, 'treeAdapter'>;
|
|
3
|
+
/**
|
|
4
|
+
* Parses untrusted markup with a ceiling on nesting which is enforced while the tree is built.
|
|
5
|
+
* The parser scans its stack of open elements on most tags, so a source of tens of thousands of
|
|
6
|
+
* nested elements costs time quadratic in its depth before any limit of the document model could
|
|
7
|
+
* see it. Here the parse ends at the first element placed deeper than the limit, with the same
|
|
8
|
+
* diagnostic the model gives. A tree within the limit is exactly the tree of the plain parser.
|
|
9
|
+
*/
|
|
10
|
+
export declare class BoundedHtmlParser {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(depth?: number);
|
|
13
|
+
document(markup: string, options?: Options): DefaultTreeAdapterMap['document'];
|
|
14
|
+
/** `context` is the element whose content the markup is, e.g. an `svg` root for an island. */
|
|
15
|
+
fragment(markup: string, options?: Options, context?: DefaultTreeAdapterMap['element']): DefaultTreeAdapterMap['documentFragment'];
|
|
16
|
+
private guard;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Downlevel-revealed conditionals (`<![if !mso]>` ... `<![endif]>`) reach the tree as bogus
|
|
3
|
+
* comments. Only the exact opening and closing forms over a closed vocabulary are recognized;
|
|
4
|
+
* the content between the markers is ordinary markup validated like the rest of the document.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DownlevelRevealedConditional {
|
|
7
|
+
isOpening(value: string): boolean;
|
|
8
|
+
isClosing(value: string): boolean;
|
|
9
|
+
isMarker(value: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* `<![ENDIF]>` or `<![endif] >` would only survive as an ordinary comment, which no longer
|
|
12
|
+
* closes the revealed block for Outlook. Anything but the exact closer is refused.
|
|
13
|
+
*/
|
|
14
|
+
isClosingLookalike(value: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Document-order comment values: every revealed opener needs a later exact closer and a
|
|
17
|
+
* second opener may not appear before it. A closer on its own stays an inert comment.
|
|
18
|
+
*/
|
|
19
|
+
isBalanced(comments: Iterable<string>): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* expression := term (('&' | '|') term)*
|
|
22
|
+
* term := ['!'] ('(' expression ')' | [gt | gte | lt | lte] (mso | IE) [version])
|
|
23
|
+
*/
|
|
24
|
+
private validExpression;
|
|
25
|
+
private tokens;
|
|
26
|
+
/** Index after the expression which starts at `start`, or -1 when none is well formed. */
|
|
27
|
+
private expression;
|
|
28
|
+
private term;
|
|
29
|
+
private version;
|
|
30
|
+
}
|