@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,84 @@
|
|
|
1
|
+
import { BlockDocument } from '../core/block-document';
|
|
2
|
+
import type { BlockDocumentData } from '../core/block-document';
|
|
3
|
+
import type { AnyDocument } from '../core/any-document';
|
|
4
|
+
import type { DocumentKind, EditorDocumentData, SourceInput } from '../core/document';
|
|
5
|
+
import { BlockEditorSession } from '../application/block-session';
|
|
6
|
+
import type { BlockStorePort } from '../application/block-session';
|
|
7
|
+
import { BlockDefinitionRegistry } from '../blocks/definitions';
|
|
8
|
+
import type { OutputMode } from '../blocks/block-type';
|
|
9
|
+
import type { GeneratedMjml, GeneratedMjmlCompilerPort } from '../compilation/generated-mjml';
|
|
10
|
+
import type { MjmlCompilerPort } from '../renderers/email-renderer';
|
|
11
|
+
import { SelectionPreviewRenderer } from '../renderers/selection-preview';
|
|
12
|
+
import { BlockTemplateCatalog } from '../templates/blocks/catalog';
|
|
13
|
+
import { BlockEditorController } from '../vue/block-controller';
|
|
14
|
+
/** A compiler of both kinds of MJML; the browser and the Node compilers are. */
|
|
15
|
+
export type BlockCompiler = MjmlCompilerPort & GeneratedMjmlCompilerPort & {
|
|
16
|
+
dispose?(): void;
|
|
17
|
+
};
|
|
18
|
+
export interface BlockToolkitOptions {
|
|
19
|
+
/** A compiler the host owns; otherwise the toolkit creates one and disposes of it. */
|
|
20
|
+
readonly compiler?: BlockCompiler;
|
|
21
|
+
/** Placeholders accepted as whole link addresses, e.g. `{{unsubscribe_url}}`. */
|
|
22
|
+
readonly exactUrlPlaceholders?: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* What a host needs of block pieces (schema 2) without the editor: validate what it stores,
|
|
26
|
+
* generate and compile the output, and convert a piece to the HTML document (schema 1).
|
|
27
|
+
*/
|
|
28
|
+
export interface BlockToolkit {
|
|
29
|
+
readonly registry: BlockDefinitionRegistry;
|
|
30
|
+
readonly templates: BlockTemplateCatalog;
|
|
31
|
+
/** A stored piece of either schema; throws `DocumentValidationError` (or a subclass). */
|
|
32
|
+
parse(input: unknown): AnyDocument;
|
|
33
|
+
/** A block piece; throws `BlockDocumentError`. */
|
|
34
|
+
parseBlocks(input: unknown): BlockDocument;
|
|
35
|
+
/** A new piece of a kind, blank or from a template, with fresh block ids. */
|
|
36
|
+
/**
|
|
37
|
+
* A new piece from a template (the blank one by default), with the texts in `language`
|
|
38
|
+
* (pt-BR by default; English and Spanish are written too).
|
|
39
|
+
*/
|
|
40
|
+
create(kind: DocumentKind, documentId: string, templateId?: string, language?: string): BlockDocument;
|
|
41
|
+
/** The HTML and CSS of a page piece. */
|
|
42
|
+
generatePage(document: BlockDocument, mode?: OutputMode): SourceInput;
|
|
43
|
+
/** The MJML of an e-mail piece, with the raw regions only the compilers accept. */
|
|
44
|
+
generateMjml(document: BlockDocument, mode?: OutputMode): GeneratedMjml;
|
|
45
|
+
/** The compiled HTML of an e-mail piece, checked against the e-mail rules. */
|
|
46
|
+
compileEmail(document: BlockDocument): Promise<SourceInput>;
|
|
47
|
+
/** The final output of a piece of either kind: what is stored, sent or published. */
|
|
48
|
+
render(document: BlockDocument): Promise<SourceInput>;
|
|
49
|
+
/** "Convert to editable HTML": one way only, to a schema 1 document. */
|
|
50
|
+
convert(document: BlockDocument): Promise<EditorDocumentData>;
|
|
51
|
+
dispose(): void;
|
|
52
|
+
}
|
|
53
|
+
export interface BlockEditorOptions extends BlockToolkitOptions {
|
|
54
|
+
readonly kind?: DocumentKind;
|
|
55
|
+
/** A stored piece (schema 2); validated here. */
|
|
56
|
+
readonly document?: BlockDocumentData;
|
|
57
|
+
/** The template a new piece starts from; the blank one of its kind by default. */
|
|
58
|
+
readonly template?: string;
|
|
59
|
+
/** Language of the texts of a new piece and of the templates applied to it. */
|
|
60
|
+
readonly language?: string;
|
|
61
|
+
/** Id of a new piece. */
|
|
62
|
+
readonly documentId?: string;
|
|
63
|
+
readonly readOnly?: boolean;
|
|
64
|
+
readonly persistedRevision?: number;
|
|
65
|
+
readonly store?: BlockStorePort;
|
|
66
|
+
readonly previewImageOrigins?: readonly string[];
|
|
67
|
+
readonly onObserverError?: (error: unknown) => void;
|
|
68
|
+
}
|
|
69
|
+
export interface BlockEditorInstance {
|
|
70
|
+
readonly session: BlockEditorSession;
|
|
71
|
+
readonly controller: BlockEditorController;
|
|
72
|
+
readonly selectionRenderer: SelectionPreviewRenderer;
|
|
73
|
+
readonly toolkit: BlockToolkit;
|
|
74
|
+
dispose(): void;
|
|
75
|
+
}
|
|
76
|
+
/** The only place that builds the graph of block pieces; every instance owns its state. */
|
|
77
|
+
export declare class BlockEditorFactory {
|
|
78
|
+
private readonly compilerFactory;
|
|
79
|
+
constructor(compilerFactory: () => BlockCompiler);
|
|
80
|
+
toolkit(options?: BlockToolkitOptions): BlockToolkit;
|
|
81
|
+
create(options?: BlockEditorOptions): BlockEditorInstance;
|
|
82
|
+
private static ofKind;
|
|
83
|
+
private parts;
|
|
84
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { EditorOptions } from './factory';
|
|
2
|
+
import type { BlockEditorInstance, BlockEditorOptions, BlockToolkit, BlockToolkitOptions } from './block-factory';
|
|
3
|
+
export declare function createEditor(options?: EditorOptions): import("./factory").EditorInstance;
|
|
4
|
+
/** An editor of a block piece (schema 2), compiling e-mails in a browser worker. */
|
|
5
|
+
export declare function createBlockEditor(options?: BlockEditorOptions): BlockEditorInstance;
|
|
6
|
+
/** Parse, generate, compile and convert block pieces in the browser, without an editor. */
|
|
7
|
+
export declare function createBlockToolkit(options?: BlockToolkitOptions): BlockToolkit;
|
|
8
|
+
export { EditorFactory, InitialDocumentError } from './factory';
|
|
9
|
+
export type { EditorOptions, EditorInstance } from './factory';
|
|
10
|
+
export { EditorDocument, EditorDocumentSchema, DocumentNodeSchema, DOCUMENT_LIMITS, } from '../core/document';
|
|
11
|
+
export type { EditorDocumentData, DocumentNode, Diagnostic, DiagnosticSeverity, DocumentKind, SourceInput, } from '../core/document';
|
|
12
|
+
export { EditorSession } from '../application/session';
|
|
13
|
+
export type { EditorState } from '../application/session';
|
|
14
|
+
export type { HostAdapters, StorePort, AssetPort, SlotsPort, AssetReference, } from '../application/host';
|
|
15
|
+
export { ContentPolicy, ContentPolicyError } from '../security/policy';
|
|
16
|
+
export type { SanitizedDocument } from '../security/policy';
|
|
17
|
+
export type { ContentInventory, ExternalReference } from '../security/content-inventory';
|
|
18
|
+
export { HtmlDocumentCodec } from '../codecs/html';
|
|
19
|
+
export { CssDocumentCodec } from '../codecs/css';
|
|
20
|
+
export { BrowserMjmlCompiler } from '../compilation/browser-compiler';
|
|
21
|
+
export { PreviewDocument } from '../renderers/preview-document';
|
|
22
|
+
export { HtmlDocumentAssembler } from '../renderers/preview-document';
|
|
23
|
+
export { SelectionPreviewRenderer } from '../renderers/selection-preview';
|
|
24
|
+
export { UrlPolicy } from '../security/url-policy';
|
|
25
|
+
export { BlockEditorFactory } from './block-factory';
|
|
26
|
+
export type { BlockCompiler, BlockEditorInstance, BlockEditorOptions, BlockToolkit, BlockToolkitOptions, } from './block-factory';
|
|
27
|
+
export { BlockDocument, BlockDocumentError, BlockDocumentSchema, BLOCK_DOCUMENT_LIMITS, BLOCK_NODE_TYPES, } from '../core/block-document';
|
|
28
|
+
export type { Block, BlockDocumentData, BlockNodeType, BlockPropValue, BlockProps, BlockTarget, GlobalStyles, StylePatch, } from '../core/block-document';
|
|
29
|
+
export { parseAnyDocument } from '../core/any-document';
|
|
30
|
+
export type { AnyDocument } from '../core/any-document';
|
|
31
|
+
export { BlockEditorSession } from '../application/block-session';
|
|
32
|
+
export type { BlockEditorState, BlockImageChoice, BlockStorePort, } from '../application/block-session';
|
|
33
|
+
export { BlockDefinitionRegistry } from '../blocks/definitions';
|
|
34
|
+
export { GLOBAL_STYLE_GROUPS } from '../blocks/styles';
|
|
35
|
+
export { BlockConversionError } from '../blocks/conversion';
|
|
36
|
+
export type { OutputMode } from '../blocks/block-type';
|
|
37
|
+
export { GeneratedMjml } from '../compilation/generated-mjml';
|
|
38
|
+
export { BlockTemplateCatalog } from '../templates/blocks/catalog';
|
|
39
|
+
export type { BlockTemplateDescriptor } from '../templates/blocks/catalog';
|
|
40
|
+
export type { BlockPreviewInput } from '../renderers/marked-preview';
|
|
41
|
+
export { BlockContentGuard } from '../blocks/content-guard';
|
|
42
|
+
export { BlockMjmlGenerator } from '../blocks/email-generator';
|
|
43
|
+
export { BlockPageGenerator } from '../blocks/page-generator';
|
|
44
|
+
export { BlockEmailRenderer } from '../blocks/email-renderer';
|
|
45
|
+
export { BlockToHtmlConversion } from '../blocks/conversion';
|
|
46
|
+
export { BlockChecker, GMAIL_CLIP_BYTES, GMAIL_NEAR_CLIP_BYTES } from '../blocks/block-checks';
|
|
47
|
+
export type { BlockCheck, BlockCheckCode } from '../blocks/block-checks';
|
|
48
|
+
export type { BlockDevice } from '../core/block-document';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Diagnostic, DocumentKind, EditorDocumentData, SourceInput } from '../core/document';
|
|
2
|
+
import type { HostAdapters } from '../application/host';
|
|
3
|
+
import { EditorSession } from '../application/session';
|
|
4
|
+
import { MjmlEmailRenderer } from '../renderers/email-renderer';
|
|
5
|
+
import type { MjmlCompilerPort } from '../renderers/email-renderer';
|
|
6
|
+
import { PageRenderer } from '../renderers/page-renderer';
|
|
7
|
+
import { SelectionPreviewRenderer } from '../renderers/selection-preview';
|
|
8
|
+
import { TemplateCatalog } from '../templates/catalog';
|
|
9
|
+
import { EditorController } from '../vue/controller';
|
|
10
|
+
export interface EditorOptions {
|
|
11
|
+
readonly kind?: DocumentKind;
|
|
12
|
+
readonly document?: EditorDocumentData;
|
|
13
|
+
readonly source?: SourceInput;
|
|
14
|
+
readonly readOnly?: boolean;
|
|
15
|
+
readonly persistedRevision?: number;
|
|
16
|
+
readonly host?: HostAdapters;
|
|
17
|
+
readonly compiler?: MjmlCompilerPort;
|
|
18
|
+
readonly exactUrlPlaceholders?: readonly string[];
|
|
19
|
+
readonly previewImageOrigins?: readonly string[];
|
|
20
|
+
/** Receives an exception thrown by a `session.subscribe` listener; the listener stays. */
|
|
21
|
+
readonly onObserverError?: (error: unknown) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface EditorInstance {
|
|
24
|
+
readonly session: EditorSession;
|
|
25
|
+
readonly controller: EditorController;
|
|
26
|
+
readonly templates: TemplateCatalog;
|
|
27
|
+
readonly pageRenderer: PageRenderer;
|
|
28
|
+
readonly emailRenderer: MjmlEmailRenderer;
|
|
29
|
+
readonly selectionRenderer: SelectionPreviewRenderer;
|
|
30
|
+
dispose(): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The initial source could not become a document. Since the tolerant import this only
|
|
34
|
+
* happens over the limits or with markup no parser reads back the same; `diagnostics`
|
|
35
|
+
* carries the specific code (`DOCUMENT_TOO_LARGE`, `DOCUMENT_TOO_MANY_NODES`...).
|
|
36
|
+
*/
|
|
37
|
+
export declare class InitialDocumentError extends Error {
|
|
38
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
39
|
+
constructor(diagnostics: readonly Diagnostic[]);
|
|
40
|
+
}
|
|
41
|
+
/** The only place that constructs the dependency graph. Every editor owns its state. */
|
|
42
|
+
export declare class EditorFactory {
|
|
43
|
+
private readonly compilerFactory;
|
|
44
|
+
constructor(compilerFactory: () => MjmlCompilerPort & {
|
|
45
|
+
dispose?(): void;
|
|
46
|
+
});
|
|
47
|
+
create(options?: EditorOptions): EditorInstance;
|
|
48
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { EditorOptions } from './factory';
|
|
2
|
+
import type { BlockToolkit, BlockToolkitOptions } from './block-factory';
|
|
3
|
+
export declare function createServerEditor(options?: EditorOptions): import("./factory").EditorInstance;
|
|
4
|
+
/**
|
|
5
|
+
* Parse, generate, compile and convert block pieces (schema 2) on the server, the source of
|
|
6
|
+
* truth: the e-mail is compiled by the isolated Node worker.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createServerBlockToolkit(options?: BlockToolkitOptions): BlockToolkit;
|
|
9
|
+
export { NodeMjmlCompiler } from '../compilation/node-compiler';
|
|
10
|
+
export { EditorFactory, InitialDocumentError } from './factory';
|
|
11
|
+
export type { EditorOptions, EditorInstance } from './factory';
|
|
12
|
+
export { EditorDocument, DOCUMENT_LIMITS } from '../core/document';
|
|
13
|
+
export type { EditorDocumentData, DocumentNode, SourceInput, Diagnostic, DiagnosticSeverity, } from '../core/document';
|
|
14
|
+
export type { HostAdapters, StorePort, AssetPort, SlotsPort, AssetReference, } from '../application/host';
|
|
15
|
+
export { ContentPolicy, ContentPolicyError } from '../security/policy';
|
|
16
|
+
export type { SanitizedDocument } from '../security/policy';
|
|
17
|
+
export type { ContentInventory, ExternalReference } from '../security/content-inventory';
|
|
18
|
+
export { HtmlDocumentCodec } from '../codecs/html';
|
|
19
|
+
export { CssDocumentCodec } from '../codecs/css';
|
|
20
|
+
export { UrlPolicy } from '../security/url-policy';
|
|
21
|
+
export { HtmlDocumentAssembler } from '../renderers/preview-document';
|
|
22
|
+
export { BlockEditorFactory } from './block-factory';
|
|
23
|
+
export type { BlockCompiler, BlockToolkit, BlockToolkitOptions } from './block-factory';
|
|
24
|
+
export { BlockDocument, BlockDocumentError, BlockDocumentSchema, BLOCK_DOCUMENT_LIMITS, BLOCK_NODE_TYPES, } from '../core/block-document';
|
|
25
|
+
export type { Block, BlockDocumentData, BlockNodeType, BlockPropValue, BlockProps, GlobalStyles, } from '../core/block-document';
|
|
26
|
+
export { parseAnyDocument } from '../core/any-document';
|
|
27
|
+
export type { AnyDocument } from '../core/any-document';
|
|
28
|
+
export type { BlockStorePort } from '../application/block-session';
|
|
29
|
+
export { BlockDefinitionRegistry } from '../blocks/definitions';
|
|
30
|
+
export { BlockConversionError } from '../blocks/conversion';
|
|
31
|
+
export type { OutputMode } from '../blocks/block-type';
|
|
32
|
+
export { GeneratedMjml } from '../compilation/generated-mjml';
|
|
33
|
+
export { BlockTemplateCatalog } from '../templates/blocks/catalog';
|
|
34
|
+
export type { BlockTemplateDescriptor } from '../templates/blocks/catalog';
|
|
35
|
+
export { BlockContentGuard } from '../blocks/content-guard';
|
|
36
|
+
export { BlockMjmlGenerator } from '../blocks/email-generator';
|
|
37
|
+
export { BlockPageGenerator } from '../blocks/page-generator';
|
|
38
|
+
export { BlockEmailRenderer } from '../blocks/email-renderer';
|
|
39
|
+
export { BlockToHtmlConversion } from '../blocks/conversion';
|
|
40
|
+
export { BlockChecker, GMAIL_CLIP_BYTES, GMAIL_NEAR_CLIP_BYTES } from '../blocks/block-checks';
|
|
41
|
+
export type { BlockCheck, BlockCheckCode } from '../blocks/block-checks';
|
|
42
|
+
export { BLOCK_DEVICES } from '../core/block-document';
|
|
43
|
+
export type { BlockDevice } from '../core/block-document';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BlockDocument } from './block-document';
|
|
2
|
+
import type { BlockRules } from './block-document';
|
|
3
|
+
import { EditorDocument } from './document';
|
|
4
|
+
/** A stored piece in either format. Nothing converts one into the other on the way in. */
|
|
5
|
+
export type AnyDocument = {
|
|
6
|
+
readonly schemaVersion: 1;
|
|
7
|
+
readonly document: EditorDocument;
|
|
8
|
+
} | {
|
|
9
|
+
readonly schemaVersion: 2;
|
|
10
|
+
readonly document: BlockDocument;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Dispatches by `schemaVersion`: 1 is the HTML document of the editor, 2 the block piece.
|
|
14
|
+
* Throws `DocumentValidationError` (or its `BlockDocumentError` subclass) like each format.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseAnyDocument(input: unknown, rules: BlockRules): AnyDocument;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { DocumentValidationError } from './document';
|
|
3
|
+
import type { DocumentKind } from './document';
|
|
4
|
+
/**
|
|
5
|
+
* Schema 2: a piece made of blocks. Each block keeps only the values its author set; what is
|
|
6
|
+
* absent is inherited from the global styles of the piece, and those from the defaults of the
|
|
7
|
+
* catalog. The HTML of an e-mail and of a page is generated from this tree, never edited.
|
|
8
|
+
*
|
|
9
|
+
* The aggregate knows the shape of the tree and its invariants. What each block type accepts
|
|
10
|
+
* (children, properties, content rules) comes from a `BlockRules` port, implemented by the
|
|
11
|
+
* block definitions outside `core`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const BLOCK_NODE_TYPES: readonly ["section", "column", "text", "heading", "image", "button", "divider", "spacer", "footer", "form", "html"];
|
|
14
|
+
export type BlockNodeType = (typeof BLOCK_NODE_TYPES)[number];
|
|
15
|
+
export type BlockPropValue = string | number | boolean;
|
|
16
|
+
export type BlockProps = Readonly<Record<string, BlockPropValue>>;
|
|
17
|
+
export type StyleValue = string | number;
|
|
18
|
+
export type GlobalStyles = Readonly<Record<string, Readonly<Record<string, StyleValue>>>>;
|
|
19
|
+
export interface Block {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly type: BlockNodeType;
|
|
22
|
+
readonly props: BlockProps;
|
|
23
|
+
/**
|
|
24
|
+
* Values the block uses on small screens instead of its own (or inherited) ones. Only the
|
|
25
|
+
* fields the rules call responsive may appear here; absent when the block has none.
|
|
26
|
+
*/
|
|
27
|
+
readonly mobile?: BlockProps;
|
|
28
|
+
readonly children?: readonly Block[];
|
|
29
|
+
}
|
|
30
|
+
/** The screen a value applies to: `desktop` writes `props`, `mobile` writes `mobile`. */
|
|
31
|
+
export type BlockDevice = 'desktop' | 'mobile';
|
|
32
|
+
export declare const BLOCK_DEVICES: readonly BlockDevice[];
|
|
33
|
+
export interface BlockDocumentMeta {
|
|
34
|
+
readonly lang: string;
|
|
35
|
+
}
|
|
36
|
+
export interface BlockDocumentData {
|
|
37
|
+
readonly schemaVersion: 2;
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly kind: DocumentKind;
|
|
40
|
+
readonly revision: number;
|
|
41
|
+
/** Internal label of the piece. The subject, preheader and SEO title belong to the host. */
|
|
42
|
+
readonly title: string;
|
|
43
|
+
readonly meta: BlockDocumentMeta;
|
|
44
|
+
readonly styles: GlobalStyles;
|
|
45
|
+
readonly blocks: readonly Block[];
|
|
46
|
+
}
|
|
47
|
+
/** Where an inserted or moved block goes. `inside` without a parent means the root. */
|
|
48
|
+
export type BlockTarget = {
|
|
49
|
+
readonly position: 'before' | 'after';
|
|
50
|
+
readonly id: string;
|
|
51
|
+
} | {
|
|
52
|
+
readonly position: 'inside';
|
|
53
|
+
readonly parentId?: string;
|
|
54
|
+
readonly index?: number;
|
|
55
|
+
};
|
|
56
|
+
export type StylePatch = Readonly<Record<string, Readonly<Record<string, StyleValue>>>>;
|
|
57
|
+
/** What a block type accepts. Implemented by the block definitions. */
|
|
58
|
+
export interface BlockRules {
|
|
59
|
+
/** Types which may stand at the root of the piece. */
|
|
60
|
+
isRoot(type: BlockNodeType): boolean;
|
|
61
|
+
/** Types a block of this type may contain; empty for a leaf. */
|
|
62
|
+
childTypes(type: BlockNodeType): readonly BlockNodeType[];
|
|
63
|
+
childCount(type: BlockNodeType): {
|
|
64
|
+
readonly min: number;
|
|
65
|
+
readonly max: number;
|
|
66
|
+
};
|
|
67
|
+
allows(type: BlockNodeType, kind: DocumentKind): boolean;
|
|
68
|
+
/** Error code for the properties of one block, or undefined when they are valid. */
|
|
69
|
+
validateProps(type: BlockNodeType, props: BlockProps, kind: DocumentKind): string | undefined;
|
|
70
|
+
/** The value a command writes: normalized, or a thrown `BlockDocumentError`. */
|
|
71
|
+
normalizeProp(type: BlockNodeType, key: string, value: BlockPropValue, kind: DocumentKind): BlockPropValue;
|
|
72
|
+
/** Keys whose value is a text the author edits in place. */
|
|
73
|
+
textKeys(type: BlockNodeType): readonly string[];
|
|
74
|
+
/**
|
|
75
|
+
* Whether a property may take a value of its own on small screens. Without this method no
|
|
76
|
+
* block of the piece accepts mobile values.
|
|
77
|
+
*/
|
|
78
|
+
responsive?(type: BlockNodeType, key: string, kind: DocumentKind): boolean;
|
|
79
|
+
validateStyles(styles: GlobalStyles, kind: DocumentKind): string | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Error code for the piece as a whole, once its tree is valid: e.g. an output larger than
|
|
82
|
+
* the compilation or the conversion accepts. Optional.
|
|
83
|
+
*/
|
|
84
|
+
validateDocument?(data: BlockDocumentData): string | undefined;
|
|
85
|
+
normalizeStyle(group: string, key: string, value: StyleValue, kind: DocumentKind): StyleValue;
|
|
86
|
+
}
|
|
87
|
+
export declare const BLOCK_DOCUMENT_LIMITS: Readonly<{
|
|
88
|
+
blocks: 5000;
|
|
89
|
+
depth: 8;
|
|
90
|
+
childrenPerBlock: 500;
|
|
91
|
+
propsPerBlock: 64;
|
|
92
|
+
propValueLength: 500000;
|
|
93
|
+
styleGroups: 32;
|
|
94
|
+
stylesPerGroup: 32;
|
|
95
|
+
styleValueLength: 200;
|
|
96
|
+
titleLength: 1000;
|
|
97
|
+
}>;
|
|
98
|
+
/** Identifiers end up in class names, selectors and MJML attributes: nothing else is allowed. */
|
|
99
|
+
export declare const BLOCK_ID_PATTERN: RegExp;
|
|
100
|
+
/** A language tag as `<html lang>` takes it: `pt-BR`, `en`, `es-419`. */
|
|
101
|
+
export declare const LANGUAGE_TAG_PATTERN: RegExp;
|
|
102
|
+
export declare const BlockSchema: v.GenericSchema<Block>;
|
|
103
|
+
export declare const GlobalStylesSchema: v.GenericSchema<GlobalStyles>;
|
|
104
|
+
export declare const BlockDocumentSchema: v.GenericSchema<BlockDocumentData>;
|
|
105
|
+
export declare class BlockDocumentError extends DocumentValidationError {
|
|
106
|
+
constructor(code: string);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Immutable aggregate of a block piece. Every operation is pure: it returns a new document
|
|
110
|
+
* with the next revision, validated as a whole, or throws `BlockDocumentError`.
|
|
111
|
+
*/
|
|
112
|
+
export declare class BlockDocument {
|
|
113
|
+
#private;
|
|
114
|
+
private constructor();
|
|
115
|
+
static from(input: unknown, rules: BlockRules): BlockDocument;
|
|
116
|
+
/** The invariants of the tree and of the piece, over data of the schema's shape. */
|
|
117
|
+
private static checked;
|
|
118
|
+
get id(): string;
|
|
119
|
+
get kind(): DocumentKind;
|
|
120
|
+
get revision(): number;
|
|
121
|
+
get title(): string;
|
|
122
|
+
get meta(): BlockDocumentMeta;
|
|
123
|
+
/** Frozen view of the overridden global styles. */
|
|
124
|
+
get styles(): GlobalStyles;
|
|
125
|
+
/** Frozen view of the tree; `snapshot()` gives an independent copy. */
|
|
126
|
+
get blocks(): readonly Block[];
|
|
127
|
+
snapshot(): BlockDocumentData;
|
|
128
|
+
/** The data itself, deeply frozen: what reads it never pays for a copy. */
|
|
129
|
+
get data(): BlockDocumentData;
|
|
130
|
+
/** Size of the JSON of the piece, for the byte budget of the history. */
|
|
131
|
+
serializedBytes(): number;
|
|
132
|
+
/**
|
|
133
|
+
* Only the revision changes: the validated tree is not checked a second time. A session uses
|
|
134
|
+
* it to move forward when it restores an earlier step of its history.
|
|
135
|
+
*/
|
|
136
|
+
withRevision(revision: number): BlockDocument;
|
|
137
|
+
find(id: string): Block | undefined;
|
|
138
|
+
/** Id of the block which contains this one; undefined at the root or when absent. */
|
|
139
|
+
parentOf(id: string): string | undefined;
|
|
140
|
+
private index;
|
|
141
|
+
insert(block: Block, target: BlockTarget): BlockDocument;
|
|
142
|
+
/**
|
|
143
|
+
* `inside` with an index counts the slots of the parent as it is before the move, like a
|
|
144
|
+
* drop indicator between two blocks: moving the first of `[a, b]` to index 2 gives `[b, a]`.
|
|
145
|
+
*/
|
|
146
|
+
move(id: string, target: BlockTarget): BlockDocument;
|
|
147
|
+
/** Copies a block and its children with new ids, right after the original. */
|
|
148
|
+
duplicate(id: string, nextId: () => string): BlockDocument;
|
|
149
|
+
remove(id: string): BlockDocument;
|
|
150
|
+
/**
|
|
151
|
+
* Sets values the author chose, for every screen or only for small ones; a patch which
|
|
152
|
+
* changes nothing returns this document. A mobile value equal to the one the block already
|
|
153
|
+
* uses on every screen is still kept: the author chose it for the small screen.
|
|
154
|
+
*/
|
|
155
|
+
updateProps(id: string, patch: BlockProps, device?: BlockDevice): BlockDocument;
|
|
156
|
+
/**
|
|
157
|
+
* "Restore default": the keys disappear and the block inherits again. On mobile only the
|
|
158
|
+
* mobile values go, and the block uses its value of every screen again.
|
|
159
|
+
*/
|
|
160
|
+
restoreDefault(id: string, keys: readonly string[], device?: BlockDevice): BlockDocument;
|
|
161
|
+
/** Whether this property of the block may take a value of its own on small screens. */
|
|
162
|
+
responsive(type: BlockNodeType, key: string): boolean;
|
|
163
|
+
/** The text of a block, in the rich-text projection its type accepts. */
|
|
164
|
+
updateText(id: string, key: string, value: string): BlockDocument;
|
|
165
|
+
updateStyles(patch: StylePatch): BlockDocument;
|
|
166
|
+
/**
|
|
167
|
+
* Back to the catalog defaults: every style without a group, a whole group without keys,
|
|
168
|
+
* or only the given keys of a group.
|
|
169
|
+
*/
|
|
170
|
+
restoreStyleDefault(group?: string, keys?: readonly string[]): BlockDocument;
|
|
171
|
+
withMeta(meta: BlockDocumentMeta): BlockDocument;
|
|
172
|
+
withTitle(title: string): BlockDocument;
|
|
173
|
+
/**
|
|
174
|
+
* The next revision. The data was built here from a validated document and from values the
|
|
175
|
+
* rules normalized, so it keeps the shape of the schema; the parsing of the schema is not
|
|
176
|
+
* paid again, but every invariant of the tree and of the piece is checked as for any input.
|
|
177
|
+
*/
|
|
178
|
+
private next;
|
|
179
|
+
/**
|
|
180
|
+
* The tree a command changes, copied on write: the root list is new, and `locate` copies
|
|
181
|
+
* only the blocks on the path to what it finds. Every other block stays the frozen object of
|
|
182
|
+
* this document, shared by the next one (and never validated again: see `assertTree`).
|
|
183
|
+
*/
|
|
184
|
+
private mutableBlocks;
|
|
185
|
+
/** A block of the tree being changed, as a copy the command may write. */
|
|
186
|
+
private open;
|
|
187
|
+
private place;
|
|
188
|
+
private contains;
|
|
189
|
+
private reidentify;
|
|
190
|
+
private blockAt;
|
|
191
|
+
private require;
|
|
192
|
+
/**
|
|
193
|
+
* Where a block of this document stands in the tree being changed. The path comes from the
|
|
194
|
+
* index of this document (a command never moves a block inside itself), and each block on it
|
|
195
|
+
* is opened for writing, the found one included.
|
|
196
|
+
*/
|
|
197
|
+
private locate;
|
|
198
|
+
private static assertStyles;
|
|
199
|
+
/**
|
|
200
|
+
* Frozen blocks whose own values were already accepted by these rules for a kind. The values
|
|
201
|
+
* of a block depend only on its type and the kind, and a frozen block never changes: a block
|
|
202
|
+
* shared by the next revision is not checked again. Its place in the tree always is.
|
|
203
|
+
*/
|
|
204
|
+
private static readonly accepted;
|
|
205
|
+
private static acceptedFor;
|
|
206
|
+
private static assertTree;
|
|
207
|
+
/**
|
|
208
|
+
* Mobile values: at least one, each of a responsive property, each one a value the property
|
|
209
|
+
* accepts. They are checked over the values of every screen, so the rules see a whole block.
|
|
210
|
+
*/
|
|
211
|
+
private static assertMobile;
|
|
212
|
+
/** Keys and values of the schema's shape, checked again for data built by a command. */
|
|
213
|
+
private static values;
|
|
214
|
+
private static freeze;
|
|
215
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare class DocumentBudgetError extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
constructor(code: string);
|
|
4
|
+
}
|
|
5
|
+
/** Bounds are checked before recursive schemas and parsers inspect untrusted input. */
|
|
6
|
+
export declare class DocumentBudget {
|
|
7
|
+
static readonly limits: Readonly<{
|
|
8
|
+
nodes: 50000;
|
|
9
|
+
totalNodes: 150000;
|
|
10
|
+
depth: 256;
|
|
11
|
+
sourceBytes: 2000000;
|
|
12
|
+
cssBytes: 500000;
|
|
13
|
+
jsonBytes: 64000000;
|
|
14
|
+
attributesPerNode: 256;
|
|
15
|
+
/** Ceiling of values typed or projected by the editor itself (links, rich text). */
|
|
16
|
+
attributeLength: 16384;
|
|
17
|
+
/** Ceiling of one attribute of an imported document, e.g. an inline `data:` image. */
|
|
18
|
+
documentAttributeLength: 2000000;
|
|
19
|
+
}>;
|
|
20
|
+
/** Strings of a JSON document: content, plus identifiers and keys of every node. */
|
|
21
|
+
static readonly jsonStringBytes: number;
|
|
22
|
+
/** UTF-8 length. Read by code unit: megabytes of source are measured on every change. */
|
|
23
|
+
byteLength(value: string): number;
|
|
24
|
+
private lowSurrogate;
|
|
25
|
+
assertSource(html: string, css: string): void;
|
|
26
|
+
assertInput(data: unknown): void;
|
|
27
|
+
/** White space between tags does not count against the node ceiling. */
|
|
28
|
+
countable(node: {
|
|
29
|
+
readonly type: string;
|
|
30
|
+
readonly value?: string;
|
|
31
|
+
}): boolean;
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the host, the renderers, the message policy and the runtime of the frame agree on about the
|
|
3
|
+
* piece on screen. It has no DOM and no dependency, so every side imports the same definition.
|
|
4
|
+
*/
|
|
5
|
+
/** Every attribute the editor adds to the copy shown in the frame starts with this. */
|
|
6
|
+
export declare const RESERVED_ATTRIBUTE_PREFIX = "data-visual-editor-";
|
|
7
|
+
/** Marks a selectable block with the id of its node. */
|
|
8
|
+
export declare const NODE_ATTRIBUTE = "data-visual-editor-node";
|
|
9
|
+
/** Marks an element of an editable text which keeps attributes of its own. */
|
|
10
|
+
export declare const TEXT_ORIGIN_ATTRIBUTE = "data-visual-editor-text-origin";
|
|
11
|
+
/** Marks the element whose text may be edited in place. */
|
|
12
|
+
export declare const EDIT_NODE_ATTRIBUTE = "data-visual-editor-edit-node";
|
|
13
|
+
/** Set by the runtime on the selected block. */
|
|
14
|
+
export declare const SELECTED_ATTRIBUTE = "data-visual-editor-selected";
|
|
15
|
+
/** Set by the runtime on its own layer of controls. */
|
|
16
|
+
export declare const CONTROLS_ATTRIBUTE = "data-visual-editor-controls";
|
|
17
|
+
export declare function isReservedAttribute(name: string): boolean;
|
|
18
|
+
/** What the action bar, the context menu and the keyboard may ask about one block. */
|
|
19
|
+
export declare const CANVAS_BLOCK_ACTIONS: readonly ["duplicate", "remove", "up", "down", "html", "image"];
|
|
20
|
+
export type CanvasBlockAction = (typeof CANVAS_BLOCK_ACTIONS)[number];
|
|
21
|
+
/** Widest image a resize gesture may ask for, in CSS pixels. */
|
|
22
|
+
export declare const CANVAS_IMAGE_WIDTH_LIMIT = 4000;
|
|
23
|
+
/** Longest color value of the host theme which may reach the style of the controls. */
|
|
24
|
+
export declare const THEME_COLOR_LENGTH = 80;
|
|
25
|
+
/** A plain CSS color value: no url, no quotes, no semicolon, nothing which could end a rule. */
|
|
26
|
+
export declare function isThemeColor(value: unknown): value is string;
|
|
27
|
+
/** Largest corner radius of the controls, in pixels. */
|
|
28
|
+
export declare const THEME_RADIUS_LIMIT = 24;
|
|
29
|
+
export declare function isInfrastructureTag(tag: string): boolean;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { DocumentNode, EditorDocumentData } from './document';
|
|
2
|
+
import { BlockCatalog } from './catalog';
|
|
3
|
+
import type { BlockType } from './catalog';
|
|
4
|
+
export type CanvasPlacement = 'before' | 'after' | 'inside';
|
|
5
|
+
export interface CanvasTarget {
|
|
6
|
+
readonly parentId?: string;
|
|
7
|
+
/** Index after removing the moving source. Insertion indices have no removal adjustment. */
|
|
8
|
+
readonly index: number;
|
|
9
|
+
}
|
|
10
|
+
export interface CanvasMotion extends CanvasTarget {
|
|
11
|
+
readonly sourceId: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CanvasMovementTarget {
|
|
14
|
+
readonly targetId: string;
|
|
15
|
+
readonly placements: readonly CanvasPlacement[];
|
|
16
|
+
}
|
|
17
|
+
export interface CanvasRegion {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly parentId: string | null;
|
|
20
|
+
readonly index: number;
|
|
21
|
+
readonly depth: number;
|
|
22
|
+
readonly kind: BlockType | 'container' | 'native';
|
|
23
|
+
readonly labelKey?: string;
|
|
24
|
+
readonly node: DocumentNode;
|
|
25
|
+
readonly editable: boolean;
|
|
26
|
+
readonly container: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Logical canvas regions and valid destinations derived from the canonical HTML tree. */
|
|
29
|
+
export declare class CanvasLayout {
|
|
30
|
+
private readonly catalog;
|
|
31
|
+
constructor(catalog?: BlockCatalog);
|
|
32
|
+
regions(document: EditorDocumentData): readonly CanvasRegion[];
|
|
33
|
+
/** Content selection is independent of the HTML unit used by structural commands. */
|
|
34
|
+
selectionRegions(document: EditorDocumentData): readonly CanvasRegion[];
|
|
35
|
+
/**
|
|
36
|
+
* The closest selection region above each selection region, in document order; `undefined`
|
|
37
|
+
* for a region at the top. Plain markup between two regions is skipped, as in the piece.
|
|
38
|
+
*/
|
|
39
|
+
selectionParents(document: EditorDocumentData): ReadonlyMap<string, string | undefined>;
|
|
40
|
+
resolveSelection(document: EditorDocumentData, id: string): CanvasRegion | undefined;
|
|
41
|
+
resolve(document: EditorDocumentData, id: string): CanvasRegion | undefined;
|
|
42
|
+
editableNode(document: EditorDocumentData, id: string): DocumentNode | undefined;
|
|
43
|
+
target(document: EditorDocumentData, sourceId: string, targetId: string, placement: CanvasPlacement): CanvasTarget | undefined;
|
|
44
|
+
motion(document: EditorDocumentData, sourceId: string, targetId: string, placement: CanvasPlacement): CanvasMotion | undefined;
|
|
45
|
+
validMovementTargets(document: EditorDocumentData, sourceId: string): readonly CanvasMovementTarget[];
|
|
46
|
+
actionUnit(document: EditorDocumentData, id: string): CanvasRegion | undefined;
|
|
47
|
+
insertionAt(document: EditorDocumentData, targetId: string, placement: CanvasPlacement): CanvasTarget | undefined;
|
|
48
|
+
insertionTarget(document: EditorDocumentData, selectedId?: string): CanvasTarget | undefined;
|
|
49
|
+
acceptsInsertion(document: EditorDocumentData, destination: CanvasTarget, nodes: readonly DocumentNode[]): boolean;
|
|
50
|
+
private movementProjection;
|
|
51
|
+
private resolveRegion;
|
|
52
|
+
private motionUsing;
|
|
53
|
+
private structuralTarget;
|
|
54
|
+
private regionDestination;
|
|
55
|
+
private acceptsAt;
|
|
56
|
+
private isContentUnit;
|
|
57
|
+
private region;
|
|
58
|
+
private rowContent;
|
|
59
|
+
private hasRichTextBlocks;
|
|
60
|
+
private isContentWrapper;
|
|
61
|
+
private contentTarget;
|
|
62
|
+
private locations;
|
|
63
|
+
private hasVisibleContent;
|
|
64
|
+
private contains;
|
|
65
|
+
private findTag;
|
|
66
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DocumentKind, DocumentNode } from './document';
|
|
2
|
+
export type BlockType = 'heading' | 'text' | 'image' | 'button' | 'section' | 'columns' | 'divider' | 'spacer' | 'footer' | 'form' | 'html';
|
|
3
|
+
export interface BlockProperty {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly labelKey: string;
|
|
6
|
+
readonly kind: 'text' | 'attribute' | 'style';
|
|
7
|
+
}
|
|
8
|
+
export interface BlockDescriptor {
|
|
9
|
+
readonly type: BlockType;
|
|
10
|
+
readonly labelKey: string;
|
|
11
|
+
readonly kinds: readonly DocumentKind[];
|
|
12
|
+
readonly tag: string;
|
|
13
|
+
readonly canContainChildren: boolean;
|
|
14
|
+
readonly properties: readonly BlockProperty[];
|
|
15
|
+
}
|
|
16
|
+
/** Recognition follows actual HTML structure; imported labels do not grant capabilities. */
|
|
17
|
+
export declare class BlockCatalog {
|
|
18
|
+
private readonly model;
|
|
19
|
+
descriptors(kind?: DocumentKind): readonly BlockDescriptor[];
|
|
20
|
+
descriptor(type: BlockType): BlockDescriptor;
|
|
21
|
+
properties(node: DocumentNode): readonly BlockProperty[];
|
|
22
|
+
acceptsProperty(node: DocumentNode, name: string, kind: BlockProperty['kind']): boolean;
|
|
23
|
+
recognize(node: DocumentNode): BlockDescriptor | undefined;
|
|
24
|
+
canEditText(node: DocumentNode): boolean;
|
|
25
|
+
canEditRichText(node: DocumentNode): boolean;
|
|
26
|
+
acceptsRichText(parent: DocumentNode, children: readonly DocumentNode[]): boolean;
|
|
27
|
+
richTextAllowsBlocks(node: DocumentNode): boolean;
|
|
28
|
+
acceptsChildren(parent: DocumentNode, children: readonly DocumentNode[]): boolean;
|
|
29
|
+
acceptsRootChildren(children: readonly DocumentNode[]): boolean;
|
|
30
|
+
private validRichText;
|
|
31
|
+
private isColumns;
|
|
32
|
+
private hasContent;
|
|
33
|
+
private hasAnchor;
|
|
34
|
+
create(type: BlockType, id: string, kind: DocumentKind): DocumentNode;
|
|
35
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export declare const IMAGE_SIZE_LIMITS: Readonly<{
|
|
3
|
+
min: 1;
|
|
4
|
+
max: 10000;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const DOCUMENT_STYLE_PROPERTIES: readonly ["font-family", "font-size", "line-height", "color", "background-color"];
|
|
7
|
+
export type DocumentStyleProperty = (typeof DOCUMENT_STYLE_PROPERTIES)[number];
|
|
8
|
+
declare const imageSizeSchema: v.StrictObjectSchema<{
|
|
9
|
+
readonly width: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 10000, undefined>]>;
|
|
10
|
+
readonly height: v.ExactOptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 10000, undefined>]>, undefined>;
|
|
11
|
+
readonly preserveRatio: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
12
|
+
}, undefined>;
|
|
13
|
+
export type ImageSizeSettings = v.InferOutput<typeof imageSizeSchema>;
|
|
14
|
+
/** Canonical bounded presentation settings, independent of adapters. */
|
|
15
|
+
export declare class DocumentPresentationPolicy {
|
|
16
|
+
image(input: unknown): ImageSizeSettings;
|
|
17
|
+
dimension(input: unknown): number;
|
|
18
|
+
safeDimension(input: unknown): number | undefined;
|
|
19
|
+
style(property: unknown, value: unknown): void;
|
|
20
|
+
}
|
|
21
|
+
export {};
|