@jvs-milkdown/crepe 1.2.20 → 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020-present Mirone
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -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) {