@puckeditor/core 0.22.1 → 0.23.0-canary.7ca16bcb

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.
@@ -4,16 +4,16 @@ import {
4
4
  import {
5
5
  EditorInner,
6
6
  LoadedRichTextMenu
7
- } from "./chunk-VOB4L2BJ.mjs";
7
+ } from "./chunk-WABMBXFK.mjs";
8
8
  import "./chunk-H635BA2V.mjs";
9
- import "./chunk-73XKHVBN.mjs";
10
- import "./chunk-2AATV7NG.mjs";
11
- import "./chunk-BVKXFA4V.mjs";
12
- import "./chunk-DATOBXTJ.mjs";
9
+ import "./chunk-OI2LQGRV.mjs";
10
+ import "./chunk-G3YMTKUD.mjs";
11
+ import "./chunk-X4NMPUXH.mjs";
12
+ import "./chunk-EQADD6J2.mjs";
13
13
  import {
14
14
  useAppStore,
15
15
  useAppStoreApi
16
- } from "./chunk-54LFCIWQ.mjs";
16
+ } from "./chunk-2KHLVDRT.mjs";
17
17
  import "./chunk-HRNJ42TO.mjs";
18
18
  import "./chunk-GR7NLT4T.mjs";
19
19
  import "./chunk-Y2EFNT5P.mjs";
@@ -1134,7 +1134,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
1134
1134
  const componentData = node == null ? void 0 : node.data;
1135
1135
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node.parentId] : null;
1136
1136
  const parent = (parentNode == null ? void 0 : parentNode.data) || null;
1137
- const { getComponentConfig, state } = appStore.getState();
1137
+ const { getComponentConfig, state, config } = appStore.getState();
1138
1138
  const componentConfig = getComponentConfig(componentData == null ? void 0 : componentData.type);
1139
1139
  if (!componentData || !componentConfig) return;
1140
1140
  const defaultFields = componentConfig.fields || {};
@@ -1167,6 +1167,9 @@ var useRegisterFieldsSlice = (appStore, id) => {
1167
1167
  if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== id) {
1168
1168
  return;
1169
1169
  }
1170
+ if (appStore.getState().config !== config) {
1171
+ return;
1172
+ }
1170
1173
  appStore.setState({
1171
1174
  fields: {
1172
1175
  fields: newFields,
@@ -1185,10 +1188,18 @@ var useRegisterFieldsSlice = (appStore, id) => {
1185
1188
  );
1186
1189
  useEffect4(() => {
1187
1190
  resolveFields(true);
1188
- return appStore.subscribe(
1191
+ const unsubscribeData = appStore.subscribe(
1189
1192
  (s) => s.state.indexes.nodes[id || "root"],
1190
1193
  () => resolveFields()
1191
1194
  );
1195
+ const unsubscribeConfig = appStore.subscribe(
1196
+ (s) => s.config,
1197
+ () => resolveFields(true)
1198
+ );
1199
+ return () => {
1200
+ unsubscribeData();
1201
+ unsubscribeConfig();
1202
+ };
1192
1203
  }, [id]);
1193
1204
  };
1194
1205
 
@@ -1234,6 +1245,7 @@ var createAppStore = (initialAppStore) => create2()(
1234
1245
  _experimentalFullScreenCanvas: false,
1235
1246
  _experimentalVirtualization: false,
1236
1247
  metadata: {},
1248
+ dictionary: {},
1237
1249
  fieldTransforms: {}
1238
1250
  }, initialAppStore), {
1239
1251
  fields: createFieldsSlice(set, get),
@@ -1620,6 +1632,106 @@ var useResetAutoZoom = (frameRef) => {
1620
1632
  init_react_import();
1621
1633
  var styles_module_default2 = { "Loader": "_Loader_1w5zn_13", "loader-animation": "_loader-animation_1w5zn_1" };
1622
1634
 
1635
+ // lib/use-message.ts
1636
+ init_react_import();
1637
+
1638
+ // lib/dictionary.ts
1639
+ init_react_import();
1640
+ var defaultDictionary = {
1641
+ // Header
1642
+ "header-publish": "Publish",
1643
+ "header-undo": "undo",
1644
+ "header-redo": "redo",
1645
+ "header-toggle-leftsidebar": "Toggle left sidebar",
1646
+ "header-toggle-rightsidebar": "Toggle right sidebar",
1647
+ "header-toggle-menubar": "Toggle menu bar",
1648
+ // Component action bar
1649
+ "action-selectparent": "Select parent",
1650
+ "action-duplicate": "Duplicate",
1651
+ "action-delete": "Delete",
1652
+ // Fallback labels — shared by the breadcrumbs, fields panel and header
1653
+ "label-page": "Page",
1654
+ "label-component": "Component",
1655
+ // Outline
1656
+ "outline-empty": "No items",
1657
+ "outline-collapse": "Collapse",
1658
+ "outline-expand": "Expand",
1659
+ // Drawer (component list)
1660
+ "drawer-category-collapse": "Collapse {title}",
1661
+ "drawer-category-expand": "Expand {title}",
1662
+ "drawer-category-other": "Other",
1663
+ // Canvas
1664
+ "canvas-noconfig": "No configuration for {type}",
1665
+ // Fields
1666
+ "field-readonly": "Read-only",
1667
+ "field-arrayitem-summary": "Item #{index}",
1668
+ "field-arrayitem-duplicate": "Duplicate",
1669
+ "field-arrayitem-delete": "Delete",
1670
+ "field-external-selectdata": "Select data",
1671
+ "field-external-search": "Search",
1672
+ "field-external-togglefilters": "Toggle filters",
1673
+ "field-external-item": "External item",
1674
+ "field-external-result-singular": "{count} result",
1675
+ "field-external-result-plural": "{count} results",
1676
+ // Rich text field
1677
+ "field-richtext-bold": "Bold",
1678
+ "field-richtext-italic": "Italic",
1679
+ "field-richtext-underline": "Underline",
1680
+ "field-richtext-strikethrough": "Strikethrough",
1681
+ "field-richtext-blockquote": "Blockquote",
1682
+ "field-richtext-code-inline": "Inline code",
1683
+ "field-richtext-code-block": "Code block",
1684
+ "field-richtext-list-bullet": "Bullet list",
1685
+ "field-richtext-list-ordered": "Ordered list",
1686
+ "field-richtext-horizontalrule": "Horizontal rule",
1687
+ "field-richtext-align-left": "Align left",
1688
+ "field-richtext-align-center": "Align center",
1689
+ "field-richtext-align-right": "Align right",
1690
+ "field-richtext-align-justify": "Justify",
1691
+ "field-richtext-select": "Select",
1692
+ "field-richtext-headingselect-1": "Heading 1",
1693
+ "field-richtext-headingselect-2": "Heading 2",
1694
+ "field-richtext-headingselect-3": "Heading 3",
1695
+ "field-richtext-headingselect-4": "Heading 4",
1696
+ "field-richtext-headingselect-5": "Heading 5",
1697
+ "field-richtext-headingselect-6": "Heading 6",
1698
+ "field-richtext-alignselect-left": "Left",
1699
+ "field-richtext-alignselect-center": "Center",
1700
+ "field-richtext-alignselect-right": "Right",
1701
+ "field-richtext-alignselect-justify": "Justify",
1702
+ "field-richtext-listselect-bullet": "Bullet list",
1703
+ "field-richtext-listselect-ordered": "Ordered list",
1704
+ // Viewport controls
1705
+ "viewport-zoom-in": "Zoom viewport in",
1706
+ "viewport-zoom-out": "Zoom viewport out",
1707
+ "viewport-zoom-auto": "{zoom}% (Auto)",
1708
+ "viewport-toggle-menu": "Toggle viewport menu",
1709
+ "viewport-switch": "Switch to {label} viewport",
1710
+ "viewport-switch-default": "Switch viewport",
1711
+ // Plugin bar
1712
+ "plugin-blocks": "Blocks",
1713
+ "plugin-outline": "Outline",
1714
+ "plugin-fields": "Fields",
1715
+ "plugin-components": "Components",
1716
+ // Layout
1717
+ "layout-maximize": "maximize",
1718
+ "layout-minimize": "minimize",
1719
+ // Loader
1720
+ "loader-loading": "loading"
1721
+ };
1722
+ var interpolate = (template, params) => template.replace(
1723
+ /\{(\w+)\}/g,
1724
+ (match, key) => params[key] !== void 0 ? String(params[key]) : match
1725
+ );
1726
+ var getMessage = (dictionary, key, params) => {
1727
+ var _a;
1728
+ const message = (_a = dictionary[key]) != null ? _a : defaultDictionary[key];
1729
+ return params ? interpolate(message, params) : message;
1730
+ };
1731
+
1732
+ // lib/use-message.ts
1733
+ var useMessage = (key, params) => useAppStore((s) => getMessage(s.dictionary, key, params));
1734
+
1623
1735
  // components/Loader/index.tsx
1624
1736
  import { jsx as jsx2 } from "react/jsx-runtime";
1625
1737
  var getClassName2 = get_class_name_factory_default("Loader", styles_module_default2);
@@ -1631,6 +1743,7 @@ var Loader = (_a) => {
1631
1743
  "color",
1632
1744
  "size"
1633
1745
  ]);
1746
+ const loadingLabel = useMessage("loader-loading");
1634
1747
  return /* @__PURE__ */ jsx2(
1635
1748
  "span",
1636
1749
  __spreadValues({
@@ -1640,7 +1753,7 @@ var Loader = (_a) => {
1640
1753
  height: size,
1641
1754
  color
1642
1755
  },
1643
- "aria-label": "loading"
1756
+ "aria-label": loadingLabel
1644
1757
  }, props)
1645
1758
  );
1646
1759
  };
@@ -1767,6 +1880,7 @@ var Select = ({
1767
1880
  disabled = false
1768
1881
  }) => {
1769
1882
  const [open, setOpen] = useState2(false);
1883
+ const selectLabel = useMessage("field-richtext-select");
1770
1884
  const hasOptions = options.length > 0;
1771
1885
  const isDisabled = disabled || !hasOptions;
1772
1886
  const buttonInner = /* @__PURE__ */ jsxs3("div", { className: getClassName4("buttonInner"), children: [
@@ -1776,7 +1890,7 @@ var Select = ({
1776
1890
  const trigger = mode === "actionBar" ? /* @__PURE__ */ jsx4(Action, { active: value !== defaultValue, disabled: isDisabled, children: buttonInner }) : /* @__PURE__ */ jsx4(
1777
1891
  IconButton,
1778
1892
  {
1779
- title: "Select",
1893
+ title: selectLabel,
1780
1894
  active: value !== defaultValue,
1781
1895
  disabled: isDisabled,
1782
1896
  children: buttonInner
@@ -1922,6 +2036,7 @@ export {
1922
2036
  useAppStoreApi,
1923
2037
  getBox,
1924
2038
  useResetAutoZoom,
2039
+ useMessage,
1925
2040
  Loader,
1926
2041
  IconButton,
1927
2042
  ControlContext,