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