@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.
- package/lib/cjs/feature/toolbar/index.js +47 -20
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +166 -82
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/toolbar/index.js +47 -20
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +325 -241
- package/lib/esm/index.js.map +1 -1
- package/lib/theme/common/toolbar.css +3 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/core/crepe.d.ts +1 -0
- package/lib/types/core/crepe.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/menu-bar.d.ts.map +1 -1
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/lib/types/utils/fixed-toolbar-popup-state.d.ts +1 -0
- package/lib/types/utils/fixed-toolbar-popup-state.d.ts.map +1 -1
- package/package.json +116 -62
- package/src/core/crepe.ts +83 -21
- package/src/feature/fixed-toolbar/component.tsx +3 -6
- package/src/feature/fixed-toolbar/index.ts +1 -1
- package/src/feature/fixed-toolbar/menu-bar.tsx +0 -1
- package/src/feature/toolbar/component.tsx +55 -21
- package/src/theme/common/toolbar.css +3 -0
- package/src/utils/fixed-toolbar-popup-state.ts +5 -0
- package/LICENSE +0 -21
|
@@ -4459,7 +4459,8 @@ const Toolbar = defineComponent({
|
|
|
4459
4459
|
const container = toolbarContainerRef.value;
|
|
4460
4460
|
if (!isFixed) {
|
|
4461
4461
|
const view = ctx.get(editorViewCtx);
|
|
4462
|
-
|
|
4462
|
+
const containerDOM = view.dom.closest(".milkdown-editor-container") || view.dom.closest(".milkdown") || view.dom;
|
|
4463
|
+
container.style.maxWidth = `${containerDOM.clientWidth - 32}px`;
|
|
4463
4464
|
}
|
|
4464
4465
|
let containerWidth;
|
|
4465
4466
|
if (isFixed) {
|
|
@@ -4479,16 +4480,13 @@ const Toolbar = defineComponent({
|
|
|
4479
4480
|
}
|
|
4480
4481
|
} else {
|
|
4481
4482
|
const view = ctx.get(editorViewCtx);
|
|
4482
|
-
|
|
4483
|
+
const containerDOM = view.dom.closest(".milkdown-editor-container") || view.dom.closest(".milkdown") || view.dom;
|
|
4484
|
+
containerWidth = containerDOM.clientWidth - 32;
|
|
4483
4485
|
}
|
|
4484
|
-
if (containerWidth === lastContainerWidth) {
|
|
4485
|
-
return;
|
|
4486
|
-
}
|
|
4487
|
-
lastContainerWidth = containerWidth;
|
|
4488
4486
|
if (showOverflowMenu.value) {
|
|
4489
4487
|
showOverflowMenu.value = false;
|
|
4490
4488
|
}
|
|
4491
|
-
const MORE_BUTTON_WIDTH =
|
|
4489
|
+
const MORE_BUTTON_WIDTH = 56;
|
|
4492
4490
|
const children = Array.from(container.children);
|
|
4493
4491
|
const toolbarChildren = children.filter(
|
|
4494
4492
|
(el) => el.style.position !== "fixed" && el.dataset.overflowButton !== "true"
|
|
@@ -4498,6 +4496,13 @@ const Toolbar = defineComponent({
|
|
|
4498
4496
|
const child = toolbarChildren[i];
|
|
4499
4497
|
totalWidth += measureChild(child, i);
|
|
4500
4498
|
}
|
|
4499
|
+
if (totalWidth === 0) {
|
|
4500
|
+
return;
|
|
4501
|
+
}
|
|
4502
|
+
if (containerWidth === lastContainerWidth) {
|
|
4503
|
+
return;
|
|
4504
|
+
}
|
|
4505
|
+
lastContainerWidth = containerWidth;
|
|
4501
4506
|
if (totalWidth <= containerWidth) {
|
|
4502
4507
|
overflowVisibleCount.value = Infinity;
|
|
4503
4508
|
totalSectionCount.value = toolbarChildren.length;
|
|
@@ -4690,6 +4695,14 @@ const Toolbar = defineComponent({
|
|
|
4690
4695
|
} else {
|
|
4691
4696
|
const view = ctx.get(editorViewCtx);
|
|
4692
4697
|
overflowResizeObserver.observe(view.dom);
|
|
4698
|
+
const containerDOM = view.dom.closest(".milkdown-editor-container");
|
|
4699
|
+
if (containerDOM) {
|
|
4700
|
+
overflowResizeObserver.observe(containerDOM);
|
|
4701
|
+
}
|
|
4702
|
+
const rootDOM = view.dom.closest(".milkdown");
|
|
4703
|
+
if (rootDOM) {
|
|
4704
|
+
overflowResizeObserver.observe(rootDOM);
|
|
4705
|
+
}
|
|
4693
4706
|
}
|
|
4694
4707
|
computeOverflow();
|
|
4695
4708
|
};
|
|
@@ -4718,6 +4731,20 @@ const Toolbar = defineComponent({
|
|
|
4718
4731
|
lastContainerWidth = 0;
|
|
4719
4732
|
setTimeout(computeOverflow, 0);
|
|
4720
4733
|
});
|
|
4734
|
+
watch(
|
|
4735
|
+
() => {
|
|
4736
|
+
var _a;
|
|
4737
|
+
return (_a = props.show) == null ? void 0 : _a.value;
|
|
4738
|
+
},
|
|
4739
|
+
(val) => {
|
|
4740
|
+
if (val) {
|
|
4741
|
+
cachedWidths.clear();
|
|
4742
|
+
overflowVisibleCount.value = Infinity;
|
|
4743
|
+
lastContainerWidth = 0;
|
|
4744
|
+
setTimeout(computeOverflow, 0);
|
|
4745
|
+
}
|
|
4746
|
+
}
|
|
4747
|
+
);
|
|
4721
4748
|
const onClick = (fn) => (e) => {
|
|
4722
4749
|
e.preventDefault();
|
|
4723
4750
|
if (ctx) fn(ctx);
|
|
@@ -5176,7 +5203,7 @@ const Toolbar = defineComponent({
|
|
|
5176
5203
|
{
|
|
5177
5204
|
style: {
|
|
5178
5205
|
position: "relative",
|
|
5179
|
-
display: isSectionOverflowed(
|
|
5206
|
+
display: isSectionOverflowed(1) ? "none" : "flex",
|
|
5180
5207
|
flexShrink: 0
|
|
5181
5208
|
}
|
|
5182
5209
|
},
|
|
@@ -5221,7 +5248,7 @@ const Toolbar = defineComponent({
|
|
|
5221
5248
|
style: {
|
|
5222
5249
|
margin: "0 4px",
|
|
5223
5250
|
alignSelf: "center",
|
|
5224
|
-
display: isSectionOverflowed(
|
|
5251
|
+
display: isSectionOverflowed(2) ? "none" : void 0,
|
|
5225
5252
|
flexShrink: 0
|
|
5226
5253
|
}
|
|
5227
5254
|
}
|
|
@@ -5234,7 +5261,7 @@ const Toolbar = defineComponent({
|
|
|
5234
5261
|
onMouseleave: handleFontFamilyLeave,
|
|
5235
5262
|
style: {
|
|
5236
5263
|
position: "relative",
|
|
5237
|
-
display: isSectionOverflowed(
|
|
5264
|
+
display: isSectionOverflowed(3) ? "none" : "flex",
|
|
5238
5265
|
alignItems: "center",
|
|
5239
5266
|
padding: "0 6px",
|
|
5240
5267
|
minWidth: "50px",
|
|
@@ -5276,7 +5303,7 @@ const Toolbar = defineComponent({
|
|
|
5276
5303
|
onMouseleave: handleFontSizeLeave,
|
|
5277
5304
|
style: {
|
|
5278
5305
|
position: "relative",
|
|
5279
|
-
display: isSectionOverflowed(
|
|
5306
|
+
display: isSectionOverflowed(4) ? "none" : "flex",
|
|
5280
5307
|
alignItems: "center",
|
|
5281
5308
|
padding: "0 6px",
|
|
5282
5309
|
minWidth: "40px",
|
|
@@ -5304,7 +5331,7 @@ const Toolbar = defineComponent({
|
|
|
5304
5331
|
style: {
|
|
5305
5332
|
margin: "0 4px",
|
|
5306
5333
|
alignSelf: "center",
|
|
5307
|
-
display: isSectionOverflowed(
|
|
5334
|
+
display: isSectionOverflowed(5) ? "none" : void 0,
|
|
5308
5335
|
flexShrink: 0
|
|
5309
5336
|
}
|
|
5310
5337
|
}
|
|
@@ -5317,7 +5344,7 @@ const Toolbar = defineComponent({
|
|
|
5317
5344
|
onMouseleave: handleAlignLeave,
|
|
5318
5345
|
style: {
|
|
5319
5346
|
position: "relative",
|
|
5320
|
-
display: isSectionOverflowed(
|
|
5347
|
+
display: isSectionOverflowed(6) ? "none" : "flex",
|
|
5321
5348
|
alignItems: "center",
|
|
5322
5349
|
padding: "0 6px",
|
|
5323
5350
|
flexShrink: 0
|
|
@@ -5346,7 +5373,7 @@ const Toolbar = defineComponent({
|
|
|
5346
5373
|
onMouseleave: handleColorLeave,
|
|
5347
5374
|
style: {
|
|
5348
5375
|
position: "relative",
|
|
5349
|
-
display: isSectionOverflowed(
|
|
5376
|
+
display: isSectionOverflowed(7) ? "none" : "flex",
|
|
5350
5377
|
alignItems: "center",
|
|
5351
5378
|
padding: "0 4px",
|
|
5352
5379
|
flexShrink: 0
|
|
@@ -5374,7 +5401,7 @@ const Toolbar = defineComponent({
|
|
|
5374
5401
|
)
|
|
5375
5402
|
),
|
|
5376
5403
|
(() => {
|
|
5377
|
-
let sectionIdx =
|
|
5404
|
+
let sectionIdx = 8;
|
|
5378
5405
|
return nonHeadingGroups.map((group, groupIndex) => {
|
|
5379
5406
|
const items = group.items.map((item) => {
|
|
5380
5407
|
const idx = sectionIdx;
|
|
@@ -6294,7 +6321,7 @@ const Toolbar = defineComponent({
|
|
|
6294
6321
|
)
|
|
6295
6322
|
);
|
|
6296
6323
|
}
|
|
6297
|
-
if (
|
|
6324
|
+
if (3 >= cutoff) {
|
|
6298
6325
|
items.push(
|
|
6299
6326
|
renderIconButton(
|
|
6300
6327
|
textIcon,
|
|
@@ -6307,7 +6334,7 @@ const Toolbar = defineComponent({
|
|
|
6307
6334
|
)
|
|
6308
6335
|
);
|
|
6309
6336
|
}
|
|
6310
|
-
if (
|
|
6337
|
+
if (4 >= cutoff) {
|
|
6311
6338
|
items.push(
|
|
6312
6339
|
renderIconButton(
|
|
6313
6340
|
textIcon,
|
|
@@ -6320,7 +6347,7 @@ const Toolbar = defineComponent({
|
|
|
6320
6347
|
)
|
|
6321
6348
|
);
|
|
6322
6349
|
}
|
|
6323
|
-
if (
|
|
6350
|
+
if (6 >= cutoff) {
|
|
6324
6351
|
items.push(
|
|
6325
6352
|
renderIconButton(
|
|
6326
6353
|
currentAlignIndent.value.align === "center" ? alignCenterIcon : currentAlignIndent.value.align === "right" ? alignRightIcon : alignLeftIcon,
|
|
@@ -6333,7 +6360,7 @@ const Toolbar = defineComponent({
|
|
|
6333
6360
|
)
|
|
6334
6361
|
);
|
|
6335
6362
|
}
|
|
6336
|
-
if (
|
|
6363
|
+
if (7 >= cutoff) {
|
|
6337
6364
|
items.push(
|
|
6338
6365
|
renderIconButton(
|
|
6339
6366
|
fontColorIcon,
|
|
@@ -6346,7 +6373,7 @@ const Toolbar = defineComponent({
|
|
|
6346
6373
|
)
|
|
6347
6374
|
);
|
|
6348
6375
|
}
|
|
6349
|
-
let fmtIdx =
|
|
6376
|
+
let fmtIdx = 8;
|
|
6350
6377
|
for (const group of nonHeadingGroups) {
|
|
6351
6378
|
for (const item of group.items) {
|
|
6352
6379
|
const idx = fmtIdx;
|