@meowdown/react 0.81.0 → 0.81.1
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.js +372 -291
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -286,6 +286,24 @@ function CodeBlockView(props) {
|
|
|
286
286
|
});
|
|
287
287
|
}
|
|
288
288
|
function CodeBlockToolbar({ code, language, setLanguage }) {
|
|
289
|
+
const [comboboxOpen, setComboboxOpen] = useState(false);
|
|
290
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
291
|
+
className: code_block_view_module_default.Toolbar,
|
|
292
|
+
contentEditable: false,
|
|
293
|
+
"data-open": comboboxOpen || void 0,
|
|
294
|
+
children: [/* @__PURE__ */ jsx(CodeBlockLanguagePickerMemo, {
|
|
295
|
+
language,
|
|
296
|
+
setLanguage,
|
|
297
|
+
onShownChange: setComboboxOpen
|
|
298
|
+
}), /* @__PURE__ */ jsx(CopyButton, {
|
|
299
|
+
getText: () => code,
|
|
300
|
+
label: "Copy code",
|
|
301
|
+
className: code_block_view_module_default.CopyButton,
|
|
302
|
+
"data-testid": "code-block-copy"
|
|
303
|
+
})]
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
function CodeBlockLanguagePicker({ language, setLanguage, onShownChange }) {
|
|
289
307
|
const collisionBoundary = use(CollisionBoundaryContext);
|
|
290
308
|
const selected = useMemo(() => {
|
|
291
309
|
return codeBlockLanguages.find((item) => item.value === language) ?? {
|
|
@@ -294,7 +312,6 @@ function CodeBlockToolbar({ code, language, setLanguage }) {
|
|
|
294
312
|
};
|
|
295
313
|
}, [language]);
|
|
296
314
|
const [query, setQuery] = useState("");
|
|
297
|
-
const [comboboxOpen, setComboboxOpen] = useState(false);
|
|
298
315
|
const itemsForView = useMemo(() => {
|
|
299
316
|
const value = query.trim();
|
|
300
317
|
if (!value) return codeBlockLanguages;
|
|
@@ -304,74 +321,65 @@ function CodeBlockToolbar({ code, language, setLanguage }) {
|
|
|
304
321
|
label: `Use "${value}"`
|
|
305
322
|
}];
|
|
306
323
|
}, [query]);
|
|
307
|
-
return /* @__PURE__ */ jsxs(
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
},
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
className: code_block_view_module_default.
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
children: /* @__PURE__ */ jsx(Combobox.Input, {
|
|
341
|
-
className: code_block_view_module_default.Search,
|
|
342
|
-
placeholder: "Search or type a language",
|
|
343
|
-
"data-testid": "code-block-language-search"
|
|
344
|
-
})
|
|
345
|
-
}),
|
|
346
|
-
/* @__PURE__ */ jsx(Combobox.Empty, {
|
|
347
|
-
className: code_block_view_module_default.Empty,
|
|
348
|
-
children: "No languages found."
|
|
349
|
-
}),
|
|
350
|
-
/* @__PURE__ */ jsx(Combobox.List, {
|
|
351
|
-
className: code_block_view_module_default.List,
|
|
352
|
-
children: (item) => /* @__PURE__ */ jsxs(Combobox.Item, {
|
|
353
|
-
value: item,
|
|
354
|
-
className: code_block_view_module_default.Item,
|
|
355
|
-
children: [/* @__PURE__ */ jsx(Combobox.ItemIndicator, {
|
|
356
|
-
className: code_block_view_module_default.ItemIndicator,
|
|
357
|
-
children: /* @__PURE__ */ jsx(CheckIcon, {})
|
|
358
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
359
|
-
className: code_block_view_module_default.ItemText,
|
|
360
|
-
children: item.label
|
|
361
|
-
})]
|
|
362
|
-
}, item.label)
|
|
324
|
+
return /* @__PURE__ */ jsxs(Combobox.Root, {
|
|
325
|
+
items: itemsForView,
|
|
326
|
+
value: selected,
|
|
327
|
+
onValueChange: (item) => setLanguage(item?.value ?? ""),
|
|
328
|
+
inputValue: query,
|
|
329
|
+
onInputValueChange: setQuery,
|
|
330
|
+
onOpenChange: (open) => {
|
|
331
|
+
if (open) onShownChange(true);
|
|
332
|
+
else setQuery("");
|
|
333
|
+
},
|
|
334
|
+
onOpenChangeComplete: (open) => {
|
|
335
|
+
if (!open) onShownChange(false);
|
|
336
|
+
},
|
|
337
|
+
children: [/* @__PURE__ */ jsxs(Combobox.Trigger, {
|
|
338
|
+
className: code_block_view_module_default.Trigger,
|
|
339
|
+
"data-testid": "code-block-language",
|
|
340
|
+
children: [/* @__PURE__ */ jsx(Combobox.Value, { placeholder: "Plain Text" }), /* @__PURE__ */ jsx(Combobox.Icon, {
|
|
341
|
+
className: code_block_view_module_default.TriggerIcon,
|
|
342
|
+
children: /* @__PURE__ */ jsx(ChevronsUpDownIcon, {})
|
|
343
|
+
})]
|
|
344
|
+
}), /* @__PURE__ */ jsx(Combobox.Portal, { children: /* @__PURE__ */ jsx(Combobox.Positioner, {
|
|
345
|
+
className: code_block_view_module_default.Positioner,
|
|
346
|
+
sideOffset: 4,
|
|
347
|
+
collisionBoundary,
|
|
348
|
+
children: /* @__PURE__ */ jsxs(Combobox.Popup, {
|
|
349
|
+
className: code_block_view_module_default.Popup,
|
|
350
|
+
children: [
|
|
351
|
+
/* @__PURE__ */ jsx("div", {
|
|
352
|
+
className: code_block_view_module_default.SearchRow,
|
|
353
|
+
children: /* @__PURE__ */ jsx(Combobox.Input, {
|
|
354
|
+
className: code_block_view_module_default.Search,
|
|
355
|
+
placeholder: "Search or type a language",
|
|
356
|
+
"data-testid": "code-block-language-search"
|
|
363
357
|
})
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
358
|
+
}),
|
|
359
|
+
/* @__PURE__ */ jsx(Combobox.Empty, {
|
|
360
|
+
className: code_block_view_module_default.Empty,
|
|
361
|
+
children: "No languages found."
|
|
362
|
+
}),
|
|
363
|
+
/* @__PURE__ */ jsx(Combobox.List, {
|
|
364
|
+
className: code_block_view_module_default.List,
|
|
365
|
+
children: (item) => /* @__PURE__ */ jsxs(Combobox.Item, {
|
|
366
|
+
value: item,
|
|
367
|
+
className: code_block_view_module_default.Item,
|
|
368
|
+
children: [/* @__PURE__ */ jsx(Combobox.ItemIndicator, {
|
|
369
|
+
className: code_block_view_module_default.ItemIndicator,
|
|
370
|
+
children: /* @__PURE__ */ jsx(CheckIcon, {})
|
|
371
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
372
|
+
className: code_block_view_module_default.ItemText,
|
|
373
|
+
children: item.label
|
|
374
|
+
})]
|
|
375
|
+
}, item.label)
|
|
376
|
+
})
|
|
377
|
+
]
|
|
378
|
+
})
|
|
379
|
+
}) })]
|
|
373
380
|
});
|
|
374
381
|
}
|
|
382
|
+
const CodeBlockLanguagePickerMemo = /* @__PURE__ */ memo(CodeBlockLanguagePicker);
|
|
375
383
|
|
|
376
384
|
//#endregion
|
|
377
385
|
//#region src/extensions/code-block-view.ts
|
|
@@ -1124,11 +1132,11 @@ function SelectionMenu({ onSelectionMenuSearch, context, onOpen, onClose, afford
|
|
|
1124
1132
|
const { from, to, empty } = view.state.selection;
|
|
1125
1133
|
const anchorable = !empty && isTextSelection(view.state.selection) && !getPendingReplacement(view.state) && getSearchStatus(view.state).active === 0;
|
|
1126
1134
|
setSelection((previous) => {
|
|
1127
|
-
if (
|
|
1135
|
+
if (!anchorable) return;
|
|
1136
|
+
if (previous?.from === from && previous?.to === to) return previous;
|
|
1128
1137
|
return {
|
|
1129
1138
|
from,
|
|
1130
|
-
to
|
|
1131
|
-
anchorable
|
|
1139
|
+
to
|
|
1132
1140
|
};
|
|
1133
1141
|
});
|
|
1134
1142
|
});
|
|
@@ -1141,7 +1149,7 @@ function SelectionMenu({ onSelectionMenuSearch, context, onOpen, onClose, afford
|
|
|
1141
1149
|
if (!context) return;
|
|
1142
1150
|
return getMenuAnchor(editor.view, context.from, context.to);
|
|
1143
1151
|
}, [context, editor]);
|
|
1144
|
-
const showAffordance = affordance && !!!context && !!selection
|
|
1152
|
+
const showAffordance = affordance && !!!context && !!selection;
|
|
1145
1153
|
const affordanceVisible = useDelayedFlag(showAffordance, 250, 0);
|
|
1146
1154
|
const affordanceAnchor = useMemo(() => {
|
|
1147
1155
|
if (!showAffordance || !selection) return;
|
|
@@ -1364,11 +1372,104 @@ function SlashMenuItem({ label, keywords, detail, kbd, onSelect }) {
|
|
|
1364
1372
|
function selectionInTableCell(editor) {
|
|
1365
1373
|
return isSelectionInTableCell(editor.state);
|
|
1366
1374
|
}
|
|
1375
|
+
function BuiltinSlashMenuItems({ editor, timeFormat, onAttachFile }) {
|
|
1376
|
+
const inTableCell = useEditorDerivedValue(selectionInTableCell);
|
|
1377
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1378
|
+
!inTableCell && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1379
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1380
|
+
label: "Text",
|
|
1381
|
+
keywords: ["paragraph", "plain"],
|
|
1382
|
+
onSelect: () => editor.commands.turnIntoText()
|
|
1383
|
+
}),
|
|
1384
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1385
|
+
label: "Heading 1",
|
|
1386
|
+
keywords: ["h1"],
|
|
1387
|
+
kbd: "#",
|
|
1388
|
+
onSelect: () => editor.commands.setHeading({ level: 1 })
|
|
1389
|
+
}),
|
|
1390
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1391
|
+
label: "Heading 2",
|
|
1392
|
+
keywords: ["h2"],
|
|
1393
|
+
kbd: "##",
|
|
1394
|
+
onSelect: () => editor.commands.setHeading({ level: 2 })
|
|
1395
|
+
}),
|
|
1396
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1397
|
+
label: "Heading 3",
|
|
1398
|
+
keywords: ["h3"],
|
|
1399
|
+
kbd: "###",
|
|
1400
|
+
onSelect: () => editor.commands.setHeading({ level: 3 })
|
|
1401
|
+
}),
|
|
1402
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1403
|
+
label: "Heading 4",
|
|
1404
|
+
keywords: ["h4"],
|
|
1405
|
+
kbd: "####",
|
|
1406
|
+
onSelect: () => editor.commands.setHeading({ level: 4 })
|
|
1407
|
+
}),
|
|
1408
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1409
|
+
label: "Blockquote",
|
|
1410
|
+
kbd: ">",
|
|
1411
|
+
onSelect: () => editor.commands.setBlockquote()
|
|
1412
|
+
}),
|
|
1413
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1414
|
+
label: "Bullet list",
|
|
1415
|
+
kbd: "-",
|
|
1416
|
+
onSelect: () => editor.commands.wrapInList({ kind: "bullet" })
|
|
1417
|
+
}),
|
|
1418
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1419
|
+
label: "Ordered list",
|
|
1420
|
+
kbd: "1.",
|
|
1421
|
+
onSelect: () => editor.commands.wrapInList({ kind: "ordered" })
|
|
1422
|
+
}),
|
|
1423
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1424
|
+
label: "Task list",
|
|
1425
|
+
kbd: "+ [ ] ",
|
|
1426
|
+
onSelect: () => editor.commands.wrapInCircleTask()
|
|
1427
|
+
}),
|
|
1428
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1429
|
+
label: "Checkbox list",
|
|
1430
|
+
kbd: "- [ ] ",
|
|
1431
|
+
onSelect: () => editor.commands.wrapInSquareTask()
|
|
1432
|
+
}),
|
|
1433
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1434
|
+
label: "Code block",
|
|
1435
|
+
kbd: "```",
|
|
1436
|
+
onSelect: () => editor.commands.setCodeBlock()
|
|
1437
|
+
}),
|
|
1438
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1439
|
+
label: "Math",
|
|
1440
|
+
keywords: ["latex"],
|
|
1441
|
+
kbd: "```math",
|
|
1442
|
+
onSelect: () => editor.commands.insertMarkdown("```math\n```")
|
|
1443
|
+
}),
|
|
1444
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1445
|
+
label: "Table",
|
|
1446
|
+
onSelect: () => editor.commands.insertTable({
|
|
1447
|
+
row: 3,
|
|
1448
|
+
col: 3,
|
|
1449
|
+
header: true
|
|
1450
|
+
})
|
|
1451
|
+
})
|
|
1452
|
+
] }),
|
|
1453
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1454
|
+
label: "Now",
|
|
1455
|
+
onSelect: () => editor.commands.insertText({ text: formatNowTime(timeFormat) })
|
|
1456
|
+
}),
|
|
1457
|
+
onAttachFile ? /* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1458
|
+
label: "Attach file",
|
|
1459
|
+
keywords: [
|
|
1460
|
+
"attachment",
|
|
1461
|
+
"file",
|
|
1462
|
+
"upload"
|
|
1463
|
+
],
|
|
1464
|
+
onSelect: onAttachFile
|
|
1465
|
+
}) : null
|
|
1466
|
+
] });
|
|
1467
|
+
}
|
|
1468
|
+
const BuiltinSlashMenuItemsMemo = /* @__PURE__ */ memo(BuiltinSlashMenuItems);
|
|
1367
1469
|
function SlashMenu({ timeFormat = "12", onSlashMenuSearch, onFilePaste, onFileSaveError }) {
|
|
1368
1470
|
const editor = useEditor$1();
|
|
1369
1471
|
const collisionBoundary = use(CollisionBoundaryContext);
|
|
1370
1472
|
const fileInputRef = useRef(null);
|
|
1371
|
-
const inTableCell = useEditorDerivedValue(selectionInTableCell);
|
|
1372
1473
|
const [open, setOpen] = useState(false);
|
|
1373
1474
|
const [query, setQuery] = useState("");
|
|
1374
1475
|
const [hostItems, setHostItems] = useState([]);
|
|
@@ -1434,94 +1535,11 @@ function SlashMenu({ timeFormat = "12", onSlashMenuSearch, onFilePaste, onFileSa
|
|
|
1434
1535
|
className: autocomplete_menu_module_default.Popup,
|
|
1435
1536
|
"data-testid": "slash-menu",
|
|
1436
1537
|
children: [
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
onSelect: () => editor.commands.turnIntoText()
|
|
1442
|
-
}),
|
|
1443
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1444
|
-
label: "Heading 1",
|
|
1445
|
-
keywords: ["h1"],
|
|
1446
|
-
kbd: "#",
|
|
1447
|
-
onSelect: () => editor.commands.setHeading({ level: 1 })
|
|
1448
|
-
}),
|
|
1449
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1450
|
-
label: "Heading 2",
|
|
1451
|
-
keywords: ["h2"],
|
|
1452
|
-
kbd: "##",
|
|
1453
|
-
onSelect: () => editor.commands.setHeading({ level: 2 })
|
|
1454
|
-
}),
|
|
1455
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1456
|
-
label: "Heading 3",
|
|
1457
|
-
keywords: ["h3"],
|
|
1458
|
-
kbd: "###",
|
|
1459
|
-
onSelect: () => editor.commands.setHeading({ level: 3 })
|
|
1460
|
-
}),
|
|
1461
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1462
|
-
label: "Heading 4",
|
|
1463
|
-
keywords: ["h4"],
|
|
1464
|
-
kbd: "####",
|
|
1465
|
-
onSelect: () => editor.commands.setHeading({ level: 4 })
|
|
1466
|
-
}),
|
|
1467
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1468
|
-
label: "Blockquote",
|
|
1469
|
-
kbd: ">",
|
|
1470
|
-
onSelect: () => editor.commands.setBlockquote()
|
|
1471
|
-
}),
|
|
1472
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1473
|
-
label: "Bullet list",
|
|
1474
|
-
kbd: "-",
|
|
1475
|
-
onSelect: () => editor.commands.wrapInList({ kind: "bullet" })
|
|
1476
|
-
}),
|
|
1477
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1478
|
-
label: "Ordered list",
|
|
1479
|
-
kbd: "1.",
|
|
1480
|
-
onSelect: () => editor.commands.wrapInList({ kind: "ordered" })
|
|
1481
|
-
}),
|
|
1482
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1483
|
-
label: "Task list",
|
|
1484
|
-
kbd: "+ [ ] ",
|
|
1485
|
-
onSelect: () => editor.commands.wrapInCircleTask()
|
|
1486
|
-
}),
|
|
1487
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1488
|
-
label: "Checkbox list",
|
|
1489
|
-
kbd: "- [ ] ",
|
|
1490
|
-
onSelect: () => editor.commands.wrapInSquareTask()
|
|
1491
|
-
}),
|
|
1492
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1493
|
-
label: "Code block",
|
|
1494
|
-
kbd: "```",
|
|
1495
|
-
onSelect: () => editor.commands.setCodeBlock()
|
|
1496
|
-
}),
|
|
1497
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1498
|
-
label: "Math",
|
|
1499
|
-
keywords: ["latex"],
|
|
1500
|
-
kbd: "```math",
|
|
1501
|
-
onSelect: () => editor.commands.insertMarkdown("```math\n```")
|
|
1502
|
-
}),
|
|
1503
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1504
|
-
label: "Table",
|
|
1505
|
-
onSelect: () => editor.commands.insertTable({
|
|
1506
|
-
row: 3,
|
|
1507
|
-
col: 3,
|
|
1508
|
-
header: true
|
|
1509
|
-
})
|
|
1510
|
-
})
|
|
1511
|
-
] }),
|
|
1512
|
-
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1513
|
-
label: "Now",
|
|
1514
|
-
onSelect: () => editor.commands.insertText({ text: formatNowTime(timeFormat) })
|
|
1538
|
+
/* @__PURE__ */ jsx(BuiltinSlashMenuItemsMemo, {
|
|
1539
|
+
editor,
|
|
1540
|
+
timeFormat,
|
|
1541
|
+
onAttachFile: onFilePaste ? openFilePicker : void 0
|
|
1515
1542
|
}),
|
|
1516
|
-
onFilePaste ? /* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1517
|
-
label: "Attach file",
|
|
1518
|
-
keywords: [
|
|
1519
|
-
"attachment",
|
|
1520
|
-
"file",
|
|
1521
|
-
"upload"
|
|
1522
|
-
],
|
|
1523
|
-
onSelect: openFilePicker
|
|
1524
|
-
}) : null,
|
|
1525
1543
|
hostItems.map((item) => /* @__PURE__ */ jsx(SlashMenuItem, {
|
|
1526
1544
|
label: item.label,
|
|
1527
1545
|
keywords: item.keywords,
|
|
@@ -1552,68 +1570,188 @@ var table_handle_module_default = {
|
|
|
1552
1570
|
|
|
1553
1571
|
//#endregion
|
|
1554
1572
|
//#region src/components/table-handle.tsx
|
|
1555
|
-
function
|
|
1556
|
-
|
|
1557
|
-
const columnAlign = getTableColumnAlign(editor.state);
|
|
1558
|
-
return {
|
|
1559
|
-
columnAlign,
|
|
1560
|
-
setTableColumnAlign: {
|
|
1561
|
-
canExec: commands.setTableColumnAlign.canExec("left"),
|
|
1562
|
-
command: (align) => {
|
|
1563
|
-
return commands.setTableColumnAlign(columnAlign === align ? null : align);
|
|
1564
|
-
}
|
|
1565
|
-
},
|
|
1566
|
-
addTableColumnBefore: {
|
|
1567
|
-
canExec: commands.addTableColumnBefore.canExec(),
|
|
1568
|
-
command: () => commands.addTableColumnBefore()
|
|
1569
|
-
},
|
|
1570
|
-
addTableColumnAfter: {
|
|
1571
|
-
canExec: commands.addTableColumnAfter.canExec(),
|
|
1572
|
-
command: () => commands.addTableColumnAfter()
|
|
1573
|
-
},
|
|
1574
|
-
addTableRowAbove: {
|
|
1575
|
-
canExec: commands.addTableRowAbove.canExec(),
|
|
1576
|
-
command: () => commands.addTableRowAbove()
|
|
1577
|
-
},
|
|
1578
|
-
addTableRowBelow: {
|
|
1579
|
-
canExec: commands.addTableRowBelow.canExec(),
|
|
1580
|
-
command: () => commands.addTableRowBelow()
|
|
1581
|
-
},
|
|
1582
|
-
deleteCellSelection: {
|
|
1583
|
-
canExec: commands.deleteCellSelection.canExec(),
|
|
1584
|
-
command: () => commands.deleteCellSelection()
|
|
1585
|
-
},
|
|
1586
|
-
deleteTableColumn: {
|
|
1587
|
-
canExec: commands.deleteTableColumn.canExec(),
|
|
1588
|
-
command: () => commands.deleteTableColumn()
|
|
1589
|
-
},
|
|
1590
|
-
deleteTableRow: {
|
|
1591
|
-
canExec: commands.deleteTableRow.canExec(),
|
|
1592
|
-
command: () => commands.deleteTableRow()
|
|
1593
|
-
},
|
|
1594
|
-
deleteTable: {
|
|
1595
|
-
canExec: commands.deleteTable.canExec(),
|
|
1596
|
-
command: () => commands.deleteTable()
|
|
1597
|
-
}
|
|
1598
|
-
};
|
|
1599
|
-
}
|
|
1600
|
-
const COLUMN_ALIGN_LABELS = {
|
|
1601
|
-
left: "Align Left",
|
|
1602
|
-
center: "Align Center",
|
|
1603
|
-
right: "Align Right"
|
|
1604
|
-
};
|
|
1605
|
-
function ColumnAlignMenuItem({ align, columnAlign, onSelect }) {
|
|
1606
|
-
const active = columnAlign === align;
|
|
1607
|
-
return /* @__PURE__ */ jsxs(MenuItem, {
|
|
1573
|
+
function TableHandleItem({ children, onSelect, testId, active = false, danger = false }) {
|
|
1574
|
+
return /* @__PURE__ */ jsx(MenuItem, {
|
|
1608
1575
|
className: table_handle_module_default.MenuItem,
|
|
1609
|
-
"data-testid": `table-align-${align}`,
|
|
1610
|
-
"data-active": active ? "" : void 0,
|
|
1611
1576
|
onSelect,
|
|
1612
|
-
|
|
1577
|
+
"data-testid": testId,
|
|
1578
|
+
"data-active": active ? "" : void 0,
|
|
1579
|
+
"data-danger": danger ? "" : void 0,
|
|
1580
|
+
children
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
function canInsertLeft(editor) {
|
|
1584
|
+
return editor.commands.addTableColumnBefore.canExec();
|
|
1585
|
+
}
|
|
1586
|
+
function runInsertLeft(editor) {
|
|
1587
|
+
editor.commands.addTableColumnBefore();
|
|
1588
|
+
}
|
|
1589
|
+
function TableMenuInsertLeft({ editor }) {
|
|
1590
|
+
const canExec = useEditorDerivedValue(canInsertLeft);
|
|
1591
|
+
const handler = useCallback(() => runInsertLeft(editor), [editor]);
|
|
1592
|
+
return canExec ? /* @__PURE__ */ jsx(TableHandleItem, {
|
|
1593
|
+
testId: "table-insert-left",
|
|
1594
|
+
onSelect: handler,
|
|
1595
|
+
children: /* @__PURE__ */ jsx("span", { children: "Insert Left" })
|
|
1596
|
+
}) : null;
|
|
1597
|
+
}
|
|
1598
|
+
function canInsertRight(editor) {
|
|
1599
|
+
return editor.commands.addTableColumnAfter.canExec();
|
|
1600
|
+
}
|
|
1601
|
+
function runInsertRight(editor) {
|
|
1602
|
+
editor.commands.addTableColumnAfter();
|
|
1603
|
+
}
|
|
1604
|
+
function TableMenuInsertRight({ editor }) {
|
|
1605
|
+
const canExec = useEditorDerivedValue(canInsertRight);
|
|
1606
|
+
const handler = useCallback(() => runInsertRight(editor), [editor]);
|
|
1607
|
+
return canExec ? /* @__PURE__ */ jsx(TableHandleItem, {
|
|
1608
|
+
testId: "table-insert-right",
|
|
1609
|
+
onSelect: handler,
|
|
1610
|
+
children: /* @__PURE__ */ jsx("span", { children: "Insert Right" })
|
|
1611
|
+
}) : null;
|
|
1612
|
+
}
|
|
1613
|
+
function canAlign(editor) {
|
|
1614
|
+
return editor.commands.setTableColumnAlign.canExec("left");
|
|
1615
|
+
}
|
|
1616
|
+
function getActiveAlign(editor) {
|
|
1617
|
+
return getTableColumnAlign(editor.state);
|
|
1618
|
+
}
|
|
1619
|
+
function runAlign(editor, align, active) {
|
|
1620
|
+
editor.commands.setTableColumnAlign(active ? null : align);
|
|
1621
|
+
}
|
|
1622
|
+
function TableMenuAlignItem({ label, editor, align, activeAlign }) {
|
|
1623
|
+
const active = activeAlign === align;
|
|
1624
|
+
const handler = useCallback(() => runAlign(editor, align, active), [
|
|
1625
|
+
editor,
|
|
1626
|
+
align,
|
|
1627
|
+
active
|
|
1628
|
+
]);
|
|
1629
|
+
return /* @__PURE__ */ jsxs(TableHandleItem, {
|
|
1630
|
+
testId: `table-align-${align}`,
|
|
1631
|
+
active,
|
|
1632
|
+
onSelect: handler,
|
|
1633
|
+
children: [/* @__PURE__ */ jsx("span", { children: label }), active && /* @__PURE__ */ jsx(CheckIcon, {})]
|
|
1613
1634
|
});
|
|
1614
1635
|
}
|
|
1636
|
+
function TableMenuAlignItems({ editor }) {
|
|
1637
|
+
const activeAlign = useEditorDerivedValue(getActiveAlign);
|
|
1638
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1639
|
+
/* @__PURE__ */ jsx(TableMenuAlignItem, {
|
|
1640
|
+
align: "left",
|
|
1641
|
+
label: "Align Left",
|
|
1642
|
+
editor,
|
|
1643
|
+
activeAlign
|
|
1644
|
+
}),
|
|
1645
|
+
/* @__PURE__ */ jsx(TableMenuAlignItem, {
|
|
1646
|
+
align: "center",
|
|
1647
|
+
label: "Align Center",
|
|
1648
|
+
editor,
|
|
1649
|
+
activeAlign
|
|
1650
|
+
}),
|
|
1651
|
+
/* @__PURE__ */ jsx(TableMenuAlignItem, {
|
|
1652
|
+
align: "right",
|
|
1653
|
+
label: "Align Right",
|
|
1654
|
+
editor,
|
|
1655
|
+
activeAlign
|
|
1656
|
+
})
|
|
1657
|
+
] });
|
|
1658
|
+
}
|
|
1659
|
+
function TableMenuAlign({ editor }) {
|
|
1660
|
+
return useEditorDerivedValue(canAlign) ? /* @__PURE__ */ jsx(TableMenuAlignItems, { editor }) : null;
|
|
1661
|
+
}
|
|
1662
|
+
function canClearContents(editor) {
|
|
1663
|
+
return editor.commands.deleteCellSelection.canExec();
|
|
1664
|
+
}
|
|
1665
|
+
function runClearContents(editor) {
|
|
1666
|
+
editor.commands.deleteCellSelection();
|
|
1667
|
+
}
|
|
1668
|
+
function TableMenuClearContents({ editor, testId }) {
|
|
1669
|
+
const canExec = useEditorDerivedValue(canClearContents);
|
|
1670
|
+
const handler = useCallback(() => runClearContents(editor), [editor]);
|
|
1671
|
+
return canExec ? /* @__PURE__ */ jsxs(TableHandleItem, {
|
|
1672
|
+
testId,
|
|
1673
|
+
onSelect: handler,
|
|
1674
|
+
children: [/* @__PURE__ */ jsx("span", { children: "Clear Contents" }), /* @__PURE__ */ jsx("kbd", { children: "Del" })]
|
|
1675
|
+
}) : null;
|
|
1676
|
+
}
|
|
1677
|
+
function canDeleteColumn(editor) {
|
|
1678
|
+
return editor.commands.deleteTableColumn.canExec();
|
|
1679
|
+
}
|
|
1680
|
+
function runDeleteColumn(editor) {
|
|
1681
|
+
editor.commands.deleteTableColumn();
|
|
1682
|
+
}
|
|
1683
|
+
function TableMenuDeleteColumn({ editor }) {
|
|
1684
|
+
const canExec = useEditorDerivedValue(canDeleteColumn);
|
|
1685
|
+
const handler = useCallback(() => runDeleteColumn(editor), [editor]);
|
|
1686
|
+
return canExec ? /* @__PURE__ */ jsx(TableHandleItem, {
|
|
1687
|
+
testId: "table-delete-column",
|
|
1688
|
+
onSelect: handler,
|
|
1689
|
+
children: /* @__PURE__ */ jsx("span", { children: "Delete Column" })
|
|
1690
|
+
}) : null;
|
|
1691
|
+
}
|
|
1692
|
+
function canInsertAbove(editor) {
|
|
1693
|
+
return editor.commands.addTableRowAbove.canExec();
|
|
1694
|
+
}
|
|
1695
|
+
function runInsertAbove(editor) {
|
|
1696
|
+
editor.commands.addTableRowAbove();
|
|
1697
|
+
}
|
|
1698
|
+
function TableMenuInsertAbove({ editor }) {
|
|
1699
|
+
const canExec = useEditorDerivedValue(canInsertAbove);
|
|
1700
|
+
const handler = useCallback(() => runInsertAbove(editor), [editor]);
|
|
1701
|
+
return canExec ? /* @__PURE__ */ jsx(TableHandleItem, {
|
|
1702
|
+
testId: "table-insert-above",
|
|
1703
|
+
onSelect: handler,
|
|
1704
|
+
children: /* @__PURE__ */ jsx("span", { children: "Insert Above" })
|
|
1705
|
+
}) : null;
|
|
1706
|
+
}
|
|
1707
|
+
function canInsertBelow(editor) {
|
|
1708
|
+
return editor.commands.addTableRowBelow.canExec();
|
|
1709
|
+
}
|
|
1710
|
+
function runInsertBelow(editor) {
|
|
1711
|
+
editor.commands.addTableRowBelow();
|
|
1712
|
+
}
|
|
1713
|
+
function TableMenuInsertBelow({ editor }) {
|
|
1714
|
+
const canExec = useEditorDerivedValue(canInsertBelow);
|
|
1715
|
+
const handler = useCallback(() => runInsertBelow(editor), [editor]);
|
|
1716
|
+
return canExec ? /* @__PURE__ */ jsx(TableHandleItem, {
|
|
1717
|
+
testId: "table-insert-below",
|
|
1718
|
+
onSelect: handler,
|
|
1719
|
+
children: /* @__PURE__ */ jsx("span", { children: "Insert Below" })
|
|
1720
|
+
}) : null;
|
|
1721
|
+
}
|
|
1722
|
+
function canDeleteRow(editor) {
|
|
1723
|
+
return editor.commands.deleteTableRow.canExec();
|
|
1724
|
+
}
|
|
1725
|
+
function runDeleteRow(editor) {
|
|
1726
|
+
editor.commands.deleteTableRow();
|
|
1727
|
+
}
|
|
1728
|
+
function TableMenuDeleteRow({ editor }) {
|
|
1729
|
+
const canExec = useEditorDerivedValue(canDeleteRow);
|
|
1730
|
+
const handler = useCallback(() => runDeleteRow(editor), [editor]);
|
|
1731
|
+
return canExec ? /* @__PURE__ */ jsx(TableHandleItem, {
|
|
1732
|
+
testId: "table-delete-row",
|
|
1733
|
+
onSelect: handler,
|
|
1734
|
+
children: /* @__PURE__ */ jsx("span", { children: "Delete Row" })
|
|
1735
|
+
}) : null;
|
|
1736
|
+
}
|
|
1737
|
+
function canDeleteTable(editor) {
|
|
1738
|
+
return editor.commands.deleteTable.canExec();
|
|
1739
|
+
}
|
|
1740
|
+
function runDeleteTable(editor) {
|
|
1741
|
+
editor.commands.deleteTable();
|
|
1742
|
+
}
|
|
1743
|
+
function TableMenuDeleteTable({ editor, testId }) {
|
|
1744
|
+
const canExec = useEditorDerivedValue(canDeleteTable);
|
|
1745
|
+
const handler = useCallback(() => runDeleteTable(editor), [editor]);
|
|
1746
|
+
return canExec ? /* @__PURE__ */ jsx(TableHandleItem, {
|
|
1747
|
+
testId,
|
|
1748
|
+
danger: true,
|
|
1749
|
+
onSelect: handler,
|
|
1750
|
+
children: /* @__PURE__ */ jsx("span", { children: "Delete Table" })
|
|
1751
|
+
}) : null;
|
|
1752
|
+
}
|
|
1615
1753
|
function TableHandle() {
|
|
1616
|
-
const
|
|
1754
|
+
const editor = useEditor$1();
|
|
1617
1755
|
return /* @__PURE__ */ jsxs(TableHandleRoot, { children: [
|
|
1618
1756
|
/* @__PURE__ */ jsx(TableHandleDragPreview, {}),
|
|
1619
1757
|
/* @__PURE__ */ jsx(TableHandleDropIndicator, {}),
|
|
@@ -1631,53 +1769,17 @@ function TableHandle() {
|
|
|
1631
1769
|
className: table_handle_module_default.MenuPopup,
|
|
1632
1770
|
"data-testid": "table-handle-column-menu",
|
|
1633
1771
|
children: [
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
state.addTableColumnAfter.canExec && /* @__PURE__ */ jsx(MenuItem, {
|
|
1641
|
-
className: table_handle_module_default.MenuItem,
|
|
1642
|
-
"data-testid": "table-insert-right",
|
|
1643
|
-
onSelect: state.addTableColumnAfter.command,
|
|
1644
|
-
children: /* @__PURE__ */ jsx("span", { children: "Insert Right" })
|
|
1645
|
-
}),
|
|
1646
|
-
state.setTableColumnAlign.canExec && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1647
|
-
/* @__PURE__ */ jsx(ColumnAlignMenuItem, {
|
|
1648
|
-
align: "left",
|
|
1649
|
-
columnAlign: state.columnAlign,
|
|
1650
|
-
onSelect: () => state.setTableColumnAlign.command("left")
|
|
1651
|
-
}),
|
|
1652
|
-
/* @__PURE__ */ jsx(ColumnAlignMenuItem, {
|
|
1653
|
-
align: "center",
|
|
1654
|
-
columnAlign: state.columnAlign,
|
|
1655
|
-
onSelect: () => state.setTableColumnAlign.command("center")
|
|
1656
|
-
}),
|
|
1657
|
-
/* @__PURE__ */ jsx(ColumnAlignMenuItem, {
|
|
1658
|
-
align: "right",
|
|
1659
|
-
columnAlign: state.columnAlign,
|
|
1660
|
-
onSelect: () => state.setTableColumnAlign.command("right")
|
|
1661
|
-
})
|
|
1662
|
-
] }),
|
|
1663
|
-
state.deleteCellSelection.canExec && /* @__PURE__ */ jsxs(MenuItem, {
|
|
1664
|
-
className: table_handle_module_default.MenuItem,
|
|
1665
|
-
"data-testid": "table-clear-column",
|
|
1666
|
-
onSelect: state.deleteCellSelection.command,
|
|
1667
|
-
children: [/* @__PURE__ */ jsx("span", { children: "Clear Contents" }), /* @__PURE__ */ jsx("kbd", { children: "Del" })]
|
|
1668
|
-
}),
|
|
1669
|
-
state.deleteTableColumn.canExec && /* @__PURE__ */ jsx(MenuItem, {
|
|
1670
|
-
className: table_handle_module_default.MenuItem,
|
|
1671
|
-
"data-testid": "table-delete-column",
|
|
1672
|
-
onSelect: state.deleteTableColumn.command,
|
|
1673
|
-
children: /* @__PURE__ */ jsx("span", { children: "Delete Column" })
|
|
1772
|
+
/* @__PURE__ */ jsx(TableMenuInsertLeft, { editor }),
|
|
1773
|
+
/* @__PURE__ */ jsx(TableMenuInsertRight, { editor }),
|
|
1774
|
+
/* @__PURE__ */ jsx(TableMenuAlign, { editor }),
|
|
1775
|
+
/* @__PURE__ */ jsx(TableMenuClearContents, {
|
|
1776
|
+
editor,
|
|
1777
|
+
testId: "table-clear-column"
|
|
1674
1778
|
}),
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
onSelect: state.deleteTable.command,
|
|
1680
|
-
children: /* @__PURE__ */ jsx("span", { children: "Delete Table" })
|
|
1779
|
+
/* @__PURE__ */ jsx(TableMenuDeleteColumn, { editor }),
|
|
1780
|
+
/* @__PURE__ */ jsx(TableMenuDeleteTable, {
|
|
1781
|
+
editor,
|
|
1782
|
+
testId: "table-delete-table-column"
|
|
1681
1783
|
})
|
|
1682
1784
|
]
|
|
1683
1785
|
})
|
|
@@ -1685,7 +1787,6 @@ function TableHandle() {
|
|
|
1685
1787
|
})
|
|
1686
1788
|
}),
|
|
1687
1789
|
/* @__PURE__ */ jsx(TableHandleRowPositioner, {
|
|
1688
|
-
placement: "left",
|
|
1689
1790
|
className: table_handle_module_default.Positioner,
|
|
1690
1791
|
children: /* @__PURE__ */ jsx(TableHandleRowPopup, {
|
|
1691
1792
|
className: table_handle_module_default.RowPopup,
|
|
@@ -1699,36 +1800,16 @@ function TableHandle() {
|
|
|
1699
1800
|
className: table_handle_module_default.MenuPopup,
|
|
1700
1801
|
"data-testid": "table-handle-row-menu",
|
|
1701
1802
|
children: [
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
}),
|
|
1708
|
-
state.addTableRowBelow.canExec && /* @__PURE__ */ jsx(MenuItem, {
|
|
1709
|
-
className: table_handle_module_default.MenuItem,
|
|
1710
|
-
"data-testid": "table-insert-below",
|
|
1711
|
-
onSelect: state.addTableRowBelow.command,
|
|
1712
|
-
children: /* @__PURE__ */ jsx("span", { children: "Insert Below" })
|
|
1713
|
-
}),
|
|
1714
|
-
state.deleteCellSelection.canExec && /* @__PURE__ */ jsxs(MenuItem, {
|
|
1715
|
-
className: table_handle_module_default.MenuItem,
|
|
1716
|
-
"data-testid": "table-clear-row",
|
|
1717
|
-
onSelect: state.deleteCellSelection.command,
|
|
1718
|
-
children: [/* @__PURE__ */ jsx("span", { children: "Clear Contents" }), /* @__PURE__ */ jsx("kbd", { children: "Del" })]
|
|
1719
|
-
}),
|
|
1720
|
-
state.deleteTableRow.canExec && /* @__PURE__ */ jsx(MenuItem, {
|
|
1721
|
-
className: table_handle_module_default.MenuItem,
|
|
1722
|
-
"data-testid": "table-delete-row",
|
|
1723
|
-
onSelect: state.deleteTableRow.command,
|
|
1724
|
-
children: /* @__PURE__ */ jsx("span", { children: "Delete Row" })
|
|
1803
|
+
/* @__PURE__ */ jsx(TableMenuInsertAbove, { editor }),
|
|
1804
|
+
/* @__PURE__ */ jsx(TableMenuInsertBelow, { editor }),
|
|
1805
|
+
/* @__PURE__ */ jsx(TableMenuClearContents, {
|
|
1806
|
+
editor,
|
|
1807
|
+
testId: "table-clear-row"
|
|
1725
1808
|
}),
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
onSelect: state.deleteTable.command,
|
|
1731
|
-
children: /* @__PURE__ */ jsx("span", { children: "Delete Table" })
|
|
1809
|
+
/* @__PURE__ */ jsx(TableMenuDeleteRow, { editor }),
|
|
1810
|
+
/* @__PURE__ */ jsx(TableMenuDeleteTable, {
|
|
1811
|
+
editor,
|
|
1812
|
+
testId: "table-delete-table-row"
|
|
1732
1813
|
})
|
|
1733
1814
|
]
|
|
1734
1815
|
})
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.81.
|
|
4
|
+
"version": "0.81.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
"@tsdown/css": "^0.23.1",
|
|
57
57
|
"@types/react": "^19.3.0",
|
|
58
58
|
"@types/react-dom": "^19.3.0",
|
|
59
|
-
"@vitest/browser-playwright": "^5.0.
|
|
59
|
+
"@vitest/browser-playwright": "^5.0.5",
|
|
60
60
|
"dedent": "^1.7.2",
|
|
61
61
|
"react": "^19.3.0",
|
|
62
62
|
"react-dom": "^19.3.0",
|
|
63
63
|
"tsdown": "^0.23.1",
|
|
64
|
-
"vitest": "^5.0.
|
|
64
|
+
"vitest": "^5.0.5",
|
|
65
65
|
"vitest-browser-commands": "^0.5.0",
|
|
66
66
|
"vitest-browser-react": "^2.3.0"
|
|
67
67
|
},
|