@trycourier/react-designer 0.0.0-canary-20251113171853 → 0.0.0-canary-20251113174211

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.
@@ -9,6 +9,6 @@ interface UseSyncEditorItemsProps {
9
9
  editor?: Editor | null;
10
10
  }
11
11
  export declare const useSyncEditorItems: ({ setItems, rafId, editor }: UseSyncEditorItemsProps) => {
12
- syncEditorItems: (editor: Editor) => () => void;
12
+ syncEditorItems: (editor: Editor) => undefined;
13
13
  };
14
14
  export {};
package/dist/esm/index.js CHANGED
@@ -16243,84 +16243,51 @@ var useSyncEditorItems = /* @__PURE__ */ __name(({ setItems, rafId, editor }) =>
16243
16243
  if (rafId.current && typeof cancelAnimationFrame !== "undefined") {
16244
16244
  cancelAnimationFrame(rafId.current);
16245
16245
  }
16246
- const timeoutId = setTimeout(() => {
16247
- if (typeof requestAnimationFrame !== "undefined") {
16248
- rafId.current = requestAnimationFrame(() => {
16249
- try {
16250
- const editorDOM = editor2 == null ? void 0 : editor2.view.dom;
16251
- if (!editorDOM) {
16252
- return;
16253
- }
16254
- const nodeWrappers = editorDOM.querySelectorAll(
16255
- ".react-renderer > div[data-node-view-wrapper][data-id]"
16256
- );
16257
- const domIds = [];
16258
- nodeWrappers.forEach((wrapper) => {
16259
- const htmlWrapper = wrapper;
16260
- const id = htmlWrapper.dataset.id;
16261
- if (id) {
16262
- let parent = htmlWrapper.parentElement;
16263
- let isInsideCell = false;
16264
- while (parent && parent !== editorDOM) {
16265
- if (parent.hasAttribute("data-column-cell")) {
16266
- isInsideCell = true;
16267
- break;
16268
- }
16269
- parent = parent.parentElement;
16270
- }
16271
- if (!isInsideCell) {
16272
- domIds.push(id);
16273
- }
16246
+ const performSync = /* @__PURE__ */ __name(() => {
16247
+ try {
16248
+ const editorDOM = editor2 == null ? void 0 : editor2.view.dom;
16249
+ if (!editorDOM) {
16250
+ return;
16251
+ }
16252
+ const nodeWrappers = editorDOM.querySelectorAll(
16253
+ ".react-renderer > div[data-node-view-wrapper][data-id]"
16254
+ );
16255
+ const domIds = [];
16256
+ nodeWrappers.forEach((wrapper) => {
16257
+ const htmlWrapper = wrapper;
16258
+ const id = htmlWrapper.dataset.id;
16259
+ if (id) {
16260
+ let parent = htmlWrapper.parentElement;
16261
+ let isInsideCell = false;
16262
+ while (parent && parent !== editorDOM) {
16263
+ if (parent.hasAttribute("data-column-cell")) {
16264
+ isInsideCell = true;
16265
+ break;
16274
16266
  }
16275
- });
16276
- setItems((prevItems) => {
16277
- return {
16278
- Editor: domIds,
16279
- Sidebar: prevItems.Sidebar
16280
- };
16281
- });
16282
- } catch (error) {
16283
- console.error("Error syncing editor items:", error);
16284
- setItems((prev) => ({ ...prev }));
16267
+ parent = parent.parentElement;
16268
+ }
16269
+ if (!isInsideCell) {
16270
+ domIds.push(id);
16271
+ }
16285
16272
  }
16286
16273
  });
16287
- } else {
16288
- try {
16289
- const editorDOM = editor2 == null ? void 0 : editor2.view.dom;
16290
- if (!editorDOM)
16291
- return;
16292
- const nodeWrappers = editorDOM.querySelectorAll(
16293
- ".react-renderer > div[data-node-view-wrapper][data-id]"
16294
- );
16295
- const domIds = [];
16296
- nodeWrappers.forEach((wrapper) => {
16297
- const htmlWrapper = wrapper;
16298
- const id = htmlWrapper.dataset.id;
16299
- if (id) {
16300
- let parent = htmlWrapper.parentElement;
16301
- let isInsideCell = false;
16302
- while (parent && parent !== editorDOM) {
16303
- if (parent.hasAttribute("data-column-cell")) {
16304
- isInsideCell = true;
16305
- break;
16306
- }
16307
- parent = parent.parentElement;
16308
- }
16309
- if (!isInsideCell) {
16310
- domIds.push(id);
16311
- }
16312
- }
16313
- });
16314
- setItems((prevItems) => ({
16274
+ setItems((prevItems) => {
16275
+ return {
16315
16276
  Editor: domIds,
16316
16277
  Sidebar: prevItems.Sidebar
16317
- }));
16318
- } catch (error) {
16319
- console.error("Error syncing editor items:", error);
16320
- }
16278
+ };
16279
+ });
16280
+ } catch (error) {
16281
+ console.error("Error syncing editor items:", error);
16282
+ setItems((prev) => ({ ...prev }));
16321
16283
  }
16322
- }, 0);
16323
- return () => clearTimeout(timeoutId);
16284
+ }, "performSync");
16285
+ if (typeof requestAnimationFrame !== "undefined") {
16286
+ rafId.current = requestAnimationFrame(performSync);
16287
+ } else {
16288
+ performSync();
16289
+ }
16290
+ return void 0;
16324
16291
  },
16325
16292
  [setItems, rafId]
16326
16293
  );