@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,34 @@
1
+ import type { BlockDocumentView } from './block-type';
2
+ /** What the review before sending or publishing points out. */
3
+ export type BlockCheckCode = 'PIECE_EMPTY' | 'LINK_EMPTY' | 'BUTTON_WITHOUT_LINK' | 'BUTTON_WITHOUT_TEXT' | 'IMAGE_WITHOUT_SOURCE' | 'IMAGE_WITHOUT_ALT' | 'HIDDEN_ON_EVERY_SCREEN' | 'EMAIL_NEAR_CLIP' | 'EMAIL_CLIPPED';
4
+ export interface BlockCheck {
5
+ readonly code: BlockCheckCode;
6
+ /** `error`: the reader meets something broken; `warning`: worth a look before sending. */
7
+ readonly severity: 'error' | 'warning';
8
+ /** The block to show; absent for a finding about the whole piece. */
9
+ readonly blockId?: string;
10
+ /** Size of the e-mail in kilobytes, for the size findings. */
11
+ readonly kilobytes?: number;
12
+ }
13
+ /** Gmail shows only the first 102 KB of the HTML of a message and hides the rest behind a link. */
14
+ export declare const GMAIL_CLIP_BYTES: number;
15
+ /**
16
+ * Below the cut, but close: the host still adds its own markup (footer, tracking) to what the
17
+ * editor generates.
18
+ */
19
+ export declare const GMAIL_NEAR_CLIP_BYTES: number;
20
+ /**
21
+ * The review of a block piece before it goes out: links that lead nowhere, images without an
22
+ * address or a description, buttons without text or link, blocks hidden on every screen and,
23
+ * for an e-mail whose final HTML is given, a size Gmail would cut. It reads the piece, never
24
+ * changes it, and works the same in the editor and in the host.
25
+ */
26
+ export declare class BlockChecker {
27
+ check(document: BlockDocumentView, finalHtml?: string): readonly BlockCheck[];
28
+ private block;
29
+ private filled;
30
+ /** An address that leads somewhere: not empty, not only `#`. */
31
+ private link;
32
+ /** A link of the text whose address is missing, empty or only `#`. */
33
+ private emptyAnchor;
34
+ }
@@ -0,0 +1,55 @@
1
+ import type { BlockDevice, BlockDocumentData, BlockPropValue } from '../core/block-document';
2
+ import type { FieldControl, FieldOption, FieldTab } from './block-type';
3
+ import type { BlockDefinitionRegistry } from './definitions';
4
+ import type { StyleKeySpec, StylePath } from './styles';
5
+ /** One property of the selected block, as the properties panel shows it. */
6
+ export interface BlockFieldModel {
7
+ readonly key: string;
8
+ readonly tab: FieldTab;
9
+ readonly control: FieldControl;
10
+ readonly labelKey: string;
11
+ readonly options: readonly FieldOption[];
12
+ /** The value the block sets; undefined while it inherits. */
13
+ readonly own: BlockPropValue | undefined;
14
+ /** What the output uses: the block's value, else the global style, else the default. */
15
+ readonly effective: BlockPropValue | undefined;
16
+ /** The global style the value comes from while the block does not set it. */
17
+ readonly inherits: StylePath | undefined;
18
+ /** The field may take a value of its own on small screens. */
19
+ readonly responsive: boolean;
20
+ /** The screen this model shows. On mobile, `own` is the mobile value of a responsive field. */
21
+ readonly device: BlockDevice;
22
+ /** The block sets a mobile value for this field (shown on both screens). */
23
+ readonly mobileOverride: boolean;
24
+ }
25
+ export interface GlobalStyleKeyModel {
26
+ readonly group: string;
27
+ readonly key: string;
28
+ readonly labelKey: string;
29
+ readonly control: StyleKeySpec['control'];
30
+ readonly options: readonly FieldOption[];
31
+ readonly value: string;
32
+ readonly overridden: boolean;
33
+ }
34
+ export interface GlobalStyleGroupModel {
35
+ readonly group: string;
36
+ readonly labelKey: string;
37
+ readonly keys: readonly GlobalStyleKeyModel[];
38
+ }
39
+ /**
40
+ * Reads a block piece the way the panels show it: the fields of a block by its definition,
41
+ * with the inherited and default values resolved, and the global styles of its kind. The
42
+ * panels are generated from this, never written per block type.
43
+ */
44
+ export declare class BlockInspector {
45
+ private readonly registry;
46
+ constructor(registry: BlockDefinitionRegistry);
47
+ /**
48
+ * The fields of a block. On mobile a responsive field shows its mobile value, and while it
49
+ * has none the value every screen uses, as what it inherits.
50
+ */
51
+ fields(document: BlockDocumentData, id: string, device?: BlockDevice): readonly BlockFieldModel[];
52
+ styles(document: Pick<BlockDocumentData, 'kind' | 'styles'>): readonly GlobalStyleGroupModel[];
53
+ private field;
54
+ private find;
55
+ }
@@ -0,0 +1,28 @@
1
+ import type { BlockDocument } from '../core/block-document';
2
+ import type { SourceInput } from '../core/document';
3
+ import type { CanvasBridgeRegion } from '../renderers/canvas-bridge';
4
+ import type { BlockPreviewInput } from '../renderers/marked-preview';
5
+ import type { BlockDefinitionRegistry } from './definitions';
6
+ import type { BlockEmailRenderer } from './email-renderer';
7
+ import type { BlockPageGenerator } from './page-generator';
8
+ /**
9
+ * The two outputs of a block piece, by kind: the final one the host stores, sends or publishes
10
+ * (the compiled e-mail, or the HTML and CSS of the page), and the marked preview of the editing
11
+ * frame with the regions of its blocks.
12
+ */
13
+ export declare class BlockOutputRenderer {
14
+ private readonly registry;
15
+ private readonly pages;
16
+ private readonly emails;
17
+ /** The e-mail renderer of the editing frame; its compiler may queue apart from the final one. */
18
+ private readonly previewEmails;
19
+ constructor(registry: BlockDefinitionRegistry, pages: BlockPageGenerator, emails: BlockEmailRenderer,
20
+ /** The e-mail renderer of the editing frame; its compiler may queue apart from the final one. */
21
+ previewEmails?: BlockEmailRenderer);
22
+ /** What is sent or published. */
23
+ render(document: BlockDocument): Promise<SourceInput>;
24
+ /** The marked markup of the editing frame and the regions of the blocks, in document order. */
25
+ preview(document: BlockDocument): Promise<BlockPreviewInput>;
26
+ /** What the frame runtime needs of each block: place, text mode, container, image. */
27
+ regions(document: Pick<BlockDocument, 'blocks'>): readonly CanvasBridgeRegion[];
28
+ }
@@ -0,0 +1,124 @@
1
+ import type { Block, BlockDocumentData, BlockNodeType, BlockPropValue, BlockProps } from '../core/block-document';
2
+ import type { DocumentKind } from '../core/document';
3
+ import type { GlobalStyleSpec, StylePath, StyleResolver } from './styles';
4
+ import type { ValueSpec } from './values';
5
+ /** What the generators read of a piece: a `BlockDocument` or its validated data. */
6
+ export type BlockDocumentView = Pick<BlockDocumentData, 'kind' | 'meta' | 'styles' | 'blocks'>;
7
+ /** The definitions the generators need; implemented by `BlockDefinitionRegistry`. */
8
+ export interface BlockTypeCatalog {
9
+ readonly styles: GlobalStyleSpec;
10
+ definition(type: BlockNodeType): BlockTypeDefinition;
11
+ }
12
+ /** `preview` feeds the editing frame; `final` is what is sent or published. */
13
+ export type OutputMode = 'preview' | 'final';
14
+ export type FieldTab = 'content' | 'style' | 'advanced';
15
+ export type FieldControl = 'text'
16
+ /** Markup on several lines (the free HTML block), edited in the code editor of the shell. */
17
+ | 'code' | 'richtext' | 'color' | 'length' | 'select' | 'image' | 'link' | 'toggle';
18
+ export interface FieldOption {
19
+ readonly value: string;
20
+ readonly labelKey: string;
21
+ }
22
+ /** One property of a block as the properties panel shows it and the generators read it. */
23
+ export interface BlockField {
24
+ readonly key: string;
25
+ readonly tab: FieldTab;
26
+ readonly control: FieldControl;
27
+ readonly labelKey: string;
28
+ readonly value: ValueSpec;
29
+ /** The global style this property inherits while the block does not set it. */
30
+ readonly inherits?: StylePath;
31
+ /** Value used while neither the block nor a global style says otherwise. */
32
+ readonly defaultValue?: BlockPropValue;
33
+ readonly options?: readonly FieldOption[];
34
+ readonly required?: boolean;
35
+ /** Hidden from the panel: set together with another field (e.g. the asset of an image). */
36
+ readonly internal?: boolean;
37
+ /**
38
+ * The field may take a value of its own on small screens. A page writes it with `css`
39
+ * inside the mobile rule; an e-mail only where the definition says how (`mobileEmail`).
40
+ */
41
+ readonly responsive?: boolean;
42
+ /** MJML attribute written when the block overrides the value. */
43
+ readonly mjml?: {
44
+ readonly attribute: string;
45
+ readonly map?: Readonly<Record<string, string>>;
46
+ };
47
+ /** CSS declaration written in `.ve-<id>` when the block overrides the value. */
48
+ readonly css?: {
49
+ readonly property: string;
50
+ readonly target?: 'self' | 'inner';
51
+ readonly map?: Readonly<Record<string, string>>;
52
+ };
53
+ }
54
+ interface RenderContext {
55
+ readonly block: Block;
56
+ readonly kind: DocumentKind;
57
+ readonly mode: OutputMode;
58
+ readonly styles: StyleResolver;
59
+ /** The block's own value, else the inherited global style, else the field default. */
60
+ value(key: string): BlockPropValue | undefined;
61
+ /** Markup of the children, in order (reversed when asked). */
62
+ children(reverse?: boolean): string;
63
+ }
64
+ export interface EmailBlockContext extends RenderContext {
65
+ /** Width of a column within its section, e.g. `50%`. */
66
+ readonly columnWidth?: string | undefined;
67
+ /**
68
+ * ` name="value"` pairs: overridden fields mapped to MJML, the extra pairs given here and,
69
+ * in preview, the `css-class` of `previewClass()`. Values are escaped.
70
+ */
71
+ attributes(extra?: Readonly<Record<string, string | undefined>>): string;
72
+ /** Registers a raw region of generated, sanitized markup and returns its `mj-raw`. */
73
+ raw(fragment: string): string;
74
+ /** In preview, the class the preview marker looks for; undefined otherwise. */
75
+ previewClass(): string | undefined;
76
+ /**
77
+ * Every class of the cell of the block: the preview class, the device classes (hidden on a
78
+ * screen, mobile values) and nothing else; undefined when there is none.
79
+ */
80
+ cellClass(): string | undefined;
81
+ }
82
+ export interface PageBlockContext extends RenderContext {
83
+ /** ` class="<base> ve-b-<id>"`. */
84
+ classes(base: string): string;
85
+ /** In preview, the canvas attribute of a selectable block; empty otherwise. */
86
+ node(): string;
87
+ /** In preview, the canvas attribute of the element whose text is edited in place. */
88
+ editable(): string;
89
+ /** Adds a structural rule for this block, e.g. the grid of a section. */
90
+ rule(selectorSuffix: string, declarations: string): void;
91
+ /** The same, only on small screens. */
92
+ mobileRule(selectorSuffix: string, declarations: string): void;
93
+ }
94
+ /**
95
+ * How an e-mail writes the mobile value of a field: CSS rules for the cell `.ve-m-<id>` that
96
+ * MJML gives the block (`''` is the cell itself, `'>div'` its text, `' a'` the link of a
97
+ * button), each with the properties to set (by default the CSS property of the field).
98
+ */
99
+ export interface MobileEmailRule {
100
+ readonly selectors: readonly string[];
101
+ readonly properties?: readonly string[];
102
+ }
103
+ /** What one block type is: its place in the tree, its fields and its two generators. */
104
+ export interface BlockTypeDefinition {
105
+ readonly type: BlockNodeType;
106
+ readonly labelKey: string;
107
+ readonly kinds: readonly DocumentKind[];
108
+ readonly root?: boolean;
109
+ readonly childTypes: readonly BlockNodeType[];
110
+ readonly childCount: {
111
+ readonly min: number;
112
+ readonly max: number;
113
+ };
114
+ readonly fields: readonly BlockField[];
115
+ /** CSS selector, relative to `.ve-b-<id>`, of the element `inner` overrides apply to. */
116
+ readonly innerSelector?: string;
117
+ /** By field key: how an e-mail writes its mobile value. A field absent here has none. */
118
+ readonly mobileEmail?: Readonly<Partial<Record<string, MobileEmailRule>>>;
119
+ /** A new block of this type with the given values. */
120
+ create(nextId: () => string, props?: BlockProps): Block;
121
+ email?(context: EmailBlockContext): string;
122
+ page(context: PageBlockContext): string;
123
+ }
124
+ export {};
@@ -0,0 +1,52 @@
1
+ import type { DocumentKind } from '../core/document';
2
+ import { UrlPolicy } from '../security/url-policy';
3
+ import type { UrlPurpose } from '../security/url-policy';
4
+ import type { RichTextMode } from '../core/rich-text-markup';
5
+ /**
6
+ * The content rules of the texts, links and free HTML a block carries. A text is the rich
7
+ * text projection the in-place editing protocol already transports: it is accepted only when
8
+ * it is a fixed point of `RichTextProjection`, imports without any notice other than `info`,
9
+ * is writable under `ContentPolicy.writable` and uses only the tags and attributes of its
10
+ * mode. A free HTML block of an e-mail is refused when the e-mail rules would remove anything.
11
+ */
12
+ export declare class BlockContentGuard {
13
+ #private;
14
+ constructor(urls?: UrlPolicy);
15
+ acceptsUrl(value: string, purpose: UrlPurpose): boolean;
16
+ /** The settled projection of a text; throws `INVALID_BLOCK_TEXT` when it has none. */
17
+ normalizeText(value: string, mode: RichTextMode, kind: DocumentKind): string;
18
+ acceptsText(value: string, mode: RichTextMode, kind: DocumentKind): boolean;
19
+ /** Balanced markup as the parser reads it back; nothing is removed here. */
20
+ normalizeHtml(value: string): string;
21
+ acceptsHtml(value: string, kind: DocumentKind): boolean;
22
+ /**
23
+ * Every element as a browser without scripting reads it (inside SVG, `noscript` and
24
+ * `template` too): no generated class, no element which swallows the rest of the output
25
+ * and, in an e-mail, nothing that redirects it or renders markup as text.
26
+ */
27
+ private authorElements;
28
+ /**
29
+ * The only external style resources an e-mail may load are Google Fonts: style sheets from
30
+ * `fonts.googleapis.com` and font files from `fonts.gstatic.com`.
31
+ */
32
+ private emailResources;
33
+ /** The document a fragment imports as, when the codec reads it with nothing but `info`. */
34
+ private inspected;
35
+ private projectionNodes;
36
+ /**
37
+ * One line: paragraphs become line breaks and, for a button, links become their text. The
38
+ * result is projected again, so it is a fixed point.
39
+ */
40
+ private flatten;
41
+ private unwrapLinks;
42
+ /**
43
+ * Results by kind, mode and SHA-256 of the value: the cache keeps 2.000 short keys, never
44
+ * the texts themselves (an HTML block may have hundreds of kilobytes).
45
+ */
46
+ private cached;
47
+ /** Entries currently held and the characters of their keys, for the bound on memory. */
48
+ cacheFootprint(): {
49
+ readonly entries: number;
50
+ readonly keyCharacters: number;
51
+ };
52
+ }
@@ -0,0 +1,22 @@
1
+ import type { BlockDocument } from '../core/block-document';
2
+ import type { Diagnostic, EditorDocumentData } from '../core/document';
3
+ import type { HtmlDocumentCodec } from '../codecs/html';
4
+ import type { BlockEmailRenderer } from './email-renderer';
5
+ import type { BlockPageGenerator } from './page-generator';
6
+ export declare class BlockConversionError extends Error {
7
+ readonly diagnostics: readonly Diagnostic[];
8
+ constructor(diagnostics: readonly Diagnostic[]);
9
+ }
10
+ /**
11
+ * "Convert to editable HTML": one way only, from a block piece (schema 2) to the HTML document
12
+ * of the editor (schema 1), made of the final output of the generators. Nothing converts back.
13
+ * The new document keeps the id and the title; its revision follows the block piece, so a
14
+ * host saving it over the same record moves forward.
15
+ */
16
+ export declare class BlockToHtmlConversion {
17
+ private readonly codec;
18
+ private readonly email;
19
+ private readonly page;
20
+ constructor(codec: HtmlDocumentCodec, email: BlockEmailRenderer, page: BlockPageGenerator);
21
+ convert(document: BlockDocument): Promise<EditorDocumentData>;
22
+ }
@@ -0,0 +1,43 @@
1
+ import type { Block, BlockDocumentData, BlockNodeType, BlockPropValue, BlockProps, BlockRules, GlobalStyles, StyleValue } from '../core/block-document';
2
+ import type { DocumentKind } from '../core/document';
3
+ import type { BlockField, BlockTypeCatalog, BlockTypeDefinition } from './block-type';
4
+ import { BlockContentGuard } from './content-guard';
5
+ import { GlobalStyleSpec } from './styles';
6
+ export declare function defaultBlockTypes(): readonly BlockTypeDefinition[];
7
+ export declare class BlockDefinitionRegistry implements BlockRules, BlockTypeCatalog {
8
+ #private;
9
+ readonly styles: GlobalStyleSpec;
10
+ constructor(content?: BlockContentGuard, styles?: GlobalStyleSpec, types?: readonly BlockTypeDefinition[]);
11
+ definition(type: BlockNodeType): BlockTypeDefinition;
12
+ /** The types an author may insert in a piece of this kind. */
13
+ list(kind: DocumentKind): readonly BlockTypeDefinition[];
14
+ field(type: BlockNodeType, key: string): BlockField | undefined;
15
+ /** A new block; the document validates it when it is inserted. */
16
+ create(type: BlockNodeType, nextId: () => string, props?: BlockProps): Block;
17
+ isRoot(type: BlockNodeType): boolean;
18
+ childTypes(type: BlockNodeType): readonly BlockNodeType[];
19
+ childCount(type: BlockNodeType): {
20
+ readonly min: number;
21
+ readonly max: number;
22
+ };
23
+ allows(type: BlockNodeType, kind: DocumentKind): boolean;
24
+ validateProps(type: BlockNodeType, props: BlockProps, kind: DocumentKind): string | undefined;
25
+ normalizeProp(type: BlockNodeType, key: string, value: BlockPropValue, kind: DocumentKind): BlockPropValue;
26
+ textKeys(type: BlockNodeType): readonly string[];
27
+ /**
28
+ * A field with a mobile value: marked responsive and written by the output of the kind (CSS
29
+ * in a page, a mobile rule of the definition in an e-mail).
30
+ */
31
+ responsive(type: BlockNodeType, key: string, kind: DocumentKind): boolean;
32
+ validateStyles(styles: GlobalStyles, kind: DocumentKind): string | undefined;
33
+ normalizeStyle(group: string, key: string, value: StyleValue, kind: DocumentKind): StyleValue;
34
+ /**
35
+ * The output of the piece must fit what consumes it: the MJML of an e-mail (preview, the
36
+ * larger of the two) within the compilation limit, and the HTML and CSS of a page within
37
+ * the source limits of the HTML document a conversion would create.
38
+ */
39
+ validateDocument(data: BlockDocumentData): string | undefined;
40
+ /** Every label key the definitions and the global styles refer to. */
41
+ labelKeys(): readonly string[];
42
+ private refusal;
43
+ }
@@ -0,0 +1,31 @@
1
+ import type { Block, BlockPropValue } from '../core/block-document';
2
+ import type { BlockField, BlockTypeDefinition, OutputMode } from './block-type';
3
+ /** Which device classes a piece uses, so the generators write only the rules it needs. */
4
+ export interface DeviceUsage {
5
+ hideDesktop: boolean;
6
+ hideMobile: boolean;
7
+ }
8
+ /**
9
+ * A CSS value written from a block value. The values were already checked by their field
10
+ * (lengths, colors, choices); this refuses anything that could close the declaration anyway.
11
+ */
12
+ export declare function cssValue(field: BlockField, value: BlockPropValue): string | undefined;
13
+ /**
14
+ * The device rules of a block piece: values of small screens and blocks hidden on one screen.
15
+ * Pages write them as CSS on the classes of the blocks; e-mails as `mj-style`, where hiding on
16
+ * large screens is inlined (Outlook for Windows reads no media rule) and every small-screen
17
+ * rule sits in a media rule with `!important`, which wins over the inline styles of MJML.
18
+ */
19
+ export declare class BlockDeviceStyles {
20
+ private readonly breakpoint;
21
+ constructor(breakpoint: number);
22
+ usage(block: Block, usage: DeviceUsage): void;
23
+ /** Mobile rules of the cell `.ve-m-<id>` of an e-mail block; empty when it has none. */
24
+ emailRules(block: Block, definition: BlockTypeDefinition): readonly string[];
25
+ /** Mobile rules of `.ve-b-<id>` (and its inner element) of a page block. */
26
+ pageRules(block: Block, definition: BlockTypeDefinition): readonly string[];
27
+ /** The `mj-style` elements of an e-mail; empty when the piece has no device rule. */
28
+ emailHead(mode: OutputMode, usage: DeviceUsage, mobile: readonly string[]): string;
29
+ /** The device CSS of a page: visibility on each screen and the mobile rules. */
30
+ pageCss(mode: OutputMode, usage: DeviceUsage, mobile: readonly string[]): string;
31
+ }
@@ -0,0 +1,22 @@
1
+ import { GeneratedMjml } from '../compilation/generated-mjml';
2
+ import type { BlockDocumentView, BlockTypeCatalog, OutputMode } from './block-type';
3
+ /** Columns sit side by side above this width and stack below it, as in the e-mail models. */
4
+ export declare const EMAIL_BREAKPOINT = "641px";
5
+ /**
6
+ * Writes the MJML of a block e-mail. The global styles become `<mj-attributes>` (and named
7
+ * `mj-class` for headings and footers), so a style is written once and MJML spreads it over
8
+ * every element it generates (cell, link, Outlook markup). A block writes only the values it
9
+ * overrides. Columns are real `mj-column`. In preview every component also carries
10
+ * `css-class="ve-p-<token>-<id>"`, with a token drawn for the rendering, which the preview
11
+ * marker turns into the canvas attributes.
12
+ */
13
+ export declare class BlockMjmlGenerator {
14
+ #private;
15
+ private readonly registry;
16
+ constructor(registry: BlockTypeCatalog);
17
+ toMjml(document: BlockDocumentView, mode: OutputMode, token?: string): GeneratedMjml;
18
+ private block;
19
+ /** Shares of the columns of a section, in percent with at most two decimals. */
20
+ private widths;
21
+ private attributes;
22
+ }
@@ -0,0 +1,23 @@
1
+ import type { BlockDocument } from '../core/block-document';
2
+ /**
3
+ * Turns the preview classes `ve-p-<token>-<id>` of a compiled preview e-mail into the canvas
4
+ * attributes: the selectable element of each block gets `data-visual-editor-node`, and the
5
+ * element holding an editable text gets `data-visual-editor-edit-node`. Only classes with the
6
+ * token of this rendering count, each block is marked once (its first element in document
7
+ * order), and the preview classes are taken out again. Works on the parsed tree, never by text
8
+ * replacement. The e-mail that is sent has neither class nor attribute.
9
+ *
10
+ * `<mj-html-attributes>` was tried first and dropped: it re-serializes the whole body with
11
+ * cheerio in XML mode, which turns `<br>` into an element that swallows the following text and
12
+ * changes white space, so the preview would no longer be the e-mail that is sent.
13
+ */
14
+ export declare class EmailPreviewMarker {
15
+ mark(html: string, document: Pick<BlockDocument, 'blocks'>, token: string): string;
16
+ /** Depth-first, in document order, `template` contents included. */
17
+ private walk;
18
+ /** Removes the preview classes of this rendering and returns the block id they name. */
19
+ private take;
20
+ private annotate;
21
+ private descendant;
22
+ private set;
23
+ }
@@ -0,0 +1,20 @@
1
+ import type { BlockDocument } from '../core/block-document';
2
+ import type { SourceInput } from '../core/document';
3
+ import { SecureIdentifier } from '../security/identity';
4
+ import type { GeneratedMjmlCompilerPort } from '../compilation/generated-mjml';
5
+ import type { OutputMode } from './block-type';
6
+ import type { BlockMjmlGenerator } from './email-generator';
7
+ import { EmailPreviewMarker } from './email-preview';
8
+ /**
9
+ * The HTML of a block e-mail: generated MJML, compiled by the isolated compiler (which checks
10
+ * the output against the e-mail rules), and, for the preview, marked for the canvas.
11
+ */
12
+ export declare class BlockEmailRenderer {
13
+ private readonly generator;
14
+ private readonly compiler;
15
+ private readonly marker;
16
+ private readonly identity;
17
+ constructor(generator: BlockMjmlGenerator, compiler: GeneratedMjmlCompilerPort, marker?: EmailPreviewMarker, identity?: SecureIdentifier);
18
+ /** A new preview token for every rendering: markup of the author cannot guess it. */
19
+ render(document: BlockDocument, mode: OutputMode): Promise<SourceInput>;
20
+ }
@@ -0,0 +1,34 @@
1
+ import type { BlockField, FieldOption } from './block-type';
2
+ import type { StylePath } from './styles';
3
+ import type { RichTextMode } from '../core/rich-text-markup';
4
+ /** Builders of the fields several block types share. Defaults follow MJML's own. */
5
+ export declare const ALIGN_OPTIONS: readonly FieldOption[];
6
+ export declare const BLOCK_PADDING = "10px 25px";
7
+ /** The two visibility toggles every block but a column has. */
8
+ export declare const DEVICE_KEYS: readonly ["hideOnDesktop", "hideOnMobile"];
9
+ /** E-mail mobile rules shared by the text blocks: the cell and the text inside it. */
10
+ export declare const TEXT_MOBILE_EMAIL: Readonly<{
11
+ fontSize: {
12
+ selectors: string[];
13
+ };
14
+ lineHeight: {
15
+ selectors: string[];
16
+ };
17
+ align: {
18
+ selectors: string[];
19
+ };
20
+ padding: {
21
+ selectors: string[];
22
+ };
23
+ }>;
24
+ export declare const fields: Readonly<{
25
+ text(mode: RichTextMode): BlockField;
26
+ color(key: string, labelKey: string, inherits?: StylePath, target?: "inner"): BlockField;
27
+ fontSize(inherits: StylePath, target?: "inner"): BlockField;
28
+ lineHeight(inherits: StylePath): BlockField;
29
+ align(defaultValue: "left" | "center" | "right", property?: string): BlockField;
30
+ padding(defaultValue?: string, inherits?: StylePath): BlockField;
31
+ /** Hide the block on large or on small screens. The generators read them, not `css`. */
32
+ visibility(): readonly BlockField[];
33
+ link(key?: string): BlockField;
34
+ }>;
@@ -0,0 +1,16 @@
1
+ import type { SourceInput } from '../core/document';
2
+ import type { BlockDocumentView, BlockTypeCatalog, OutputMode } from './block-type';
3
+ import type { StylePath } from './styles';
4
+ /** Width below which the columns of a section stack, as in the e-mail breakpoint. */
5
+ export declare const PAGE_BREAKPOINT = 640;
6
+ /** CSS variable of a global style: `body.textColor` is `--ve-body-text-color`. */
7
+ export declare function styleVariable(path: StylePath): string;
8
+ export declare class BlockPageGenerator {
9
+ #private;
10
+ private readonly registry;
11
+ constructor(registry: BlockTypeCatalog);
12
+ toHtml(document: BlockDocumentView, mode: OutputMode): SourceInput;
13
+ private block;
14
+ /** `.ve-b-<id>{...}` and `.ve-b-<id> <inner>{...}` for the values the block overrides. */
15
+ private overrides;
16
+ }
@@ -0,0 +1,58 @@
1
+ import type { Block, BlockPropValue } from '../core/block-document';
2
+ import type { DocumentKind } from '../core/document';
3
+ import type { BlockTypeDefinition, EmailBlockContext, OutputMode, PageBlockContext } from './block-type';
4
+ import type { StyleResolver } from './styles';
5
+ /**
6
+ * Class of a block in the page output: `ve-b-<id>`. The prefix keeps it apart from the
7
+ * structural classes (`ve-page`, `ve-section`, `ve-button`...) whatever the id is.
8
+ */
9
+ export declare function blockClass(block: Block): string;
10
+ /**
11
+ * Class of a block in an e-mail preview: `ve-p-<token>-<id>`, with a token drawn for each
12
+ * rendering, so markup of the author can never pose as a block for the marker.
13
+ */
14
+ export declare function previewClass(token: string, block: Block): string;
15
+ /** Classes of a block hidden on a screen; the generators write what each one does. */
16
+ export declare const HIDE_DESKTOP_CLASS = "ve-hide-d";
17
+ export declare const HIDE_MOBILE_CLASS = "ve-hide-m";
18
+ /** Class of the cell of an e-mail block with mobile values: `ve-m-<id>`. */
19
+ export declare function mobileClass(block: Block): string;
20
+ /** The visibility classes of a block, in a fixed order. */
21
+ export declare function visibilityClasses(block: Block): readonly string[];
22
+ /** Shared reading of values: own, else inherited, else the field default. */
23
+ declare abstract class BaseContext {
24
+ readonly block: Block;
25
+ readonly definition: BlockTypeDefinition;
26
+ readonly kind: DocumentKind;
27
+ readonly mode: OutputMode;
28
+ readonly styles: StyleResolver;
29
+ private readonly renderChildren;
30
+ constructor(block: Block, definition: BlockTypeDefinition, kind: DocumentKind, mode: OutputMode, styles: StyleResolver, renderChildren: (reverse: boolean) => string);
31
+ value(key: string): BlockPropValue | undefined;
32
+ children(reverse?: boolean): string;
33
+ }
34
+ export declare class EmailRenderContext extends BaseContext implements EmailBlockContext {
35
+ private readonly fragments;
36
+ private readonly token;
37
+ readonly columnWidth?: string | undefined;
38
+ /** Whether the generator wrote mobile rules for the cell of this block. */
39
+ private readonly mobile;
40
+ constructor(block: Block, definition: BlockTypeDefinition, mode: OutputMode, styles: StyleResolver, renderChildren: (reverse: boolean) => string, fragments: string[], token: string, columnWidth?: string | undefined,
41
+ /** Whether the generator wrote mobile rules for the cell of this block. */
42
+ mobile?: boolean);
43
+ attributes(extra?: Readonly<Record<string, string | undefined>>): string;
44
+ cellClass(): string | undefined;
45
+ raw(fragment: string): string;
46
+ previewClass(): string | undefined;
47
+ }
48
+ export declare class PageRenderContext extends BaseContext implements PageBlockContext {
49
+ private readonly rules;
50
+ private readonly mobileRules;
51
+ constructor(block: Block, definition: BlockTypeDefinition, mode: OutputMode, styles: StyleResolver, renderChildren: (reverse: boolean) => string, rules: string[], mobileRules?: string[]);
52
+ classes(base: string): string;
53
+ node(): string;
54
+ editable(): string;
55
+ rule(selectorSuffix: string, declarations: string): void;
56
+ mobileRule(selectorSuffix: string, declarations: string): void;
57
+ }
58
+ export {};
@@ -0,0 +1,54 @@
1
+ import type { GlobalStyles } from '../core/block-document';
2
+ import type { DocumentKind } from '../core/document';
3
+ import type { ValueSpec } from './values';
4
+ /** An MJML component, or a named `mj-class`, whose attribute carries a global style. */
5
+ export interface MjmlTarget {
6
+ readonly element: 'mj-all' | 'mj-text' | 'mj-button' | 'mj-divider' | 'mj-section';
7
+ readonly mjClass?: string;
8
+ readonly attribute: string;
9
+ }
10
+ export interface StyleKeySpec {
11
+ readonly key: string;
12
+ readonly labelKey: string;
13
+ readonly control: 'color' | 'length' | 'select';
14
+ readonly value: ValueSpec;
15
+ readonly default: string | Readonly<Record<DocumentKind, string>>;
16
+ readonly options?: readonly {
17
+ readonly value: string;
18
+ readonly labelKey: string;
19
+ }[];
20
+ /** Where an e-mail carries it in `<mj-attributes>`; absent for page-only styles. */
21
+ readonly mjml?: readonly MjmlTarget[];
22
+ readonly kinds?: readonly DocumentKind[];
23
+ }
24
+ export interface StyleGroupSpec {
25
+ readonly group: string;
26
+ readonly labelKey: string;
27
+ readonly keys: readonly StyleKeySpec[];
28
+ }
29
+ /** `group.key` of a global style, the path a block field inherits from. */
30
+ export type StylePath = `${string}.${string}`;
31
+ /**
32
+ * The global styles of a piece and their catalog defaults. A piece stores only what differs;
33
+ * "restore default" removes the key. Labels are keys of the package catalogs.
34
+ */
35
+ export declare const GLOBAL_STYLE_GROUPS: readonly StyleGroupSpec[];
36
+ export declare class GlobalStyleSpec {
37
+ #private;
38
+ readonly groups: readonly StyleGroupSpec[];
39
+ constructor(groups?: readonly StyleGroupSpec[]);
40
+ key(group: string, key: string): StyleKeySpec | undefined;
41
+ has(path: string): path is StylePath;
42
+ paths(): readonly StylePath[];
43
+ defaultOf(path: StylePath, kind: DocumentKind): string;
44
+ }
45
+ /** The effective value of every global style: the piece's override, or the catalog default. */
46
+ export declare class StyleResolver {
47
+ private readonly spec;
48
+ private readonly styles;
49
+ private readonly kind;
50
+ constructor(spec: GlobalStyleSpec, styles: GlobalStyles, kind: DocumentKind);
51
+ value(path: StylePath): string;
52
+ /** Whether the piece overrides this style; false means the catalog default applies. */
53
+ overridden(path: StylePath): boolean;
54
+ }