@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.
Files changed (258) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +8 -0
  4. package/README.md +135 -2
  5. package/THIRD_PARTY_NOTICES.md +21259 -0
  6. package/dist/application/block-placement.d.ts +30 -0
  7. package/dist/application/block-session.d.ts +135 -0
  8. package/dist/application/content-service.d.ts +73 -0
  9. package/dist/application/document-commands.d.ts +51 -0
  10. package/dist/application/document-metadata.d.ts +30 -0
  11. package/dist/application/document-presentation.d.ts +35 -0
  12. package/dist/application/email-insertion.d.ts +76 -0
  13. package/dist/application/host.d.ts +36 -0
  14. package/dist/application/image-link.d.ts +36 -0
  15. package/dist/application/section-layout.d.ts +25 -0
  16. package/dist/application/session.d.ts +128 -0
  17. package/dist/assets/browser-worker-D56tNvnb.js +1014 -0
  18. package/dist/assets/browser-worker-D56tNvnb.js.map +1 -0
  19. package/dist/block-controller-RjYGvOcn.js +2468 -0
  20. package/dist/block-controller-RjYGvOcn.js.map +1 -0
  21. package/dist/block-factory-C5oHi4Fm.js +5397 -0
  22. package/dist/block-factory-C5oHi4Fm.js.map +1 -0
  23. package/dist/blocks/block-checks.d.ts +34 -0
  24. package/dist/blocks/block-inspector.d.ts +55 -0
  25. package/dist/blocks/block-output.d.ts +28 -0
  26. package/dist/blocks/block-type.d.ts +124 -0
  27. package/dist/blocks/content-guard.d.ts +52 -0
  28. package/dist/blocks/conversion.d.ts +22 -0
  29. package/dist/blocks/definitions.d.ts +43 -0
  30. package/dist/blocks/device-styles.d.ts +31 -0
  31. package/dist/blocks/email-generator.d.ts +22 -0
  32. package/dist/blocks/email-preview.d.ts +23 -0
  33. package/dist/blocks/email-renderer.d.ts +20 -0
  34. package/dist/blocks/fields.d.ts +34 -0
  35. package/dist/blocks/page-generator.d.ts +16 -0
  36. package/dist/blocks/render-context.d.ts +58 -0
  37. package/dist/blocks/styles.d.ts +54 -0
  38. package/dist/blocks/types/embed.d.ts +40 -0
  39. package/dist/blocks/types/layout.d.ts +41 -0
  40. package/dist/blocks/types/media.d.ts +53 -0
  41. package/dist/blocks/types/structure.d.ts +44 -0
  42. package/dist/blocks/types/text.d.ts +88 -0
  43. package/dist/blocks/values.d.ts +64 -0
  44. package/dist/browser.js +69 -0
  45. package/dist/browser.js.map +1 -0
  46. package/dist/canvas-runtime/action-bar.d.ts +19 -0
  47. package/dist/canvas-runtime/auto-scroll.d.ts +10 -0
  48. package/dist/canvas-runtime/block-drag.d.ts +29 -0
  49. package/dist/canvas-runtime/bridge.d.ts +6 -0
  50. package/dist/canvas-runtime/context.d.ts +53 -0
  51. package/dist/canvas-runtime/document-sync.d.ts +21 -0
  52. package/dist/canvas-runtime/drop-targets.d.ts +34 -0
  53. package/dist/canvas-runtime/embed-markers.d.ts +15 -0
  54. package/dist/canvas-runtime/file-guard.d.ts +12 -0
  55. package/dist/canvas-runtime/image-tools.d.ts +31 -0
  56. package/dist/canvas-runtime/keyboard.d.ts +18 -0
  57. package/dist/canvas-runtime/main.d.ts +1 -0
  58. package/dist/canvas-runtime/messages.d.ts +26 -0
  59. package/dist/canvas-runtime/morph.d.ts +21 -0
  60. package/dist/canvas-runtime/navigation.d.ts +29 -0
  61. package/dist/canvas-runtime/overlay.d.ts +15 -0
  62. package/dist/canvas-runtime/pointer-intents.d.ts +14 -0
  63. package/dist/canvas-runtime/selection-layer.d.ts +16 -0
  64. package/dist/canvas-runtime/shared/shortcuts.d.ts +27 -0
  65. package/dist/canvas-runtime/text-editor.d.ts +55 -0
  66. package/dist/canvas-runtime/text-session.d.ts +39 -0
  67. package/dist/canvas-runtime/variable-marks.d.ts +20 -0
  68. package/dist/canvas-runtime/viewport.d.ts +10 -0
  69. package/dist/codecs/css.d.ts +74 -0
  70. package/dist/codecs/html.d.ts +81 -0
  71. package/dist/compilation/browser-compiler.d.ts +14 -0
  72. package/dist/compilation/browser-worker.d.ts +1 -0
  73. package/dist/compilation/compile-lanes.d.ts +18 -0
  74. package/dist/compilation/generated-mjml.d.ts +25 -0
  75. package/dist/compilation/guard.d.ts +40 -0
  76. package/dist/compilation/node-compiler.d.ts +17 -0
  77. package/dist/compilation/node-worker.d.ts +1 -0
  78. package/dist/composition/block-factory.d.ts +84 -0
  79. package/dist/composition/browser.d.ts +48 -0
  80. package/dist/composition/factory.d.ts +48 -0
  81. package/dist/composition/server.d.ts +43 -0
  82. package/dist/core/any-document.d.ts +16 -0
  83. package/dist/core/block-document.d.ts +215 -0
  84. package/dist/core/budget.d.ts +32 -0
  85. package/dist/core/canvas-contract.d.ts +29 -0
  86. package/dist/core/canvas-layout.d.ts +66 -0
  87. package/dist/core/catalog.d.ts +35 -0
  88. package/dist/core/document-presentation.d.ts +21 -0
  89. package/dist/core/document.d.ts +99 -0
  90. package/dist/core/history.d.ts +26 -0
  91. package/dist/core/html-content-model.d.ts +32 -0
  92. package/dist/core/html-escape.d.ts +2 -0
  93. package/dist/core/rich-text-format.d.ts +14 -0
  94. package/dist/core/rich-text-markup.d.ts +28 -0
  95. package/dist/core/section-layout.d.ts +83 -0
  96. package/dist/generated-mjml-CtzE-f3v.js +1235 -0
  97. package/dist/generated-mjml-CtzE-f3v.js.map +1 -0
  98. package/dist/identity-CJHb6l9N.js +13759 -0
  99. package/dist/identity-CJHb6l9N.js.map +1 -0
  100. package/dist/renderers/canvas-bridge.d.ts +75 -0
  101. package/dist/renderers/canvas-icons.d.ts +1 -0
  102. package/dist/renderers/canvas-runtime.generated.d.ts +3 -0
  103. package/dist/renderers/element-source.d.ts +13 -0
  104. package/dist/renderers/email-renderer.d.ts +14 -0
  105. package/dist/renderers/marked-preview.d.ts +34 -0
  106. package/dist/renderers/markup-tree.d.ts +36 -0
  107. package/dist/renderers/page-renderer.d.ts +15 -0
  108. package/dist/renderers/preview-document.d.ts +39 -0
  109. package/dist/renderers/preview-frame.d.ts +102 -0
  110. package/dist/renderers/section-scaffold.d.ts +16 -0
  111. package/dist/renderers/selection-preview.d.ts +47 -0
  112. package/dist/rich-text/command-executor.d.ts +26 -0
  113. package/dist/rich-text/commands.d.ts +36 -0
  114. package/dist/rich-text/document-builder.d.ts +52 -0
  115. package/dist/rich-text/formatting.d.ts +17 -0
  116. package/dist/rich-text/projection-export.d.ts +17 -0
  117. package/dist/rich-text/projection-rules.d.ts +13 -0
  118. package/dist/rich-text/schema.d.ts +50 -0
  119. package/dist/rich-text/whitespace.d.ts +7 -0
  120. package/dist/security/bounded-parser.d.ts +18 -0
  121. package/dist/security/conditional-comment.d.ts +30 -0
  122. package/dist/security/content-inventory.d.ts +78 -0
  123. package/dist/security/email-sanitizer.d.ts +36 -0
  124. package/dist/security/identity.d.ts +6 -0
  125. package/dist/security/markup-rules.d.ts +31 -0
  126. package/dist/security/policy.d.ts +61 -0
  127. package/dist/security/preview-message.d.ts +317 -0
  128. package/dist/security/rich-text-projection.d.ts +19 -0
  129. package/dist/security/sha256.d.ts +6 -0
  130. package/dist/security/source-markup.d.ts +53 -0
  131. package/dist/security/text-presentation.d.ts +19 -0
  132. package/dist/security/url-policy.d.ts +23 -0
  133. package/dist/server-worker.js +17 -0
  134. package/dist/server-worker.js.map +1 -0
  135. package/dist/server.js +79 -0
  136. package/dist/server.js.map +1 -0
  137. package/dist/templates/blank-email.d.ts +6 -0
  138. package/dist/templates/blocks/catalog.d.ts +31 -0
  139. package/dist/templates/catalog.d.ts +31 -0
  140. package/dist/visual-editor.css +2 -0
  141. package/dist/vue/block-controller.d.ts +106 -0
  142. package/dist/vue/block-workbench.d.ts +70 -0
  143. package/dist/vue/canvas/canvas-theme.d.ts +8 -0
  144. package/dist/vue/canvas/file-drop.d.ts +38 -0
  145. package/dist/vue/canvas/frame-window.d.ts +26 -0
  146. package/dist/vue/canvas/inline-text.d.ts +98 -0
  147. package/dist/vue/canvas/palette-drag.d.ts +55 -0
  148. package/dist/vue/canvas/piece-requests.d.ts +48 -0
  149. package/dist/vue/canvas/strip-reserve.d.ts +14 -0
  150. package/dist/vue/canvas-content-label.d.ts +5 -0
  151. package/dist/vue/components/BlockVisualEditor.vue.d.ts +44 -0
  152. package/dist/vue/components/CanvasSurface.vue.d.ts +11 -0
  153. package/dist/vue/components/CodeEditor.vue.d.ts +22 -0
  154. package/dist/vue/components/EditorBlockMenus.vue.d.ts +3 -0
  155. package/dist/vue/components/EditorBlockPalette.vue.d.ts +3 -0
  156. package/dist/vue/components/EditorDiagnostics.vue.d.ts +3 -0
  157. package/dist/vue/components/EditorDialogs.vue.d.ts +16 -0
  158. package/dist/vue/components/EditorDocumentMetadata.vue.d.ts +3 -0
  159. package/dist/vue/components/EditorDocumentStyles.vue.d.ts +15 -0
  160. package/dist/vue/components/EditorImageSizeControls.vue.d.ts +23 -0
  161. package/dist/vue/components/EditorLayoutControls.vue.d.ts +16 -0
  162. package/dist/vue/components/EditorLeftPanel.vue.d.ts +3 -0
  163. package/dist/vue/components/EditorNoticeIndicator.vue.d.ts +3 -0
  164. package/dist/vue/components/EditorPreview.vue.d.ts +8 -0
  165. package/dist/vue/components/EditorProperties.vue.d.ts +14 -0
  166. package/dist/vue/components/EditorRichTextControls.vue.d.ts +25 -0
  167. package/dist/vue/components/EditorSelectionPath.vue.d.ts +11 -0
  168. package/dist/vue/components/EditorShortcutHelp.vue.d.ts +3 -0
  169. package/dist/vue/components/EditorSourcePane.vue.d.ts +3 -0
  170. package/dist/vue/components/EditorStructureTree.vue.d.ts +3 -0
  171. package/dist/vue/components/EditorTemplateGallery.vue.d.ts +15 -0
  172. package/dist/vue/components/EditorTopBar.vue.d.ts +33 -0
  173. package/dist/vue/components/RichTextEditor.vue.d.ts +47 -0
  174. package/dist/vue/components/SelectionPreviewFrame.vue.d.ts +212 -0
  175. package/dist/vue/components/VisualEditor.vue.d.ts +53 -0
  176. package/dist/vue/components/blocks/BlockCanvas.vue.d.ts +15 -0
  177. package/dist/vue/components/blocks/BlockFieldControl.vue.d.ts +39 -0
  178. package/dist/vue/components/blocks/BlockGlobalStyles.vue.d.ts +3 -0
  179. package/dist/vue/components/blocks/BlockPalette.vue.d.ts +6 -0
  180. package/dist/vue/components/blocks/BlockProperties.vue.d.ts +5 -0
  181. package/dist/vue/components/blocks/BlockReview.vue.d.ts +5 -0
  182. package/dist/vue/components/properties/EditorPropertyAdvanced.vue.d.ts +8 -0
  183. package/dist/vue/components/properties/EditorPropertyContent.vue.d.ts +13 -0
  184. package/dist/vue/components/properties/EditorPropertyStyle.vue.d.ts +8 -0
  185. package/dist/vue/components/ui/EditorAnchoredMenu.vue.d.ts +36 -0
  186. package/dist/vue/components/ui/EditorBadge.vue.d.ts +18 -0
  187. package/dist/vue/components/ui/EditorButton.vue.d.ts +28 -0
  188. package/dist/vue/components/ui/EditorCheckbox.vue.d.ts +13 -0
  189. package/dist/vue/components/ui/EditorColorInput.vue.d.ts +27 -0
  190. package/dist/vue/components/ui/EditorConfirmDialog.vue.d.ts +35 -0
  191. package/dist/vue/components/ui/EditorContextMenu.vue.d.ts +27 -0
  192. package/dist/vue/components/ui/EditorContextPopover.vue.d.ts +33 -0
  193. package/dist/vue/components/ui/EditorEmpty.vue.d.ts +8 -0
  194. package/dist/vue/components/ui/EditorField.vue.d.ts +24 -0
  195. package/dist/vue/components/ui/EditorGroup.vue.d.ts +16 -0
  196. package/dist/vue/components/ui/EditorIcon.vue.d.ts +6 -0
  197. package/dist/vue/components/ui/EditorIconButton.vue.d.ts +19 -0
  198. package/dist/vue/components/ui/EditorInput.vue.d.ts +41 -0
  199. package/dist/vue/components/ui/EditorKeys.vue.d.ts +6 -0
  200. package/dist/vue/components/ui/EditorMeasurement.vue.d.ts +34 -0
  201. package/dist/vue/components/ui/EditorMenu.vue.d.ts +56 -0
  202. package/dist/vue/components/ui/EditorNotice.vue.d.ts +30 -0
  203. package/dist/vue/components/ui/EditorPropertyGroup.vue.d.ts +22 -0
  204. package/dist/vue/components/ui/EditorRecoveryDialog.vue.d.ts +23 -0
  205. package/dist/vue/components/ui/EditorScrollArea.vue.d.ts +13 -0
  206. package/dist/vue/components/ui/EditorSelect.vue.d.ts +25 -0
  207. package/dist/vue/components/ui/EditorSeparator.vue.d.ts +8 -0
  208. package/dist/vue/components/ui/EditorSidePanel.vue.d.ts +26 -0
  209. package/dist/vue/components/ui/EditorSwitch.vue.d.ts +12 -0
  210. package/dist/vue/components/ui/EditorTabs.vue.d.ts +28 -0
  211. package/dist/vue/components/ui/EditorTemplatePreview.vue.d.ts +9 -0
  212. package/dist/vue/components/ui/EditorTextToolbar.vue.d.ts +16 -0
  213. package/dist/vue/components/ui/EditorTree.vue.d.ts +37 -0
  214. package/dist/vue/components/ui/EditorUiProvider.vue.d.ts +13 -0
  215. package/dist/vue/components/ui/EditorVariablePicker.vue.d.ts +20 -0
  216. package/dist/vue/components/ui/color-style-value.d.ts +9 -0
  217. package/dist/vue/components/ui/composition-dismissal.d.ts +1 -0
  218. package/dist/vue/components/ui/editor-dialog-focus.d.ts +6 -0
  219. package/dist/vue/components/ui/numeric-style-value.d.ts +15 -0
  220. package/dist/vue/controller.d.ts +115 -0
  221. package/dist/vue/font-options.d.ts +6 -0
  222. package/dist/vue/icon-data.d.ts +233 -0
  223. package/dist/vue/icons.d.ts +5 -0
  224. package/dist/vue/locale.d.ts +7 -0
  225. package/dist/vue/outline.d.ts +26 -0
  226. package/dist/vue/projection-key.d.ts +7 -0
  227. package/dist/vue/properties/selection-properties.d.ts +40 -0
  228. package/dist/vue/properties/style-fields.d.ts +30 -0
  229. package/dist/vue/public.d.ts +14 -0
  230. package/dist/vue/recovery.d.ts +30 -0
  231. package/dist/vue/responsive-panel.d.ts +1 -0
  232. package/dist/vue/rich-text-commands.d.ts +29 -0
  233. package/dist/vue/services/block-command-definitions.d.ts +14 -0
  234. package/dist/vue/services/block-commands.d.ts +114 -0
  235. package/dist/vue/services/block-menu.d.ts +12 -0
  236. package/dist/vue/services/block-palette.d.ts +21 -0
  237. package/dist/vue/services/block-presentation.d.ts +16 -0
  238. package/dist/vue/services/diagnostic-groups.d.ts +25 -0
  239. package/dist/vue/services/image-requests.d.ts +80 -0
  240. package/dist/vue/services/live-change.d.ts +26 -0
  241. package/dist/vue/services/property-commands.d.ts +28 -0
  242. package/dist/vue/services/saved-blocks.d.ts +32 -0
  243. package/dist/vue/services/selection-path.d.ts +20 -0
  244. package/dist/vue/services/shortcuts.d.ts +39 -0
  245. package/dist/vue/services/structure-tree.d.ts +38 -0
  246. package/dist/vue/services/template-application.d.ts +33 -0
  247. package/dist/vue/services/tree-drag.d.ts +28 -0
  248. package/dist/vue/session/blocks.d.ts +44 -0
  249. package/dist/vue/session/guard.d.ts +13 -0
  250. package/dist/vue/session/structure.d.ts +36 -0
  251. package/dist/vue/session/text.d.ts +23 -0
  252. package/dist/vue/session/transfer.d.ts +23 -0
  253. package/dist/vue/theme.d.ts +20 -0
  254. package/dist/vue/variables.d.ts +21 -0
  255. package/dist/vue/workbench.d.ts +100 -0
  256. package/dist/vue.js +71418 -0
  257. package/dist/vue.js.map +1 -0
  258. package/package.json +125 -4
@@ -0,0 +1,99 @@
1
+ import * as v from 'valibot';
2
+ import type { HtmlNodeType } from './html-content-model';
3
+ export type DocumentKind = 'email' | 'page';
4
+ export type EditorMode = 'visual' | 'html';
5
+ export interface NodeMetadata {
6
+ readonly blockType?: string;
7
+ readonly sourceStart?: number;
8
+ readonly sourceEnd?: number;
9
+ readonly namespace?: string;
10
+ /**
11
+ * How a comment was written: `<!--` for a regular comment, or the opener of the bogus
12
+ * comment the parser read (`<![if !mso]>`, `<?xml ... ?>`, `</3>`). Absent on old documents.
13
+ */
14
+ readonly commentOpener?: CommentOpener;
15
+ }
16
+ export type CommentOpener = '<!--' | '<!' | '<?' | '</';
17
+ export interface DocumentNode {
18
+ readonly id: string;
19
+ readonly type: HtmlNodeType;
20
+ readonly tag?: string;
21
+ readonly value?: string;
22
+ readonly attrs?: Readonly<Record<string, string>>;
23
+ readonly children?: readonly DocumentNode[];
24
+ readonly metadata?: NodeMetadata;
25
+ }
26
+ export interface EditorDocumentData {
27
+ readonly schemaVersion: 1;
28
+ readonly id: string;
29
+ readonly kind: DocumentKind;
30
+ readonly revision: number;
31
+ readonly title: string;
32
+ readonly nodes: readonly DocumentNode[];
33
+ readonly css: string;
34
+ }
35
+ export interface SourceInput {
36
+ readonly html: string;
37
+ readonly css: string;
38
+ }
39
+ /**
40
+ * `error` refuses the operation. `warning` tells the author something was removed or
41
+ * rewritten. `info` describes what the document holds and was kept as written.
42
+ */
43
+ export type DiagnosticSeverity = 'error' | 'warning' | 'info';
44
+ export interface Diagnostic {
45
+ readonly code: string;
46
+ readonly severity: DiagnosticSeverity;
47
+ readonly messageKey: string;
48
+ /** First node the notice refers to, when it still exists in the document. */
49
+ readonly nodeId?: string;
50
+ /** Occurrences grouped under this code; absent means one. */
51
+ readonly count?: number;
52
+ }
53
+ export interface ImportResult {
54
+ readonly document?: EditorDocumentData;
55
+ readonly diagnostics: readonly Diagnostic[];
56
+ /**
57
+ * The validated aggregate `document` was read from, when the codec has it: a policy given it
58
+ * checks the content again without parsing the schema a second time.
59
+ */
60
+ readonly validated?: EditorDocument;
61
+ }
62
+ export declare const DOCUMENT_LIMITS: Readonly<{
63
+ nodes: 50000;
64
+ totalNodes: 150000;
65
+ depth: 256;
66
+ sourceBytes: 2000000;
67
+ cssBytes: 500000;
68
+ jsonBytes: 64000000;
69
+ attributesPerNode: 256;
70
+ attributeLength: 16384;
71
+ documentAttributeLength: 2000000;
72
+ }>;
73
+ /** Every element the HTML parser and serializer treat as void, obsolete ones included. */
74
+ export declare const HTML_VOID_ELEMENTS: readonly string[];
75
+ export declare const DocumentNodeSchema: v.GenericSchema<DocumentNode>;
76
+ export declare const EditorDocumentSchema: v.GenericSchema<EditorDocumentData>;
77
+ export declare class DocumentValidationError extends Error {
78
+ readonly code: string;
79
+ constructor(code: string);
80
+ }
81
+ /** The aggregate owns a validated snapshot. Callers only receive independent copies. */
82
+ export declare class EditorDocument {
83
+ #private;
84
+ private constructor();
85
+ static from(data: unknown): EditorDocument;
86
+ get id(): string;
87
+ get kind(): DocumentKind;
88
+ get revision(): number;
89
+ snapshot(): EditorDocumentData;
90
+ withChanges(change: Partial<Pick<EditorDocumentData, 'title' | 'nodes' | 'css'>>): EditorDocument;
91
+ /** UTF-8 size of the serialized snapshot, for budgets which bound what is retained. */
92
+ serializedBytes(): number;
93
+ /** Only the revision changes: the validated tree is not parsed a second time. */
94
+ withRevision(revision: number): EditorDocument;
95
+ private clone;
96
+ private static assertBounded;
97
+ private static normalizeText;
98
+ private static assertTree;
99
+ }
@@ -0,0 +1,26 @@
1
+ import type { EditorDocument } from './document';
2
+ /** What a history keeps: an immutable, validated document which knows its serialized size. */
3
+ export interface HistoryEntry {
4
+ serializedBytes(): number;
5
+ }
6
+ /**
7
+ * One history per editing session. A new branch discards only the redo branch. The HTML
8
+ * document (schema 1) and the block piece (schema 2) use the same history.
9
+ */
10
+ export declare class DocumentHistory<T extends HistoryEntry = EditorDocument> {
11
+ #private;
12
+ /**
13
+ * A document inside the import limits can serialize to about 30 MB of JSON, and its history
14
+ * has to hold it at least twice.
15
+ */
16
+ constructor(maxEntries?: number, maxBytes?: number);
17
+ get canUndo(): boolean;
18
+ get canRedo(): boolean;
19
+ get size(): number;
20
+ get retainedBytes(): number;
21
+ push(document: T): void;
22
+ current(): T | undefined;
23
+ undo(): T | undefined;
24
+ redo(): T | undefined;
25
+ reset(document?: T): void;
26
+ }
@@ -0,0 +1,32 @@
1
+ export type HtmlNodeType = 'element' | 'text' | 'comment' | 'doctype';
2
+ export interface HtmlContentNode {
3
+ readonly type: HtmlNodeType;
4
+ readonly tag?: string;
5
+ readonly value?: string;
6
+ }
7
+ /** Structural constraints prevent HTML parsers from silently relocating or dropping nodes. */
8
+ export declare class HtmlContentModel {
9
+ private readonly requiredParents;
10
+ private readonly structuralChildren;
11
+ /** Parents the HTML parser itself guarantees; anything else it accepts where it was written. */
12
+ private readonly parserParents;
13
+ /** Children the parser leaves inside these parents instead of moving them elsewhere. */
14
+ private readonly parserChildren;
15
+ /** HTML elements whose content the tokenizer reads as text, never as markup. */
16
+ private readonly rawText;
17
+ /**
18
+ * Whether a tree an HTML parser produced may hold this child. It is the integrity rule of
19
+ * a stored document: looser than `accepts`, which governs what editing commands may build.
20
+ */
21
+ parses(parentTag: string | undefined, child: HtmlContentNode): boolean;
22
+ /**
23
+ * Elements whose single text child is their source, written back verbatim: the raw text
24
+ * elements of HTML, `template`, and whole inline `svg` / `math` islands.
25
+ */
26
+ holdsSource(tag: string): boolean;
27
+ /** Markup kept as an opaque block of source rather than as a subtree. */
28
+ isSourceIsland(tag: string): boolean;
29
+ accepts(parentTag: string | undefined, child: HtmlContentNode): boolean;
30
+ acceptsChildren(parentTag: string, children: readonly HtmlContentNode[]): boolean;
31
+ isStructuralContainer(tag: string): boolean;
32
+ }
@@ -0,0 +1,2 @@
1
+ /** Escapes a value for an HTML text node or a double-quoted attribute. */
2
+ export declare function escapeHtml(value: string): string;
@@ -0,0 +1,14 @@
1
+ export declare const RICH_TEXT_FORMATS: readonly ["bold", "italic", "underline", "strike", "link"];
2
+ export type RichTextFormat = (typeof RICH_TEXT_FORMATS)[number];
3
+ export type RichTextDecorationLine = 'underline' | 'line-through';
4
+ export declare const RICH_TEXT_ORIGIN_ATTRIBUTE = "data-editor-rich-origin";
5
+ export declare const RICH_TEXT_REMOVED_ATTRIBUTE = "data-editor-rich-removed";
6
+ /** Canonical semantic-mark removal transitions and their fixed visual resets. */
7
+ export declare class RichTextFormatPolicy {
8
+ formatForTag(tag: string | undefined): RichTextFormat | undefined;
9
+ isFormat(value: unknown): value is RichTextFormat;
10
+ canRemove(originalTag: string | undefined, replacementTag: string | undefined, format: unknown): boolean;
11
+ resets(format: RichTextFormat): Readonly<Record<string, string>>;
12
+ decorationFor(format: RichTextFormat): RichTextDecorationLine | undefined;
13
+ removedAttributes(format: RichTextFormat): readonly string[];
14
+ }
@@ -0,0 +1,28 @@
1
+ import type { DocumentNode } from './document';
2
+ /**
3
+ * `block`: paragraphs, lists, headings and quotes (the HTML document and the text and footer
4
+ * blocks). `inline`: one line of formatted text with links (heading block). `button`: formatted
5
+ * text without links, since the button is the link.
6
+ */
7
+ export type RichTextMode = 'block' | 'inline' | 'button';
8
+ export type RichTextMarkupViolation = 'tag' | 'attribute' | 'style' | 'node';
9
+ export interface RichTextMarkupCheck {
10
+ /** Attributes the caller adds to every element, e.g. the origin marks of schema 1. */
11
+ readonly extraAttributes?: readonly string[];
12
+ /** Whether a `style` attribute holds only the declarations a rich text may carry. */
13
+ style(value: string): boolean;
14
+ /** A further rule for one element; false makes the tree invalid. */
15
+ element?(node: DocumentNode): boolean;
16
+ }
17
+ /**
18
+ * The single rule of the markup a rich-text projection may hold once it is imported: which
19
+ * elements each mode accepts and which attributes each element keeps. The in-place editing of
20
+ * the HTML document (schema 1) and the texts of the block pieces (schema 2) both apply it.
21
+ */
22
+ export declare class RichTextMarkup {
23
+ tags(mode: RichTextMode): ReadonlySet<string>;
24
+ /** The attributes an element of the projection keeps besides `style`. */
25
+ semanticAttributes(tag: string): readonly string[];
26
+ /** The first rule the tree breaks, or undefined when all of it follows the mode. */
27
+ violation(nodes: readonly DocumentNode[], mode: RichTextMode, check: RichTextMarkupCheck): RichTextMarkupViolation | undefined;
28
+ }
@@ -0,0 +1,83 @@
1
+ import * as v from 'valibot';
2
+ import type { DocumentKind, DocumentNode, EditorDocumentData } from './document';
3
+ export declare const SECTION_LAYOUT_LIMITS: Readonly<{
4
+ columns: 4;
5
+ weight: 12;
6
+ }>;
7
+ export declare const SECTION_STACKING: readonly ["normal", "reverse", "none"];
8
+ export declare const SECTION_BREAKPOINTS: readonly [480, 640, 768];
9
+ export declare const SECTION_LAYOUT_PRESETS: readonly [{
10
+ readonly id: "single";
11
+ readonly ratios: readonly [1];
12
+ readonly titleKey: "properties.oneColumn";
13
+ }, {
14
+ readonly id: "equal2";
15
+ readonly ratios: readonly [1, 1];
16
+ readonly titleKey: "properties.twoColumns";
17
+ }, {
18
+ readonly id: "wideLeft";
19
+ readonly ratios: readonly [2, 1];
20
+ readonly titleKey: "properties.widerLeft";
21
+ }, {
22
+ readonly id: "wideRight";
23
+ readonly ratios: readonly [1, 2];
24
+ readonly titleKey: "properties.widerRight";
25
+ }, {
26
+ readonly id: "equal3";
27
+ readonly ratios: readonly [1, 1, 1];
28
+ readonly titleKey: "properties.threeColumns";
29
+ }, {
30
+ readonly id: "equal4";
31
+ readonly ratios: readonly [1, 1, 1, 1];
32
+ readonly titleKey: "properties.fourColumns";
33
+ }];
34
+ export type SectionStacking = (typeof SECTION_STACKING)[number];
35
+ export type SectionBreakpoint = (typeof SECTION_BREAKPOINTS)[number];
36
+ export type SectionLayoutReason = 'unsupported-structure' | 'invalid-settings' | 'column-not-empty' | 'identity-bearing-column' | 'readonly' | 'unavailable';
37
+ export interface SectionLayoutSettings {
38
+ readonly ratios: readonly number[];
39
+ readonly stacking: SectionStacking;
40
+ readonly breakpoint: SectionBreakpoint;
41
+ }
42
+ export interface SectionLayoutPatch {
43
+ readonly ratios?: readonly number[];
44
+ readonly stacking?: SectionStacking;
45
+ readonly breakpoint?: SectionBreakpoint;
46
+ }
47
+ export interface SectionLayoutContext extends SectionLayoutSettings {
48
+ readonly id: string;
49
+ readonly kind: DocumentKind;
50
+ readonly columnIds: readonly string[];
51
+ readonly removableColumnIds: readonly string[];
52
+ readonly editable: boolean;
53
+ readonly reason?: SectionLayoutReason;
54
+ }
55
+ export interface SectionLayoutProjection {
56
+ readonly section: DocumentNode;
57
+ readonly columns: readonly DocumentNode[];
58
+ readonly contentParent?: DocumentNode;
59
+ readonly shell?: readonly DocumentNode[];
60
+ }
61
+ export declare const SectionLayoutSettingsSchema: v.StrictObjectSchema<{
62
+ readonly ratios: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 12, undefined>]>, undefined>, v.MinLengthAction<number[], 1, undefined>, v.MaxLengthAction<number[], 4, undefined>]>;
63
+ readonly stacking: v.PicklistSchema<readonly ["normal", "reverse", "none"], undefined>;
64
+ readonly breakpoint: v.PicklistSchema<readonly [480, 640, 768], undefined>;
65
+ }, undefined>;
66
+ export declare const SectionLayoutPatchSchema: v.StrictObjectSchema<{
67
+ readonly ratios: v.ExactOptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 12, undefined>]>, undefined>, v.MinLengthAction<number[], 1, undefined>, v.MaxLengthAction<number[], 4, undefined>]>, undefined>;
68
+ readonly stacking: v.ExactOptionalSchema<v.PicklistSchema<readonly ["normal", "reverse", "none"], undefined>, undefined>;
69
+ readonly breakpoint: v.ExactOptionalSchema<v.PicklistSchema<readonly [480, 640, 768], undefined>, undefined>;
70
+ }, undefined>;
71
+ /** Structural projection only: an imported marker never grants a mutation by itself. */
72
+ export declare class SectionLayoutPolicy {
73
+ hasClass(node: DocumentNode, name: string): boolean;
74
+ projection(document: EditorDocumentData, id: string): SectionLayoutProjection | undefined;
75
+ columnBody(column: DocumentNode): DocumentNode | undefined;
76
+ context(document: EditorDocumentData, id: string): SectionLayoutContext | undefined;
77
+ removalReason(column: DocumentNode, kind: DocumentKind): SectionLayoutReason | undefined;
78
+ settings(current: SectionLayoutContext, patch: SectionLayoutPatch): SectionLayoutSettings;
79
+ attributes(settings: SectionLayoutSettings): Readonly<Record<string, string>>;
80
+ elements(node: DocumentNode): readonly DocumentNode[];
81
+ private onlyElement;
82
+ private path;
83
+ }