@firecms/editor 3.0.0-tw4.1 → 3.0.0
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.es.js +52 -18
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +52 -18
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -5
package/dist/index.es.js
CHANGED
|
@@ -63,7 +63,7 @@ const EditorBubble = forwardRef((t0, ref) => {
|
|
|
63
63
|
} = useCurrentEditor();
|
|
64
64
|
tippyOptions?.placement;
|
|
65
65
|
let t1;
|
|
66
|
-
const shouldShow = _temp$
|
|
66
|
+
const shouldShow = _temp$2;
|
|
67
67
|
const t2 = tippyOptions?.placement ?? options?.placement;
|
|
68
68
|
let t3;
|
|
69
69
|
if ($[5] !== options || $[6] !== t2) {
|
|
@@ -117,7 +117,7 @@ const EditorBubble = forwardRef((t0, ref) => {
|
|
|
117
117
|
}
|
|
118
118
|
return t6;
|
|
119
119
|
});
|
|
120
|
-
function _temp$
|
|
120
|
+
function _temp$2(t0) {
|
|
121
121
|
const {
|
|
122
122
|
editor: editor_0,
|
|
123
123
|
state
|
|
@@ -477,7 +477,7 @@ const TextButtons = () => {
|
|
|
477
477
|
if ($[0] !== editor) {
|
|
478
478
|
const items2 = [{
|
|
479
479
|
name: "bold",
|
|
480
|
-
isActive: _temp,
|
|
480
|
+
isActive: _temp$1,
|
|
481
481
|
command: _temp2,
|
|
482
482
|
icon: FormatBoldIcon
|
|
483
483
|
}, {
|
|
@@ -514,7 +514,7 @@ const TextButtons = () => {
|
|
|
514
514
|
}
|
|
515
515
|
return t0;
|
|
516
516
|
};
|
|
517
|
-
function _temp(editor_0) {
|
|
517
|
+
function _temp$1(editor_0) {
|
|
518
518
|
return editor_0?.isActive("bold") ?? false;
|
|
519
519
|
}
|
|
520
520
|
function _temp2(editor_1) {
|
|
@@ -1429,18 +1429,50 @@ const suggestion = (ref, {
|
|
|
1429
1429
|
return item.searchTerms?.some((term) => term.toLowerCase().startsWith(query.toLowerCase()));
|
|
1430
1430
|
});
|
|
1431
1431
|
},
|
|
1432
|
+
allow: ({
|
|
1433
|
+
editor,
|
|
1434
|
+
range
|
|
1435
|
+
}) => {
|
|
1436
|
+
return editor.can().insertContentAt(range, {
|
|
1437
|
+
type: "command"
|
|
1438
|
+
});
|
|
1439
|
+
},
|
|
1432
1440
|
render: () => {
|
|
1433
1441
|
let component;
|
|
1434
1442
|
let containerEl = null;
|
|
1435
1443
|
let cleanupAutoUpdate = null;
|
|
1436
1444
|
let reference = null;
|
|
1445
|
+
let escapeListener = null;
|
|
1446
|
+
function exit() {
|
|
1447
|
+
if (cleanupAutoUpdate) cleanupAutoUpdate();
|
|
1448
|
+
if (containerEl && containerEl.parentNode) {
|
|
1449
|
+
containerEl.parentNode.removeChild(containerEl);
|
|
1450
|
+
}
|
|
1451
|
+
if (escapeListener) {
|
|
1452
|
+
document.removeEventListener("keydown", escapeListener, true);
|
|
1453
|
+
escapeListener = null;
|
|
1454
|
+
}
|
|
1455
|
+
containerEl = null;
|
|
1456
|
+
reference = null;
|
|
1457
|
+
component?.destroy();
|
|
1458
|
+
}
|
|
1437
1459
|
return {
|
|
1438
1460
|
onStart: (props) => {
|
|
1461
|
+
escapeListener = (e) => {
|
|
1462
|
+
if (e.key === "Escape") {
|
|
1463
|
+
e.preventDefault();
|
|
1464
|
+
e.stopPropagation();
|
|
1465
|
+
e.stopImmediatePropagation();
|
|
1466
|
+
exit();
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1469
|
+
document.addEventListener("keydown", escapeListener, true);
|
|
1439
1470
|
component = new ReactRenderer(CommandList, {
|
|
1440
1471
|
props: {
|
|
1441
1472
|
...props,
|
|
1442
1473
|
upload,
|
|
1443
|
-
aiController
|
|
1474
|
+
aiController,
|
|
1475
|
+
onClose: exit
|
|
1444
1476
|
},
|
|
1445
1477
|
editor: props.editor
|
|
1446
1478
|
});
|
|
@@ -1448,6 +1480,7 @@ const suggestion = (ref, {
|
|
|
1448
1480
|
return;
|
|
1449
1481
|
}
|
|
1450
1482
|
containerEl = document.createElement("div");
|
|
1483
|
+
containerEl.setAttribute("data-suggestion-menu", "true");
|
|
1451
1484
|
containerEl.style.position = "fixed";
|
|
1452
1485
|
containerEl.style.left = "0px";
|
|
1453
1486
|
containerEl.style.top = "0px";
|
|
@@ -1499,18 +1532,14 @@ const suggestion = (ref, {
|
|
|
1499
1532
|
onKeyDown(props) {
|
|
1500
1533
|
if (props.event.key === "Escape") {
|
|
1501
1534
|
props.event.preventDefault();
|
|
1535
|
+
props.event.stopPropagation();
|
|
1536
|
+
exit();
|
|
1502
1537
|
return true;
|
|
1503
1538
|
}
|
|
1504
1539
|
return component.ref?.onKeyDown(props);
|
|
1505
1540
|
},
|
|
1506
1541
|
onExit() {
|
|
1507
|
-
|
|
1508
|
-
if (containerEl && containerEl.parentNode) {
|
|
1509
|
-
containerEl.parentNode.removeChild(containerEl);
|
|
1510
|
-
}
|
|
1511
|
-
containerEl = null;
|
|
1512
|
-
reference = null;
|
|
1513
|
-
component?.destroy();
|
|
1542
|
+
exit();
|
|
1514
1543
|
}
|
|
1515
1544
|
};
|
|
1516
1545
|
}
|
|
@@ -1523,10 +1552,12 @@ const CommandList = forwardRef((props, ref) => {
|
|
|
1523
1552
|
} = useCurrentEditor();
|
|
1524
1553
|
let t0;
|
|
1525
1554
|
if ($[0] !== editor || $[1] !== props.aiController || $[2] !== props.range || $[3] !== props.upload) {
|
|
1526
|
-
t0 = (item) => {
|
|
1555
|
+
t0 = (item, event) => {
|
|
1527
1556
|
if (!editor) {
|
|
1528
1557
|
return;
|
|
1529
1558
|
}
|
|
1559
|
+
event?.preventDefault();
|
|
1560
|
+
event?.stopPropagation();
|
|
1530
1561
|
item?.command?.({
|
|
1531
1562
|
editor,
|
|
1532
1563
|
range: props.range,
|
|
@@ -1602,17 +1633,17 @@ const CommandList = forwardRef((props, ref) => {
|
|
|
1602
1633
|
t6 = () => ({
|
|
1603
1634
|
onKeyDown: (t72) => {
|
|
1604
1635
|
const {
|
|
1605
|
-
event
|
|
1636
|
+
event: event_0
|
|
1606
1637
|
} = t72;
|
|
1607
|
-
if (
|
|
1638
|
+
if (event_0.key === "ArrowUp") {
|
|
1608
1639
|
upHandler();
|
|
1609
1640
|
return true;
|
|
1610
1641
|
}
|
|
1611
|
-
if (
|
|
1642
|
+
if (event_0.key === "ArrowDown") {
|
|
1612
1643
|
downHandler();
|
|
1613
1644
|
return true;
|
|
1614
1645
|
}
|
|
1615
|
-
if (
|
|
1646
|
+
if (event_0.key === "Enter") {
|
|
1616
1647
|
enterHandler();
|
|
1617
1648
|
return true;
|
|
1618
1649
|
}
|
|
@@ -1668,7 +1699,7 @@ const CommandList = forwardRef((props, ref) => {
|
|
|
1668
1699
|
return;
|
|
1669
1700
|
}
|
|
1670
1701
|
itemRefs.current[index] = el;
|
|
1671
|
-
}, onClick: () => selectItem(item_1), tabIndex: index === selectedIndex ? 0 : -1, "aria-selected": index === selectedIndex, className: cls("flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm hover:bg-blue-50 hover:dark:bg-surface-700 aria-selected:bg-blue-50 aria-selected:dark:bg-surface-700", index === selectedIndex ? "bg-blue-100 dark:bg-surface-accent-950" : ""), children: [
|
|
1702
|
+
}, onMouseDown: _temp, onClick: (e_0) => selectItem(item_1, e_0), tabIndex: index === selectedIndex ? 0 : -1, "aria-selected": index === selectedIndex, className: cls("flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm hover:bg-blue-50 hover:dark:bg-surface-700 aria-selected:bg-blue-50 aria-selected:dark:bg-surface-700", index === selectedIndex ? "bg-blue-100 dark:bg-surface-accent-950" : ""), children: [
|
|
1672
1703
|
/* @__PURE__ */ jsx("div", { className: cls("flex h-10 w-10 items-center justify-center rounded-md border bg-white dark:bg-surface-900", defaultBorderMixin), children: item_1.icon }),
|
|
1673
1704
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1674
1705
|
/* @__PURE__ */ jsx("p", { className: "font-medium", children: item_1.title }),
|
|
@@ -1871,6 +1902,9 @@ const suggestionItems = [{
|
|
|
1871
1902
|
input.click();
|
|
1872
1903
|
}
|
|
1873
1904
|
}];
|
|
1905
|
+
function _temp(e) {
|
|
1906
|
+
return e.preventDefault();
|
|
1907
|
+
}
|
|
1874
1908
|
const proseClasses = {
|
|
1875
1909
|
"sm": "prose-sm",
|
|
1876
1910
|
"base": "prose-base",
|