@jvs-milkdown/crepe 1.2.12 → 1.2.13
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/block-edit/index.js +1 -0
- package/lib/cjs/feature/block-edit/index.js.map +1 -1
- package/lib/cjs/feature/image-block/index.js +1 -1
- package/lib/cjs/feature/image-block/index.js.map +1 -1
- package/lib/cjs/feature/link-tooltip/index.js +1 -0
- package/lib/cjs/feature/link-tooltip/index.js.map +1 -1
- package/lib/cjs/feature/table/index.js +1 -0
- package/lib/cjs/feature/table/index.js.map +1 -1
- package/lib/cjs/feature/toolbar/index.js +123 -9
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +164 -15
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/block-edit/index.js +1 -0
- package/lib/esm/feature/block-edit/index.js.map +1 -1
- package/lib/esm/feature/image-block/index.js +1 -1
- package/lib/esm/feature/image-block/index.js.map +1 -1
- package/lib/esm/feature/link-tooltip/index.js +1 -0
- package/lib/esm/feature/link-tooltip/index.js.map +1 -1
- package/lib/esm/feature/table/index.js +1 -0
- package/lib/esm/feature/table/index.js.map +1 -1
- package/lib/esm/feature/toolbar/index.js +123 -9
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +164 -15
- package/lib/esm/index.js.map +1 -1
- package/lib/theme/common/table.css +4 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/feature/fixed-toolbar/document-header.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/index.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/feature/toolbar/index.d.ts.map +1 -1
- package/lib/types/icons/remove.d.ts +1 -1
- package/lib/types/icons/remove.d.ts.map +1 -1
- package/lib/types/utils/fixed-toolbar-popup-state.d.ts +7 -0
- package/lib/types/utils/fixed-toolbar-popup-state.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/feature/fixed-toolbar/index.ts +39 -2
- package/src/feature/fixed-toolbar/menu-bar.tsx +13 -2
- package/src/feature/fixed-toolbar/shortcut-help-modal.tsx +1 -1
- package/src/feature/fixed-toolbar/view-menu-state.ts +1 -1
- package/src/feature/image-block/index.ts +1 -1
- package/src/feature/toolbar/component.tsx +95 -8
- package/src/feature/toolbar/index.ts +33 -0
- package/src/icons/remove.ts +1 -0
- package/src/theme/common/table.css +4 -4
- package/src/utils/fixed-toolbar-popup-state.ts +27 -0
package/lib/cjs/index.js
CHANGED
|
@@ -441,6 +441,7 @@ const removeIcon = `
|
|
|
441
441
|
>
|
|
442
442
|
<path
|
|
443
443
|
d="M7.30775 20.4997C6.81058 20.4997 6.385 20.3227 6.031 19.9687C5.677 19.6147 5.5 19.1892 5.5 18.692V5.99973H5.25C5.0375 5.99973 4.85942 5.92782 4.71575 5.78398C4.57192 5.64015 4.5 5.46198 4.5 5.24948C4.5 5.03682 4.57192 4.85873 4.71575 4.71523C4.85942 4.57157 5.0375 4.49973 5.25 4.49973H9C9 4.2549 9.08625 4.04624 9.25875 3.87374C9.43108 3.7014 9.63967 3.61523 9.8845 3.61523H14.1155C14.3603 3.61523 14.5689 3.7014 14.7413 3.87374C14.9138 4.04624 15 4.2549 15 4.49973H18.75C18.9625 4.49973 19.1406 4.57165 19.2843 4.71548C19.4281 4.85932 19.5 5.03748 19.5 5.24998C19.5 5.46265 19.4281 5.64073 19.2843 5.78423C19.1406 5.9279 18.9625 5.99973 18.75 5.99973H18.5V18.692C18.5 19.1892 18.323 19.6147 17.969 19.9687C17.615 20.3227 17.1894 20.4997 16.6923 20.4997H7.30775ZM17 5.99973H7V18.692C7 18.7818 7.02883 18.8556 7.0865 18.9132C7.14417 18.9709 7.21792 18.9997 7.30775 18.9997H16.6923C16.7821 18.9997 16.8558 18.9709 16.9135 18.9132C16.9712 18.8556 17 18.7818 17 18.692V5.99973ZM10.1543 16.9997C10.3668 16.9997 10.5448 16.9279 10.6885 16.7842C10.832 16.6404 10.9037 16.4622 10.9037 16.2497V8.74973C10.9037 8.53723 10.8318 8.35907 10.688 8.21523C10.5443 8.07157 10.3662 7.99973 10.1535 7.99973C9.941 7.99973 9.76292 8.07157 9.61925 8.21523C9.47575 8.35907 9.404 8.53723 9.404 8.74973V16.2497C9.404 16.4622 9.47583 16.6404 9.6195 16.7842C9.76333 16.9279 9.94158 16.9997 10.1543 16.9997ZM13.8465 16.9997C14.059 16.9997 14.2371 16.9279 14.3807 16.7842C14.5243 16.6404 14.596 16.4622 14.596 16.2497V8.74973C14.596 8.53723 14.5242 8.35907 14.3805 8.21523C14.2367 8.07157 14.0584 7.99973 13.8458 7.99973C13.6333 7.99973 13.4552 8.07157 13.3115 8.21523C13.168 8.35907 13.0962 8.53723 13.0962 8.74973V16.2497C13.0962 16.4622 13.1682 16.6404 13.312 16.7842C13.4557 16.9279 13.6338 16.9997 13.8465 16.9997Z"
|
|
444
|
+
fill="#363B4C"
|
|
444
445
|
/>
|
|
445
446
|
</svg>
|
|
446
447
|
`;
|
|
@@ -4296,6 +4297,29 @@ const cursor = (editor, config) => {
|
|
|
4296
4297
|
editor.use(utils.$prose(() => virtualCursor));
|
|
4297
4298
|
};
|
|
4298
4299
|
|
|
4300
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
4301
|
+
let _popupCount = 0;
|
|
4302
|
+
function getIsAnyPopupOpen() {
|
|
4303
|
+
return _popupCount > 0;
|
|
4304
|
+
}
|
|
4305
|
+
function addPopupChangeListener(fn) {
|
|
4306
|
+
listeners.add(fn);
|
|
4307
|
+
return () => listeners.delete(fn);
|
|
4308
|
+
}
|
|
4309
|
+
function incrementPopupCount() {
|
|
4310
|
+
const wasZero = _popupCount === 0;
|
|
4311
|
+
_popupCount++;
|
|
4312
|
+
if (wasZero) {
|
|
4313
|
+
listeners.forEach((fn) => fn());
|
|
4314
|
+
}
|
|
4315
|
+
}
|
|
4316
|
+
function decrementPopupCount() {
|
|
4317
|
+
_popupCount = Math.max(0, _popupCount - 1);
|
|
4318
|
+
if (_popupCount === 0) {
|
|
4319
|
+
listeners.forEach((fn) => fn());
|
|
4320
|
+
}
|
|
4321
|
+
}
|
|
4322
|
+
|
|
4299
4323
|
const remarkHighlightMarkPlugin = utils.$remark(
|
|
4300
4324
|
"remarkHighlightMark",
|
|
4301
4325
|
() => function() {
|
|
@@ -5392,6 +5416,8 @@ const Toolbar = vue.defineComponent({
|
|
|
5392
5416
|
const {
|
|
5393
5417
|
marks: savedMarks,
|
|
5394
5418
|
align: savedAlign,
|
|
5419
|
+
blockType: savedBlockType,
|
|
5420
|
+
blockAttrs: savedBlockAttrs,
|
|
5395
5421
|
isPersistent
|
|
5396
5422
|
} = formatPainterState.value;
|
|
5397
5423
|
let applied = false;
|
|
@@ -5413,6 +5439,30 @@ const Toolbar = vue.defineComponent({
|
|
|
5413
5439
|
}
|
|
5414
5440
|
);
|
|
5415
5441
|
}
|
|
5442
|
+
if (savedBlockType) {
|
|
5443
|
+
curState.doc.nodesBetween(
|
|
5444
|
+
curSelection.from,
|
|
5445
|
+
curSelection.to,
|
|
5446
|
+
(node, pos) => {
|
|
5447
|
+
if (node.type.name === "paragraph") {
|
|
5448
|
+
tr.setNodeMarkup(
|
|
5449
|
+
pos,
|
|
5450
|
+
curState.schema.nodes[savedBlockType],
|
|
5451
|
+
{
|
|
5452
|
+
...savedBlockAttrs,
|
|
5453
|
+
...savedAlign ? { align: savedAlign } : {}
|
|
5454
|
+
}
|
|
5455
|
+
);
|
|
5456
|
+
} else if (node.type.name === "heading" && savedBlockAttrs) {
|
|
5457
|
+
tr.setNodeMarkup(pos, null, {
|
|
5458
|
+
...node.attrs,
|
|
5459
|
+
...savedBlockAttrs,
|
|
5460
|
+
...savedAlign ? { align: savedAlign } : {}
|
|
5461
|
+
});
|
|
5462
|
+
}
|
|
5463
|
+
}
|
|
5464
|
+
);
|
|
5465
|
+
}
|
|
5416
5466
|
dispatch(tr);
|
|
5417
5467
|
applied = true;
|
|
5418
5468
|
} else {
|
|
@@ -5445,6 +5495,22 @@ const Toolbar = vue.defineComponent({
|
|
|
5445
5495
|
});
|
|
5446
5496
|
}
|
|
5447
5497
|
}
|
|
5498
|
+
if (savedBlockType) {
|
|
5499
|
+
const pos = curSelection.$from.before(curSelection.$from.depth);
|
|
5500
|
+
const node = curState.doc.nodeAt(pos);
|
|
5501
|
+
if (node && node.type.name === "paragraph") {
|
|
5502
|
+
tr.setNodeMarkup(pos, curState.schema.nodes[savedBlockType], {
|
|
5503
|
+
...savedBlockAttrs,
|
|
5504
|
+
...savedAlign ? { align: savedAlign } : {}
|
|
5505
|
+
});
|
|
5506
|
+
} else if (node && node.type.name === "heading" && savedBlockAttrs) {
|
|
5507
|
+
tr.setNodeMarkup(pos, null, {
|
|
5508
|
+
...node.attrs,
|
|
5509
|
+
...savedBlockAttrs,
|
|
5510
|
+
...savedAlign ? { align: savedAlign } : {}
|
|
5511
|
+
});
|
|
5512
|
+
}
|
|
5513
|
+
}
|
|
5448
5514
|
tr.setStoredMarks(savedMarks);
|
|
5449
5515
|
dispatch(tr);
|
|
5450
5516
|
applied = true;
|
|
@@ -5493,7 +5559,22 @@ const Toolbar = vue.defineComponent({
|
|
|
5493
5559
|
}
|
|
5494
5560
|
}
|
|
5495
5561
|
align = foundAlign;
|
|
5496
|
-
|
|
5562
|
+
let blockType = null;
|
|
5563
|
+
let blockAttrs = null;
|
|
5564
|
+
{
|
|
5565
|
+
const parent = selection.$from.parent;
|
|
5566
|
+
if (parent.type.name === "heading") {
|
|
5567
|
+
blockType = "heading";
|
|
5568
|
+
blockAttrs = { level: parent.attrs.level };
|
|
5569
|
+
}
|
|
5570
|
+
}
|
|
5571
|
+
formatPainterState.value = {
|
|
5572
|
+
marks,
|
|
5573
|
+
align,
|
|
5574
|
+
blockType,
|
|
5575
|
+
blockAttrs,
|
|
5576
|
+
isPersistent
|
|
5577
|
+
};
|
|
5497
5578
|
document.removeEventListener("pointerup", formatPainterHandler);
|
|
5498
5579
|
setTimeout(() => {
|
|
5499
5580
|
document.addEventListener("pointerup", formatPainterHandler);
|
|
@@ -5546,6 +5627,13 @@ const Toolbar = vue.defineComponent({
|
|
|
5546
5627
|
const showOverflowMenu = vue.ref(false);
|
|
5547
5628
|
const overflowMenuPos = vue.ref({ top: 0 });
|
|
5548
5629
|
const cachedWidths = /* @__PURE__ */ new Map();
|
|
5630
|
+
const anyFixedPopup = vue.computed(
|
|
5631
|
+
() => !!isFixed && (showBlockMenu.value || showAlignMenu.value || showColorMenu.value || showFontFamilyMenu.value || showFontSizeMenu.value || showTableMenu.value || showOverflowMenu.value)
|
|
5632
|
+
);
|
|
5633
|
+
vue.watch(anyFixedPopup, (val) => {
|
|
5634
|
+
if (val) incrementPopupCount();
|
|
5635
|
+
else decrementPopupCount();
|
|
5636
|
+
});
|
|
5549
5637
|
const getMenuLeftPos = (rect, menuWidth) => {
|
|
5550
5638
|
let left = rect.left;
|
|
5551
5639
|
if (left + menuWidth > window.innerWidth) {
|
|
@@ -5782,6 +5870,7 @@ const Toolbar = vue.defineComponent({
|
|
|
5782
5870
|
if (hideFontFamilyTimer) clearTimeout(hideFontFamilyTimer);
|
|
5783
5871
|
if (hideFontSizeTimer) clearTimeout(hideFontSizeTimer);
|
|
5784
5872
|
if (hideTableTimer) clearTimeout(hideTableTimer);
|
|
5873
|
+
if (anyFixedPopup.value) decrementPopupCount();
|
|
5785
5874
|
});
|
|
5786
5875
|
let overflowResizeObserver = null;
|
|
5787
5876
|
let overflowSetupDone = false;
|
|
@@ -6220,13 +6309,11 @@ const Toolbar = vue.defineComponent({
|
|
|
6220
6309
|
});
|
|
6221
6310
|
}
|
|
6222
6311
|
});
|
|
6223
|
-
const nonHeadingGroups = toolbarGroupInfo.value.filter(
|
|
6224
|
-
(group)
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
}
|
|
6229
|
-
);
|
|
6312
|
+
const nonHeadingGroups = toolbarGroupInfo.value.filter((group) => {
|
|
6313
|
+
if (group.key === "heading") return false;
|
|
6314
|
+
if (props.isFixed && group.key === "function") return false;
|
|
6315
|
+
return true;
|
|
6316
|
+
});
|
|
6230
6317
|
const isSectionOverflowed = (idx) => idx >= overflowVisibleCount.value;
|
|
6231
6318
|
const hasOverflow = overflowVisibleCount.value < totalSectionCount.value;
|
|
6232
6319
|
return /* @__PURE__ */ vue.h(
|
|
@@ -7522,7 +7609,7 @@ const createViewMenuState = () => vue.reactive({
|
|
|
7522
7609
|
outlineVisible: false,
|
|
7523
7610
|
outlinePosition: "left",
|
|
7524
7611
|
outlineWidth: 250,
|
|
7525
|
-
documentBackground:
|
|
7612
|
+
documentBackground: "#FFFFFF",
|
|
7526
7613
|
showTitle: false,
|
|
7527
7614
|
showCover: false,
|
|
7528
7615
|
coverUrl: "",
|
|
@@ -7622,10 +7709,15 @@ const MenuBar = vue.defineComponent({
|
|
|
7622
7709
|
vue.onUnmounted(() => {
|
|
7623
7710
|
document.removeEventListener("click", closeMenu);
|
|
7624
7711
|
if (rafId) cancelAnimationFrame(rafId);
|
|
7712
|
+
if (showMenu.value) decrementPopupCount();
|
|
7713
|
+
});
|
|
7714
|
+
vue.watch(showMenu, (val) => {
|
|
7715
|
+
if (val) incrementPopupCount();
|
|
7716
|
+
else decrementPopupCount();
|
|
7625
7717
|
});
|
|
7626
7718
|
const viewState = vue.computed(() => props.ctx.get(viewMenuStateCtx.key));
|
|
7627
7719
|
const bgColors = [
|
|
7628
|
-
{ name: "\
|
|
7720
|
+
{ name: "\u767D\u8272", value: "#FFFFFF" },
|
|
7629
7721
|
{ name: "\u6D45\u7070", value: "#F7F7F5" },
|
|
7630
7722
|
{ name: "\u6D45\u68D5", value: "#F4EEDB" },
|
|
7631
7723
|
{ name: "\u6D45\u6A59", value: "#FBECDD" },
|
|
@@ -8113,7 +8205,7 @@ const rightGroups = [
|
|
|
8113
8205
|
titleKey: "shortcuts.history",
|
|
8114
8206
|
items: [
|
|
8115
8207
|
{ labelKey: "shortcuts.undo", keys: ["Mod+z"] },
|
|
8116
|
-
{ labelKey: "shortcuts.redo", keys: ["Mod+y", "Shift+Mod+
|
|
8208
|
+
{ labelKey: "shortcuts.redo", keys: ["Mod+y", "Shift+Mod+Z"] }
|
|
8117
8209
|
]
|
|
8118
8210
|
}
|
|
8119
8211
|
];
|
|
@@ -9441,7 +9533,7 @@ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Ca
|
|
|
9441
9533
|
var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9442
9534
|
var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
9443
9535
|
var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
|
|
9444
|
-
var _content$2, _app$2, _headerContent, _headerApp, _outlineContent, _outlineApp, _watcher, _selection$1, _show$1, _resizeObserver, _updateOutlineGeometry, _scrollContainers, _view;
|
|
9536
|
+
var _content$2, _app$2, _headerContent, _headerApp, _outlineContent, _outlineApp, _watcher, _selection$1, _show$1, _resizeObserver, _updateOutlineGeometry, _scrollContainers, _onDblClick, _view;
|
|
9445
9537
|
const fixedToolbarConfig = utils.$ctx(
|
|
9446
9538
|
{},
|
|
9447
9539
|
"fixedToolbarConfigCtx"
|
|
@@ -9461,12 +9553,16 @@ class FixedToolbarView {
|
|
|
9461
9553
|
__privateAdd$3(this, _resizeObserver);
|
|
9462
9554
|
__privateAdd$3(this, _updateOutlineGeometry);
|
|
9463
9555
|
__privateAdd$3(this, _scrollContainers, []);
|
|
9556
|
+
__privateAdd$3(this, _onDblClick);
|
|
9464
9557
|
__privateAdd$3(this, _view);
|
|
9465
9558
|
this.update = (view) => {
|
|
9466
9559
|
__privateGet$3(this, _selection$1).value = view.state.selection;
|
|
9467
9560
|
};
|
|
9468
9561
|
this.destroy = () => {
|
|
9469
9562
|
if (__privateGet$3(this, _watcher)) __privateGet$3(this, _watcher).call(this);
|
|
9563
|
+
if (__privateGet$3(this, _onDblClick)) {
|
|
9564
|
+
__privateGet$3(this, _view).dom.removeEventListener("dblclick", __privateGet$3(this, _onDblClick));
|
|
9565
|
+
}
|
|
9470
9566
|
if (__privateGet$3(this, _resizeObserver)) __privateGet$3(this, _resizeObserver).disconnect();
|
|
9471
9567
|
window.removeEventListener("resize", __privateGet$3(this, _updateOutlineGeometry));
|
|
9472
9568
|
window.removeEventListener("scroll", __privateGet$3(this, _updateOutlineGeometry), {
|
|
@@ -9517,6 +9613,31 @@ class FixedToolbarView {
|
|
|
9517
9613
|
__privateGet$3(this, _outlineApp).mount(outlineContent);
|
|
9518
9614
|
__privateSet$3(this, _outlineContent, outlineContent);
|
|
9519
9615
|
root.appendChild(outlineContent);
|
|
9616
|
+
__privateSet$3(this, _onDblClick, (event) => {
|
|
9617
|
+
const view2 = __privateGet$3(this, _view);
|
|
9618
|
+
if (!view2.editable) return;
|
|
9619
|
+
const dom = view2.dom;
|
|
9620
|
+
const children = dom.children;
|
|
9621
|
+
if (children.length === 0) return;
|
|
9622
|
+
const lastChild = children[children.length - 1];
|
|
9623
|
+
if (!lastChild) return;
|
|
9624
|
+
const lastRect = lastChild.getBoundingClientRect();
|
|
9625
|
+
if (event.clientY <= lastRect.bottom) return;
|
|
9626
|
+
const { doc } = view2.state;
|
|
9627
|
+
const lastNode = doc.lastChild;
|
|
9628
|
+
if (!lastNode) return;
|
|
9629
|
+
if (lastNode.type.name === "paragraph" && lastNode.content.size === 0)
|
|
9630
|
+
return;
|
|
9631
|
+
const paragraphType = view2.state.schema.nodes["paragraph"];
|
|
9632
|
+
if (!paragraphType) return;
|
|
9633
|
+
const pos = doc.content.size;
|
|
9634
|
+
const tr = view2.state.tr.insert(pos, paragraphType.create());
|
|
9635
|
+
const sel = state.TextSelection.create(tr.doc, pos + 1);
|
|
9636
|
+
tr.setSelection(sel);
|
|
9637
|
+
view2.dispatch(tr);
|
|
9638
|
+
view2.focus();
|
|
9639
|
+
});
|
|
9640
|
+
view.dom.addEventListener("dblclick", __privateGet$3(this, _onDblClick));
|
|
9520
9641
|
__privateGet$3(this, _content$2).style.transition = "margin 0.1s ease-out, width 0.1s ease-out";
|
|
9521
9642
|
const viewState = ctx.get(viewMenuStateCtx.key);
|
|
9522
9643
|
if (config.outlinePosition) {
|
|
@@ -9615,7 +9736,7 @@ class FixedToolbarView {
|
|
|
9615
9736
|
__privateGet$3(this, _view).dom.style.maxWidth = maxWidth;
|
|
9616
9737
|
__privateGet$3(this, _view).dom.style.width = isFull ? "100%" : maxWidth;
|
|
9617
9738
|
__privateGet$3(this, _view).dom.style.margin = isFull ? "0" : "0 auto";
|
|
9618
|
-
__privateGet$3(this, _view).dom.style.padding = `20px ${px}
|
|
9739
|
+
__privateGet$3(this, _view).dom.style.padding = `20px ${px} 36px`;
|
|
9619
9740
|
if (__privateGet$3(this, _headerContent)) {
|
|
9620
9741
|
__privateGet$3(this, _headerContent).style.margin = isFull && !viewState.showCover ? "0 auto" : "0";
|
|
9621
9742
|
__privateGet$3(this, _headerContent).style.padding = `0px`;
|
|
@@ -9642,6 +9763,7 @@ _show$1 = new WeakMap();
|
|
|
9642
9763
|
_resizeObserver = new WeakMap();
|
|
9643
9764
|
_updateOutlineGeometry = new WeakMap();
|
|
9644
9765
|
_scrollContainers = new WeakMap();
|
|
9766
|
+
_onDblClick = new WeakMap();
|
|
9645
9767
|
_view = new WeakMap();
|
|
9646
9768
|
const fixedToolbarPlugin = utils.$prose((ctx) => {
|
|
9647
9769
|
return new state.Plugin({
|
|
@@ -9763,7 +9885,7 @@ const imageBlockConverter = utils$1.$prose((ctx) => {
|
|
|
9763
9885
|
const r = replacements[i];
|
|
9764
9886
|
tr.replaceWith(r.from, r.to, r.blocks);
|
|
9765
9887
|
}
|
|
9766
|
-
return tr;
|
|
9888
|
+
return tr.setMeta("addToHistory", false);
|
|
9767
9889
|
}
|
|
9768
9890
|
});
|
|
9769
9891
|
});
|
|
@@ -10244,7 +10366,7 @@ var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Ca
|
|
|
10244
10366
|
var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
10245
10367
|
var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10246
10368
|
var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
10247
|
-
var _tooltipProvider, _content, _app, _selection, _show, _mousePressed;
|
|
10369
|
+
var _tooltipProvider, _content, _app, _selection, _show, _mousePressed, _removePopupListener, _onDocumentMouseUp;
|
|
10248
10370
|
const toolbarTooltip = tooltip.tooltipFactory("CREPE_TOOLBAR");
|
|
10249
10371
|
class ToolbarView {
|
|
10250
10372
|
constructor(ctx, view, config) {
|
|
@@ -10254,11 +10376,18 @@ class ToolbarView {
|
|
|
10254
10376
|
__privateAdd$1(this, _selection);
|
|
10255
10377
|
__privateAdd$1(this, _show, vue.ref(false));
|
|
10256
10378
|
__privateAdd$1(this, _mousePressed, false);
|
|
10379
|
+
__privateAdd$1(this, _removePopupListener);
|
|
10380
|
+
__privateAdd$1(this, _onDocumentMouseUp);
|
|
10257
10381
|
this.update = (view, prevState) => {
|
|
10258
10382
|
__privateGet$1(this, _tooltipProvider).update(view, prevState);
|
|
10259
10383
|
__privateGet$1(this, _selection).value = view.state.selection;
|
|
10260
10384
|
};
|
|
10261
10385
|
this.destroy = () => {
|
|
10386
|
+
var _a;
|
|
10387
|
+
(_a = __privateGet$1(this, _removePopupListener)) == null ? void 0 : _a.call(this);
|
|
10388
|
+
if (__privateGet$1(this, _onDocumentMouseUp)) {
|
|
10389
|
+
document.removeEventListener("mouseup", __privateGet$1(this, _onDocumentMouseUp));
|
|
10390
|
+
}
|
|
10262
10391
|
__privateGet$1(this, _tooltipProvider).destroy();
|
|
10263
10392
|
__privateGet$1(this, _app).unmount();
|
|
10264
10393
|
__privateGet$1(this, _content).remove();
|
|
@@ -10288,12 +10417,23 @@ class ToolbarView {
|
|
|
10288
10417
|
this.update(view);
|
|
10289
10418
|
}, 0);
|
|
10290
10419
|
});
|
|
10420
|
+
const onDocumentMouseUp = () => {
|
|
10421
|
+
if (__privateGet$1(this, _mousePressed)) {
|
|
10422
|
+
__privateSet$1(this, _mousePressed, false);
|
|
10423
|
+
setTimeout(() => {
|
|
10424
|
+
this.update(view);
|
|
10425
|
+
}, 0);
|
|
10426
|
+
}
|
|
10427
|
+
};
|
|
10428
|
+
document.addEventListener("mouseup", onDocumentMouseUp);
|
|
10429
|
+
__privateSet$1(this, _onDocumentMouseUp, onDocumentMouseUp);
|
|
10291
10430
|
__privateSet$1(this, _tooltipProvider, new tooltip.TooltipProvider({
|
|
10292
10431
|
content: __privateGet$1(this, _content),
|
|
10293
10432
|
debounce: 20,
|
|
10294
10433
|
offset: 10,
|
|
10295
10434
|
shouldShow: (view2) => {
|
|
10296
10435
|
if (__privateGet$1(this, _mousePressed)) return false;
|
|
10436
|
+
if (getIsAnyPopupOpen()) return false;
|
|
10297
10437
|
const { doc, selection } = view2.state;
|
|
10298
10438
|
const { empty, from, to } = selection;
|
|
10299
10439
|
const isEmptyTextBlock = !doc.textBetween(from, to).length && selection instanceof state.TextSelection;
|
|
@@ -10313,6 +10453,13 @@ class ToolbarView {
|
|
|
10313
10453
|
__privateGet$1(this, _tooltipProvider).onHide = () => {
|
|
10314
10454
|
__privateGet$1(this, _show).value = false;
|
|
10315
10455
|
};
|
|
10456
|
+
__privateSet$1(this, _removePopupListener, addPopupChangeListener(() => {
|
|
10457
|
+
if (getIsAnyPopupOpen()) {
|
|
10458
|
+
__privateGet$1(this, _tooltipProvider).hide();
|
|
10459
|
+
} else {
|
|
10460
|
+
__privateGet$1(this, _tooltipProvider).update(view);
|
|
10461
|
+
}
|
|
10462
|
+
}));
|
|
10316
10463
|
this.update(view);
|
|
10317
10464
|
}
|
|
10318
10465
|
}
|
|
@@ -10322,6 +10469,8 @@ _app = new WeakMap();
|
|
|
10322
10469
|
_selection = new WeakMap();
|
|
10323
10470
|
_show = new WeakMap();
|
|
10324
10471
|
_mousePressed = new WeakMap();
|
|
10472
|
+
_removePopupListener = new WeakMap();
|
|
10473
|
+
_onDocumentMouseUp = new WeakMap();
|
|
10325
10474
|
const toolbar = (editor, config) => {
|
|
10326
10475
|
editor.config(crepeFeatureConfig(CrepeFeature.Toolbar)).config((ctx) => {
|
|
10327
10476
|
ctx.set(toolbarTooltip.key, {
|