@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/esm/index.js
CHANGED
|
@@ -439,6 +439,7 @@ const removeIcon = `
|
|
|
439
439
|
>
|
|
440
440
|
<path
|
|
441
441
|
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"
|
|
442
|
+
fill="#363B4C"
|
|
442
443
|
/>
|
|
443
444
|
</svg>
|
|
444
445
|
`;
|
|
@@ -4294,6 +4295,29 @@ const cursor = (editor, config) => {
|
|
|
4294
4295
|
editor.use($prose(() => virtualCursor));
|
|
4295
4296
|
};
|
|
4296
4297
|
|
|
4298
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
4299
|
+
let _popupCount = 0;
|
|
4300
|
+
function getIsAnyPopupOpen() {
|
|
4301
|
+
return _popupCount > 0;
|
|
4302
|
+
}
|
|
4303
|
+
function addPopupChangeListener(fn) {
|
|
4304
|
+
listeners.add(fn);
|
|
4305
|
+
return () => listeners.delete(fn);
|
|
4306
|
+
}
|
|
4307
|
+
function incrementPopupCount() {
|
|
4308
|
+
const wasZero = _popupCount === 0;
|
|
4309
|
+
_popupCount++;
|
|
4310
|
+
if (wasZero) {
|
|
4311
|
+
listeners.forEach((fn) => fn());
|
|
4312
|
+
}
|
|
4313
|
+
}
|
|
4314
|
+
function decrementPopupCount() {
|
|
4315
|
+
_popupCount = Math.max(0, _popupCount - 1);
|
|
4316
|
+
if (_popupCount === 0) {
|
|
4317
|
+
listeners.forEach((fn) => fn());
|
|
4318
|
+
}
|
|
4319
|
+
}
|
|
4320
|
+
|
|
4297
4321
|
const remarkHighlightMarkPlugin = $remark(
|
|
4298
4322
|
"remarkHighlightMark",
|
|
4299
4323
|
() => function() {
|
|
@@ -5390,6 +5414,8 @@ const Toolbar = defineComponent({
|
|
|
5390
5414
|
const {
|
|
5391
5415
|
marks: savedMarks,
|
|
5392
5416
|
align: savedAlign,
|
|
5417
|
+
blockType: savedBlockType,
|
|
5418
|
+
blockAttrs: savedBlockAttrs,
|
|
5393
5419
|
isPersistent
|
|
5394
5420
|
} = formatPainterState.value;
|
|
5395
5421
|
let applied = false;
|
|
@@ -5411,6 +5437,30 @@ const Toolbar = defineComponent({
|
|
|
5411
5437
|
}
|
|
5412
5438
|
);
|
|
5413
5439
|
}
|
|
5440
|
+
if (savedBlockType) {
|
|
5441
|
+
curState.doc.nodesBetween(
|
|
5442
|
+
curSelection.from,
|
|
5443
|
+
curSelection.to,
|
|
5444
|
+
(node, pos) => {
|
|
5445
|
+
if (node.type.name === "paragraph") {
|
|
5446
|
+
tr.setNodeMarkup(
|
|
5447
|
+
pos,
|
|
5448
|
+
curState.schema.nodes[savedBlockType],
|
|
5449
|
+
{
|
|
5450
|
+
...savedBlockAttrs,
|
|
5451
|
+
...savedAlign ? { align: savedAlign } : {}
|
|
5452
|
+
}
|
|
5453
|
+
);
|
|
5454
|
+
} else if (node.type.name === "heading" && savedBlockAttrs) {
|
|
5455
|
+
tr.setNodeMarkup(pos, null, {
|
|
5456
|
+
...node.attrs,
|
|
5457
|
+
...savedBlockAttrs,
|
|
5458
|
+
...savedAlign ? { align: savedAlign } : {}
|
|
5459
|
+
});
|
|
5460
|
+
}
|
|
5461
|
+
}
|
|
5462
|
+
);
|
|
5463
|
+
}
|
|
5414
5464
|
dispatch(tr);
|
|
5415
5465
|
applied = true;
|
|
5416
5466
|
} else {
|
|
@@ -5443,6 +5493,22 @@ const Toolbar = defineComponent({
|
|
|
5443
5493
|
});
|
|
5444
5494
|
}
|
|
5445
5495
|
}
|
|
5496
|
+
if (savedBlockType) {
|
|
5497
|
+
const pos = curSelection.$from.before(curSelection.$from.depth);
|
|
5498
|
+
const node = curState.doc.nodeAt(pos);
|
|
5499
|
+
if (node && node.type.name === "paragraph") {
|
|
5500
|
+
tr.setNodeMarkup(pos, curState.schema.nodes[savedBlockType], {
|
|
5501
|
+
...savedBlockAttrs,
|
|
5502
|
+
...savedAlign ? { align: savedAlign } : {}
|
|
5503
|
+
});
|
|
5504
|
+
} else if (node && node.type.name === "heading" && savedBlockAttrs) {
|
|
5505
|
+
tr.setNodeMarkup(pos, null, {
|
|
5506
|
+
...node.attrs,
|
|
5507
|
+
...savedBlockAttrs,
|
|
5508
|
+
...savedAlign ? { align: savedAlign } : {}
|
|
5509
|
+
});
|
|
5510
|
+
}
|
|
5511
|
+
}
|
|
5446
5512
|
tr.setStoredMarks(savedMarks);
|
|
5447
5513
|
dispatch(tr);
|
|
5448
5514
|
applied = true;
|
|
@@ -5491,7 +5557,22 @@ const Toolbar = defineComponent({
|
|
|
5491
5557
|
}
|
|
5492
5558
|
}
|
|
5493
5559
|
align = foundAlign;
|
|
5494
|
-
|
|
5560
|
+
let blockType = null;
|
|
5561
|
+
let blockAttrs = null;
|
|
5562
|
+
{
|
|
5563
|
+
const parent = selection.$from.parent;
|
|
5564
|
+
if (parent.type.name === "heading") {
|
|
5565
|
+
blockType = "heading";
|
|
5566
|
+
blockAttrs = { level: parent.attrs.level };
|
|
5567
|
+
}
|
|
5568
|
+
}
|
|
5569
|
+
formatPainterState.value = {
|
|
5570
|
+
marks,
|
|
5571
|
+
align,
|
|
5572
|
+
blockType,
|
|
5573
|
+
blockAttrs,
|
|
5574
|
+
isPersistent
|
|
5575
|
+
};
|
|
5495
5576
|
document.removeEventListener("pointerup", formatPainterHandler);
|
|
5496
5577
|
setTimeout(() => {
|
|
5497
5578
|
document.addEventListener("pointerup", formatPainterHandler);
|
|
@@ -5544,6 +5625,13 @@ const Toolbar = defineComponent({
|
|
|
5544
5625
|
const showOverflowMenu = ref(false);
|
|
5545
5626
|
const overflowMenuPos = ref({ top: 0 });
|
|
5546
5627
|
const cachedWidths = /* @__PURE__ */ new Map();
|
|
5628
|
+
const anyFixedPopup = computed(
|
|
5629
|
+
() => !!isFixed && (showBlockMenu.value || showAlignMenu.value || showColorMenu.value || showFontFamilyMenu.value || showFontSizeMenu.value || showTableMenu.value || showOverflowMenu.value)
|
|
5630
|
+
);
|
|
5631
|
+
watch(anyFixedPopup, (val) => {
|
|
5632
|
+
if (val) incrementPopupCount();
|
|
5633
|
+
else decrementPopupCount();
|
|
5634
|
+
});
|
|
5547
5635
|
const getMenuLeftPos = (rect, menuWidth) => {
|
|
5548
5636
|
let left = rect.left;
|
|
5549
5637
|
if (left + menuWidth > window.innerWidth) {
|
|
@@ -5780,6 +5868,7 @@ const Toolbar = defineComponent({
|
|
|
5780
5868
|
if (hideFontFamilyTimer) clearTimeout(hideFontFamilyTimer);
|
|
5781
5869
|
if (hideFontSizeTimer) clearTimeout(hideFontSizeTimer);
|
|
5782
5870
|
if (hideTableTimer) clearTimeout(hideTableTimer);
|
|
5871
|
+
if (anyFixedPopup.value) decrementPopupCount();
|
|
5783
5872
|
});
|
|
5784
5873
|
let overflowResizeObserver = null;
|
|
5785
5874
|
let overflowSetupDone = false;
|
|
@@ -6218,13 +6307,11 @@ const Toolbar = defineComponent({
|
|
|
6218
6307
|
});
|
|
6219
6308
|
}
|
|
6220
6309
|
});
|
|
6221
|
-
const nonHeadingGroups = toolbarGroupInfo.value.filter(
|
|
6222
|
-
(group)
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
}
|
|
6227
|
-
);
|
|
6310
|
+
const nonHeadingGroups = toolbarGroupInfo.value.filter((group) => {
|
|
6311
|
+
if (group.key === "heading") return false;
|
|
6312
|
+
if (props.isFixed && group.key === "function") return false;
|
|
6313
|
+
return true;
|
|
6314
|
+
});
|
|
6228
6315
|
const isSectionOverflowed = (idx) => idx >= overflowVisibleCount.value;
|
|
6229
6316
|
const hasOverflow = overflowVisibleCount.value < totalSectionCount.value;
|
|
6230
6317
|
return /* @__PURE__ */ h(
|
|
@@ -7520,7 +7607,7 @@ const createViewMenuState = () => reactive({
|
|
|
7520
7607
|
outlineVisible: false,
|
|
7521
7608
|
outlinePosition: "left",
|
|
7522
7609
|
outlineWidth: 250,
|
|
7523
|
-
documentBackground:
|
|
7610
|
+
documentBackground: "#FFFFFF",
|
|
7524
7611
|
showTitle: false,
|
|
7525
7612
|
showCover: false,
|
|
7526
7613
|
coverUrl: "",
|
|
@@ -7620,10 +7707,15 @@ const MenuBar = defineComponent({
|
|
|
7620
7707
|
onUnmounted(() => {
|
|
7621
7708
|
document.removeEventListener("click", closeMenu);
|
|
7622
7709
|
if (rafId) cancelAnimationFrame(rafId);
|
|
7710
|
+
if (showMenu.value) decrementPopupCount();
|
|
7711
|
+
});
|
|
7712
|
+
watch(showMenu, (val) => {
|
|
7713
|
+
if (val) incrementPopupCount();
|
|
7714
|
+
else decrementPopupCount();
|
|
7623
7715
|
});
|
|
7624
7716
|
const viewState = computed(() => props.ctx.get(viewMenuStateCtx.key));
|
|
7625
7717
|
const bgColors = [
|
|
7626
|
-
{ name: "\
|
|
7718
|
+
{ name: "\u767D\u8272", value: "#FFFFFF" },
|
|
7627
7719
|
{ name: "\u6D45\u7070", value: "#F7F7F5" },
|
|
7628
7720
|
{ name: "\u6D45\u68D5", value: "#F4EEDB" },
|
|
7629
7721
|
{ name: "\u6D45\u6A59", value: "#FBECDD" },
|
|
@@ -8111,7 +8203,7 @@ const rightGroups = [
|
|
|
8111
8203
|
titleKey: "shortcuts.history",
|
|
8112
8204
|
items: [
|
|
8113
8205
|
{ labelKey: "shortcuts.undo", keys: ["Mod+z"] },
|
|
8114
|
-
{ labelKey: "shortcuts.redo", keys: ["Mod+y", "Shift+Mod+
|
|
8206
|
+
{ labelKey: "shortcuts.redo", keys: ["Mod+y", "Shift+Mod+Z"] }
|
|
8115
8207
|
]
|
|
8116
8208
|
}
|
|
8117
8209
|
];
|
|
@@ -9439,7 +9531,7 @@ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Ca
|
|
|
9439
9531
|
var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9440
9532
|
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);
|
|
9441
9533
|
var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
|
|
9442
|
-
var _content$2, _app$2, _headerContent, _headerApp, _outlineContent, _outlineApp, _watcher, _selection$1, _show$1, _resizeObserver, _updateOutlineGeometry, _scrollContainers, _view;
|
|
9534
|
+
var _content$2, _app$2, _headerContent, _headerApp, _outlineContent, _outlineApp, _watcher, _selection$1, _show$1, _resizeObserver, _updateOutlineGeometry, _scrollContainers, _onDblClick, _view;
|
|
9443
9535
|
const fixedToolbarConfig = $ctx(
|
|
9444
9536
|
{},
|
|
9445
9537
|
"fixedToolbarConfigCtx"
|
|
@@ -9459,12 +9551,16 @@ class FixedToolbarView {
|
|
|
9459
9551
|
__privateAdd$3(this, _resizeObserver);
|
|
9460
9552
|
__privateAdd$3(this, _updateOutlineGeometry);
|
|
9461
9553
|
__privateAdd$3(this, _scrollContainers, []);
|
|
9554
|
+
__privateAdd$3(this, _onDblClick);
|
|
9462
9555
|
__privateAdd$3(this, _view);
|
|
9463
9556
|
this.update = (view) => {
|
|
9464
9557
|
__privateGet$3(this, _selection$1).value = view.state.selection;
|
|
9465
9558
|
};
|
|
9466
9559
|
this.destroy = () => {
|
|
9467
9560
|
if (__privateGet$3(this, _watcher)) __privateGet$3(this, _watcher).call(this);
|
|
9561
|
+
if (__privateGet$3(this, _onDblClick)) {
|
|
9562
|
+
__privateGet$3(this, _view).dom.removeEventListener("dblclick", __privateGet$3(this, _onDblClick));
|
|
9563
|
+
}
|
|
9468
9564
|
if (__privateGet$3(this, _resizeObserver)) __privateGet$3(this, _resizeObserver).disconnect();
|
|
9469
9565
|
window.removeEventListener("resize", __privateGet$3(this, _updateOutlineGeometry));
|
|
9470
9566
|
window.removeEventListener("scroll", __privateGet$3(this, _updateOutlineGeometry), {
|
|
@@ -9515,6 +9611,31 @@ class FixedToolbarView {
|
|
|
9515
9611
|
__privateGet$3(this, _outlineApp).mount(outlineContent);
|
|
9516
9612
|
__privateSet$3(this, _outlineContent, outlineContent);
|
|
9517
9613
|
root.appendChild(outlineContent);
|
|
9614
|
+
__privateSet$3(this, _onDblClick, (event) => {
|
|
9615
|
+
const view2 = __privateGet$3(this, _view);
|
|
9616
|
+
if (!view2.editable) return;
|
|
9617
|
+
const dom = view2.dom;
|
|
9618
|
+
const children = dom.children;
|
|
9619
|
+
if (children.length === 0) return;
|
|
9620
|
+
const lastChild = children[children.length - 1];
|
|
9621
|
+
if (!lastChild) return;
|
|
9622
|
+
const lastRect = lastChild.getBoundingClientRect();
|
|
9623
|
+
if (event.clientY <= lastRect.bottom) return;
|
|
9624
|
+
const { doc } = view2.state;
|
|
9625
|
+
const lastNode = doc.lastChild;
|
|
9626
|
+
if (!lastNode) return;
|
|
9627
|
+
if (lastNode.type.name === "paragraph" && lastNode.content.size === 0)
|
|
9628
|
+
return;
|
|
9629
|
+
const paragraphType = view2.state.schema.nodes["paragraph"];
|
|
9630
|
+
if (!paragraphType) return;
|
|
9631
|
+
const pos = doc.content.size;
|
|
9632
|
+
const tr = view2.state.tr.insert(pos, paragraphType.create());
|
|
9633
|
+
const sel = TextSelection.create(tr.doc, pos + 1);
|
|
9634
|
+
tr.setSelection(sel);
|
|
9635
|
+
view2.dispatch(tr);
|
|
9636
|
+
view2.focus();
|
|
9637
|
+
});
|
|
9638
|
+
view.dom.addEventListener("dblclick", __privateGet$3(this, _onDblClick));
|
|
9518
9639
|
__privateGet$3(this, _content$2).style.transition = "margin 0.1s ease-out, width 0.1s ease-out";
|
|
9519
9640
|
const viewState = ctx.get(viewMenuStateCtx.key);
|
|
9520
9641
|
if (config.outlinePosition) {
|
|
@@ -9613,7 +9734,7 @@ class FixedToolbarView {
|
|
|
9613
9734
|
__privateGet$3(this, _view).dom.style.maxWidth = maxWidth;
|
|
9614
9735
|
__privateGet$3(this, _view).dom.style.width = isFull ? "100%" : maxWidth;
|
|
9615
9736
|
__privateGet$3(this, _view).dom.style.margin = isFull ? "0" : "0 auto";
|
|
9616
|
-
__privateGet$3(this, _view).dom.style.padding = `20px ${px}
|
|
9737
|
+
__privateGet$3(this, _view).dom.style.padding = `20px ${px} 36px`;
|
|
9617
9738
|
if (__privateGet$3(this, _headerContent)) {
|
|
9618
9739
|
__privateGet$3(this, _headerContent).style.margin = isFull && !viewState.showCover ? "0 auto" : "0";
|
|
9619
9740
|
__privateGet$3(this, _headerContent).style.padding = `0px`;
|
|
@@ -9640,6 +9761,7 @@ _show$1 = new WeakMap();
|
|
|
9640
9761
|
_resizeObserver = new WeakMap();
|
|
9641
9762
|
_updateOutlineGeometry = new WeakMap();
|
|
9642
9763
|
_scrollContainers = new WeakMap();
|
|
9764
|
+
_onDblClick = new WeakMap();
|
|
9643
9765
|
_view = new WeakMap();
|
|
9644
9766
|
const fixedToolbarPlugin = $prose((ctx) => {
|
|
9645
9767
|
return new Plugin({
|
|
@@ -9761,7 +9883,7 @@ const imageBlockConverter = $prose$1((ctx) => {
|
|
|
9761
9883
|
const r = replacements[i];
|
|
9762
9884
|
tr.replaceWith(r.from, r.to, r.blocks);
|
|
9763
9885
|
}
|
|
9764
|
-
return tr;
|
|
9886
|
+
return tr.setMeta("addToHistory", false);
|
|
9765
9887
|
}
|
|
9766
9888
|
});
|
|
9767
9889
|
});
|
|
@@ -10242,7 +10364,7 @@ var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Ca
|
|
|
10242
10364
|
var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
10243
10365
|
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);
|
|
10244
10366
|
var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
10245
|
-
var _tooltipProvider, _content, _app, _selection, _show, _mousePressed;
|
|
10367
|
+
var _tooltipProvider, _content, _app, _selection, _show, _mousePressed, _removePopupListener, _onDocumentMouseUp;
|
|
10246
10368
|
const toolbarTooltip = tooltipFactory("CREPE_TOOLBAR");
|
|
10247
10369
|
class ToolbarView {
|
|
10248
10370
|
constructor(ctx, view, config) {
|
|
@@ -10252,11 +10374,18 @@ class ToolbarView {
|
|
|
10252
10374
|
__privateAdd$1(this, _selection);
|
|
10253
10375
|
__privateAdd$1(this, _show, ref(false));
|
|
10254
10376
|
__privateAdd$1(this, _mousePressed, false);
|
|
10377
|
+
__privateAdd$1(this, _removePopupListener);
|
|
10378
|
+
__privateAdd$1(this, _onDocumentMouseUp);
|
|
10255
10379
|
this.update = (view, prevState) => {
|
|
10256
10380
|
__privateGet$1(this, _tooltipProvider).update(view, prevState);
|
|
10257
10381
|
__privateGet$1(this, _selection).value = view.state.selection;
|
|
10258
10382
|
};
|
|
10259
10383
|
this.destroy = () => {
|
|
10384
|
+
var _a;
|
|
10385
|
+
(_a = __privateGet$1(this, _removePopupListener)) == null ? void 0 : _a.call(this);
|
|
10386
|
+
if (__privateGet$1(this, _onDocumentMouseUp)) {
|
|
10387
|
+
document.removeEventListener("mouseup", __privateGet$1(this, _onDocumentMouseUp));
|
|
10388
|
+
}
|
|
10260
10389
|
__privateGet$1(this, _tooltipProvider).destroy();
|
|
10261
10390
|
__privateGet$1(this, _app).unmount();
|
|
10262
10391
|
__privateGet$1(this, _content).remove();
|
|
@@ -10286,12 +10415,23 @@ class ToolbarView {
|
|
|
10286
10415
|
this.update(view);
|
|
10287
10416
|
}, 0);
|
|
10288
10417
|
});
|
|
10418
|
+
const onDocumentMouseUp = () => {
|
|
10419
|
+
if (__privateGet$1(this, _mousePressed)) {
|
|
10420
|
+
__privateSet$1(this, _mousePressed, false);
|
|
10421
|
+
setTimeout(() => {
|
|
10422
|
+
this.update(view);
|
|
10423
|
+
}, 0);
|
|
10424
|
+
}
|
|
10425
|
+
};
|
|
10426
|
+
document.addEventListener("mouseup", onDocumentMouseUp);
|
|
10427
|
+
__privateSet$1(this, _onDocumentMouseUp, onDocumentMouseUp);
|
|
10289
10428
|
__privateSet$1(this, _tooltipProvider, new TooltipProvider({
|
|
10290
10429
|
content: __privateGet$1(this, _content),
|
|
10291
10430
|
debounce: 20,
|
|
10292
10431
|
offset: 10,
|
|
10293
10432
|
shouldShow: (view2) => {
|
|
10294
10433
|
if (__privateGet$1(this, _mousePressed)) return false;
|
|
10434
|
+
if (getIsAnyPopupOpen()) return false;
|
|
10295
10435
|
const { doc, selection } = view2.state;
|
|
10296
10436
|
const { empty, from, to } = selection;
|
|
10297
10437
|
const isEmptyTextBlock = !doc.textBetween(from, to).length && selection instanceof TextSelection;
|
|
@@ -10311,6 +10451,13 @@ class ToolbarView {
|
|
|
10311
10451
|
__privateGet$1(this, _tooltipProvider).onHide = () => {
|
|
10312
10452
|
__privateGet$1(this, _show).value = false;
|
|
10313
10453
|
};
|
|
10454
|
+
__privateSet$1(this, _removePopupListener, addPopupChangeListener(() => {
|
|
10455
|
+
if (getIsAnyPopupOpen()) {
|
|
10456
|
+
__privateGet$1(this, _tooltipProvider).hide();
|
|
10457
|
+
} else {
|
|
10458
|
+
__privateGet$1(this, _tooltipProvider).update(view);
|
|
10459
|
+
}
|
|
10460
|
+
}));
|
|
10314
10461
|
this.update(view);
|
|
10315
10462
|
}
|
|
10316
10463
|
}
|
|
@@ -10320,6 +10467,8 @@ _app = new WeakMap();
|
|
|
10320
10467
|
_selection = new WeakMap();
|
|
10321
10468
|
_show = new WeakMap();
|
|
10322
10469
|
_mousePressed = new WeakMap();
|
|
10470
|
+
_removePopupListener = new WeakMap();
|
|
10471
|
+
_onDocumentMouseUp = new WeakMap();
|
|
10323
10472
|
const toolbar = (editor, config) => {
|
|
10324
10473
|
editor.config(crepeFeatureConfig(CrepeFeature.Toolbar)).config((ctx) => {
|
|
10325
10474
|
ctx.set(toolbarTooltip.key, {
|