@jvs-milkdown/crepe 1.2.18 → 1.2.20

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.
@@ -4461,7 +4461,8 @@ const Toolbar = vue.defineComponent({
4461
4461
  const container = toolbarContainerRef.value;
4462
4462
  if (!isFixed) {
4463
4463
  const view = ctx.get(core.editorViewCtx);
4464
- container.style.maxWidth = `${view.dom.clientWidth - 32}px`;
4464
+ const containerDOM = view.dom.closest(".milkdown-editor-container") || view.dom.closest(".milkdown") || view.dom;
4465
+ container.style.maxWidth = `${containerDOM.clientWidth - 32}px`;
4465
4466
  }
4466
4467
  let containerWidth;
4467
4468
  if (isFixed) {
@@ -4481,16 +4482,13 @@ const Toolbar = vue.defineComponent({
4481
4482
  }
4482
4483
  } else {
4483
4484
  const view = ctx.get(core.editorViewCtx);
4484
- containerWidth = view.dom.clientWidth - 32;
4485
+ const containerDOM = view.dom.closest(".milkdown-editor-container") || view.dom.closest(".milkdown") || view.dom;
4486
+ containerWidth = containerDOM.clientWidth - 32;
4485
4487
  }
4486
- if (containerWidth === lastContainerWidth) {
4487
- return;
4488
- }
4489
- lastContainerWidth = containerWidth;
4490
4488
  if (showOverflowMenu.value) {
4491
4489
  showOverflowMenu.value = false;
4492
4490
  }
4493
- const MORE_BUTTON_WIDTH = 44;
4491
+ const MORE_BUTTON_WIDTH = 56;
4494
4492
  const children = Array.from(container.children);
4495
4493
  const toolbarChildren = children.filter(
4496
4494
  (el) => el.style.position !== "fixed" && el.dataset.overflowButton !== "true"
@@ -4500,6 +4498,13 @@ const Toolbar = vue.defineComponent({
4500
4498
  const child = toolbarChildren[i];
4501
4499
  totalWidth += measureChild(child, i);
4502
4500
  }
4501
+ if (totalWidth === 0) {
4502
+ return;
4503
+ }
4504
+ if (containerWidth === lastContainerWidth) {
4505
+ return;
4506
+ }
4507
+ lastContainerWidth = containerWidth;
4503
4508
  if (totalWidth <= containerWidth) {
4504
4509
  overflowVisibleCount.value = Infinity;
4505
4510
  totalSectionCount.value = toolbarChildren.length;
@@ -4692,6 +4697,14 @@ const Toolbar = vue.defineComponent({
4692
4697
  } else {
4693
4698
  const view = ctx.get(core.editorViewCtx);
4694
4699
  overflowResizeObserver.observe(view.dom);
4700
+ const containerDOM = view.dom.closest(".milkdown-editor-container");
4701
+ if (containerDOM) {
4702
+ overflowResizeObserver.observe(containerDOM);
4703
+ }
4704
+ const rootDOM = view.dom.closest(".milkdown");
4705
+ if (rootDOM) {
4706
+ overflowResizeObserver.observe(rootDOM);
4707
+ }
4695
4708
  }
4696
4709
  computeOverflow();
4697
4710
  };
@@ -4720,6 +4733,20 @@ const Toolbar = vue.defineComponent({
4720
4733
  lastContainerWidth = 0;
4721
4734
  setTimeout(computeOverflow, 0);
4722
4735
  });
4736
+ vue.watch(
4737
+ () => {
4738
+ var _a;
4739
+ return (_a = props.show) == null ? void 0 : _a.value;
4740
+ },
4741
+ (val) => {
4742
+ if (val) {
4743
+ cachedWidths.clear();
4744
+ overflowVisibleCount.value = Infinity;
4745
+ lastContainerWidth = 0;
4746
+ setTimeout(computeOverflow, 0);
4747
+ }
4748
+ }
4749
+ );
4723
4750
  const onClick = (fn) => (e) => {
4724
4751
  e.preventDefault();
4725
4752
  if (ctx) fn(ctx);
@@ -5178,7 +5205,7 @@ const Toolbar = vue.defineComponent({
5178
5205
  {
5179
5206
  style: {
5180
5207
  position: "relative",
5181
- display: isSectionOverflowed(0) ? "none" : "flex",
5208
+ display: isSectionOverflowed(1) ? "none" : "flex",
5182
5209
  flexShrink: 0
5183
5210
  }
5184
5211
  },
@@ -5223,7 +5250,7 @@ const Toolbar = vue.defineComponent({
5223
5250
  style: {
5224
5251
  margin: "0 4px",
5225
5252
  alignSelf: "center",
5226
- display: isSectionOverflowed(1) ? "none" : void 0,
5253
+ display: isSectionOverflowed(2) ? "none" : void 0,
5227
5254
  flexShrink: 0
5228
5255
  }
5229
5256
  }
@@ -5236,7 +5263,7 @@ const Toolbar = vue.defineComponent({
5236
5263
  onMouseleave: handleFontFamilyLeave,
5237
5264
  style: {
5238
5265
  position: "relative",
5239
- display: isSectionOverflowed(2) ? "none" : "flex",
5266
+ display: isSectionOverflowed(3) ? "none" : "flex",
5240
5267
  alignItems: "center",
5241
5268
  padding: "0 6px",
5242
5269
  minWidth: "50px",
@@ -5278,7 +5305,7 @@ const Toolbar = vue.defineComponent({
5278
5305
  onMouseleave: handleFontSizeLeave,
5279
5306
  style: {
5280
5307
  position: "relative",
5281
- display: isSectionOverflowed(3) ? "none" : "flex",
5308
+ display: isSectionOverflowed(4) ? "none" : "flex",
5282
5309
  alignItems: "center",
5283
5310
  padding: "0 6px",
5284
5311
  minWidth: "40px",
@@ -5306,7 +5333,7 @@ const Toolbar = vue.defineComponent({
5306
5333
  style: {
5307
5334
  margin: "0 4px",
5308
5335
  alignSelf: "center",
5309
- display: isSectionOverflowed(4) ? "none" : void 0,
5336
+ display: isSectionOverflowed(5) ? "none" : void 0,
5310
5337
  flexShrink: 0
5311
5338
  }
5312
5339
  }
@@ -5319,7 +5346,7 @@ const Toolbar = vue.defineComponent({
5319
5346
  onMouseleave: handleAlignLeave,
5320
5347
  style: {
5321
5348
  position: "relative",
5322
- display: isSectionOverflowed(5) ? "none" : "flex",
5349
+ display: isSectionOverflowed(6) ? "none" : "flex",
5323
5350
  alignItems: "center",
5324
5351
  padding: "0 6px",
5325
5352
  flexShrink: 0
@@ -5348,7 +5375,7 @@ const Toolbar = vue.defineComponent({
5348
5375
  onMouseleave: handleColorLeave,
5349
5376
  style: {
5350
5377
  position: "relative",
5351
- display: isSectionOverflowed(6) ? "none" : "flex",
5378
+ display: isSectionOverflowed(7) ? "none" : "flex",
5352
5379
  alignItems: "center",
5353
5380
  padding: "0 4px",
5354
5381
  flexShrink: 0
@@ -5376,7 +5403,7 @@ const Toolbar = vue.defineComponent({
5376
5403
  )
5377
5404
  ),
5378
5405
  (() => {
5379
- let sectionIdx = 7;
5406
+ let sectionIdx = 8;
5380
5407
  return nonHeadingGroups.map((group, groupIndex) => {
5381
5408
  const items = group.items.map((item) => {
5382
5409
  const idx = sectionIdx;
@@ -6296,7 +6323,7 @@ const Toolbar = vue.defineComponent({
6296
6323
  )
6297
6324
  );
6298
6325
  }
6299
- if (2 >= cutoff) {
6326
+ if (3 >= cutoff) {
6300
6327
  items.push(
6301
6328
  renderIconButton(
6302
6329
  textIcon,
@@ -6309,7 +6336,7 @@ const Toolbar = vue.defineComponent({
6309
6336
  )
6310
6337
  );
6311
6338
  }
6312
- if (3 >= cutoff) {
6339
+ if (4 >= cutoff) {
6313
6340
  items.push(
6314
6341
  renderIconButton(
6315
6342
  textIcon,
@@ -6322,7 +6349,7 @@ const Toolbar = vue.defineComponent({
6322
6349
  )
6323
6350
  );
6324
6351
  }
6325
- if (5 >= cutoff) {
6352
+ if (6 >= cutoff) {
6326
6353
  items.push(
6327
6354
  renderIconButton(
6328
6355
  currentAlignIndent.value.align === "center" ? alignCenterIcon : currentAlignIndent.value.align === "right" ? alignRightIcon : alignLeftIcon,
@@ -6335,7 +6362,7 @@ const Toolbar = vue.defineComponent({
6335
6362
  )
6336
6363
  );
6337
6364
  }
6338
- if (6 >= cutoff) {
6365
+ if (7 >= cutoff) {
6339
6366
  items.push(
6340
6367
  renderIconButton(
6341
6368
  fontColorIcon,
@@ -6348,7 +6375,7 @@ const Toolbar = vue.defineComponent({
6348
6375
  )
6349
6376
  );
6350
6377
  }
6351
- let fmtIdx = 7;
6378
+ let fmtIdx = 8;
6352
6379
  for (const group of nonHeadingGroups) {
6353
6380
  for (const item of group.items) {
6354
6381
  const idx = fmtIdx;