rme 0.1.27 → 0.1.29
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/dist/index.mjs +363 -54
- package/dist/index.mjs.map +4 -4
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -20675,29 +20675,41 @@ var defaultIgnoredKeys = [
|
|
|
20675
20675
|
];
|
|
20676
20676
|
|
|
20677
20677
|
// src/editor/extensions/SlashMenu/slashmenu-extension.ts
|
|
20678
|
-
import {
|
|
20678
|
+
import { extension as extension10, PlainExtension as PlainExtension8 } from "remirror";
|
|
20679
20679
|
|
|
20680
20680
|
// src/editor/extensions/SlashMenu/case.ts
|
|
20681
20681
|
var defaultConditions = (openInSelection = false) => {
|
|
20682
20682
|
return {
|
|
20683
20683
|
shouldOpen: (state, event, view) => {
|
|
20684
|
+
if (event.isComposing) {
|
|
20685
|
+
return false;
|
|
20686
|
+
}
|
|
20684
20687
|
const editorState = view.state;
|
|
20685
20688
|
const resolvedPos = editorState.selection.from < 0 || editorState.selection.from > editorState.doc.content.size ? null : editorState.doc.resolve(editorState.selection.from);
|
|
20686
20689
|
const parentNode = resolvedPos?.parent;
|
|
20687
20690
|
const inParagraph = parentNode?.type.name === "paragraph";
|
|
20688
|
-
const inEmptyPar = inParagraph && parentNode?.nodeSize === 2;
|
|
20689
20691
|
const posInLine = editorState.selection.$head.parentOffset;
|
|
20690
20692
|
const prevCharacter = editorState.selection.$head.parent.textContent.slice(
|
|
20691
20693
|
posInLine - 1,
|
|
20692
20694
|
posInLine
|
|
20693
20695
|
);
|
|
20696
|
+
const inEmptyPar = inParagraph && parentNode?.textContent === prevCharacter;
|
|
20694
20697
|
const spaceBeforePos = prevCharacter === "\u200A" || prevCharacter === "" || prevCharacter === " ";
|
|
20695
|
-
return !state.open && event.
|
|
20698
|
+
return !state.open && event.code === "Slash" && inParagraph && (inEmptyPar || spaceBeforePos || editorState.selection.from !== editorState.selection.to && openInSelection);
|
|
20696
20699
|
},
|
|
20697
|
-
shouldClose: (state, event) => state.open && (event.key === "
|
|
20700
|
+
shouldClose: (state, event) => state.open && (event.key === "Slash" || event.key === "Escape" || event.key === "Backspace") && state.filter.length === 0
|
|
20698
20701
|
};
|
|
20699
20702
|
};
|
|
20700
20703
|
var getCase = (state, event, view, ignoredKeys, customConditions, shouldOpenInSelection) => {
|
|
20704
|
+
if (event.isComposing) {
|
|
20705
|
+
if (event.key === "Escape") {
|
|
20706
|
+
return "closeMenu" /* CloseMenu */;
|
|
20707
|
+
}
|
|
20708
|
+
if (event.key === "Backspace" && state.filter.length === 0) {
|
|
20709
|
+
return "closeMenu" /* CloseMenu */;
|
|
20710
|
+
}
|
|
20711
|
+
return "Ignore" /* Ignore */;
|
|
20712
|
+
}
|
|
20701
20713
|
const condition = customConditions || defaultConditions(shouldOpenInSelection);
|
|
20702
20714
|
if (condition.shouldOpen(state, event, view)) {
|
|
20703
20715
|
return "openMenu" /* OpenMenu */;
|
|
@@ -20752,19 +20764,32 @@ var SlashMenuExtension = class extends PlainExtension8 {
|
|
|
20752
20764
|
const slashCase = getCase(state, event, view, initialState.ignoredKeys);
|
|
20753
20765
|
switch (slashCase) {
|
|
20754
20766
|
case "openMenu" /* OpenMenu */:
|
|
20767
|
+
const resolvedPos = editorState.selection.from < 0 || editorState.selection.from > editorState.doc.content.size ? null : editorState.doc.resolve(editorState.selection.from);
|
|
20768
|
+
const parentNode = resolvedPos?.parent;
|
|
20769
|
+
const inParagraph = parentNode?.type.name === "paragraph";
|
|
20770
|
+
if (inParagraph && parentNode.textContent === "/" && resolvedPos) {
|
|
20771
|
+
view.dispatch(
|
|
20772
|
+
editorState.tr.delete(resolvedPos.start(), resolvedPos.end()).setMeta(this.spec.key, { type: "open" /* open */ })
|
|
20773
|
+
);
|
|
20774
|
+
}
|
|
20755
20775
|
dispatchWithMeta(view, this.spec.key, { type: "open" /* open */ });
|
|
20756
20776
|
return true;
|
|
20757
20777
|
case "closeMenu" /* CloseMenu */: {
|
|
20758
|
-
if (event.
|
|
20778
|
+
if (event.isComposing) {
|
|
20779
|
+
dispatchWithMeta(view, this.spec.key, {
|
|
20780
|
+
type: "close" /* close */
|
|
20781
|
+
});
|
|
20782
|
+
} else if (event.code === "Slash") {
|
|
20759
20783
|
view.dispatch(
|
|
20760
20784
|
editorState.tr.insertText("/").setMeta(this.spec.key, {
|
|
20761
20785
|
type: "close" /* close */
|
|
20762
20786
|
})
|
|
20763
20787
|
);
|
|
20764
|
-
} else
|
|
20788
|
+
} else {
|
|
20765
20789
|
dispatchWithMeta(view, this.spec.key, {
|
|
20766
20790
|
type: "close" /* close */
|
|
20767
20791
|
});
|
|
20792
|
+
}
|
|
20768
20793
|
return true;
|
|
20769
20794
|
}
|
|
20770
20795
|
case "Execute" /* Execute */:
|
|
@@ -22359,15 +22384,35 @@ import { memo as memo6, useCallback as useCallback18, useEffect as useEffect8, u
|
|
|
22359
22384
|
import { useExtension, useRemirrorContext as useRemirrorContext3 } from "@remirror/react-core";
|
|
22360
22385
|
import { useCallback as useCallback4, useEffect as useEffect6, useMemo as useMemo3, useRef as useRef6, useState as useState7 } from "react";
|
|
22361
22386
|
import { usePopper } from "react-popper";
|
|
22387
|
+
import styled9 from "styled-components";
|
|
22362
22388
|
|
|
22363
22389
|
// src/editor/toolbar/SlashMenu/SlashMenuRoot.tsx
|
|
22364
22390
|
import { memo as memo5, useCallback as useCallback3, useEffect as useEffect5, useMemo as useMemo2, useRef as useRef5, useState as useState6 } from "react";
|
|
22391
|
+
import { useTranslation } from "react-i18next";
|
|
22365
22392
|
import styled8, { css as css5 } from "styled-components";
|
|
22393
|
+
import { Input as Input2, Space as Space2 } from "zens";
|
|
22366
22394
|
|
|
22367
22395
|
// src/editor/theme/darken-colors.ts
|
|
22368
22396
|
import Color from "color";
|
|
22369
22397
|
var darken = (color, amount) => Color(color).darken(amount).string();
|
|
22370
22398
|
|
|
22399
|
+
// src/editor/utils/getOS.ts
|
|
22400
|
+
function getOS() {
|
|
22401
|
+
const userAgent = window.navigator.userAgent;
|
|
22402
|
+
const platform2 = window.navigator.platform;
|
|
22403
|
+
if (/Win/.test(platform2) || /Win/.test(userAgent)) {
|
|
22404
|
+
return "Windows";
|
|
22405
|
+
} else if (/Mac/.test(platform2) || /Mac/.test(userAgent)) {
|
|
22406
|
+
return "macOS";
|
|
22407
|
+
} else {
|
|
22408
|
+
return "Unknown";
|
|
22409
|
+
}
|
|
22410
|
+
}
|
|
22411
|
+
function getModKeyName() {
|
|
22412
|
+
const os = getOS();
|
|
22413
|
+
return os === "macOS" ? "\u2318" : "Ctrl";
|
|
22414
|
+
}
|
|
22415
|
+
|
|
22371
22416
|
// src/editor/toolbar/SlashMenu/TablePanel.tsx
|
|
22372
22417
|
import { forwardRef, useState as useState5, useImperativeHandle, memo as memo4 } from "react";
|
|
22373
22418
|
import styled7 from "styled-components";
|
|
@@ -22459,10 +22504,12 @@ var TablePanel = memo4(
|
|
|
22459
22504
|
var TablePanel_default = TablePanel;
|
|
22460
22505
|
|
|
22461
22506
|
// src/editor/toolbar/SlashMenu/SlashMenuRoot.tsx
|
|
22462
|
-
import { jsx as jsx15, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
22507
|
+
import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
22463
22508
|
var SlashMenuRoot = memo5(
|
|
22464
22509
|
({ rootRef, commands, closeMenu }) => {
|
|
22465
22510
|
const componentRefMap = useRef5({});
|
|
22511
|
+
const [searchText, setSearchText] = useState6("");
|
|
22512
|
+
const { t: t18 } = useTranslation();
|
|
22466
22513
|
const menuItems = useMemo2(() => {
|
|
22467
22514
|
const headingItems = Array.from({ length: 6 }).map((_, i) => {
|
|
22468
22515
|
return {
|
|
@@ -22477,11 +22524,13 @@ var SlashMenuRoot = memo5(
|
|
|
22477
22524
|
{
|
|
22478
22525
|
title: "Text",
|
|
22479
22526
|
id: "text",
|
|
22527
|
+
iconName: "ri-text",
|
|
22480
22528
|
children: headingItems
|
|
22481
22529
|
},
|
|
22482
22530
|
{
|
|
22483
22531
|
title: "Table",
|
|
22484
22532
|
id: "table",
|
|
22533
|
+
iconName: "ri-table-line",
|
|
22485
22534
|
handler: () => {
|
|
22486
22535
|
componentRefMap.current.table?.createTable();
|
|
22487
22536
|
},
|
|
@@ -22500,8 +22549,9 @@ var SlashMenuRoot = memo5(
|
|
|
22500
22549
|
];
|
|
22501
22550
|
if (commands.createAiBlock) {
|
|
22502
22551
|
res.unshift({
|
|
22503
|
-
title: "
|
|
22552
|
+
title: "AI",
|
|
22504
22553
|
id: "ai",
|
|
22554
|
+
iconName: "ri-bard-line",
|
|
22505
22555
|
handler: () => {
|
|
22506
22556
|
commands.createAiBlock({});
|
|
22507
22557
|
}
|
|
@@ -22509,10 +22559,55 @@ var SlashMenuRoot = memo5(
|
|
|
22509
22559
|
}
|
|
22510
22560
|
return res;
|
|
22511
22561
|
}, [closeMenu, commands]);
|
|
22512
|
-
const
|
|
22562
|
+
const filteredMenuItems = useMemo2(() => {
|
|
22563
|
+
if (!searchText.trim()) {
|
|
22564
|
+
return menuItems;
|
|
22565
|
+
}
|
|
22566
|
+
const searchLower = searchText.toLowerCase();
|
|
22567
|
+
return menuItems.filter((item) => {
|
|
22568
|
+
if (item.title.toLowerCase().includes(searchLower)) {
|
|
22569
|
+
return true;
|
|
22570
|
+
}
|
|
22571
|
+
if (item.children) {
|
|
22572
|
+
const filteredChildren = item.children.filter(
|
|
22573
|
+
(child) => child.title.toLowerCase().includes(searchLower)
|
|
22574
|
+
);
|
|
22575
|
+
if (filteredChildren.length > 0) {
|
|
22576
|
+
return true;
|
|
22577
|
+
}
|
|
22578
|
+
}
|
|
22579
|
+
return false;
|
|
22580
|
+
}).map((item) => {
|
|
22581
|
+
if (item.children && searchText.trim()) {
|
|
22582
|
+
const searchLower2 = searchText.toLowerCase();
|
|
22583
|
+
if (item.title.toLowerCase().includes(searchLower2)) {
|
|
22584
|
+
return item;
|
|
22585
|
+
}
|
|
22586
|
+
const filteredChildren = item.children.filter(
|
|
22587
|
+
(child) => child.title.toLowerCase().includes(searchLower2)
|
|
22588
|
+
);
|
|
22589
|
+
return {
|
|
22590
|
+
...item,
|
|
22591
|
+
children: filteredChildren
|
|
22592
|
+
};
|
|
22593
|
+
}
|
|
22594
|
+
return item;
|
|
22595
|
+
});
|
|
22596
|
+
}, [menuItems, searchText]);
|
|
22597
|
+
const [activeGroupId, setActiveGroupId] = useState6(filteredMenuItems[0]?.id);
|
|
22513
22598
|
const [activeItemId, setActiveItemId] = useState6();
|
|
22514
|
-
|
|
22515
|
-
|
|
22599
|
+
useEffect5(() => {
|
|
22600
|
+
if (filteredMenuItems.length > 0) {
|
|
22601
|
+
setActiveGroupId(filteredMenuItems[0].id);
|
|
22602
|
+
if (filteredMenuItems[0].children) {
|
|
22603
|
+
setActiveItemId(filteredMenuItems[0].children[0].id);
|
|
22604
|
+
} else {
|
|
22605
|
+
setActiveItemId(void 0);
|
|
22606
|
+
}
|
|
22607
|
+
}
|
|
22608
|
+
}, [filteredMenuItems]);
|
|
22609
|
+
const currentIndex = filteredMenuItems.findIndex((item) => item.id === activeGroupId);
|
|
22610
|
+
const currentMenuItem = filteredMenuItems[currentIndex];
|
|
22516
22611
|
const handleDown = useCallback3(() => {
|
|
22517
22612
|
if (activeItemId) {
|
|
22518
22613
|
if (currentMenuItem?.children) {
|
|
@@ -22523,16 +22618,22 @@ var SlashMenuRoot = memo5(
|
|
|
22523
22618
|
if (nextIndex < currentMenuItem.children.length) {
|
|
22524
22619
|
setActiveItemId(currentMenuItem.children[nextIndex].id);
|
|
22525
22620
|
}
|
|
22526
|
-
} else if (currentMenuItem
|
|
22621
|
+
} else if (currentMenuItem?.Renderer) {
|
|
22527
22622
|
setActiveItemId(currentMenuItem.Renderer.id);
|
|
22528
22623
|
}
|
|
22529
22624
|
} else {
|
|
22530
22625
|
const nextIndex = currentIndex + 1;
|
|
22531
|
-
if (nextIndex <
|
|
22532
|
-
setActiveGroupId(
|
|
22626
|
+
if (nextIndex < filteredMenuItems.length) {
|
|
22627
|
+
setActiveGroupId(filteredMenuItems[nextIndex].id);
|
|
22533
22628
|
}
|
|
22534
22629
|
}
|
|
22535
|
-
}, [
|
|
22630
|
+
}, [
|
|
22631
|
+
activeItemId,
|
|
22632
|
+
currentIndex,
|
|
22633
|
+
currentMenuItem?.Renderer,
|
|
22634
|
+
currentMenuItem?.children,
|
|
22635
|
+
filteredMenuItems
|
|
22636
|
+
]);
|
|
22536
22637
|
const handleUp = useCallback3(() => {
|
|
22537
22638
|
if (activeItemId) {
|
|
22538
22639
|
if (currentMenuItem?.children) {
|
|
@@ -22543,16 +22644,22 @@ var SlashMenuRoot = memo5(
|
|
|
22543
22644
|
if (nextIndex >= 0) {
|
|
22544
22645
|
setActiveItemId(currentMenuItem.children[nextIndex].id);
|
|
22545
22646
|
}
|
|
22546
|
-
} else if (currentMenuItem
|
|
22647
|
+
} else if (currentMenuItem?.Renderer) {
|
|
22547
22648
|
setActiveItemId(currentMenuItem.Renderer.id);
|
|
22548
22649
|
}
|
|
22549
22650
|
} else {
|
|
22550
22651
|
const nextIndex = currentIndex - 1;
|
|
22551
22652
|
if (nextIndex >= 0) {
|
|
22552
|
-
setActiveGroupId(
|
|
22653
|
+
setActiveGroupId(filteredMenuItems[nextIndex].id);
|
|
22553
22654
|
}
|
|
22554
22655
|
}
|
|
22555
|
-
}, [
|
|
22656
|
+
}, [
|
|
22657
|
+
activeItemId,
|
|
22658
|
+
currentIndex,
|
|
22659
|
+
currentMenuItem?.Renderer,
|
|
22660
|
+
currentMenuItem?.children,
|
|
22661
|
+
filteredMenuItems
|
|
22662
|
+
]);
|
|
22556
22663
|
const handleRight = useCallback3(() => {
|
|
22557
22664
|
if (currentMenuItem?.children) {
|
|
22558
22665
|
setActiveItemId(currentMenuItem.children[0].id);
|
|
@@ -22563,8 +22670,17 @@ var SlashMenuRoot = memo5(
|
|
|
22563
22670
|
const handleLeft = useCallback3(() => {
|
|
22564
22671
|
setActiveItemId(void 0);
|
|
22565
22672
|
}, []);
|
|
22673
|
+
const handleSearchChange = useCallback3((e) => {
|
|
22674
|
+
setSearchText(e.target.value);
|
|
22675
|
+
}, []);
|
|
22566
22676
|
useEffect5(() => {
|
|
22567
22677
|
const keydownHandler = (event) => {
|
|
22678
|
+
if (event.key === "Escape") {
|
|
22679
|
+
return closeMenu();
|
|
22680
|
+
}
|
|
22681
|
+
if (searchText && event.metaKey === false) {
|
|
22682
|
+
return;
|
|
22683
|
+
}
|
|
22568
22684
|
if (activeItemId) {
|
|
22569
22685
|
const componentRef = componentRefMap.current[activeItemId];
|
|
22570
22686
|
if (componentRef?.handleKeyDown) {
|
|
@@ -22611,40 +22727,211 @@ var SlashMenuRoot = memo5(
|
|
|
22611
22727
|
handleRight,
|
|
22612
22728
|
handleUp,
|
|
22613
22729
|
closeMenu,
|
|
22614
|
-
|
|
22615
|
-
currentMenuItem
|
|
22730
|
+
filteredMenuItems,
|
|
22731
|
+
currentMenuItem,
|
|
22732
|
+
searchText
|
|
22616
22733
|
]);
|
|
22617
|
-
return /* @__PURE__ */ jsxs6("div", { ref: rootRef, style: { display: "flex" }, children: [
|
|
22618
|
-
/* @__PURE__ */ jsx15(
|
|
22619
|
-
|
|
22620
|
-
|
|
22621
|
-
|
|
22622
|
-
|
|
22623
|
-
|
|
22624
|
-
|
|
22625
|
-
MenuItem,
|
|
22626
|
-
{
|
|
22627
|
-
selected,
|
|
22628
|
-
onClick: () => {
|
|
22629
|
-
setActiveItemId(item.id);
|
|
22630
|
-
item.handler?.();
|
|
22631
|
-
closeMenu();
|
|
22632
|
-
},
|
|
22633
|
-
children: item.title
|
|
22734
|
+
return /* @__PURE__ */ jsxs6("div", { ref: rootRef, style: { display: "flex", flexDirection: "column" }, children: [
|
|
22735
|
+
/* @__PURE__ */ jsx15(SearchContainer, { children: /* @__PURE__ */ jsx15(
|
|
22736
|
+
Input2,
|
|
22737
|
+
{
|
|
22738
|
+
type: "text",
|
|
22739
|
+
size: "small",
|
|
22740
|
+
style: {
|
|
22741
|
+
width: "100%"
|
|
22634
22742
|
},
|
|
22635
|
-
|
|
22636
|
-
|
|
22637
|
-
|
|
22743
|
+
placeholder: t18("slashMenu.searchPlaceholder"),
|
|
22744
|
+
value: searchText,
|
|
22745
|
+
onChange: handleSearchChange,
|
|
22746
|
+
autoFocus: true,
|
|
22747
|
+
onKeyDown: (e) => {
|
|
22748
|
+
if (e.code === "Backspace") {
|
|
22749
|
+
if (searchText === "") {
|
|
22750
|
+
e.preventDefault();
|
|
22751
|
+
e.stopPropagation();
|
|
22752
|
+
closeMenu();
|
|
22753
|
+
}
|
|
22754
|
+
} else if (e.code === "Slash" && (searchText === "" || searchText === "/")) {
|
|
22755
|
+
e.preventDefault();
|
|
22756
|
+
e.stopPropagation();
|
|
22757
|
+
closeMenu({
|
|
22758
|
+
insertSlash: true
|
|
22759
|
+
});
|
|
22760
|
+
}
|
|
22761
|
+
}
|
|
22762
|
+
}
|
|
22763
|
+
) }),
|
|
22764
|
+
/* @__PURE__ */ jsxs6(MenuContainer, { children: [
|
|
22765
|
+
/* @__PURE__ */ jsxs6(MenuPanel, { active: true, location: "left", children: [
|
|
22766
|
+
filteredMenuItems.map((item) => {
|
|
22767
|
+
const selected = item.id === activeGroupId;
|
|
22768
|
+
return /* @__PURE__ */ jsx15(
|
|
22769
|
+
MenuItem,
|
|
22770
|
+
{
|
|
22771
|
+
onClick: () => setActiveGroupId(item.id),
|
|
22772
|
+
selected,
|
|
22773
|
+
children: /* @__PURE__ */ jsxs6(Space2, { size: 4, children: [
|
|
22774
|
+
/* @__PURE__ */ jsx15("i", { className: item.iconName }),
|
|
22775
|
+
" ",
|
|
22776
|
+
item.title
|
|
22777
|
+
] })
|
|
22778
|
+
},
|
|
22779
|
+
item.id
|
|
22780
|
+
);
|
|
22781
|
+
}),
|
|
22782
|
+
filteredMenuItems.length === 0 && /* @__PURE__ */ jsx15("div", { children: /* @__PURE__ */ jsx15("span", { children: t18("slashMenu.noResults") }) })
|
|
22783
|
+
] }),
|
|
22784
|
+
currentMenuItem?.children || currentMenuItem?.Renderer?.Component ? /* @__PURE__ */ jsx15(MenuPanel, { active: !!activeItemId, location: "right", children: currentMenuItem?.Renderer ? currentMenuItem.Renderer.Component : currentMenuItem?.children?.map((item) => {
|
|
22785
|
+
const selected = item.id === activeItemId;
|
|
22786
|
+
return /* @__PURE__ */ jsx15(
|
|
22787
|
+
MenuItem,
|
|
22788
|
+
{
|
|
22789
|
+
selected,
|
|
22790
|
+
onClick: () => {
|
|
22791
|
+
setActiveItemId(item.id);
|
|
22792
|
+
item.handler?.();
|
|
22793
|
+
closeMenu();
|
|
22794
|
+
},
|
|
22795
|
+
children: item.title
|
|
22796
|
+
},
|
|
22797
|
+
item.id
|
|
22798
|
+
);
|
|
22799
|
+
}) }) : null
|
|
22800
|
+
] }),
|
|
22801
|
+
/* @__PURE__ */ jsxs6(SlashMenuFooter, { children: [
|
|
22802
|
+
/* @__PURE__ */ jsxs6(Shortcut, { children: [
|
|
22803
|
+
searchText ? /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
22804
|
+
/* @__PURE__ */ jsx15("kbd", { children: getModKeyName() }),
|
|
22805
|
+
/* @__PURE__ */ jsx15("span", { children: " + " })
|
|
22806
|
+
] }) : null,
|
|
22807
|
+
/* @__PURE__ */ jsx15("kbd", { "aria-label": "Up Arrow", children: /* @__PURE__ */ jsxs6(
|
|
22808
|
+
"svg",
|
|
22809
|
+
{
|
|
22810
|
+
width: "14",
|
|
22811
|
+
height: "14",
|
|
22812
|
+
viewBox: "0 0 24 24",
|
|
22813
|
+
fill: "none",
|
|
22814
|
+
stroke: "currentColor",
|
|
22815
|
+
"stroke-width": "2",
|
|
22816
|
+
"stroke-linecap": "round",
|
|
22817
|
+
"stroke-linejoin": "round",
|
|
22818
|
+
children: [
|
|
22819
|
+
/* @__PURE__ */ jsx15("path", { d: "m5 12 7-7 7 7" }),
|
|
22820
|
+
/* @__PURE__ */ jsx15("path", { d: "M12 19V5" })
|
|
22821
|
+
]
|
|
22822
|
+
}
|
|
22823
|
+
) }),
|
|
22824
|
+
/* @__PURE__ */ jsx15("kbd", { "aria-label": "Down Arrow", children: /* @__PURE__ */ jsxs6(
|
|
22825
|
+
"svg",
|
|
22826
|
+
{
|
|
22827
|
+
width: "14",
|
|
22828
|
+
height: "14",
|
|
22829
|
+
viewBox: "0 0 24 24",
|
|
22830
|
+
fill: "none",
|
|
22831
|
+
stroke: "currentColor",
|
|
22832
|
+
"stroke-width": "2",
|
|
22833
|
+
"stroke-linecap": "round",
|
|
22834
|
+
"stroke-linejoin": "round",
|
|
22835
|
+
children: [
|
|
22836
|
+
/* @__PURE__ */ jsx15("path", { d: "M12 5v14" }),
|
|
22837
|
+
/* @__PURE__ */ jsx15("path", { d: "m19 12-7 7-7-7" })
|
|
22838
|
+
]
|
|
22839
|
+
}
|
|
22840
|
+
) }),
|
|
22841
|
+
currentMenuItem?.children || currentMenuItem?.Renderer ? /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
22842
|
+
/* @__PURE__ */ jsx15("kbd", { "aria-label": "Left Arrow", children: /* @__PURE__ */ jsxs6(
|
|
22843
|
+
"svg",
|
|
22844
|
+
{
|
|
22845
|
+
width: "14",
|
|
22846
|
+
height: "14",
|
|
22847
|
+
viewBox: "0 0 24 24",
|
|
22848
|
+
fill: "none",
|
|
22849
|
+
stroke: "currentColor",
|
|
22850
|
+
"stroke-width": "2",
|
|
22851
|
+
"stroke-linecap": "round",
|
|
22852
|
+
"stroke-linejoin": "round",
|
|
22853
|
+
children: [
|
|
22854
|
+
/* @__PURE__ */ jsx15("path", { d: "m12 19-7-7 7-7" }),
|
|
22855
|
+
/* @__PURE__ */ jsx15("path", { d: "M19 12H5" })
|
|
22856
|
+
]
|
|
22857
|
+
}
|
|
22858
|
+
) }),
|
|
22859
|
+
/* @__PURE__ */ jsx15("kbd", { "aria-label": "Right Arrow", children: /* @__PURE__ */ jsxs6(
|
|
22860
|
+
"svg",
|
|
22861
|
+
{
|
|
22862
|
+
width: "14",
|
|
22863
|
+
height: "14",
|
|
22864
|
+
viewBox: "0 0 24 24",
|
|
22865
|
+
fill: "none",
|
|
22866
|
+
stroke: "currentColor",
|
|
22867
|
+
"stroke-width": "2",
|
|
22868
|
+
"stroke-linecap": "round",
|
|
22869
|
+
"stroke-linejoin": "round",
|
|
22870
|
+
children: [
|
|
22871
|
+
/* @__PURE__ */ jsx15("path", { d: "M5 12h14" }),
|
|
22872
|
+
/* @__PURE__ */ jsx15("path", { d: "m12 5 7 7-7 7" })
|
|
22873
|
+
]
|
|
22874
|
+
}
|
|
22875
|
+
) })
|
|
22876
|
+
] }) : null,
|
|
22877
|
+
t18("slashMenu.toNavigate")
|
|
22878
|
+
] }),
|
|
22879
|
+
/* @__PURE__ */ jsxs6(Shortcut, { children: [
|
|
22880
|
+
searchText ? /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
22881
|
+
/* @__PURE__ */ jsx15("kbd", { children: getModKeyName() }),
|
|
22882
|
+
/* @__PURE__ */ jsx15("span", { children: " + " })
|
|
22883
|
+
] }) : null,
|
|
22884
|
+
/* @__PURE__ */ jsx15("kbd", { "aria-label": "Enter", children: /* @__PURE__ */ jsxs6(
|
|
22885
|
+
"svg",
|
|
22886
|
+
{
|
|
22887
|
+
width: "14",
|
|
22888
|
+
height: "14",
|
|
22889
|
+
viewBox: "0 0 24 24",
|
|
22890
|
+
fill: "none",
|
|
22891
|
+
stroke: "currentColor",
|
|
22892
|
+
"stroke-width": "2",
|
|
22893
|
+
"stroke-linecap": "round",
|
|
22894
|
+
"stroke-linejoin": "round",
|
|
22895
|
+
children: [
|
|
22896
|
+
/* @__PURE__ */ jsx15("polyline", { points: "9 10 4 15 9 20" }),
|
|
22897
|
+
/* @__PURE__ */ jsx15("path", { d: "M20 4v7a4 4 0 0 1-4 4H4" })
|
|
22898
|
+
]
|
|
22899
|
+
}
|
|
22900
|
+
) }),
|
|
22901
|
+
t18("slashMenu.toSelect")
|
|
22902
|
+
] })
|
|
22903
|
+
] })
|
|
22638
22904
|
] });
|
|
22639
22905
|
}
|
|
22640
22906
|
);
|
|
22907
|
+
var SlashMenuFooter = styled8.div`
|
|
22908
|
+
display: flex;
|
|
22909
|
+
justify-content: space-between;
|
|
22910
|
+
padding: ${(props) => props.theme.spaceXs};
|
|
22911
|
+
background-color: ${(props) => props.theme.contextMenuBgColor};
|
|
22912
|
+
border-top: 1px solid ${(props) => props.theme.slashMenuBorderColor};
|
|
22913
|
+
gap: 8px;
|
|
22914
|
+
font-size: 0.85em;
|
|
22915
|
+
`;
|
|
22916
|
+
var Shortcut = styled8.div`
|
|
22917
|
+
display: flex;
|
|
22918
|
+
gap: 0.25rem;
|
|
22919
|
+
white-space: nowrap;
|
|
22920
|
+
|
|
22921
|
+
& kbd {
|
|
22922
|
+
padding: 0 4px;
|
|
22923
|
+
display: flex;
|
|
22924
|
+
justify-content: center;
|
|
22925
|
+
align-items: center;
|
|
22926
|
+
font-size: 16px;
|
|
22927
|
+
}
|
|
22928
|
+
`;
|
|
22641
22929
|
var MenuPanel = styled8.div.attrs((p) => p)`
|
|
22642
22930
|
display: flex;
|
|
22643
22931
|
min-width: 130px;
|
|
22932
|
+
width: 100%;
|
|
22644
22933
|
flex-direction: column;
|
|
22645
22934
|
overscroll-behavior: contain;
|
|
22646
|
-
border-radius: ${(props) => props.location === "left" ? `${props.theme.smallBorderRadius} 0 0
|
|
22647
|
-
${props.theme.smallBorderRadius}` : `0 ${props.theme.smallBorderRadius} ${props.theme.smallBorderRadius} 0`};
|
|
22648
22935
|
background-color: ${(props) => props.active ? darken(props.theme.contextMenuBgColorHover, 0.2) : props.theme.contextMenuBgColorHover};
|
|
22649
22936
|
padding: ${(props) => props.theme.spaceXs};
|
|
22650
22937
|
color: ${(props) => props.theme.primaryFontColor};
|
|
@@ -22660,6 +22947,7 @@ var MenuItem = styled8.li.attrs((props) => ({
|
|
|
22660
22947
|
align-items: center;
|
|
22661
22948
|
border-radius: ${(props) => props.theme.smallBorderRadius};
|
|
22662
22949
|
padding: ${(props) => props.theme.spaceXs};
|
|
22950
|
+
font-size: ${(props) => props.theme.fontXs};
|
|
22663
22951
|
outline: none !important;
|
|
22664
22952
|
|
|
22665
22953
|
&:hover {
|
|
@@ -22674,10 +22962,20 @@ var MenuItem = styled8.li.attrs((props) => ({
|
|
|
22674
22962
|
}
|
|
22675
22963
|
}}
|
|
22676
22964
|
`;
|
|
22965
|
+
var SearchContainer = styled8.div`
|
|
22966
|
+
padding: ${(props) => props.theme.spaceXs};
|
|
22967
|
+
background-color: ${(props) => props.theme.contextMenuBgColor};
|
|
22968
|
+
border-bottom: 1px solid ${(props) => props.theme.slashMenuBorderColor};
|
|
22969
|
+
border-radius: ${(props) => props.theme.smallBorderRadius}
|
|
22970
|
+
${(props) => props.theme.smallBorderRadius} 0 0;
|
|
22971
|
+
`;
|
|
22972
|
+
var MenuContainer = styled8.div`
|
|
22973
|
+
display: flex;
|
|
22974
|
+
flex: 1;
|
|
22975
|
+
`;
|
|
22677
22976
|
|
|
22678
22977
|
// src/editor/toolbar/SlashMenu/index.tsx
|
|
22679
|
-
import
|
|
22680
|
-
import { Fragment as Fragment5, jsx as jsx16 } from "react/jsx-runtime";
|
|
22978
|
+
import { Fragment as Fragment6, jsx as jsx16 } from "react/jsx-runtime";
|
|
22681
22979
|
var SlashMenu = () => {
|
|
22682
22980
|
const { view: editorView, getState, commands } = useRemirrorContext3({ autoUpdate: true });
|
|
22683
22981
|
if (!editorView) {
|
|
@@ -22742,17 +23040,22 @@ var SlashMenu = () => {
|
|
|
22742
23040
|
}
|
|
22743
23041
|
]
|
|
22744
23042
|
});
|
|
22745
|
-
const closeMenu = useCallback4(() => {
|
|
23043
|
+
const closeMenu = useCallback4((config) => {
|
|
22746
23044
|
if (menuState.open) {
|
|
22747
23045
|
dispatchWithMeta(editorView, slashMenuExtension.pluginKey, {
|
|
22748
23046
|
type: "close" /* close */
|
|
22749
23047
|
});
|
|
23048
|
+
if (config?.insertSlash) {
|
|
23049
|
+
editorView.dispatch(
|
|
23050
|
+
editorView.state.tr.insertText("/").setMeta(slashMenuExtension.pluginKey, {
|
|
23051
|
+
type: "close" /* close */
|
|
23052
|
+
})
|
|
23053
|
+
);
|
|
23054
|
+
}
|
|
23055
|
+
editorView.focus();
|
|
22750
23056
|
}
|
|
22751
23057
|
}, [editorView, menuState.open, slashMenuExtension.pluginKey]);
|
|
22752
|
-
|
|
22753
|
-
editorView.focus();
|
|
22754
|
-
}, [menuState?.open]);
|
|
22755
|
-
return /* @__PURE__ */ jsx16(Fragment5, { children: menuState.open ? /* @__PURE__ */ jsx16(
|
|
23058
|
+
return /* @__PURE__ */ jsx16(Fragment6, { children: menuState.open ? /* @__PURE__ */ jsx16(
|
|
22756
23059
|
Container2,
|
|
22757
23060
|
{
|
|
22758
23061
|
ref: setPopperElement,
|
|
@@ -22787,7 +23090,7 @@ import {
|
|
|
22787
23090
|
} from "@mui/material";
|
|
22788
23091
|
import { useCommands } from "@remirror/react";
|
|
22789
23092
|
import styled10 from "styled-components";
|
|
22790
|
-
import { useTranslation } from "react-i18next";
|
|
23093
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
22791
23094
|
import { jsx as jsx17, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
22792
23095
|
var Container3 = styled10.div`
|
|
22793
23096
|
position: absolute;
|
|
@@ -22801,7 +23104,7 @@ var ActiveCellMenu = (props) => {
|
|
|
22801
23104
|
const commands = useCommands();
|
|
22802
23105
|
const [open, setOpen] = useState8(false);
|
|
22803
23106
|
const anchorRef = useRef7(null);
|
|
22804
|
-
const { t: t18 } =
|
|
23107
|
+
const { t: t18 } = useTranslation2();
|
|
22805
23108
|
const options = [
|
|
22806
23109
|
{
|
|
22807
23110
|
label: "insert column before",
|
|
@@ -23016,7 +23319,7 @@ var activeCellColumnAndRowPositioner = Positioner.create({
|
|
|
23016
23319
|
});
|
|
23017
23320
|
|
|
23018
23321
|
// src/editor/toolbar/TableToolbar/index.tsx
|
|
23019
|
-
import { Fragment as
|
|
23322
|
+
import { Fragment as Fragment7, jsx as jsx19 } from "react/jsx-runtime";
|
|
23020
23323
|
var MultiPositionerIllustration = ({ positioner }) => {
|
|
23021
23324
|
const positioners = useMultiPositioner(positioner, []);
|
|
23022
23325
|
const { forceUpdatePositioners } = useCommands3();
|
|
@@ -23025,13 +23328,13 @@ var MultiPositionerIllustration = ({ positioner }) => {
|
|
|
23025
23328
|
}, [forceUpdatePositioners]);
|
|
23026
23329
|
if (positioners.length === 0) return null;
|
|
23027
23330
|
const positionersRender = [TableBar_default, ActiveCellMenu_default];
|
|
23028
|
-
return /* @__PURE__ */ jsx19(
|
|
23331
|
+
return /* @__PURE__ */ jsx19(Fragment7, { children: positioners.map((pos, i) => {
|
|
23029
23332
|
const Component = positionersRender[i];
|
|
23030
23333
|
return /* @__PURE__ */ jsx19(Component, { positioner: pos }, pos.key);
|
|
23031
23334
|
}) });
|
|
23032
23335
|
};
|
|
23033
23336
|
var TableToolbar = () => {
|
|
23034
|
-
return /* @__PURE__ */ jsx19(
|
|
23337
|
+
return /* @__PURE__ */ jsx19(Fragment7, { children: /* @__PURE__ */ jsx19(PositionerPortal, { children: /* @__PURE__ */ jsx19(MultiPositionerIllustration, { positioner: activeCellColumnAndRowPositioner }) }) });
|
|
23035
23338
|
};
|
|
23036
23339
|
var TableToolbar_default = TableToolbar;
|
|
23037
23340
|
|
|
@@ -23769,6 +24072,12 @@ var en_default = {
|
|
|
23769
24072
|
bulletList: "Bullet List",
|
|
23770
24073
|
orderedList: "Ordered List",
|
|
23771
24074
|
taskList: "Task List"
|
|
24075
|
+
},
|
|
24076
|
+
slashMenu: {
|
|
24077
|
+
searchPlaceholder: "Search menu items...",
|
|
24078
|
+
noResults: "No results",
|
|
24079
|
+
toNavigate: "to navigate",
|
|
24080
|
+
toSelect: "to select"
|
|
23772
24081
|
}
|
|
23773
24082
|
};
|
|
23774
24083
|
|