@perkyzz/emvb 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +59 -2
- package/THIRD_PARTY_NOTICES.md +32 -0
- package/licenses/fontawesome-free.LICENSE +165 -0
- package/licenses/lucide-static.LICENSE +43 -0
- package/licenses/remixicon.LICENSE +201 -0
- package/licenses/tabler-icons.LICENSE +21 -0
- package/package.json +76 -4
- package/src/admin/access/RequireEditor.tsx +39 -0
- package/src/admin/access/role.ts +36 -0
- package/src/admin/access/sidebar-shim.ts +108 -0
- package/src/admin/api.ts +75 -0
- package/src/admin/content-api.ts +210 -0
- package/src/admin/editor/Editor.tsx +532 -0
- package/src/admin/editor/EditorOverlay.tsx +66 -0
- package/src/admin/editor/ShortcutsDialog.tsx +30 -0
- package/src/admin/editor/SmallScreenNotice.tsx +21 -0
- package/src/admin/editor/TopBar.tsx +243 -0
- package/src/admin/editor/canvas/CanvasFrame.tsx +536 -0
- package/src/admin/editor/canvas/CanvasTextEdit.tsx +87 -0
- package/src/admin/editor/canvas/DeviceBar.tsx +91 -0
- package/src/admin/editor/canvas/EmptyCanvas.tsx +49 -0
- package/src/admin/editor/canvas/SelectionOverlay.tsx +239 -0
- package/src/admin/editor/canvas/canvas-events.ts +245 -0
- package/src/admin/editor/canvas/state-preview.ts +19 -0
- package/src/admin/editor/canvas/tab-reveal.ts +101 -0
- package/src/admin/editor/canvas/vnode-react.tsx +69 -0
- package/src/admin/editor/clipboard-store.ts +44 -0
- package/src/admin/editor/dialogs.tsx +164 -0
- package/src/admin/editor/dnd/drag-stash.ts +27 -0
- package/src/admin/editor/dnd/drop-target.ts +148 -0
- package/src/admin/editor/dnd/new-element.ts +107 -0
- package/src/admin/editor/editor-css.ts +625 -0
- package/src/admin/editor/exit.ts +27 -0
- package/src/admin/editor/host.ts +30 -0
- package/src/admin/editor/icons/IconLibraryDialog.tsx +850 -0
- package/src/admin/editor/icons/library.ts +243 -0
- package/src/admin/editor/icons/set-format.ts +29 -0
- package/src/admin/editor/icons/sets/fontawesome.json +1 -0
- package/src/admin/editor/icons/sets/lucide.json +1 -0
- package/src/admin/editor/icons/sets/remix.json +1 -0
- package/src/admin/editor/icons/sets/tabler.json +1 -0
- package/src/admin/editor/panels/AddPanel.tsx +146 -0
- package/src/admin/editor/panels/ClassesSection.tsx +372 -0
- package/src/admin/editor/panels/ColorControl.tsx +477 -0
- package/src/admin/editor/panels/ConditionsEditor.tsx +201 -0
- package/src/admin/editor/panels/ElementPanel.tsx +773 -0
- package/src/admin/editor/panels/LayersPanel.tsx +573 -0
- package/src/admin/editor/panels/LeftPanel.tsx +81 -0
- package/src/admin/editor/panels/PageSettings.tsx +255 -0
- package/src/admin/editor/panels/SettingsPanel.tsx +113 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +548 -0
- package/src/admin/editor/panels/TriggerSettings.tsx +132 -0
- package/src/admin/editor/panels/TriggersEditor.tsx +214 -0
- package/src/admin/editor/panels/VariableSection.tsx +530 -0
- package/src/admin/editor/panels/color-space.ts +195 -0
- package/src/admin/editor/panels/settings/AdvancedFields.tsx +119 -0
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +418 -0
- package/src/admin/editor/panels/settings/BackgroundFill.tsx +221 -0
- package/src/admin/editor/panels/settings/BoxControl.tsx +271 -0
- package/src/admin/editor/panels/settings/ChoiceGroup.tsx +138 -0
- package/src/admin/editor/panels/settings/ClassChip.tsx +167 -0
- package/src/admin/editor/panels/settings/ClassChipInput.tsx +451 -0
- package/src/admin/editor/panels/settings/DraftTextField.tsx +242 -0
- package/src/admin/editor/panels/settings/EffectsControls.tsx +354 -0
- package/src/admin/editor/panels/settings/FieldBindControl.tsx +119 -0
- package/src/admin/editor/panels/settings/FieldControl.tsx +270 -0
- package/src/admin/editor/panels/settings/FormBindControl.tsx +106 -0
- package/src/admin/editor/panels/settings/IconControls.tsx +438 -0
- package/src/admin/editor/panels/settings/IconPicker.tsx +170 -0
- package/src/admin/editor/panels/settings/ItemList.tsx +199 -0
- package/src/admin/editor/panels/settings/LengthRow.tsx +217 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +130 -0
- package/src/admin/editor/panels/settings/MediaPicker.tsx +220 -0
- package/src/admin/editor/panels/settings/NumberRow.tsx +154 -0
- package/src/admin/editor/panels/settings/StateSwitcher.tsx +87 -0
- package/src/admin/editor/panels/settings/StyleRow.tsx +563 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +171 -0
- package/src/admin/editor/panels/settings/advanced-rules.ts +63 -0
- package/src/admin/editor/panels/settings/background-mode.ts +112 -0
- package/src/admin/editor/panels/settings/box-link-name.ts +38 -0
- package/src/admin/editor/panels/settings/box-sides.ts +153 -0
- package/src/admin/editor/panels/settings/button-url.ts +27 -0
- package/src/admin/editor/panels/settings/class-suggest.ts +53 -0
- package/src/admin/editor/panels/settings/form-names.ts +38 -0
- package/src/admin/editor/panels/settings/heading-warning.ts +25 -0
- package/src/admin/editor/panels/settings/image-alt.ts +25 -0
- package/src/admin/editor/panels/settings/length-units.ts +116 -0
- package/src/admin/editor/panels/settings/loop-context.ts +26 -0
- package/src/admin/editor/panels/settings/node-props.ts +11 -0
- package/src/admin/editor/panels/settings/style-sections.ts +394 -0
- package/src/admin/editor/panels/settings/svg-images.ts +14 -0
- package/src/admin/editor/panels/site-list.tsx +209 -0
- package/src/admin/editor/panels/variable-values.ts +73 -0
- package/src/admin/editor/restore-deleted.ts +80 -0
- package/src/admin/editor/section-templates.ts +50 -0
- package/src/admin/editor/shortcuts.ts +20 -0
- package/src/admin/editor/store.ts +240 -0
- package/src/admin/editor/useClipboardActions.ts +136 -0
- package/src/admin/editor/useEditorCommands.ts +203 -0
- package/src/admin/editor/useEditorData.ts +193 -0
- package/src/admin/editor/useEditorShortcuts.ts +180 -0
- package/src/admin/editor/useMediaQuery.ts +20 -0
- package/src/admin/editor/useNodeActions.ts +184 -0
- package/src/admin/editor/useSave.ts +242 -0
- package/src/admin/entry-status.ts +19 -0
- package/src/admin/forms-api.ts +73 -0
- package/src/admin/icon-uploads-api.ts +44 -0
- package/src/admin/index.tsx +20 -0
- package/src/admin/media-api.ts +68 -0
- package/src/admin/pages/CreateDialog.tsx +150 -0
- package/src/admin/pages/EditorPage.tsx +57 -0
- package/src/admin/pages/NewPageDialog.tsx +83 -0
- package/src/admin/pages/NewThemePartDialog.tsx +61 -0
- package/src/admin/pages/PageList.tsx +91 -0
- package/src/admin/pages/PagesPage.tsx +25 -0
- package/src/admin/pages/SetupShell.tsx +90 -0
- package/src/admin/pages/ThemeBuilderPage.tsx +25 -0
- package/src/admin/pages/ThemePartList.tsx +221 -0
- package/src/admin/pages/list-kit.tsx +125 -0
- package/src/admin/setup/plan.ts +150 -0
- package/src/admin/setup/run.ts +61 -0
- package/src/admin/setup/spec.ts +107 -0
- package/src/admin/setup/useSetupStatus.ts +62 -0
- package/src/admin/theme-api.ts +233 -0
- package/src/admin/ui.ts +244 -0
- package/src/admin/widgets/LayoutField.tsx +67 -0
- package/src/astro/EmVBPage.astro +63 -0
- package/src/astro/env.d.ts +5 -0
- package/src/astro/floats/EmVBFloatsRuntime.astro +9 -0
- package/src/astro/floats/index.ts +1 -0
- package/src/astro/floats/runtime.ts +78 -0
- package/src/astro/forms/EmVBFormsRuntime.astro +9 -0
- package/src/astro/forms/index.ts +1 -0
- package/src/astro/forms-definitions.ts +126 -0
- package/src/astro/index.ts +16 -0
- package/src/astro/menu/EmVBMenuRuntime.astro +9 -0
- package/src/astro/menu/index.ts +1 -0
- package/src/astro/menu/runtime.ts +37 -0
- package/src/astro/popups/EmVBPopupsRuntime.astro +9 -0
- package/src/astro/popups/index.ts +1 -0
- package/src/astro/popups/runtime.ts +296 -0
- package/src/astro/render.ts +108 -0
- package/src/astro/resolve-theme.ts +515 -0
- package/src/astro/resolve.ts +65 -0
- package/src/astro/tabs/EmVBTabsRuntime.astro +10 -0
- package/src/astro/tabs/index.ts +1 -0
- package/src/astro/tabs/runtime.ts +116 -0
- package/src/astro/theme-context.ts +89 -0
- package/src/astro/theme-posts.ts +84 -0
- package/src/constants.ts +12 -0
- package/src/core/arrange.ts +448 -0
- package/src/core/clipboard.ts +504 -0
- package/src/core/css/generate.ts +236 -0
- package/src/core/css/scope.ts +88 -0
- package/src/core/design/cascade.ts +28 -0
- package/src/core/design/classes.ts +224 -0
- package/src/core/design/devices.ts +56 -0
- package/src/core/design/states.ts +49 -0
- package/src/core/design/transfer.ts +132 -0
- package/src/core/design/variables.ts +359 -0
- package/src/core/elements/definition.ts +12 -0
- package/src/core/elements/dynamic-elements.ts +225 -0
- package/src/core/elements/field-id.ts +6 -0
- package/src/core/elements/form-elements.ts +219 -0
- package/src/core/elements/index.ts +960 -0
- package/src/core/elements/menu.ts +190 -0
- package/src/core/elements/plain-text.ts +32 -0
- package/src/core/forms/binding.ts +61 -0
- package/src/core/forms/definition.ts +45 -0
- package/src/core/forms/success-layout.ts +63 -0
- package/src/core/icons/catalog.ts +273 -0
- package/src/core/index.ts +380 -0
- package/src/core/limits.ts +9 -0
- package/src/core/migrate/index.ts +126 -0
- package/src/core/nesting.ts +51 -0
- package/src/core/render/context.ts +21 -0
- package/src/core/render/dynamic-post.ts +175 -0
- package/src/core/render/extras.ts +98 -0
- package/src/core/render/form.ts +235 -0
- package/src/core/render/index.ts +372 -0
- package/src/core/render/loop.ts +43 -0
- package/src/core/render/pagination.ts +76 -0
- package/src/core/render/section.ts +37 -0
- package/src/core/render/tabs.ts +76 -0
- package/src/core/render/vnode.ts +87 -0
- package/src/core/sanitize/css.ts +771 -0
- package/src/core/sanitize/embed-url.ts +160 -0
- package/src/core/sanitize/escape.ts +10 -0
- package/src/core/sanitize/href.ts +6 -0
- package/src/core/sanitize/media-url.ts +7 -0
- package/src/core/sanitize/svg-upload.ts +203 -0
- package/src/core/sanitize/svg.ts +374 -0
- package/src/core/sanitize/url.ts +31 -0
- package/src/core/schema/descriptors.ts +37 -0
- package/src/core/schema/design.ts +93 -0
- package/src/core/schema/layout.ts +1008 -0
- package/src/core/schema/state-names.ts +4 -0
- package/src/core/schema/style.ts +336 -0
- package/src/core/stats.ts +18 -0
- package/src/core/tabs/presence.ts +25 -0
- package/src/core/theme/conditions.ts +324 -0
- package/src/core/theme/dynamic.ts +143 -0
- package/src/core/theme/float.ts +113 -0
- package/src/core/theme/pagination.ts +97 -0
- package/src/core/theme/parse-doc.ts +36 -0
- package/src/core/theme/part-types.ts +81 -0
- package/src/core/theme/popup-markup.ts +41 -0
- package/src/core/theme/popup-rules.ts +62 -0
- package/src/core/theme/triggers.ts +104 -0
- package/src/core/tree-ops.ts +139 -0
- package/src/core/validate.ts +185 -0
- package/src/index.ts +18 -0
- package/src/server/design-routes.ts +125 -0
- package/src/server/hooks.ts +118 -0
- package/src/server/icon-routes.ts +79 -0
- package/src/server/plugin.ts +43 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
export * from "./limits.ts";
|
|
2
|
+
export {
|
|
3
|
+
LAYOUT_SCHEMA_VERSION,
|
|
4
|
+
Layout,
|
|
5
|
+
type LayoutNode,
|
|
6
|
+
type UnknownNode,
|
|
7
|
+
ContainerNode,
|
|
8
|
+
DivBlockNode,
|
|
9
|
+
FlexboxNode,
|
|
10
|
+
SvgNode,
|
|
11
|
+
TabPanelNode,
|
|
12
|
+
HeadingNode,
|
|
13
|
+
SpacerNode,
|
|
14
|
+
DividerNode,
|
|
15
|
+
TextNode,
|
|
16
|
+
LabelNode,
|
|
17
|
+
LinkNode,
|
|
18
|
+
ButtonNode,
|
|
19
|
+
ListNode,
|
|
20
|
+
ImageNode,
|
|
21
|
+
IconNode,
|
|
22
|
+
VideoNode,
|
|
23
|
+
NodeId,
|
|
24
|
+
CONTAINER_TAGS,
|
|
25
|
+
TEXT_TAGS,
|
|
26
|
+
KNOWN_ELEMENT_TYPES,
|
|
27
|
+
isContainerNode,
|
|
28
|
+
isDivBlockNode,
|
|
29
|
+
isFlexboxNode,
|
|
30
|
+
isLayoutParentNode,
|
|
31
|
+
isTabsNode,
|
|
32
|
+
isTabPanelNode,
|
|
33
|
+
isFormNode,
|
|
34
|
+
isLoopNode,
|
|
35
|
+
isSectionNode,
|
|
36
|
+
isParentNode,
|
|
37
|
+
isFormFieldType,
|
|
38
|
+
FORM_FIELD_TYPES,
|
|
39
|
+
FIELD_NAME_PATTERN,
|
|
40
|
+
MAX_FIELD_NAME,
|
|
41
|
+
isHeadingNode,
|
|
42
|
+
isUnknownNode,
|
|
43
|
+
FormNode,
|
|
44
|
+
LoopNode,
|
|
45
|
+
SectionNode,
|
|
46
|
+
TextInputNode,
|
|
47
|
+
TextareaNode,
|
|
48
|
+
SelectNode,
|
|
49
|
+
CheckboxNode,
|
|
50
|
+
RadioNode,
|
|
51
|
+
SubmitNode,
|
|
52
|
+
PostTitleNode,
|
|
53
|
+
PostExcerptNode,
|
|
54
|
+
PostContentNode,
|
|
55
|
+
PostImageNode,
|
|
56
|
+
PostLinkNode,
|
|
57
|
+
PaginationNode,
|
|
58
|
+
} from "./schema/layout.ts";
|
|
59
|
+
export {
|
|
60
|
+
type FieldKind,
|
|
61
|
+
type FieldOption,
|
|
62
|
+
type FieldDescriptor,
|
|
63
|
+
type ElementDescriptor,
|
|
64
|
+
} from "./schema/descriptors.ts";
|
|
65
|
+
export {
|
|
66
|
+
ELEMENTS,
|
|
67
|
+
ELEMENT_DESCRIPTORS,
|
|
68
|
+
defaultElement,
|
|
69
|
+
iconHasAdjustableStroke,
|
|
70
|
+
iconHasOwnColors,
|
|
71
|
+
type ElementType,
|
|
72
|
+
} from "./elements/index.ts";
|
|
73
|
+
export {
|
|
74
|
+
commitPlainText,
|
|
75
|
+
isMultilineText,
|
|
76
|
+
isPlainTextNode,
|
|
77
|
+
plainTextOf,
|
|
78
|
+
withPlainText,
|
|
79
|
+
} from "./elements/plain-text.ts";
|
|
80
|
+
export {
|
|
81
|
+
StyleProps,
|
|
82
|
+
StyleStates,
|
|
83
|
+
DeviceStyles,
|
|
84
|
+
HiddenOn,
|
|
85
|
+
ColorValue,
|
|
86
|
+
Length,
|
|
87
|
+
LengthValue,
|
|
88
|
+
VariableRef,
|
|
89
|
+
} from "./schema/style.ts";
|
|
90
|
+
export { STYLE_STATES, type StyleStateName } from "./schema/state-names.ts";
|
|
91
|
+
export {
|
|
92
|
+
upgradeLayout,
|
|
93
|
+
isNewerThanSupported,
|
|
94
|
+
LAYOUT_MIGRATIONS,
|
|
95
|
+
DESIGN_MIGRATIONS,
|
|
96
|
+
type Migration,
|
|
97
|
+
type UpgradeResult,
|
|
98
|
+
} from "./migrate/index.ts";
|
|
99
|
+
export {
|
|
100
|
+
validateLayout,
|
|
101
|
+
validateDesign,
|
|
102
|
+
summarizeIssues,
|
|
103
|
+
byteLength,
|
|
104
|
+
type LayoutIssue,
|
|
105
|
+
type LayoutValidation,
|
|
106
|
+
type DesignValidation,
|
|
107
|
+
} from "./validate.ts";
|
|
108
|
+
export { nestingIssues } from "./nesting.ts";
|
|
109
|
+
export {
|
|
110
|
+
DESIGN_SCHEMA_VERSION,
|
|
111
|
+
DEFAULT_STYLE_TAGS,
|
|
112
|
+
DesignSystem,
|
|
113
|
+
ColorVariable,
|
|
114
|
+
emptyDesign,
|
|
115
|
+
FontVariable,
|
|
116
|
+
LengthVariable,
|
|
117
|
+
type DefaultStyleTag,
|
|
118
|
+
} from "./schema/design.ts";
|
|
119
|
+
export {
|
|
120
|
+
MAX_VARIABLES,
|
|
121
|
+
variableListFull,
|
|
122
|
+
findVariableUsages,
|
|
123
|
+
findVariableUsagesInDesign,
|
|
124
|
+
clearVariableRefs,
|
|
125
|
+
removeVariable,
|
|
126
|
+
renameVariable,
|
|
127
|
+
variableNameTaken,
|
|
128
|
+
variableNameTakenMessage,
|
|
129
|
+
duplicateVariable,
|
|
130
|
+
deleteVariable,
|
|
131
|
+
refMatchesKind,
|
|
132
|
+
type VariableKind,
|
|
133
|
+
type VariableUsage,
|
|
134
|
+
} from "./design/variables.ts";
|
|
135
|
+
export { classStylesInListOrder, resolveCascade } from "./design/cascade.ts";
|
|
136
|
+
export {
|
|
137
|
+
findMissingRequiredFields,
|
|
138
|
+
layoutHasForm,
|
|
139
|
+
type MissingRequiredField,
|
|
140
|
+
} from "./forms/binding.ts";
|
|
141
|
+
export {
|
|
142
|
+
fieldsOf,
|
|
143
|
+
fieldByName,
|
|
144
|
+
type PublicFormDefinition,
|
|
145
|
+
type PublicFormField,
|
|
146
|
+
type FormDefinitions,
|
|
147
|
+
} from "./forms/definition.ts";
|
|
148
|
+
export { FORMS_SUBMIT_PATH } from "./render/index.ts";
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
cleanClassName,
|
|
152
|
+
MAX_CLASSES,
|
|
153
|
+
moveClassId,
|
|
154
|
+
addClassId,
|
|
155
|
+
removeClassId,
|
|
156
|
+
findClassUsages,
|
|
157
|
+
clearClassRefs,
|
|
158
|
+
duplicateClass,
|
|
159
|
+
moveDesignClass,
|
|
160
|
+
renameClass,
|
|
161
|
+
classNameTaken,
|
|
162
|
+
classNameTakenMessage,
|
|
163
|
+
patchClassStyle,
|
|
164
|
+
replaceClassId,
|
|
165
|
+
hasLocalStyles,
|
|
166
|
+
localToClassRefusal,
|
|
167
|
+
localStylesToClass,
|
|
168
|
+
} from "./design/classes.ts";
|
|
169
|
+
export { hasStateStyles, patchClassState, patchStates } from "./design/states.ts";
|
|
170
|
+
export {
|
|
171
|
+
designFromJson,
|
|
172
|
+
designToJson,
|
|
173
|
+
importLosses,
|
|
174
|
+
MAX_DESIGN_FILE_BYTES,
|
|
175
|
+
type DesignImport,
|
|
176
|
+
type ImportRename,
|
|
177
|
+
uniqueImportNames,
|
|
178
|
+
type ImportLosses,
|
|
179
|
+
} from "./design/transfer.ts";
|
|
180
|
+
export {
|
|
181
|
+
patchClassDevices,
|
|
182
|
+
patchDeviceStyle,
|
|
183
|
+
toggleHidden,
|
|
184
|
+
type ResponsiveDevice,
|
|
185
|
+
} from "./design/devices.ts";
|
|
186
|
+
export {
|
|
187
|
+
renderPage,
|
|
188
|
+
type RenderMode,
|
|
189
|
+
type RenderResult,
|
|
190
|
+
type RenderWarning,
|
|
191
|
+
} from "./render/index.ts";
|
|
192
|
+
export { serialize, isAllowedTag, isAllowedAttr, type VNode } from "./render/vnode.ts";
|
|
193
|
+
export { escapeAttr, escapeText } from "./sanitize/escape.ts";
|
|
194
|
+
export { sanitizeHref } from "./sanitize/href.ts";
|
|
195
|
+
export { isSafeFontStack } from "./sanitize/css.ts";
|
|
196
|
+
export { sanitizeMediaUrl } from "./sanitize/media-url.ts";
|
|
197
|
+
export {
|
|
198
|
+
sanitizeSvgMarkup,
|
|
199
|
+
sanitizeSvgReport,
|
|
200
|
+
isSafeSvgMarkup,
|
|
201
|
+
isAllowedSvgImageHref,
|
|
202
|
+
type SvgReport,
|
|
203
|
+
} from "./sanitize/svg.ts";
|
|
204
|
+
export {
|
|
205
|
+
prepareUploadedSvg,
|
|
206
|
+
UPLOAD_SVG_MAX_BYTES,
|
|
207
|
+
type PreparedSvg,
|
|
208
|
+
type UploadedIcon,
|
|
209
|
+
type UploadedIconItem,
|
|
210
|
+
} from "./sanitize/svg-upload.ts";
|
|
211
|
+
export { resolveEmbedUrl, type EmbedTarget } from "./sanitize/embed-url.ts";
|
|
212
|
+
export { summarizeLayout, type LayoutSummary } from "./stats.ts";
|
|
213
|
+
export {
|
|
214
|
+
findNode,
|
|
215
|
+
updateNode,
|
|
216
|
+
removeNode,
|
|
217
|
+
insertNode,
|
|
218
|
+
nodeIdAtPath,
|
|
219
|
+
newNodeId,
|
|
220
|
+
starterLayout,
|
|
221
|
+
slugify,
|
|
222
|
+
type Removed,
|
|
223
|
+
} from "./tree-ops.ts";
|
|
224
|
+
export {
|
|
225
|
+
REASONS,
|
|
226
|
+
addNode,
|
|
227
|
+
addNodeNear,
|
|
228
|
+
canDrop,
|
|
229
|
+
duplicateNode,
|
|
230
|
+
firstChild,
|
|
231
|
+
insertionPoint,
|
|
232
|
+
moveDown,
|
|
233
|
+
moveIn,
|
|
234
|
+
moveNode,
|
|
235
|
+
moveOut,
|
|
236
|
+
moveUp,
|
|
237
|
+
nextInOrder,
|
|
238
|
+
parentOf,
|
|
239
|
+
previousInOrder,
|
|
240
|
+
selectionAfterDelete,
|
|
241
|
+
subtreeSize,
|
|
242
|
+
withFreshIds,
|
|
243
|
+
layoutFromPageTemplate,
|
|
244
|
+
CSS_ID_KEPT,
|
|
245
|
+
type Allowed,
|
|
246
|
+
type Arranged,
|
|
247
|
+
type DragSource,
|
|
248
|
+
type Place,
|
|
249
|
+
type Refusal,
|
|
250
|
+
} from "./arrange.ts";
|
|
251
|
+
export {
|
|
252
|
+
BUNDLED_ICONS,
|
|
253
|
+
BUNDLED_ICON_IDS,
|
|
254
|
+
getBundledIcon,
|
|
255
|
+
type BundledIcon,
|
|
256
|
+
type IconPrimitive,
|
|
257
|
+
} from "./icons/catalog.ts";
|
|
258
|
+
|
|
259
|
+
export {
|
|
260
|
+
CONDITIONS_SCHEMA_VERSION,
|
|
261
|
+
MAX_CONDITION_RULES,
|
|
262
|
+
defaultConditions,
|
|
263
|
+
defaultConditionsFor,
|
|
264
|
+
validateConditions,
|
|
265
|
+
matchesConditions,
|
|
266
|
+
conditionSpecificity,
|
|
267
|
+
conditionsSpecificity,
|
|
268
|
+
themePartLocationApplies,
|
|
269
|
+
contentPartTypeForContext,
|
|
270
|
+
pickThemePartWinner,
|
|
271
|
+
listMatchingThemeParts,
|
|
272
|
+
type ConditionRule,
|
|
273
|
+
type ConditionsDoc,
|
|
274
|
+
type ConditionsValidation,
|
|
275
|
+
type ThemeRequestContext,
|
|
276
|
+
type ThemePartCandidate,
|
|
277
|
+
} from "./theme/conditions.ts";
|
|
278
|
+
|
|
279
|
+
export {
|
|
280
|
+
THEME_PART_TYPES,
|
|
281
|
+
CONTENT_THEME_PART_TYPES,
|
|
282
|
+
ITEM_THEME_PART_TYPES,
|
|
283
|
+
OVERLAY_THEME_PART_TYPES,
|
|
284
|
+
THEME_PART_TYPE_LABELS,
|
|
285
|
+
isThemePartType,
|
|
286
|
+
parseThemePartType,
|
|
287
|
+
isContentThemePartType,
|
|
288
|
+
isItemThemePartType,
|
|
289
|
+
isOverlayThemePartType,
|
|
290
|
+
type ThemePartType,
|
|
291
|
+
type ContentThemePartType,
|
|
292
|
+
type ItemThemePartType,
|
|
293
|
+
type OverlayThemePartType,
|
|
294
|
+
} from "./theme/part-types.ts";
|
|
295
|
+
|
|
296
|
+
export {
|
|
297
|
+
TRIGGERS_SCHEMA_VERSION,
|
|
298
|
+
MAX_POPUP_TRIGGERS,
|
|
299
|
+
defaultTriggers,
|
|
300
|
+
validateTriggers,
|
|
301
|
+
isSafeClickSelector,
|
|
302
|
+
type PopupOpenTrigger,
|
|
303
|
+
type PopupAdvancedRules,
|
|
304
|
+
type TriggersDoc,
|
|
305
|
+
type TriggersValidation,
|
|
306
|
+
} from "./theme/triggers.ts";
|
|
307
|
+
|
|
308
|
+
export {
|
|
309
|
+
TRIGGER_LIMITS,
|
|
310
|
+
clampScrollPercent,
|
|
311
|
+
deviceForWidth,
|
|
312
|
+
POPUP_DEVICES,
|
|
313
|
+
DEVICE_MEDIA,
|
|
314
|
+
DEVICE_PREVIEW_PX,
|
|
315
|
+
matchesPopupDevices,
|
|
316
|
+
withinShowTimes,
|
|
317
|
+
type PopupDevice,
|
|
318
|
+
} from "./theme/popup-rules.ts";
|
|
319
|
+
|
|
320
|
+
export { POPUP_CHROME_CSS, wrapPopupMarkup, type PopupPublicConfig } from "./theme/popup-markup.ts";
|
|
321
|
+
|
|
322
|
+
export {
|
|
323
|
+
FLOAT_EDGES,
|
|
324
|
+
defaultFloatSettings,
|
|
325
|
+
validateFloatSettings,
|
|
326
|
+
FLOAT_CHROME_CSS,
|
|
327
|
+
floatHasOwnSurface,
|
|
328
|
+
wrapFloatMarkup,
|
|
329
|
+
type FloatEdge,
|
|
330
|
+
type FloatSettings,
|
|
331
|
+
type FloatValidation,
|
|
332
|
+
} from "./theme/float.ts";
|
|
333
|
+
|
|
334
|
+
export {
|
|
335
|
+
SAMPLE_POST,
|
|
336
|
+
portableTextToVNodes,
|
|
337
|
+
collectLoopItemPartIds,
|
|
338
|
+
collectSectionPartIds,
|
|
339
|
+
resolvePostForRender,
|
|
340
|
+
resolvePostsForLoop,
|
|
341
|
+
type ThemePostFields,
|
|
342
|
+
type ThemeDynamicData,
|
|
343
|
+
} from "./theme/dynamic.ts";
|
|
344
|
+
export {
|
|
345
|
+
archivePagePath,
|
|
346
|
+
archivePageTitle,
|
|
347
|
+
DEFAULT_PER_PAGE,
|
|
348
|
+
loopPerPage,
|
|
349
|
+
MAX_ARCHIVE_PAGE,
|
|
350
|
+
paginationItems,
|
|
351
|
+
splitArchivePage,
|
|
352
|
+
type ArchivePagination,
|
|
353
|
+
type PaginationItem,
|
|
354
|
+
} from "./theme/pagination.ts";
|
|
355
|
+
|
|
356
|
+
export { layoutHasMenuDropdown, layoutHasTabs } from "./tabs/presence.ts";
|
|
357
|
+
export {
|
|
358
|
+
CLIPBOARD_FORMAT,
|
|
359
|
+
CLIPBOARD_VERSION,
|
|
360
|
+
CLIP_REASONS,
|
|
361
|
+
applyStyle,
|
|
362
|
+
clipStyle,
|
|
363
|
+
droppedNotice,
|
|
364
|
+
elementClip,
|
|
365
|
+
encodeClip,
|
|
366
|
+
pasteNode,
|
|
367
|
+
pastePlace,
|
|
368
|
+
peekClipKind,
|
|
369
|
+
prepareElement,
|
|
370
|
+
prepareStyle,
|
|
371
|
+
readClip,
|
|
372
|
+
styleClip,
|
|
373
|
+
styleOf,
|
|
374
|
+
type Clip,
|
|
375
|
+
type ClipEnvelope,
|
|
376
|
+
type CopiedStyle,
|
|
377
|
+
type Dropped,
|
|
378
|
+
type PasteMode,
|
|
379
|
+
type ReadClip,
|
|
380
|
+
} from "./clipboard.ts";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Server-enforced budgets (N-005). Real D1 caps rows at 2 MB but local D1 doesn't (K12, S0-8). */
|
|
2
|
+
export const MAX_LAYOUT_BYTES = 512 * 1024;
|
|
3
|
+
/** Plugin storage compare-and-set fails above 1 MiB (S0-9); the design doc budget stays well below. */
|
|
4
|
+
export const MAX_DESIGN_BYTES = 256 * 1024;
|
|
5
|
+
export const MAX_DEPTH = 24;
|
|
6
|
+
export const MAX_NODES = 2000;
|
|
7
|
+
export const MAX_TEXT_LENGTH = 2000;
|
|
8
|
+
/** Tabs show at most this many panels; the CSS-only switcher has a rule per tab. */
|
|
9
|
+
export const MAX_TABS = 12;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { LAYOUT_SCHEMA_VERSION } from "../schema/layout.ts";
|
|
2
|
+
|
|
3
|
+
export type Migration = (doc: Record<string, unknown>) => Record<string, unknown>;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* v1 → v2 (D-031) marks the W-088 style keys as possible, v2 → v3 (D-032) the W-089
|
|
7
|
+
* `states` and `transition`, v3 → v4 (D-034) background images, gradients and overlays,
|
|
8
|
+
* v4 → v5 (D-036) per-device styles, v5 → v6 (D-038) synced sections,
|
|
9
|
+
* v6 → v7 (D-039) CSS Grid, v7 → v8 (D-041) entrance animations, and v8 → v9
|
|
10
|
+
* (D-042) attributes, accordion, richer entrances, post date and author, background video,
|
|
11
|
+
* a link on a box, and tag defaults, and v9 → v10 (D-044, D-039) per-side border widths,
|
|
12
|
+
* per-corner radii and grid columns per device, and v10 → v11 (D-045) the layout Section and node
|
|
13
|
+
* labels, and v11 → v12 (W-160) rewrites a gradient `{ angle, from, to }` into
|
|
14
|
+
* `{ type: "linear", angle, stops }`. Every other value is unchanged.
|
|
15
|
+
*/
|
|
16
|
+
const unchanged: Migration = (doc) => doc;
|
|
17
|
+
|
|
18
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
19
|
+
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
+
|
|
21
|
+
/** v11 two-stop gradient → v12 stops. A gradient that already has `stops` is left as it is. */
|
|
22
|
+
function convertGradient(value: unknown): unknown {
|
|
23
|
+
if (!isRecord(value) || Array.isArray(value["stops"])) return value;
|
|
24
|
+
if (!("from" in value) || !("to" in value)) return value;
|
|
25
|
+
const angle = value["angle"];
|
|
26
|
+
return {
|
|
27
|
+
type: "linear",
|
|
28
|
+
angle: typeof angle === "number" ? angle : 180,
|
|
29
|
+
stops: [
|
|
30
|
+
{ color: value["from"], at: 0 },
|
|
31
|
+
{ color: value["to"], at: 100 },
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function walkGradients(value: unknown): unknown {
|
|
37
|
+
if (Array.isArray(value)) {
|
|
38
|
+
let changed = false;
|
|
39
|
+
const next = value.map((item) => {
|
|
40
|
+
const child = walkGradients(item);
|
|
41
|
+
if (child !== item) changed = true;
|
|
42
|
+
return child;
|
|
43
|
+
});
|
|
44
|
+
return changed ? next : value;
|
|
45
|
+
}
|
|
46
|
+
if (!isRecord(value)) return value;
|
|
47
|
+
let changed = false;
|
|
48
|
+
const next: Record<string, unknown> = {};
|
|
49
|
+
for (const [key, child] of Object.entries(value)) {
|
|
50
|
+
const converted = key === "gradient" ? convertGradient(child) : walkGradients(child);
|
|
51
|
+
if (converted !== child) changed = true;
|
|
52
|
+
next[key] = converted;
|
|
53
|
+
}
|
|
54
|
+
return changed ? next : value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const gradients: Migration = (doc) => walkGradients(doc) as Record<string, unknown>;
|
|
58
|
+
|
|
59
|
+
/** `LAYOUT_MIGRATIONS[n]` upgrades a version-n layout to version n + 1. Migrations must be pure. */
|
|
60
|
+
export const LAYOUT_MIGRATIONS: Readonly<Record<number, Migration>> = {
|
|
61
|
+
1: unchanged,
|
|
62
|
+
2: unchanged,
|
|
63
|
+
3: unchanged,
|
|
64
|
+
4: unchanged,
|
|
65
|
+
5: unchanged,
|
|
66
|
+
6: unchanged,
|
|
67
|
+
7: unchanged,
|
|
68
|
+
8: unchanged,
|
|
69
|
+
9: unchanged,
|
|
70
|
+
10: unchanged,
|
|
71
|
+
11: gradients,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** `DESIGN_MIGRATIONS[n]` upgrades a version-n design document to version n + 1. */
|
|
75
|
+
export const DESIGN_MIGRATIONS: Readonly<Record<number, Migration>> = {
|
|
76
|
+
1: unchanged,
|
|
77
|
+
2: unchanged,
|
|
78
|
+
3: unchanged,
|
|
79
|
+
4: unchanged,
|
|
80
|
+
5: unchanged,
|
|
81
|
+
6: unchanged,
|
|
82
|
+
7: unchanged,
|
|
83
|
+
8: unchanged,
|
|
84
|
+
9: unchanged,
|
|
85
|
+
10: unchanged,
|
|
86
|
+
11: gradients,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type UpgradeResult =
|
|
90
|
+
| { ok: true; doc: Record<string, unknown>; from: number }
|
|
91
|
+
| {
|
|
92
|
+
ok: false;
|
|
93
|
+
reason: "not-an-object" | "missing-version" | "newer-version" | "no-migration";
|
|
94
|
+
version?: number;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
function versionOf(doc: unknown): number | undefined {
|
|
98
|
+
if (typeof doc !== "object" || doc === null) return undefined;
|
|
99
|
+
const v = (doc as { schemaVersion?: unknown }).schemaVersion;
|
|
100
|
+
return typeof v === "number" && Number.isInteger(v) && v >= 0 ? v : undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function isNewerThanSupported(doc: unknown, current = LAYOUT_SCHEMA_VERSION): boolean {
|
|
104
|
+
const v = versionOf(doc);
|
|
105
|
+
return v !== undefined && v > current;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Runs the migration chain up to `current`. Never mutates the input. */
|
|
109
|
+
export function upgradeLayout(
|
|
110
|
+
doc: unknown,
|
|
111
|
+
migrations: Readonly<Record<number, Migration>> = LAYOUT_MIGRATIONS,
|
|
112
|
+
current = LAYOUT_SCHEMA_VERSION,
|
|
113
|
+
): UpgradeResult {
|
|
114
|
+
if (typeof doc !== "object" || doc === null || Array.isArray(doc))
|
|
115
|
+
return { ok: false, reason: "not-an-object" };
|
|
116
|
+
const from = versionOf(doc);
|
|
117
|
+
if (from === undefined) return { ok: false, reason: "missing-version" };
|
|
118
|
+
if (from > current) return { ok: false, reason: "newer-version", version: from };
|
|
119
|
+
let result = structuredClone(doc) as Record<string, unknown>;
|
|
120
|
+
for (let v = from; v < current; v++) {
|
|
121
|
+
const step = migrations[v];
|
|
122
|
+
if (!step) return { ok: false, reason: "no-migration", version: v };
|
|
123
|
+
result = { ...step(result), schemaVersion: v + 1 };
|
|
124
|
+
}
|
|
125
|
+
return { ok: true, doc: result, from };
|
|
126
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { REASONS } from "./arrange.ts";
|
|
2
|
+
import { isFormFieldType, isFormNode, type Layout, type LayoutNode } from "./schema/layout.ts";
|
|
3
|
+
import { nodeChildren } from "./tree-ops.ts";
|
|
4
|
+
import type { LayoutIssue } from "./validate.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Elements in a parent the editor would never let them into: a menu item outside a Menu, a tab
|
|
8
|
+
* panel outside Tabs, a form field outside a form, a form in a form, and so on (W-225). The
|
|
9
|
+
* same rules and messages as drag and drop (arrange.ts DROP_RULES). The editor can't build
|
|
10
|
+
* these trees, but the content API accepted them and they render broken markup (an orphan
|
|
11
|
+
* `<li>`, a panel no tab opens). Not part of validateLayout, so stored pages still render and
|
|
12
|
+
* a copied field can still be pasted; the save hook refuses them instead.
|
|
13
|
+
*/
|
|
14
|
+
export function nestingIssues(layout: Layout, max = 5): LayoutIssue[] {
|
|
15
|
+
const issues: LayoutIssue[] = [];
|
|
16
|
+
const add = (path: string, node: LayoutNode, reason: string) => {
|
|
17
|
+
if (issues.length < max) {
|
|
18
|
+
issues.push({ path, code: "nesting", message: `${reason} (${node.type} ${node.id})` });
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const walk = (node: LayoutNode, path: string, inForm: boolean): void => {
|
|
22
|
+
const kids = nodeChildren(node);
|
|
23
|
+
for (const [i, child] of kids.entries()) {
|
|
24
|
+
if (issues.length >= max) return;
|
|
25
|
+
const at = `${path}.children[${i}]`;
|
|
26
|
+
const reason = misplaced(node, child, inForm);
|
|
27
|
+
if (reason) add(at, child, reason);
|
|
28
|
+
walk(child, at, inForm || isFormNode(child));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
walk(layout.root, "root", isFormNode(layout.root));
|
|
32
|
+
return issues;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function misplaced(parent: LayoutNode, child: LayoutNode, inForm: boolean): string | undefined {
|
|
36
|
+
if (child.type === "tab-panel" && parent.type !== "tabs") return REASONS.tabOutsideTabs;
|
|
37
|
+
if (parent.type === "tabs" && child.type !== "tab-panel") return REASONS.onlyTabPanels;
|
|
38
|
+
if (child.type === "accordion-item" && parent.type !== "accordion") {
|
|
39
|
+
return REASONS.itemOutsideAccordion;
|
|
40
|
+
}
|
|
41
|
+
if (parent.type === "accordion" && child.type !== "accordion-item") {
|
|
42
|
+
return REASONS.onlyAccordionItems;
|
|
43
|
+
}
|
|
44
|
+
if (child.type === "menu-item" && parent.type !== "menu" && parent.type !== "menu-item") {
|
|
45
|
+
return REASONS.itemOutsideMenu;
|
|
46
|
+
}
|
|
47
|
+
if (parent.type === "menu" && child.type !== "menu-item") return REASONS.onlyMenuItems;
|
|
48
|
+
if (isFormNode(child) && inForm) return REASONS.nestedForm;
|
|
49
|
+
if (isFormFieldType(child.type) && !inForm) return REASONS.fieldOutsideForm;
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FormDefinitions } from "../forms/definition.ts";
|
|
2
|
+
import type { LayoutNode } from "../schema/layout.ts";
|
|
3
|
+
import type { ThemeDynamicData } from "../theme/dynamic.ts";
|
|
4
|
+
import type { VNode } from "./vnode.ts";
|
|
5
|
+
|
|
6
|
+
export type RenderMode = "public" | "editor";
|
|
7
|
+
|
|
8
|
+
/** What the per-element renderers share with the page walk. */
|
|
9
|
+
export type RenderContext = {
|
|
10
|
+
mode: RenderMode;
|
|
11
|
+
definitions: FormDefinitions;
|
|
12
|
+
/** Renders child nodes against the given dynamic data, dropping those that render nothing. */
|
|
13
|
+
children: (nodes: LayoutNode[], dynamic: ThemeDynamicData | undefined) => VNode[];
|
|
14
|
+
/**
|
|
15
|
+
* An HTML id unique in this render (W-249): `base` the first time, then `base-r2`, `base-r3`.
|
|
16
|
+
* The same synced section placed twice, or a loop item repeated per post, renders the same
|
|
17
|
+
* element ids again; Tabs, form fields and the honeypot use this so labels and radio groups
|
|
18
|
+
* stay with their own copy.
|
|
19
|
+
*/
|
|
20
|
+
uniqueId: (base: string) => string;
|
|
21
|
+
};
|