@jvs-milkdown/crepe 1.2.21 → 1.2.22

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.
@@ -4457,12 +4457,18 @@ const Toolbar = vue.defineComponent({
4457
4457
  };
4458
4458
  let lastContainerWidth = 0;
4459
4459
  const computeOverflow = () => {
4460
+ var _a;
4460
4461
  if (!toolbarContainerRef.value) return;
4462
+ const status = (_a = ctx == null ? void 0 : ctx.get(core.editorCtx)) == null ? void 0 : _a.status;
4463
+ if (status !== core.EditorStatus.Created) return;
4464
+ const view = ctx.get(core.editorViewCtx);
4465
+ if (!view || !view.dom) return;
4461
4466
  const container = toolbarContainerRef.value;
4462
4467
  if (!isFixed) {
4463
- const view = ctx.get(core.editorViewCtx);
4464
4468
  const containerDOM = view.dom.closest(".milkdown-editor-container") || view.dom.closest(".milkdown") || view.dom;
4465
- container.style.maxWidth = `${containerDOM.clientWidth - 32}px`;
4469
+ if (containerDOM) {
4470
+ container.style.maxWidth = `${containerDOM.clientWidth - 32}px`;
4471
+ }
4466
4472
  }
4467
4473
  let containerWidth;
4468
4474
  if (isFixed) {
@@ -4481,9 +4487,8 @@ const Toolbar = vue.defineComponent({
4481
4487
  containerWidth = container.clientWidth;
4482
4488
  }
4483
4489
  } else {
4484
- const view = ctx.get(core.editorViewCtx);
4485
4490
  const containerDOM = view.dom.closest(".milkdown-editor-container") || view.dom.closest(".milkdown") || view.dom;
4486
- containerWidth = containerDOM.clientWidth - 32;
4491
+ containerWidth = containerDOM ? containerDOM.clientWidth - 32 : 0;
4487
4492
  }
4488
4493
  if (showOverflowMenu.value) {
4489
4494
  showOverflowMenu.value = false;
@@ -4685,7 +4690,18 @@ const Toolbar = vue.defineComponent({
4685
4690
  let overflowResizeObserver = null;
4686
4691
  let overflowSetupDone = false;
4687
4692
  const setupOverflowObserver = () => {
4693
+ var _a;
4688
4694
  if (!toolbarContainerRef.value || overflowSetupDone) return;
4695
+ const status = (_a = ctx == null ? void 0 : ctx.get(core.editorCtx)) == null ? void 0 : _a.status;
4696
+ if (status !== core.EditorStatus.Created) {
4697
+ setTimeout(setupOverflowObserver, 50);
4698
+ return;
4699
+ }
4700
+ const view = ctx.get(core.editorViewCtx);
4701
+ if (!view || !view.dom) {
4702
+ setTimeout(setupOverflowObserver, 50);
4703
+ return;
4704
+ }
4689
4705
  overflowSetupDone = true;
4690
4706
  overflowResizeObserver = new ResizeObserver(() => {
4691
4707
  computeOverflow();
@@ -4695,7 +4711,6 @@ const Toolbar = vue.defineComponent({
4695
4711
  const parent = toolbarContainerRef.value.parentElement;
4696
4712
  if (parent) overflowResizeObserver.observe(parent);
4697
4713
  } else {
4698
- const view = ctx.get(core.editorViewCtx);
4699
4714
  overflowResizeObserver.observe(view.dom);
4700
4715
  const containerDOM = view.dom.closest(".milkdown-editor-container");
4701
4716
  if (containerDOM) {