@bluemarble/bm-components 2.6.0-rc → 2.6.0-rc.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/dist/index.js CHANGED
@@ -1836,7 +1836,6 @@ function BaseGridAutoRows({ data, columns, rowKey }) {
1836
1836
  }
1837
1837
 
1838
1838
  // src/components/BlockEditor/index.tsx
1839
- import EditorJS from "@editorjs/editorjs";
1840
1839
  import { forwardRef, useEffect, useId, useImperativeHandle, useRef } from "react";
1841
1840
 
1842
1841
  // src/components/BlockEditor/plugins/index.ts
@@ -4199,15 +4198,17 @@ var BlockEditor = forwardRef(function BlockEditor2({
4199
4198
  const generatedId = useId().replace(/[^a-zA-Z0-9-_]/g, "");
4200
4199
  const holderRef = useRef(null);
4201
4200
  const editorRef = useRef(null);
4201
+ const loadRef = useRef(null);
4202
4202
  const undoRef = useRef(null);
4203
4203
  const dragDropRef = useRef(null);
4204
4204
  const propsRef = useRef({ onChange, onInitialize, onReady });
4205
4205
  propsRef.current = { onChange, onInitialize, onReady };
4206
+ const ready = async () => {
4207
+ const editor = await loadRef.current;
4208
+ await editor?.isReady;
4209
+ return editor;
4210
+ };
4206
4211
  useImperativeHandle(ref, () => {
4207
- const ready = async () => {
4208
- await editorRef.current?.isReady;
4209
- return editorRef.current;
4210
- };
4211
4212
  return {
4212
4213
  get editor() {
4213
4214
  return editorRef.current;
@@ -4226,43 +4227,53 @@ var BlockEditor = forwardRef(function BlockEditor2({
4226
4227
  useEffect(() => {
4227
4228
  const holderNode = holderRef.current;
4228
4229
  if (!holderNode) return;
4229
- const editor = new EditorJS({
4230
- ...config,
4231
- readOnly,
4232
- placeholder,
4233
- holder: holderNode,
4234
- tools: createTools({ uploader, placeholder, headerPlaceholder, tools }),
4235
- data: defaultValue,
4236
- style: nonce ? { nonce } : void 0,
4237
- onChange: (api, event) => {
4238
- undoRef.current?.registerChange();
4239
- propsRef.current.onChange?.(api, event);
4240
- },
4241
- onReady: () => {
4242
- if (undo) {
4243
- undoRef.current = new Undo(editor, holderNode);
4244
- undoRef.current.initialize(defaultValue);
4245
- }
4246
- if (dragDrop && !readOnly) {
4247
- dragDropRef.current = new DragDrop(editor, holderNode);
4230
+ let disposed = false;
4231
+ const load = (async () => {
4232
+ const { default: EditorJS } = await import("@editorjs/editorjs");
4233
+ if (disposed) return null;
4234
+ const editor = new EditorJS({
4235
+ ...config,
4236
+ readOnly,
4237
+ placeholder,
4238
+ holder: holderNode,
4239
+ tools: createTools({ uploader, placeholder, headerPlaceholder, tools }),
4240
+ data: defaultValue,
4241
+ style: nonce ? { nonce } : void 0,
4242
+ onChange: (api, event) => {
4243
+ undoRef.current?.registerChange();
4244
+ propsRef.current.onChange?.(api, event);
4245
+ },
4246
+ onReady: () => {
4247
+ if (disposed) return;
4248
+ if (undo) {
4249
+ undoRef.current = new Undo(editor, holderNode);
4250
+ undoRef.current.initialize(defaultValue);
4251
+ }
4252
+ if (dragDrop && !readOnly) {
4253
+ dragDropRef.current = new DragDrop(editor, holderNode);
4254
+ }
4255
+ propsRef.current.onReady?.(editor);
4248
4256
  }
4249
- propsRef.current.onReady?.(editor);
4250
- }
4251
- });
4252
- editorRef.current = editor;
4253
- propsRef.current.onInitialize?.(editor);
4257
+ });
4258
+ editorRef.current = editor;
4259
+ propsRef.current.onInitialize?.(editor);
4260
+ return editor;
4261
+ })();
4262
+ loadRef.current = load;
4254
4263
  return () => {
4264
+ disposed = true;
4255
4265
  undoRef.current?.destroy();
4256
4266
  dragDropRef.current?.destroy();
4257
4267
  undoRef.current = null;
4258
4268
  dragDropRef.current = null;
4259
4269
  editorRef.current = null;
4260
- editor.isReady.then(() => editor.destroy()).catch(() => void 0);
4270
+ loadRef.current = null;
4271
+ load.then((editor) => editor?.isReady.then(() => editor.destroy())).catch(() => void 0);
4261
4272
  };
4262
4273
  }, []);
4263
4274
  useEffect(() => {
4264
4275
  if (readOnly === void 0) return;
4265
- editorRef.current?.isReady.then(() => editorRef.current?.readOnly.toggle(readOnly)).catch(() => void 0);
4276
+ ready().then((editor) => editor?.readOnly.toggle(readOnly)).catch(() => void 0);
4266
4277
  }, [readOnly]);
4267
4278
  return /* @__PURE__ */ jsx9(
4268
4279
  "div",