@perkyzz/emvb 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +2 -2
- package/src/admin/bulk-api.ts +5 -1
- package/src/admin/content-item.ts +3 -0
- package/src/admin/copy-rich-text.ts +99 -9
- package/src/admin/editor/A11yCopilot.tsx +3 -1
- package/src/admin/editor/Editor.tsx +28 -3
- package/src/admin/editor/Timeline.tsx +1 -8
- package/src/admin/editor/canvas/DeviceBar.tsx +7 -2
- package/src/admin/editor/canvas/EmptyCanvas.tsx +11 -2
- package/src/admin/editor/canvas/use-canvas-dnd.ts +1 -20
- package/src/admin/editor/canvas/vnode-react.tsx +2 -0
- package/src/admin/editor/co-design.ts +36 -1
- package/src/admin/editor/collection-previews.ts +7 -8
- package/src/admin/editor/dnd/dragged-source.ts +22 -0
- package/src/admin/editor/dnd/layer-drop.ts +141 -0
- package/src/admin/editor/dnd/new-element.ts +16 -0
- package/src/admin/editor/editor-css.ts +9 -1
- package/src/admin/editor/element-chrome.ts +6 -0
- package/src/admin/editor/extensions/ExtensionPanels.tsx +33 -1
- package/src/admin/editor/extensions-context.tsx +16 -1
- package/src/admin/editor/feature-css.ts +27 -0
- package/src/admin/editor/inert-links.ts +8 -0
- package/src/admin/editor/panels/ColorControl.tsx +2 -2
- package/src/admin/editor/panels/ConditionsEditor.tsx +18 -0
- package/src/admin/editor/panels/ElementPanel.tsx +2 -2
- package/src/admin/editor/panels/FontFaces.tsx +342 -0
- package/src/admin/editor/panels/LayersPanel.tsx +56 -6
- package/src/admin/editor/panels/LeftPanel.tsx +153 -29
- package/src/admin/editor/panels/SettingsPanel.tsx +1 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +5 -0
- package/src/admin/editor/panels/TemplatesPanel.tsx +205 -0
- package/src/admin/editor/panels/TokenScales.tsx +2 -0
- package/src/admin/editor/panels/TriggersEditor.tsx +203 -9
- package/src/admin/editor/panels/VariableSection.tsx +111 -7
- package/src/admin/editor/panels/color-space.ts +71 -6
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +3 -0
- package/src/admin/editor/panels/settings/FieldControl.tsx +33 -0
- package/src/admin/editor/panels/settings/FormBindControl.tsx +27 -31
- package/src/admin/editor/panels/settings/ImageFieldControl.tsx +106 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +9 -3
- package/src/admin/editor/panels/settings/StickyControl.tsx +97 -0
- package/src/admin/editor/panels/settings/StyleRow.tsx +14 -0
- package/src/admin/editor/panels/settings/loop-context.ts +34 -3
- package/src/admin/editor/panels/settings/style-sections.ts +19 -2
- package/src/admin/editor/panels/url-rules.ts +43 -0
- package/src/admin/editor/panels/use-layers-drop.ts +232 -0
- package/src/admin/editor/store.ts +4 -2
- package/src/admin/editor/useExtensions.ts +3 -1
- package/src/admin/editor/useNodeActions.ts +74 -1
- package/src/admin/editor/useSave.ts +116 -85
- package/src/admin/export-api.ts +27 -2
- package/src/admin/extension-outputs.ts +236 -0
- package/src/admin/font-files-api.ts +38 -0
- package/src/admin/import-forms.ts +133 -0
- package/src/admin/pages/ImportButton.tsx +15 -4
- package/src/admin/pages/ImportElementorDialog.tsx +53 -187
- package/src/admin/pages/ImportForms.tsx +71 -0
- package/src/admin/pages/ImportHtmlDialog.tsx +209 -0
- package/src/admin/pages/ImportImageCopies.tsx +167 -0
- package/src/admin/pages/ImportReport.tsx +63 -0
- package/src/admin/pages/NewPageDialog.tsx +54 -32
- package/src/admin/pages/PageList.tsx +9 -0
- package/src/admin/pages/ThemePartList.tsx +9 -0
- package/src/admin/setup/plan.ts +2 -0
- package/src/admin/ui.ts +7 -0
- package/src/admin/widgets/ConvertToRichText.tsx +3 -2
- package/src/astro/EmVBPage.astro +5 -2
- package/src/astro/extension-styles.ts +35 -0
- package/src/astro/forms/EmVBFormsClient.astro +3 -0
- package/src/astro/forms/enhance.ts +107 -0
- package/src/astro/popups/runtime.ts +47 -2
- package/src/astro/render.ts +25 -4
- package/src/astro/resolve-theme.ts +11 -4
- package/src/astro/resolve.ts +2 -0
- package/src/astro/theme-posts.ts +17 -23
- package/src/astro/visitor.ts +14 -5
- package/src/astro/widgets/EmVBStickyRuntime.astro +9 -0
- package/src/astro/widgets/EmVBThemeRuntime.astro +9 -0
- package/src/astro/widgets/EmVBWidgetRuntimes.astro +12 -0
- package/src/astro/widgets/alerts.ts +16 -2
- package/src/astro/widgets/carousel.ts +65 -24
- package/src/astro/widgets/countdown.ts +18 -7
- package/src/astro/widgets/extension-runtimes.ts +27 -0
- package/src/astro/widgets/headline.ts +14 -5
- package/src/astro/widgets/sticky.ts +87 -0
- package/src/astro/widgets/theme.ts +52 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +150 -2
- package/src/core/arrange.ts +19 -1
- package/src/core/css/font-face.ts +72 -0
- package/src/core/css/generate.ts +41 -2
- package/src/core/css/trace.ts +8 -0
- package/src/core/data/bindings.ts +7 -4
- package/src/core/elements/dynamic-elements.ts +1 -1
- package/src/core/elements/element-nouns.ts +48 -0
- package/src/core/elements/form-elements.ts +119 -9
- package/src/core/elements/icon-svg.ts +14 -0
- package/src/core/elements/index.ts +24 -4
- package/src/core/elements/input-limits.ts +44 -0
- package/src/core/elements/menu.ts +109 -47
- package/src/core/elements/site.ts +108 -0
- package/src/core/elements/widgets.ts +13 -3
- package/src/core/export/runtimes.generated.ts +7 -5
- package/src/core/export/site.ts +53 -4
- package/src/core/extensions/classes.ts +114 -0
- package/src/core/extensions/index.ts +19 -2
- package/src/core/extensions/normalize.ts +13 -0
- package/src/core/extensions/placeholder.ts +7 -2
- package/src/core/extensions/registry.ts +134 -10
- package/src/core/extensions/render-ext.ts +115 -36
- package/src/core/extensions/safe-nodes.ts +67 -11
- package/src/core/extensions/types.ts +48 -1
- package/src/core/fonts/files.ts +74 -0
- package/src/core/fonts/google.ts +112 -0
- package/src/core/fonts/test-font.ts +9 -0
- package/src/core/import/elementor/context.ts +42 -4
- package/src/core/import/elementor/index.ts +55 -23
- package/src/core/import/elementor/widgets.ts +242 -20
- package/src/core/import/html/blocks.ts +602 -0
- package/src/core/import/html/index.ts +155 -0
- package/src/core/import/html/map.ts +958 -0
- package/src/core/import/html/parse.ts +430 -0
- package/src/core/index.ts +54 -0
- package/src/core/migrate/v18.ts +3 -0
- package/src/core/public-attributes.ts +17 -0
- package/src/core/render/extras.ts +31 -7
- package/src/core/render/form.ts +103 -10
- package/src/core/render/index.ts +165 -16
- package/src/core/render/section.ts +31 -1
- package/src/core/render/spacer-basis.ts +102 -0
- package/src/core/render/theme-boot.ts +16 -0
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +68 -3
- package/src/core/sanitize/motion.ts +12 -0
- package/src/core/schema/design.ts +40 -0
- package/src/core/schema/layout.ts +118 -6
- package/src/core/schema/style.ts +28 -0
- package/src/core/templates/index.ts +218 -0
- package/src/core/templates/pages.ts +29 -0
- package/src/core/templates/sections.ts +794 -0
- package/src/core/templates/types.ts +9 -0
- package/src/core/theme/dynamic.ts +9 -6
- package/src/core/theme/media-value.ts +88 -0
- package/src/core/theme/popup-markup.ts +21 -2
- package/src/core/theme/popup-rules.ts +36 -0
- package/src/core/theme/triggers.ts +64 -5
- package/src/core/translatable.ts +5 -2
- package/src/core/visitor-cookie.ts +91 -0
- package/src/extension-build.ts +331 -0
- package/src/index.ts +53 -4
- package/src/mcp/agent-defaults.ts +40 -0
- package/src/mcp/brief.ts +191 -0
- package/src/mcp/extensions.ts +138 -0
- package/src/mcp/prompts.ts +33 -0
- package/src/mcp/read.ts +84 -20
- package/src/mcp/tools.ts +42 -3
- package/src/mcp/write.ts +124 -9
- package/src/server/extension-routes.ts +110 -0
- package/src/server/font-routes.ts +301 -0
- package/src/server/plugin.ts +15 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import from WordPress or HTML (W-1074): WordPress post content (Gutenberg block markup) or any
|
|
3
|
+
* HTML page → an EmVB layout and a report, like the Elementor import (D-069). Pure and
|
|
4
|
+
* synchronous; the admin passes the pasted or uploaded text in and nothing is ever fetched.
|
|
5
|
+
* The result is always a layout EmVB accepts: what fails validation is pruned and reported.
|
|
6
|
+
*/
|
|
7
|
+
import type { Layout } from "../../schema/layout.ts";
|
|
8
|
+
import { ImportContext, type ImportNote, type ImportOptions } from "../elementor/context.ts";
|
|
9
|
+
import { cleanText, stripControl } from "../elementor/html.ts";
|
|
10
|
+
import { pointAtCopies, validImport } from "../elementor/index.ts";
|
|
11
|
+
import { mapBlock } from "./blocks.ts";
|
|
12
|
+
import { Mapper } from "./map.ts";
|
|
13
|
+
import { type HtmlElement, type HtmlNode, parseHtml } from "./parse.ts";
|
|
14
|
+
|
|
15
|
+
/** Pasted or uploaded HTML larger than this is refused before reading. */
|
|
16
|
+
export const MAX_HTML_IMPORT_CHARS = 4 * 1024 * 1024;
|
|
17
|
+
|
|
18
|
+
export type HtmlImportOptions = Pick<ImportOptions, "media" | "random">;
|
|
19
|
+
|
|
20
|
+
export type HtmlImport =
|
|
21
|
+
| {
|
|
22
|
+
ok: true;
|
|
23
|
+
layout: Layout;
|
|
24
|
+
/** The page's `<title>` (or its first main heading). */
|
|
25
|
+
title?: string;
|
|
26
|
+
/** WordPress block markup, or plain HTML. */
|
|
27
|
+
source: "wordpress" | "html";
|
|
28
|
+
/** Blocks (WordPress) or content elements (HTML) read, and how many became EmVB elements. */
|
|
29
|
+
elements: number;
|
|
30
|
+
mapped: number;
|
|
31
|
+
notes: ImportNote[];
|
|
32
|
+
/** Images on another site the page uses (the dialog can copy them to the media library). */
|
|
33
|
+
images: string[];
|
|
34
|
+
}
|
|
35
|
+
| { ok: false; error: string };
|
|
36
|
+
|
|
37
|
+
/** The `main` element, when a whole page has exactly one: only it is imported. */
|
|
38
|
+
function mainOf(nodes: readonly HtmlNode[]): HtmlElement | undefined {
|
|
39
|
+
const found: HtmlElement[] = [];
|
|
40
|
+
const visit = (list: readonly HtmlNode[], level: number) => {
|
|
41
|
+
for (const item of list) {
|
|
42
|
+
if (item.kind !== "element" || level > 12 || found.length > 1) continue;
|
|
43
|
+
if (item.tag === "main") found.push(item);
|
|
44
|
+
else visit(item.children, level + 1);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
visit(nodes, 0);
|
|
48
|
+
return found.length === 1 ? found[0] : undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The text of the first `h1`, for the page title when there is no `<title>`. */
|
|
52
|
+
function firstHeading(nodes: readonly HtmlNode[]): string | undefined {
|
|
53
|
+
const textOf = (list: readonly HtmlNode[]): string =>
|
|
54
|
+
list.map((item) => (item.kind === "text" ? item.text : textOf(item.children))).join("");
|
|
55
|
+
const stack = [...nodes];
|
|
56
|
+
for (let seen = 0; stack.length > 0 && seen < 5000; seen++) {
|
|
57
|
+
const item = stack.shift();
|
|
58
|
+
if (!item || item.kind === "text") continue;
|
|
59
|
+
if (item.kind === "element" && item.tag === "h1")
|
|
60
|
+
return cleanText(stripControl(textOf(item.children))).slice(0, 200) || undefined;
|
|
61
|
+
stack.unshift(...item.children);
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** WordPress post content or an HTML page → an EmVB layout and an import report. */
|
|
67
|
+
export function importHtml(input: string, options: HtmlImportOptions = {}): HtmlImport {
|
|
68
|
+
if (input.length > MAX_HTML_IMPORT_CHARS)
|
|
69
|
+
return { ok: false, error: "This file is larger than 4 MB. Import one page at a time." };
|
|
70
|
+
const text = input.trim();
|
|
71
|
+
if (!text) return { ok: false, error: "Paste or choose some HTML first." };
|
|
72
|
+
if (/^[[{]/.test(text))
|
|
73
|
+
return {
|
|
74
|
+
ok: false,
|
|
75
|
+
error: "This looks like JSON. For an Elementor export, use Import from Elementor.",
|
|
76
|
+
};
|
|
77
|
+
if (/^<\?xml[\s\S]{0,400}<rss/i.test(text))
|
|
78
|
+
return {
|
|
79
|
+
ok: false,
|
|
80
|
+
error:
|
|
81
|
+
"This is a WordPress export file (WXR). Open the post in WordPress's code editor and paste its content instead.",
|
|
82
|
+
};
|
|
83
|
+
const parsed = parseHtml(text);
|
|
84
|
+
const ctx = new ImportContext(options);
|
|
85
|
+
ctx.findOldSite(text.slice(0, 1_000_000));
|
|
86
|
+
const gutenberg = parsed.blocks;
|
|
87
|
+
const m = new Mapper(ctx, gutenberg, mapBlock);
|
|
88
|
+
|
|
89
|
+
let nodes = parsed.nodes;
|
|
90
|
+
const main = gutenberg ? undefined : mainOf(nodes);
|
|
91
|
+
if (main) {
|
|
92
|
+
nodes = main.children;
|
|
93
|
+
ctx.note(
|
|
94
|
+
"approximated",
|
|
95
|
+
"Page",
|
|
96
|
+
"Only the page's main content was imported. Its header, navigation and footer were left out; build those in Theme Builder.",
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
const children = m.nodes(nodes, 1);
|
|
100
|
+
for (const what of parsed.dropped)
|
|
101
|
+
ctx.note("skipped", "Scripts and styles", `Left out: ${what}.`);
|
|
102
|
+
if (parsed.flattened)
|
|
103
|
+
ctx.note("approximated", "Page", "Markup nested very deeply was flattened.");
|
|
104
|
+
if (parsed.cut)
|
|
105
|
+
ctx.note(
|
|
106
|
+
"skipped",
|
|
107
|
+
"Page",
|
|
108
|
+
"The page has more markup than one import reads; the rest was left out.",
|
|
109
|
+
);
|
|
110
|
+
if (children.length === 0)
|
|
111
|
+
return {
|
|
112
|
+
ok: false,
|
|
113
|
+
error:
|
|
114
|
+
"Nothing in this HTML could be imported." +
|
|
115
|
+
(ctx.report()[0] ? ` (${ctx.report()[0]?.message})` : " It has no text, images or videos."),
|
|
116
|
+
};
|
|
117
|
+
ctx.note(
|
|
118
|
+
"approximated",
|
|
119
|
+
"Styles",
|
|
120
|
+
"Your old site's stylesheets and classes aren't imported; the page takes your EmVB site styles.",
|
|
121
|
+
);
|
|
122
|
+
const root = m.node(
|
|
123
|
+
"container",
|
|
124
|
+
{},
|
|
125
|
+
{
|
|
126
|
+
style: {
|
|
127
|
+
flexDirection: "column",
|
|
128
|
+
gap: { value: 16, unit: "px" },
|
|
129
|
+
width: { value: 100, unit: "%" },
|
|
130
|
+
maxWidth: { value: 1140, unit: "px" },
|
|
131
|
+
marginLeft: "auto",
|
|
132
|
+
marginRight: "auto",
|
|
133
|
+
paddingTop: { value: 40, unit: "px" },
|
|
134
|
+
paddingBottom: { value: 40, unit: "px" },
|
|
135
|
+
paddingLeft: { value: 20, unit: "px" },
|
|
136
|
+
paddingRight: { value: 20, unit: "px" },
|
|
137
|
+
},
|
|
138
|
+
children,
|
|
139
|
+
},
|
|
140
|
+
);
|
|
141
|
+
if (options.media) pointAtCopies(root, ctx);
|
|
142
|
+
const checked = validImport(root, ctx);
|
|
143
|
+
if (!checked.ok) return checked;
|
|
144
|
+
const title = parsed.title ?? firstHeading(nodes);
|
|
145
|
+
return {
|
|
146
|
+
ok: true,
|
|
147
|
+
layout: checked.layout,
|
|
148
|
+
...(title ? { title } : {}),
|
|
149
|
+
source: gutenberg ? "wordpress" : "html",
|
|
150
|
+
elements: ctx.elements,
|
|
151
|
+
mapped: ctx.mapped,
|
|
152
|
+
notes: ctx.report(),
|
|
153
|
+
images: [...ctx.images],
|
|
154
|
+
};
|
|
155
|
+
}
|