@perkyzz/emvb 1.0.0 → 1.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.
Files changed (142) hide show
  1. package/README.md +9 -0
  2. package/THIRD_PARTY_NOTICES.md +1 -0
  3. package/package.json +10 -9
  4. package/src/admin/agents-api.ts +5 -1
  5. package/src/admin/bulk-api.ts +67 -0
  6. package/src/admin/content-api.ts +39 -6
  7. package/src/admin/copy-rich-text.ts +119 -0
  8. package/src/admin/dialog-tab-wrap.ts +78 -0
  9. package/src/admin/editor/A11yCopilot.tsx +2 -0
  10. package/src/admin/editor/Editor.tsx +24 -7
  11. package/src/admin/editor/ScheduleDialog.tsx +167 -0
  12. package/src/admin/editor/Timeline.tsx +6 -2
  13. package/src/admin/editor/TopBar.tsx +60 -8
  14. package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
  15. package/src/admin/editor/canvas/DeviceBar.tsx +22 -9
  16. package/src/admin/editor/canvas/canvas-scale.ts +3 -3
  17. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  18. package/src/admin/editor/dnd/new-element.ts +68 -0
  19. package/src/admin/editor/editor-chrome.tsx +16 -5
  20. package/src/admin/editor/editor-commands.ts +10 -4
  21. package/src/admin/editor/editor-css.ts +2 -1
  22. package/src/admin/editor/element-chrome.ts +22 -0
  23. package/src/admin/editor/panels/ElementPanel.tsx +34 -17
  24. package/src/admin/editor/panels/SettingsPanel.tsx +2 -2
  25. package/src/admin/editor/panels/settings/DraftTextField.tsx +33 -1
  26. package/src/admin/editor/panels/settings/EffectsControls.tsx +79 -1
  27. package/src/admin/editor/panels/settings/FieldBindControl.tsx +6 -1
  28. package/src/admin/editor/panels/settings/FieldControl.tsx +10 -1
  29. package/src/admin/editor/panels/settings/IconControls.tsx +11 -0
  30. package/src/admin/editor/panels/settings/IconPicker.tsx +4 -1
  31. package/src/admin/editor/panels/settings/ItemList.tsx +36 -2
  32. package/src/admin/editor/panels/settings/LengthRow.tsx +36 -3
  33. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +18 -0
  34. package/src/admin/editor/panels/settings/StyleRow.tsx +7 -0
  35. package/src/admin/editor/panels/settings/advanced-rules.ts +3 -0
  36. package/src/admin/editor/panels/settings/length-units.ts +15 -3
  37. package/src/admin/editor/panels/settings/style-sections.ts +1 -0
  38. package/src/admin/editor/panels/style-target.ts +17 -4
  39. package/src/admin/editor/section-templates.ts +26 -4
  40. package/src/admin/editor/store.ts +15 -3
  41. package/src/admin/editor/useEditorCommands.ts +7 -5
  42. package/src/admin/editor/useEditorData.ts +4 -0
  43. package/src/admin/editor/useNodeActions.ts +4 -2
  44. package/src/admin/editor/useSave.ts +47 -3
  45. package/src/admin/export-api.ts +238 -0
  46. package/src/admin/index.tsx +6 -1
  47. package/src/admin/menus-api.ts +113 -0
  48. package/src/admin/pages/ExportDialog.tsx +395 -0
  49. package/src/admin/pages/ImportElementorDialog.tsx +25 -1
  50. package/src/admin/pages/PageList.tsx +67 -2
  51. package/src/admin/pages/ThemePartList.tsx +37 -1
  52. package/src/admin/pages/bulk.tsx +303 -0
  53. package/src/admin/search.ts +20 -0
  54. package/src/admin/theme-api.ts +4 -0
  55. package/src/admin/ui.ts +11 -2
  56. package/src/admin/widgets/CanvasField.tsx +8 -0
  57. package/src/admin/widgets/ConvertToRichText.tsx +136 -0
  58. package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
  59. package/src/admin/widgets/convert-body.ts +73 -2
  60. package/src/astro/EmVBPage.astro +3 -0
  61. package/src/astro/render.ts +47 -22
  62. package/src/astro/request-data.ts +3 -0
  63. package/src/astro/resolve-theme.ts +88 -51
  64. package/src/astro/tabs/runtime.ts +16 -6
  65. package/src/astro/visitor.ts +23 -4
  66. package/src/astro/widgets/EmVBAlertsRuntime.astro +8 -0
  67. package/src/astro/widgets/EmVBCarouselRuntime.astro +8 -0
  68. package/src/astro/widgets/EmVBLightboxRuntime.astro +8 -0
  69. package/src/astro/widgets/EmVBWidgetRuntimes.astro +19 -0
  70. package/src/astro/widgets/alerts.ts +37 -0
  71. package/src/astro/widgets/carousel.ts +167 -0
  72. package/src/astro/widgets/index.ts +1 -0
  73. package/src/astro/widgets/lightbox.ts +123 -0
  74. package/src/constants.ts +1 -1
  75. package/src/core/a11y/audit.ts +103 -3
  76. package/src/core/arrange.ts +57 -1
  77. package/src/core/bounded-array.ts +16 -13
  78. package/src/core/contract.ts +26 -3
  79. package/src/core/css/generate.ts +83 -21
  80. package/src/core/css/scope.ts +10 -2
  81. package/src/core/css/trace.ts +33 -8
  82. package/src/core/design/classes.ts +25 -5
  83. package/src/core/design/devices.ts +78 -2
  84. package/src/core/design/variables.ts +14 -1
  85. package/src/core/elements/icon-svg.ts +135 -0
  86. package/src/core/elements/index.ts +33 -127
  87. package/src/core/elements/widgets.ts +907 -0
  88. package/src/core/export/runtimes.generated.ts +12 -0
  89. package/src/core/export/site.ts +579 -0
  90. package/src/core/export/zip.ts +95 -0
  91. package/src/core/extensions/schema.ts +2 -1
  92. package/src/core/geo-trust.ts +18 -0
  93. package/src/core/history/diff.ts +25 -0
  94. package/src/core/icons/social.generated.ts +29 -0
  95. package/src/core/image-edit/schema.ts +2 -1
  96. package/src/core/import/elementor/atomic.ts +22 -9
  97. package/src/core/import/elementor/context.ts +18 -0
  98. package/src/core/import/elementor/index.ts +72 -11
  99. package/src/core/import/elementor/style.ts +21 -1
  100. package/src/core/import/elementor/widgets.ts +394 -133
  101. package/src/core/index.ts +14 -0
  102. package/src/core/issue-cap.ts +19 -0
  103. package/src/core/json-schema.ts +8 -1
  104. package/src/core/limits.ts +6 -0
  105. package/src/core/loop-collections.ts +33 -0
  106. package/src/core/perf/meter.ts +37 -19
  107. package/src/core/portable-text-export.ts +243 -0
  108. package/src/core/proposals.ts +8 -2
  109. package/src/core/public-attributes.ts +30 -0
  110. package/src/core/render/index.ts +115 -13
  111. package/src/core/render/tabs.ts +18 -11
  112. package/src/core/render/vnode.ts +44 -6
  113. package/src/core/sanitize/css.ts +26 -0
  114. package/src/core/sanitize/svg-upload.ts +276 -23
  115. package/src/core/sanitize/svg.ts +3 -3
  116. package/src/core/schema/descriptors.ts +4 -0
  117. package/src/core/schema/design.ts +8 -7
  118. package/src/core/schema/layout.ts +406 -18
  119. package/src/core/schema/style.ts +49 -1
  120. package/src/core/search-text.ts +70 -0
  121. package/src/core/shadowing-ids.ts +41 -0
  122. package/src/core/theme/conditions.ts +2 -1
  123. package/src/core/theme/float.ts +1 -0
  124. package/src/core/theme/parse-doc.ts +10 -5
  125. package/src/core/theme/popup-rules.ts +16 -0
  126. package/src/core/theme/triggers.ts +3 -2
  127. package/src/core/validate.ts +3 -2
  128. package/src/index.ts +23 -2
  129. package/src/mcp/ports.ts +18 -7
  130. package/src/mcp/proposals.ts +36 -11
  131. package/src/mcp/read.ts +2 -3
  132. package/src/mcp/tools.ts +1 -1
  133. package/src/server/agent-settings.ts +12 -1
  134. package/src/server/hooks.ts +41 -6
  135. package/src/server/icon-routes.ts +52 -12
  136. package/src/server/mcp-routes.ts +11 -5
  137. package/src/server/plugin.ts +27 -2
  138. package/src/server/presence.ts +5 -1
  139. package/src/server/proposals.ts +16 -4
  140. package/src/server/requests.ts +60 -11
  141. package/src/server/site-origin.ts +13 -0
  142. package/src/server/targets.ts +26 -0
@@ -36,7 +36,22 @@ import { resolveEmbedUrl } from "../sanitize/embed-url.ts";
36
36
  import type { VNode } from "../render/vnode.ts";
37
37
 
38
38
  import type { ElementDefinition } from "./definition.ts";
39
+ import { ICON_STROKE_WIDTHS, iconGlyph } from "./icon-svg.ts";
40
+ export { iconHasAdjustableStroke, iconHasOwnColors } from "./icon-svg.ts";
39
41
  import { menu, menuItem } from "./menu.ts";
42
+ import {
43
+ alert,
44
+ carousel,
45
+ carouselSlide,
46
+ gallery,
47
+ galleryImage,
48
+ iconBox,
49
+ imageBox,
50
+ rating,
51
+ socialIcons,
52
+ socialLink,
53
+ testimonial,
54
+ } from "./widgets.ts";
40
55
  import { checkbox, form, radio, selectEl, submit, textInput, textareaEl } from "./form-elements.ts";
41
56
  import {
42
57
  loop,
@@ -608,9 +623,6 @@ function imageSources(
608
623
  return parts.join(", ");
609
624
  }
610
625
 
611
- /** Root stroke widths the Stroke width control can override (W-237); Lucide and Tabler use 2. */
612
- const ICON_STROKE_WIDTHS = ["1", "1.5", "2", "2.5", "3"] as const;
613
-
614
626
  const icon: ElementDefinition<IconNode> = {
615
627
  baseCss:
616
628
  // W-237: the glyph reads the wrapper's icon custom properties (rotate, flip, shadow, loop,
@@ -651,10 +663,12 @@ const icon: ElementDefinition<IconNode> = {
651
663
  ],
652
664
  },
653
665
  build: (node, attrs) => {
654
- // W-234: a picked library icon carries its own SVG; the allowlist checks it on every render.
655
- const picked = node.props.iconSvg ? sanitizeSvgMarkup(node.props.iconSvg) : undefined;
656
- const bundled = picked ? undefined : getBundledIcon(node.props.iconId);
657
- if (!picked && !bundled) {
666
+ const decorative = node.props.decorative === true;
667
+ const aria: Record<string, string> = decorative
668
+ ? { "aria-hidden": "true" }
669
+ : { role: "img", ...(node.props.title ? { "aria-label": node.props.title } : {}) };
670
+ const svg = iconGlyph(node.props, node.props.size ?? 24, aria);
671
+ if (!svg) {
658
672
  // Never treat iconId as a URL or raw HTML (R-032 / R-033).
659
673
  return {
660
674
  tag: "span",
@@ -666,48 +680,7 @@ const icon: ElementDefinition<IconNode> = {
666
680
  children: [],
667
681
  };
668
682
  }
669
- const decorative = node.props.decorative === true;
670
- const size = node.props.size ?? 24;
671
- const svgAttrs: Record<string, string> = picked
672
- ? {
673
- ...pickedIconAttrs(picked.attrs),
674
- width: String(size),
675
- height: String(size),
676
- focusable: "false",
677
- }
678
- : {
679
- xmlns: "http://www.w3.org/2000/svg",
680
- width: String(size),
681
- height: String(size),
682
- viewBox: "0 0 24 24",
683
- fill: "none",
684
- stroke: "currentColor",
685
- "stroke-width": "2",
686
- "stroke-linecap": "round",
687
- "stroke-linejoin": "round",
688
- focusable: "false",
689
- };
690
- if (decorative) {
691
- svgAttrs["aria-hidden"] = "true";
692
- } else {
693
- svgAttrs.role = "img";
694
- if (node.props.title) svgAttrs["aria-label"] = node.props.title;
695
- }
696
- const children: (VNode | string)[] = picked
697
- ? picked.children
698
- : (bundled?.children ?? []).map((child) => ({
699
- tag: child.tag,
700
- attrs: { ...child.attrs },
701
- children: [],
702
- }));
703
- strokeClass(svgAttrs);
704
- const single = picked !== undefined && node.props.singleColor === true;
705
- if (single) monochromeRoot(svgAttrs);
706
- const svg: VNode = {
707
- tag: "svg",
708
- attrs: svgAttrs,
709
- children: single ? monochrome(children) : children,
710
- };
683
+ const svgAttrs = svg.attrs;
711
684
  // A linked icon is named by its title on the link, so the svg inside is hidden.
712
685
  const title = node.props.title?.trim();
713
686
  const { role: _role, "aria-label": _label, ...plain } = svgAttrs;
@@ -721,84 +694,6 @@ const icon: ElementDefinition<IconNode> = {
721
694
  },
722
695
  };
723
696
 
724
- /**
725
- * W-237: a stroke icon's root `stroke-width` moves into a class whose CSS reads the wrapper's
726
- * `--emvb-icon-stroke` with the original width as fallback; any other width stays as it was.
727
- */
728
- function strokeClass(svgAttrs: Record<string, string>): void {
729
- const width = svgAttrs["stroke-width"];
730
- if (!width || !(ICON_STROKE_WIDTHS as readonly string[]).includes(width)) return;
731
- if (!svgAttrs.stroke || svgAttrs.stroke === "none") return;
732
- delete svgAttrs["stroke-width"];
733
- const cls = `emvb-icon-sw${width.replace(".", "_")}`;
734
- svgAttrs.class = svgAttrs.class ? `${svgAttrs.class} ${cls}` : cls;
735
- }
736
-
737
- /** Whether an icon's SVG is stroke-drawn with an adjustable width (the panel shows the control). */
738
- export function iconHasAdjustableStroke(svg: string | undefined): boolean {
739
- if (!svg) return true; // bundled Lucide
740
- const picked = sanitizeSvgMarkup(svg);
741
- if (!picked) return false;
742
- const attrs = pickedIconAttrs(picked.attrs);
743
- const before = attrs["stroke-width"];
744
- strokeClass(attrs);
745
- return before !== undefined && attrs["stroke-width"] === undefined;
746
- }
747
-
748
- /** Paint attributes a multi-colour SVG sets its colours with (W-238). */
749
- const PAINT_ATTRS = ["fill", "stroke", "stop-color"] as const;
750
-
751
- const ownColor = (value: string | undefined) =>
752
- value !== undefined && value !== "none" && value.toLowerCase() !== "currentcolor";
753
-
754
- /** W-238: every fill, stroke and gradient stop becomes the icon's colour; `none` stays none. */
755
- function monochrome(nodes: (VNode | string)[]): (VNode | string)[] {
756
- return nodes.map((child) => {
757
- if (typeof child === "string") return child;
758
- const attrs = { ...child.attrs };
759
- for (const name of PAINT_ATTRS) if (ownColor(attrs[name])) attrs[name] = "currentColor";
760
- return { ...child, attrs, children: monochrome(child.children) };
761
- });
762
- }
763
-
764
- /** The root too; without a fill, SVG paints black, so it gets the icon's colour. */
765
- function monochromeRoot(attrs: Record<string, string>): void {
766
- if (attrs.fill === undefined || ownColor(attrs.fill)) attrs.fill = "currentColor";
767
- if (ownColor(attrs.stroke)) attrs.stroke = "currentColor";
768
- }
769
-
770
- /**
771
- * Whether an icon's SVG paints with its own colours (W-238): any fill, stroke or stop other than
772
- * `none`/`currentColor`, or a root without a fill (SVG's default is black). The panel offers
773
- * Force single colour only then. Bundled Lucide icons follow the icon's colour already.
774
- */
775
- export function iconHasOwnColors(svg: string | undefined): boolean {
776
- if (!svg) return false;
777
- const picked = sanitizeSvgMarkup(svg);
778
- if (!picked) return false;
779
- if (picked.attrs.fill === undefined || PAINT_ATTRS.some((name) => ownColor(picked.attrs[name])))
780
- return true;
781
- const walk = (nodes: (VNode | string)[]): boolean =>
782
- nodes.some(
783
- (child) =>
784
- typeof child !== "string" &&
785
- (PAINT_ATTRS.some((name) => ownColor(child.attrs[name])) || walk(child.children)),
786
- );
787
- return walk(picked.children);
788
- }
789
-
790
- /** A picked icon's root attributes minus what the element sets itself (size, name, id). */
791
- function pickedIconAttrs(attrs: Record<string, string>): Record<string, string> {
792
- const kept: Record<string, string> = { xmlns: "http://www.w3.org/2000/svg" };
793
- for (const [name, value] of Object.entries(attrs)) {
794
- if (name === "width" || name === "height" || name === "id" || name === "role") continue;
795
- if (name.startsWith("aria-") || name === "focusable") continue;
796
- kept[name] = value;
797
- }
798
- if (!kept.viewBox) kept.viewBox = "0 0 24 24";
799
- return kept;
800
- }
801
-
802
697
  const video: ElementDefinition<VideoNode> = {
803
698
  baseCss:
804
699
  // W-266: the iframe or <video> is the .emvb-video element itself, so the 16:9 size sits on it
@@ -1218,6 +1113,17 @@ export const ELEMENTS = {
1218
1113
  heading,
1219
1114
  toc,
1220
1115
  "language-switcher": languageSwitcher,
1116
+ rating,
1117
+ alert,
1118
+ "icon-box": iconBox,
1119
+ "image-box": imageBox,
1120
+ testimonial,
1121
+ "social-icons": socialIcons,
1122
+ "social-link": socialLink,
1123
+ gallery,
1124
+ "gallery-image": galleryImage,
1125
+ carousel,
1126
+ "carousel-slide": carouselSlide,
1221
1127
  container,
1222
1128
  "layout-section": layoutSection,
1223
1129
  spacer,