@lumir-company/editor 0.4.15 → 0.4.17
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/README.md +65 -0
- package/dist/index.d.mts +105 -1
- package/dist/index.d.ts +105 -1
- package/dist/index.js +2116 -610
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2093 -573
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +112 -0
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -24,7 +24,10 @@ __export(index_exports, {
|
|
|
24
24
|
BACKGROUND_COLORS: () => BACKGROUND_COLORS,
|
|
25
25
|
ContentUtils: () => ContentUtils,
|
|
26
26
|
EditorConfig: () => EditorConfig,
|
|
27
|
+
FONT_SIZE_PRESETS: () => FONT_SIZE_PRESETS,
|
|
27
28
|
FloatingMenu: () => FloatingMenu,
|
|
29
|
+
FontSize: () => FontSize,
|
|
30
|
+
FontSizeButton: () => FontSizeButton2,
|
|
28
31
|
HtmlPreviewBlock: () => HtmlPreviewBlock,
|
|
29
32
|
HtmlPreviewSchema: () => schema,
|
|
30
33
|
LinkPreviewBlock: () => LinkPreviewBlock,
|
|
@@ -35,15 +38,17 @@ __export(index_exports, {
|
|
|
35
38
|
cn: () => cn,
|
|
36
39
|
createS3Uploader: () => createS3Uploader,
|
|
37
40
|
fetchLinkMetadata: () => fetchLinkMetadata,
|
|
38
|
-
getHexFromColorValue: () => getHexFromColorValue
|
|
41
|
+
getHexFromColorValue: () => getHexFromColorValue,
|
|
42
|
+
liftFontSize: () => liftFontSize,
|
|
43
|
+
lowerFontSize: () => lowerFontSize
|
|
39
44
|
});
|
|
40
45
|
module.exports = __toCommonJS(index_exports);
|
|
41
46
|
|
|
42
47
|
// src/components/LumirEditor.tsx
|
|
43
|
-
var
|
|
44
|
-
var
|
|
48
|
+
var import_react37 = require("react");
|
|
49
|
+
var import_react38 = require("@blocknote/react");
|
|
45
50
|
var import_mantine = require("@blocknote/mantine");
|
|
46
|
-
var
|
|
51
|
+
var import_core9 = require("@blocknote/core");
|
|
47
52
|
var import_locales = require("@blocknote/core/locales");
|
|
48
53
|
|
|
49
54
|
// src/utils/cn.ts
|
|
@@ -280,8 +285,8 @@ var createS3Uploader = (config) => {
|
|
|
280
285
|
};
|
|
281
286
|
|
|
282
287
|
// src/blocks/HtmlPreview.tsx
|
|
283
|
-
var
|
|
284
|
-
var
|
|
288
|
+
var import_react6 = require("@blocknote/react");
|
|
289
|
+
var import_core3 = require("@blocknote/core");
|
|
285
290
|
|
|
286
291
|
// src/blocks/LinkPreview.tsx
|
|
287
292
|
var import_react = require("@blocknote/react");
|
|
@@ -1241,9 +1246,336 @@ var VideoBlock = (0, import_react3.createReactBlockSpec)(
|
|
|
1241
1246
|
}
|
|
1242
1247
|
);
|
|
1243
1248
|
|
|
1244
|
-
// src/blocks/
|
|
1245
|
-
var
|
|
1249
|
+
// src/blocks/columns/ColumnList.ts
|
|
1250
|
+
var import_core = require("@blocknote/core");
|
|
1251
|
+
|
|
1252
|
+
// src/blocks/columns/columnNormalization.ts
|
|
1253
|
+
var import_prosemirror_state = require("prosemirror-state");
|
|
1254
|
+
var columnNormalizationKey = new import_prosemirror_state.PluginKey("lumirColumnNormalization");
|
|
1255
|
+
function columnNormalization() {
|
|
1256
|
+
return new import_prosemirror_state.Plugin({
|
|
1257
|
+
key: columnNormalizationKey,
|
|
1258
|
+
appendTransaction(transactions, _oldState, newState) {
|
|
1259
|
+
if (!transactions.some((tr2) => tr2.docChanged)) {
|
|
1260
|
+
return null;
|
|
1261
|
+
}
|
|
1262
|
+
const lists = [];
|
|
1263
|
+
newState.doc.descendants((node, pos) => {
|
|
1264
|
+
if (node.type.name === "columnList") {
|
|
1265
|
+
lists.push({ pos, node });
|
|
1266
|
+
return false;
|
|
1267
|
+
}
|
|
1268
|
+
return void 0;
|
|
1269
|
+
});
|
|
1270
|
+
if (lists.length === 0) {
|
|
1271
|
+
return null;
|
|
1272
|
+
}
|
|
1273
|
+
const tr = newState.tr;
|
|
1274
|
+
let modified = false;
|
|
1275
|
+
for (let i = lists.length - 1; i >= 0; i--) {
|
|
1276
|
+
const { pos, node } = lists[i];
|
|
1277
|
+
const nonEmptyColumns = [];
|
|
1278
|
+
node.forEach((col) => {
|
|
1279
|
+
if (col.type.name === "column" && col.childCount > 0) {
|
|
1280
|
+
nonEmptyColumns.push(col);
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
if (nonEmptyColumns.length >= 2) {
|
|
1284
|
+
continue;
|
|
1285
|
+
}
|
|
1286
|
+
const from = tr.mapping.map(pos);
|
|
1287
|
+
const to = tr.mapping.map(pos + node.nodeSize);
|
|
1288
|
+
const blocks = [];
|
|
1289
|
+
nonEmptyColumns.forEach((col) => {
|
|
1290
|
+
col.forEach((bc) => blocks.push(bc));
|
|
1291
|
+
});
|
|
1292
|
+
if (blocks.length > 0) {
|
|
1293
|
+
tr.replaceWith(from, to, blocks);
|
|
1294
|
+
} else {
|
|
1295
|
+
tr.delete(from, to);
|
|
1296
|
+
}
|
|
1297
|
+
modified = true;
|
|
1298
|
+
}
|
|
1299
|
+
return modified ? tr : null;
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
// src/blocks/columns/columnDnd.ts
|
|
1305
|
+
var import_prosemirror_state2 = require("prosemirror-state");
|
|
1306
|
+
var import_prosemirror_view = require("prosemirror-view");
|
|
1307
|
+
|
|
1308
|
+
// src/blocks/columns/mergeColumns.ts
|
|
1309
|
+
function mergeBlocksIntoColumns(editor, draggedId, targetId, side) {
|
|
1310
|
+
if (!editor || !draggedId || !targetId || draggedId === targetId) {
|
|
1311
|
+
return false;
|
|
1312
|
+
}
|
|
1313
|
+
const dragged = editor.getBlock?.(draggedId);
|
|
1314
|
+
const target = editor.getBlock?.(targetId);
|
|
1315
|
+
if (!dragged || !target) {
|
|
1316
|
+
return false;
|
|
1317
|
+
}
|
|
1318
|
+
if (dragged.type === "columnList" || dragged.type === "column" || target.type === "columnList" || target.type === "column") {
|
|
1319
|
+
return false;
|
|
1320
|
+
}
|
|
1321
|
+
const columnList = {
|
|
1322
|
+
type: "columnList",
|
|
1323
|
+
children: side === "left" ? [
|
|
1324
|
+
{ type: "column", children: [dragged] },
|
|
1325
|
+
{ type: "column", children: [target] }
|
|
1326
|
+
] : [
|
|
1327
|
+
{ type: "column", children: [target] },
|
|
1328
|
+
{ type: "column", children: [dragged] }
|
|
1329
|
+
]
|
|
1330
|
+
};
|
|
1331
|
+
try {
|
|
1332
|
+
const run = () => {
|
|
1333
|
+
editor.removeBlocks([draggedId]);
|
|
1334
|
+
editor.replaceBlocks([targetId], [columnList]);
|
|
1335
|
+
};
|
|
1336
|
+
if (typeof editor.transact === "function") {
|
|
1337
|
+
editor.transact(run);
|
|
1338
|
+
} else {
|
|
1339
|
+
run();
|
|
1340
|
+
}
|
|
1341
|
+
return true;
|
|
1342
|
+
} catch {
|
|
1343
|
+
return false;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
// src/blocks/columns/columnDnd.ts
|
|
1348
|
+
var columnDndKey = new import_prosemirror_state2.PluginKey("lumirColumnDnd");
|
|
1349
|
+
function edgeThreshold(width) {
|
|
1350
|
+
return Math.min(80, width * 0.3);
|
|
1351
|
+
}
|
|
1352
|
+
function topLevelBlockAtCoords(view, x, y) {
|
|
1353
|
+
const found = view.posAtCoords({ left: x, top: y });
|
|
1354
|
+
if (!found) {
|
|
1355
|
+
return null;
|
|
1356
|
+
}
|
|
1357
|
+
const $pos = view.state.doc.resolve(found.pos);
|
|
1358
|
+
for (let d = $pos.depth; d > 0; d--) {
|
|
1359
|
+
if ($pos.node(d).type.name === "blockContainer") {
|
|
1360
|
+
if (d !== 2 || $pos.node(d - 1).type.name !== "blockGroup") {
|
|
1361
|
+
return null;
|
|
1362
|
+
}
|
|
1363
|
+
const pos = $pos.before(d);
|
|
1364
|
+
const node = $pos.node(d);
|
|
1365
|
+
const dom = view.nodeDOM(pos);
|
|
1366
|
+
if (!dom || !node.attrs?.id) {
|
|
1367
|
+
return null;
|
|
1368
|
+
}
|
|
1369
|
+
return { pos, nodeSize: node.nodeSize, id: node.attrs.id, dom };
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
return null;
|
|
1373
|
+
}
|
|
1374
|
+
function draggedBlockId(view) {
|
|
1375
|
+
const sel = view.state.selection;
|
|
1376
|
+
return sel?.node?.attrs?.id ?? null;
|
|
1377
|
+
}
|
|
1378
|
+
function setDnd(view, next) {
|
|
1379
|
+
const cur = columnDndKey.getState(view.state);
|
|
1380
|
+
if (cur && cur.targetPos === next.targetPos && cur.side === next.side) {
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
view.dispatch(view.state.tr.setMeta(columnDndKey, next));
|
|
1384
|
+
}
|
|
1385
|
+
var CLEARED = { targetPos: null, side: null };
|
|
1386
|
+
function columnDnd() {
|
|
1387
|
+
return new import_prosemirror_state2.Plugin({
|
|
1388
|
+
key: columnDndKey,
|
|
1389
|
+
state: {
|
|
1390
|
+
init: () => CLEARED,
|
|
1391
|
+
apply(tr, prev) {
|
|
1392
|
+
const meta = tr.getMeta(columnDndKey);
|
|
1393
|
+
if (meta) {
|
|
1394
|
+
return meta;
|
|
1395
|
+
}
|
|
1396
|
+
if (tr.docChanged && prev.targetPos !== null) {
|
|
1397
|
+
return CLEARED;
|
|
1398
|
+
}
|
|
1399
|
+
return prev;
|
|
1400
|
+
}
|
|
1401
|
+
},
|
|
1402
|
+
props: {
|
|
1403
|
+
handleDOMEvents: {
|
|
1404
|
+
dragover: (view, event) => {
|
|
1405
|
+
if (!view.dragging) {
|
|
1406
|
+
return false;
|
|
1407
|
+
}
|
|
1408
|
+
const target = topLevelBlockAtCoords(
|
|
1409
|
+
view,
|
|
1410
|
+
event.clientX,
|
|
1411
|
+
event.clientY
|
|
1412
|
+
);
|
|
1413
|
+
const draggedId = draggedBlockId(view);
|
|
1414
|
+
if (!target || !draggedId || target.id === draggedId) {
|
|
1415
|
+
setDnd(view, CLEARED);
|
|
1416
|
+
view.dom.classList.remove("lumir-col-dnd-active");
|
|
1417
|
+
return false;
|
|
1418
|
+
}
|
|
1419
|
+
const rect = target.dom.getBoundingClientRect();
|
|
1420
|
+
const th = edgeThreshold(rect.width);
|
|
1421
|
+
let side = null;
|
|
1422
|
+
if (event.clientX - rect.left <= th) {
|
|
1423
|
+
side = "left";
|
|
1424
|
+
} else if (rect.right - event.clientX <= th) {
|
|
1425
|
+
side = "right";
|
|
1426
|
+
}
|
|
1427
|
+
if (side) {
|
|
1428
|
+
setDnd(view, { targetPos: target.pos, side });
|
|
1429
|
+
view.dom.classList.add("lumir-col-dnd-active");
|
|
1430
|
+
} else {
|
|
1431
|
+
setDnd(view, CLEARED);
|
|
1432
|
+
view.dom.classList.remove("lumir-col-dnd-active");
|
|
1433
|
+
}
|
|
1434
|
+
return false;
|
|
1435
|
+
},
|
|
1436
|
+
dragend: (view) => {
|
|
1437
|
+
setDnd(view, CLEARED);
|
|
1438
|
+
view.dom.classList.remove("lumir-col-dnd-active");
|
|
1439
|
+
return false;
|
|
1440
|
+
},
|
|
1441
|
+
dragleave: (view, event) => {
|
|
1442
|
+
if (!event.relatedTarget) {
|
|
1443
|
+
setDnd(view, CLEARED);
|
|
1444
|
+
view.dom.classList.remove("lumir-col-dnd-active");
|
|
1445
|
+
}
|
|
1446
|
+
return false;
|
|
1447
|
+
}
|
|
1448
|
+
},
|
|
1449
|
+
handleDrop: (view, _event, _slice, _moved) => {
|
|
1450
|
+
const st = columnDndKey.getState(view.state);
|
|
1451
|
+
view.dom.classList.remove("lumir-col-dnd-active");
|
|
1452
|
+
if (!st || st.side === null || st.targetPos === null) {
|
|
1453
|
+
return false;
|
|
1454
|
+
}
|
|
1455
|
+
const draggedId = draggedBlockId(view);
|
|
1456
|
+
const targetNode = view.state.doc.nodeAt(st.targetPos);
|
|
1457
|
+
const targetId = targetNode?.attrs?.id;
|
|
1458
|
+
view.dispatch(view.state.tr.setMeta(columnDndKey, CLEARED));
|
|
1459
|
+
if (!draggedId || !targetId) {
|
|
1460
|
+
return false;
|
|
1461
|
+
}
|
|
1462
|
+
const editor = view.__lumirEditor;
|
|
1463
|
+
if (!editor) {
|
|
1464
|
+
return false;
|
|
1465
|
+
}
|
|
1466
|
+
const ok = mergeBlocksIntoColumns(editor, draggedId, targetId, st.side);
|
|
1467
|
+
return ok;
|
|
1468
|
+
},
|
|
1469
|
+
decorations: (state) => {
|
|
1470
|
+
const st = columnDndKey.getState(state);
|
|
1471
|
+
if (!st || st.side === null || st.targetPos === null) {
|
|
1472
|
+
return null;
|
|
1473
|
+
}
|
|
1474
|
+
const node = state.doc.nodeAt(st.targetPos);
|
|
1475
|
+
if (!node) {
|
|
1476
|
+
return null;
|
|
1477
|
+
}
|
|
1478
|
+
return import_prosemirror_view.DecorationSet.create(state.doc, [
|
|
1479
|
+
import_prosemirror_view.Decoration.node(st.targetPos, st.targetPos + node.nodeSize, {
|
|
1480
|
+
class: st.side === "left" ? "lumir-col-drop-left" : "lumir-col-drop-right"
|
|
1481
|
+
})
|
|
1482
|
+
]);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
// src/blocks/columns/ColumnList.ts
|
|
1489
|
+
var ColumnList = (0, import_core.createStronglyTypedTiptapNode)({
|
|
1490
|
+
name: "columnList",
|
|
1491
|
+
group: "childContainer bnBlock blockGroupChild",
|
|
1492
|
+
content: "column column+",
|
|
1493
|
+
parseHTML() {
|
|
1494
|
+
return [{ tag: 'div[data-node-type="columnList"]' }];
|
|
1495
|
+
},
|
|
1496
|
+
renderHTML({ HTMLAttributes }) {
|
|
1497
|
+
const dom = document.createElement("div");
|
|
1498
|
+
dom.className = "bn-column-list";
|
|
1499
|
+
dom.setAttribute("data-node-type", "columnList");
|
|
1500
|
+
for (const [attribute, value] of Object.entries(HTMLAttributes)) {
|
|
1501
|
+
if (attribute !== "class") {
|
|
1502
|
+
dom.setAttribute(attribute, value);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
return { dom, contentDOM: dom };
|
|
1506
|
+
},
|
|
1507
|
+
// columnNormalization: 빈 컬럼/1단 columnList 자동 복구(unwrap).
|
|
1508
|
+
// columnDnd: 블록을 다른 블록 좌/우로 드롭하면 2단 컬럼 생성.
|
|
1509
|
+
addProseMirrorPlugins() {
|
|
1510
|
+
return [columnNormalization(), columnDnd()];
|
|
1511
|
+
}
|
|
1512
|
+
});
|
|
1513
|
+
|
|
1514
|
+
// src/blocks/columns/Column.ts
|
|
1515
|
+
var import_core2 = require("@blocknote/core");
|
|
1516
|
+
var Column = (0, import_core2.createStronglyTypedTiptapNode)({
|
|
1517
|
+
name: "column",
|
|
1518
|
+
group: "bnBlock childContainer",
|
|
1519
|
+
content: "blockContainer+",
|
|
1520
|
+
addAttributes() {
|
|
1521
|
+
return {
|
|
1522
|
+
width: {
|
|
1523
|
+
default: 1,
|
|
1524
|
+
parseHTML: (element) => {
|
|
1525
|
+
const w = parseFloat(element.getAttribute("data-column-width") || "");
|
|
1526
|
+
return Number.isFinite(w) && w > 0 ? w : 1;
|
|
1527
|
+
},
|
|
1528
|
+
renderHTML: (attributes) => {
|
|
1529
|
+
if (!attributes.width || attributes.width === 1) {
|
|
1530
|
+
return {};
|
|
1531
|
+
}
|
|
1532
|
+
return { "data-column-width": String(attributes.width) };
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
};
|
|
1536
|
+
},
|
|
1537
|
+
parseHTML() {
|
|
1538
|
+
return [{ tag: 'div[data-node-type="column"]' }];
|
|
1539
|
+
},
|
|
1540
|
+
renderHTML({ HTMLAttributes }) {
|
|
1541
|
+
const dom = document.createElement("div");
|
|
1542
|
+
dom.className = "bn-column";
|
|
1543
|
+
dom.setAttribute("data-node-type", "column");
|
|
1544
|
+
for (const [attribute, value] of Object.entries(HTMLAttributes)) {
|
|
1545
|
+
if (attribute !== "class") {
|
|
1546
|
+
dom.setAttribute(attribute, value);
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
return { dom, contentDOM: dom };
|
|
1550
|
+
}
|
|
1551
|
+
});
|
|
1552
|
+
|
|
1553
|
+
// src/styles/FontSizeStyle.tsx
|
|
1554
|
+
var import_react5 = require("@blocknote/react");
|
|
1246
1555
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1556
|
+
var FontSize = (0, import_react5.createReactStyleSpec)(
|
|
1557
|
+
{
|
|
1558
|
+
type: "fontSize",
|
|
1559
|
+
propSchema: "string"
|
|
1560
|
+
},
|
|
1561
|
+
{
|
|
1562
|
+
render: (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontSize: props.value }, ref: props.contentRef })
|
|
1563
|
+
}
|
|
1564
|
+
);
|
|
1565
|
+
var FONT_SIZE_PRESETS = [
|
|
1566
|
+
"10px",
|
|
1567
|
+
"12px",
|
|
1568
|
+
"14px",
|
|
1569
|
+
"16px",
|
|
1570
|
+
"18px",
|
|
1571
|
+
"20px",
|
|
1572
|
+
"24px",
|
|
1573
|
+
"28px"
|
|
1574
|
+
];
|
|
1575
|
+
|
|
1576
|
+
// src/blocks/HtmlPreview.tsx
|
|
1577
|
+
var import_react7 = require("react");
|
|
1578
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1247
1579
|
var MIN_HEIGHT = 100;
|
|
1248
1580
|
var MAX_HEIGHT = 1200;
|
|
1249
1581
|
var ensureCharset = (html) => {
|
|
@@ -1281,7 +1613,7 @@ var createSecureBlobUrl = (htmlContent) => {
|
|
|
1281
1613
|
});
|
|
1282
1614
|
return URL.createObjectURL(blob);
|
|
1283
1615
|
};
|
|
1284
|
-
var HtmlPreviewBlock = (0,
|
|
1616
|
+
var HtmlPreviewBlock = (0, import_react6.createReactBlockSpec)(
|
|
1285
1617
|
{
|
|
1286
1618
|
type: "htmlPreview",
|
|
1287
1619
|
propSchema: {
|
|
@@ -1299,15 +1631,15 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1299
1631
|
},
|
|
1300
1632
|
{
|
|
1301
1633
|
render: (props) => {
|
|
1302
|
-
const [isExpanded, setIsExpanded] = (0,
|
|
1303
|
-
const [isResizing, setIsResizing] = (0,
|
|
1304
|
-
const [blobUrl, setBlobUrl] = (0,
|
|
1305
|
-
const containerRef = (0,
|
|
1634
|
+
const [isExpanded, setIsExpanded] = (0, import_react7.useState)(true);
|
|
1635
|
+
const [isResizing, setIsResizing] = (0, import_react7.useState)(false);
|
|
1636
|
+
const [blobUrl, setBlobUrl] = (0, import_react7.useState)("");
|
|
1637
|
+
const containerRef = (0, import_react7.useRef)(null);
|
|
1306
1638
|
const htmlContent = props.block.props.htmlContent || "";
|
|
1307
1639
|
const fileName = props.block.props.fileName || "HTML Document";
|
|
1308
1640
|
const savedHeight = props.block.props.height || "400px";
|
|
1309
1641
|
const currentHeight = parseInt(savedHeight, 10) || 400;
|
|
1310
|
-
(0,
|
|
1642
|
+
(0, import_react7.useEffect)(() => {
|
|
1311
1643
|
if (htmlContent) {
|
|
1312
1644
|
const url = createSecureBlobUrl(htmlContent);
|
|
1313
1645
|
setBlobUrl(url);
|
|
@@ -1316,14 +1648,14 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1316
1648
|
};
|
|
1317
1649
|
}
|
|
1318
1650
|
}, [htmlContent]);
|
|
1319
|
-
const handleResizeStart = (0,
|
|
1651
|
+
const handleResizeStart = (0, import_react7.useCallback)(
|
|
1320
1652
|
(e) => {
|
|
1321
1653
|
e.preventDefault();
|
|
1322
1654
|
e.stopPropagation();
|
|
1323
1655
|
setIsResizing(true);
|
|
1324
1656
|
const startY = e.clientY;
|
|
1325
1657
|
const startHeight = currentHeight;
|
|
1326
|
-
const
|
|
1658
|
+
const handleMouseMove2 = (moveEvent) => {
|
|
1327
1659
|
const deltaY = moveEvent.clientY - startY;
|
|
1328
1660
|
const newHeight = Math.min(
|
|
1329
1661
|
MAX_HEIGHT,
|
|
@@ -1335,15 +1667,15 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1335
1667
|
};
|
|
1336
1668
|
const handleMouseUp = () => {
|
|
1337
1669
|
setIsResizing(false);
|
|
1338
|
-
document.removeEventListener("mousemove",
|
|
1670
|
+
document.removeEventListener("mousemove", handleMouseMove2);
|
|
1339
1671
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
1340
1672
|
};
|
|
1341
|
-
document.addEventListener("mousemove",
|
|
1673
|
+
document.addEventListener("mousemove", handleMouseMove2);
|
|
1342
1674
|
document.addEventListener("mouseup", handleMouseUp);
|
|
1343
1675
|
},
|
|
1344
1676
|
[currentHeight, props.editor, props.block]
|
|
1345
1677
|
);
|
|
1346
|
-
const handleExport = (0,
|
|
1678
|
+
const handleExport = (0, import_react7.useCallback)(
|
|
1347
1679
|
(e) => {
|
|
1348
1680
|
e.stopPropagation();
|
|
1349
1681
|
const safeFileName = sanitizeFileName(fileName);
|
|
@@ -1364,7 +1696,7 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1364
1696
|
},
|
|
1365
1697
|
[htmlContent, fileName]
|
|
1366
1698
|
);
|
|
1367
|
-
const handleOpenNewWindow = (0,
|
|
1699
|
+
const handleOpenNewWindow = (0, import_react7.useCallback)(
|
|
1368
1700
|
(e) => {
|
|
1369
1701
|
e.stopPropagation();
|
|
1370
1702
|
if (typeof window === "undefined") return;
|
|
@@ -1378,7 +1710,7 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1378
1710
|
},
|
|
1379
1711
|
[htmlContent]
|
|
1380
1712
|
);
|
|
1381
|
-
return /* @__PURE__ */ (0,
|
|
1713
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1382
1714
|
"div",
|
|
1383
1715
|
{
|
|
1384
1716
|
ref: containerRef,
|
|
@@ -1394,7 +1726,7 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1394
1726
|
boxShadow: "none"
|
|
1395
1727
|
},
|
|
1396
1728
|
children: [
|
|
1397
|
-
/* @__PURE__ */ (0,
|
|
1729
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1398
1730
|
"div",
|
|
1399
1731
|
{
|
|
1400
1732
|
style: {
|
|
@@ -1406,7 +1738,7 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1406
1738
|
borderBottom: isExpanded ? "1px solid #e0e0e0" : "none"
|
|
1407
1739
|
},
|
|
1408
1740
|
children: [
|
|
1409
|
-
/* @__PURE__ */ (0,
|
|
1741
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1410
1742
|
"div",
|
|
1411
1743
|
{
|
|
1412
1744
|
style: {
|
|
@@ -1418,7 +1750,7 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1418
1750
|
},
|
|
1419
1751
|
onClick: () => setIsExpanded(!isExpanded),
|
|
1420
1752
|
children: [
|
|
1421
|
-
/* @__PURE__ */ (0,
|
|
1753
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1422
1754
|
"svg",
|
|
1423
1755
|
{
|
|
1424
1756
|
width: "16",
|
|
@@ -1433,15 +1765,15 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1433
1765
|
transform: isExpanded ? "rotate(180deg)" : "rotate(0deg)",
|
|
1434
1766
|
transition: "transform 0.2s"
|
|
1435
1767
|
},
|
|
1436
|
-
children: /* @__PURE__ */ (0,
|
|
1768
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("polyline", { points: "6 9 12 15 18 9" })
|
|
1437
1769
|
}
|
|
1438
1770
|
),
|
|
1439
|
-
/* @__PURE__ */ (0,
|
|
1771
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontWeight: 500, fontSize: "14px" }, children: fileName })
|
|
1440
1772
|
]
|
|
1441
1773
|
}
|
|
1442
1774
|
),
|
|
1443
|
-
/* @__PURE__ */ (0,
|
|
1444
|
-
/* @__PURE__ */ (0,
|
|
1775
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
|
|
1776
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1445
1777
|
"button",
|
|
1446
1778
|
{
|
|
1447
1779
|
onClick: handleOpenNewWindow,
|
|
@@ -1464,7 +1796,7 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1464
1796
|
onMouseLeave: (e) => {
|
|
1465
1797
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
1466
1798
|
},
|
|
1467
|
-
children: /* @__PURE__ */ (0,
|
|
1799
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1468
1800
|
"svg",
|
|
1469
1801
|
{
|
|
1470
1802
|
width: "16",
|
|
@@ -1476,15 +1808,15 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1476
1808
|
strokeLinecap: "round",
|
|
1477
1809
|
strokeLinejoin: "round",
|
|
1478
1810
|
children: [
|
|
1479
|
-
/* @__PURE__ */ (0,
|
|
1480
|
-
/* @__PURE__ */ (0,
|
|
1481
|
-
/* @__PURE__ */ (0,
|
|
1811
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
|
|
1812
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("polyline", { points: "15 3 21 3 21 9" }),
|
|
1813
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
|
|
1482
1814
|
]
|
|
1483
1815
|
}
|
|
1484
1816
|
)
|
|
1485
1817
|
}
|
|
1486
1818
|
),
|
|
1487
|
-
/* @__PURE__ */ (0,
|
|
1819
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1488
1820
|
"button",
|
|
1489
1821
|
{
|
|
1490
1822
|
onClick: handleExport,
|
|
@@ -1507,7 +1839,7 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1507
1839
|
onMouseLeave: (e) => {
|
|
1508
1840
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
1509
1841
|
},
|
|
1510
|
-
children: /* @__PURE__ */ (0,
|
|
1842
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1511
1843
|
"svg",
|
|
1512
1844
|
{
|
|
1513
1845
|
width: "16",
|
|
@@ -1519,9 +1851,9 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1519
1851
|
strokeLinecap: "round",
|
|
1520
1852
|
strokeLinejoin: "round",
|
|
1521
1853
|
children: [
|
|
1522
|
-
/* @__PURE__ */ (0,
|
|
1523
|
-
/* @__PURE__ */ (0,
|
|
1524
|
-
/* @__PURE__ */ (0,
|
|
1854
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
1855
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("polyline", { points: "7 10 12 15 17 10" }),
|
|
1856
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
|
|
1525
1857
|
]
|
|
1526
1858
|
}
|
|
1527
1859
|
)
|
|
@@ -1531,7 +1863,7 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1531
1863
|
]
|
|
1532
1864
|
}
|
|
1533
1865
|
),
|
|
1534
|
-
isExpanded && /* @__PURE__ */ (0,
|
|
1866
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1535
1867
|
"div",
|
|
1536
1868
|
{
|
|
1537
1869
|
style: {
|
|
@@ -1540,7 +1872,7 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1540
1872
|
position: "relative"
|
|
1541
1873
|
},
|
|
1542
1874
|
children: [
|
|
1543
|
-
/* @__PURE__ */ (0,
|
|
1875
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1544
1876
|
"iframe",
|
|
1545
1877
|
{
|
|
1546
1878
|
src: blobUrl || "about:blank",
|
|
@@ -1557,7 +1889,7 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1557
1889
|
loading: "lazy"
|
|
1558
1890
|
}
|
|
1559
1891
|
),
|
|
1560
|
-
/* @__PURE__ */ (0,
|
|
1892
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1561
1893
|
"div",
|
|
1562
1894
|
{
|
|
1563
1895
|
onMouseDown: handleResizeStart,
|
|
@@ -1582,7 +1914,7 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1582
1914
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
1583
1915
|
}
|
|
1584
1916
|
},
|
|
1585
|
-
children: /* @__PURE__ */ (0,
|
|
1917
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1586
1918
|
"div",
|
|
1587
1919
|
{
|
|
1588
1920
|
style: {
|
|
@@ -1604,72 +1936,83 @@ var HtmlPreviewBlock = (0, import_react5.createReactBlockSpec)(
|
|
|
1604
1936
|
}
|
|
1605
1937
|
}
|
|
1606
1938
|
);
|
|
1607
|
-
var
|
|
1939
|
+
var ColumnListBlock = (0, import_core3.createBlockSpecFromStronglyTypedTiptapNode)(
|
|
1940
|
+
ColumnList,
|
|
1941
|
+
{}
|
|
1942
|
+
);
|
|
1943
|
+
var ColumnBlock = (0, import_core3.createBlockSpecFromStronglyTypedTiptapNode)(Column, {});
|
|
1944
|
+
var schema = import_core3.BlockNoteSchema.create({
|
|
1608
1945
|
blockSpecs: {
|
|
1609
|
-
...
|
|
1946
|
+
...import_core3.defaultBlockSpecs,
|
|
1610
1947
|
htmlPreview: HtmlPreviewBlock,
|
|
1611
1948
|
linkPreview: LinkPreviewBlock,
|
|
1612
|
-
video: VideoBlock
|
|
1949
|
+
video: VideoBlock,
|
|
1950
|
+
columnList: ColumnListBlock,
|
|
1951
|
+
column: ColumnBlock
|
|
1613
1952
|
},
|
|
1614
|
-
inlineContentSpecs:
|
|
1615
|
-
styleSpecs:
|
|
1953
|
+
inlineContentSpecs: import_core3.defaultInlineContentSpecs,
|
|
1954
|
+
styleSpecs: {
|
|
1955
|
+
...import_core3.defaultStyleSpecs,
|
|
1956
|
+
// 인라인 글자 크기. 저장 JSON 직렬화는 형제 키 방식(font-size-serialization.ts) 사용.
|
|
1957
|
+
fontSize: FontSize
|
|
1958
|
+
}
|
|
1616
1959
|
});
|
|
1617
1960
|
|
|
1618
1961
|
// src/components/FloatingMenu/index.tsx
|
|
1619
|
-
var
|
|
1962
|
+
var import_react19 = require("react");
|
|
1620
1963
|
|
|
1621
1964
|
// src/components/FloatingMenu/Icons.tsx
|
|
1622
|
-
var
|
|
1965
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1623
1966
|
var Icons = {
|
|
1624
|
-
undo: /* @__PURE__ */ (0,
|
|
1625
|
-
redo: /* @__PURE__ */ (0,
|
|
1626
|
-
bold: /* @__PURE__ */ (0,
|
|
1627
|
-
italic: /* @__PURE__ */ (0,
|
|
1628
|
-
underline: /* @__PURE__ */ (0,
|
|
1629
|
-
strikethrough: /* @__PURE__ */ (0,
|
|
1630
|
-
alignLeft: /* @__PURE__ */ (0,
|
|
1631
|
-
alignCenter: /* @__PURE__ */ (0,
|
|
1632
|
-
alignRight: /* @__PURE__ */ (0,
|
|
1633
|
-
bulletList: /* @__PURE__ */ (0,
|
|
1634
|
-
numberedList: /* @__PURE__ */ (0,
|
|
1635
|
-
image: /* @__PURE__ */ (0,
|
|
1636
|
-
expandMore: /* @__PURE__ */ (0,
|
|
1637
|
-
textColor: /* @__PURE__ */ (0,
|
|
1638
|
-
bgColor: /* @__PURE__ */ (0,
|
|
1639
|
-
/* @__PURE__ */ (0,
|
|
1640
|
-
/* @__PURE__ */ (0,
|
|
1967
|
+
undo: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z" }) }),
|
|
1968
|
+
redo: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z" }) }),
|
|
1969
|
+
bold: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z" }) }),
|
|
1970
|
+
italic: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z" }) }),
|
|
1971
|
+
underline: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z" }) }),
|
|
1972
|
+
strikethrough: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z" }) }),
|
|
1973
|
+
alignLeft: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z" }) }),
|
|
1974
|
+
alignCenter: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z" }) }),
|
|
1975
|
+
alignRight: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z" }) }),
|
|
1976
|
+
bulletList: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z" }) }),
|
|
1977
|
+
numberedList: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z" }) }),
|
|
1978
|
+
image: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z" }) }),
|
|
1979
|
+
expandMore: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "18", height: "18", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z" }) }),
|
|
1980
|
+
textColor: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2zm-1.38 9L12 5.67 14.38 12H9.62z" }) }),
|
|
1981
|
+
bgColor: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: [
|
|
1982
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M16.56 8.94L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.59-.59 1.54 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.58.59-1.53 0-2.12zM5.21 10L10 5.21 14.79 10H5.21zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5z" }),
|
|
1983
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { fillOpacity: ".36", d: "M0 20h24v4H0z" })
|
|
1641
1984
|
] }),
|
|
1642
|
-
link: /* @__PURE__ */ (0,
|
|
1643
|
-
chevronRight: /* @__PURE__ */ (0,
|
|
1644
|
-
chevronLeft: /* @__PURE__ */ (0,
|
|
1645
|
-
table: /* @__PURE__ */ (0,
|
|
1646
|
-
htmlFile: /* @__PURE__ */ (0,
|
|
1985
|
+
link: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z" }) }),
|
|
1986
|
+
chevronRight: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" }) }),
|
|
1987
|
+
chevronLeft: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }) }),
|
|
1988
|
+
table: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M20 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM10 17H5v-2h5v2zm0-4H5v-2h5v2zm0-4H5V7h5v2zm9 8h-7v-2h7v2zm0-4h-7v-2h7v2zm0-4h-7V7h7v2z" }) }),
|
|
1989
|
+
htmlFile: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 2v5h5l-5-5zm-4 14H7v-1h2v1zm0-2H7v-1h2v1zm-2-2h2v1H7v-1zm4 4h-2v-1h2v1zm0-2h-2v-1h2v1zm0-2h-2v-1h2v1zm6 4h-4v-1h4v1zm0-2h-4v-1h4v1zm0-2h-4v-1h4v1z" }) })
|
|
1647
1990
|
};
|
|
1648
1991
|
var BlockTypeIcons = {
|
|
1649
|
-
paragraph: /* @__PURE__ */ (0,
|
|
1650
|
-
h1: /* @__PURE__ */ (0,
|
|
1651
|
-
h2: /* @__PURE__ */ (0,
|
|
1652
|
-
h3: /* @__PURE__ */ (0,
|
|
1653
|
-
h4: /* @__PURE__ */ (0,
|
|
1654
|
-
h5: /* @__PURE__ */ (0,
|
|
1655
|
-
h6: /* @__PURE__ */ (0,
|
|
1656
|
-
toggleH1: /* @__PURE__ */ (0,
|
|
1657
|
-
/* @__PURE__ */ (0,
|
|
1658
|
-
/* @__PURE__ */ (0,
|
|
1992
|
+
paragraph: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M5 5h14v2H5zM5 11h14v2H5zM5 17h10v2H5z" }) }),
|
|
1993
|
+
h1: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "lumir-block-icon-text", children: "H1" }),
|
|
1994
|
+
h2: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "lumir-block-icon-text", children: "H2" }),
|
|
1995
|
+
h3: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "lumir-block-icon-text", children: "H3" }),
|
|
1996
|
+
h4: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "lumir-block-icon-text", children: "H4" }),
|
|
1997
|
+
h5: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "lumir-block-icon-text", children: "H5" }),
|
|
1998
|
+
h6: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "lumir-block-icon-text", children: "H6" }),
|
|
1999
|
+
toggleH1: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "lumir-block-icon-toggle", children: [
|
|
2000
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "8", height: "8", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M8 5v14l11-7z" }) }),
|
|
2001
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "H1" })
|
|
1659
2002
|
] }),
|
|
1660
|
-
toggleH2: /* @__PURE__ */ (0,
|
|
1661
|
-
/* @__PURE__ */ (0,
|
|
1662
|
-
/* @__PURE__ */ (0,
|
|
2003
|
+
toggleH2: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "lumir-block-icon-toggle", children: [
|
|
2004
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "8", height: "8", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M8 5v14l11-7z" }) }),
|
|
2005
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "H2" })
|
|
1663
2006
|
] }),
|
|
1664
|
-
toggleH3: /* @__PURE__ */ (0,
|
|
1665
|
-
/* @__PURE__ */ (0,
|
|
1666
|
-
/* @__PURE__ */ (0,
|
|
2007
|
+
toggleH3: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "lumir-block-icon-toggle", children: [
|
|
2008
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "8", height: "8", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M8 5v14l11-7z" }) }),
|
|
2009
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "H3" })
|
|
1667
2010
|
] }),
|
|
1668
|
-
quote: /* @__PURE__ */ (0,
|
|
1669
|
-
codeBlock: /* @__PURE__ */ (0,
|
|
1670
|
-
toggleList: /* @__PURE__ */ (0,
|
|
1671
|
-
/* @__PURE__ */ (0,
|
|
1672
|
-
/* @__PURE__ */ (0,
|
|
2011
|
+
quote: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z" }) }),
|
|
2012
|
+
codeBlock: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z" }) }),
|
|
2013
|
+
toggleList: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: [
|
|
2014
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M10 6h10v2H10zM10 11h10v2H10zM10 16h10v2H10z" }),
|
|
2015
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1673
2016
|
"path",
|
|
1674
2017
|
{
|
|
1675
2018
|
d: "M4 8l4 4-4 4",
|
|
@@ -1681,15 +2024,15 @@ var BlockTypeIcons = {
|
|
|
1681
2024
|
}
|
|
1682
2025
|
)
|
|
1683
2026
|
] }),
|
|
1684
|
-
bulletList: /* @__PURE__ */ (0,
|
|
1685
|
-
/* @__PURE__ */ (0,
|
|
1686
|
-
/* @__PURE__ */ (0,
|
|
1687
|
-
/* @__PURE__ */ (0,
|
|
1688
|
-
/* @__PURE__ */ (0,
|
|
2027
|
+
bulletList: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: [
|
|
2028
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: "4", cy: "6", r: "1.5" }),
|
|
2029
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: "4", cy: "12", r: "1.5" }),
|
|
2030
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: "4", cy: "18", r: "1.5" }),
|
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M8 5h12v2H8zM8 11h12v2H8zM8 17h12v2H8z" })
|
|
1689
2032
|
] }),
|
|
1690
|
-
numberedList: /* @__PURE__ */ (0,
|
|
1691
|
-
checkList: /* @__PURE__ */ (0,
|
|
1692
|
-
/* @__PURE__ */ (0,
|
|
2033
|
+
numberedList: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z" }) }),
|
|
2034
|
+
checkList: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: [
|
|
2035
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1693
2036
|
"rect",
|
|
1694
2037
|
{
|
|
1695
2038
|
x: "3",
|
|
@@ -1702,7 +2045,7 @@ var BlockTypeIcons = {
|
|
|
1702
2045
|
strokeWidth: "1.5"
|
|
1703
2046
|
}
|
|
1704
2047
|
),
|
|
1705
|
-
/* @__PURE__ */ (0,
|
|
2048
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1706
2049
|
"path",
|
|
1707
2050
|
{
|
|
1708
2051
|
d: "M4.5 7l1.5 1.5 3-3",
|
|
@@ -1713,8 +2056,8 @@ var BlockTypeIcons = {
|
|
|
1713
2056
|
strokeLinejoin: "round"
|
|
1714
2057
|
}
|
|
1715
2058
|
),
|
|
1716
|
-
/* @__PURE__ */ (0,
|
|
1717
|
-
/* @__PURE__ */ (0,
|
|
2059
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M12 6h8v2h-8z" }),
|
|
2060
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1718
2061
|
"rect",
|
|
1719
2062
|
{
|
|
1720
2063
|
x: "3",
|
|
@@ -1727,53 +2070,53 @@ var BlockTypeIcons = {
|
|
|
1727
2070
|
strokeWidth: "1.5"
|
|
1728
2071
|
}
|
|
1729
2072
|
),
|
|
1730
|
-
/* @__PURE__ */ (0,
|
|
2073
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M12 16h8v2h-8z" })
|
|
1731
2074
|
] })
|
|
1732
2075
|
};
|
|
1733
2076
|
|
|
1734
2077
|
// src/components/FloatingMenu/components/ToolbarDivider.tsx
|
|
1735
|
-
var
|
|
1736
|
-
var ToolbarDivider = () => /* @__PURE__ */ (0,
|
|
2078
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2079
|
+
var ToolbarDivider = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "lumir-toolbar-divider" });
|
|
1737
2080
|
|
|
1738
2081
|
// src/components/FloatingMenu/components/UndoRedoButtons.tsx
|
|
1739
|
-
var
|
|
1740
|
-
var
|
|
2082
|
+
var import_react8 = require("react");
|
|
2083
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1741
2084
|
var UndoRedoButtons = ({ editor }) => {
|
|
1742
|
-
const handleUndo = (0,
|
|
2085
|
+
const handleUndo = (0, import_react8.useCallback)(() => {
|
|
1743
2086
|
try {
|
|
1744
2087
|
editor?.undo?.();
|
|
1745
2088
|
} catch (err) {
|
|
1746
2089
|
console.error("Undo failed:", err);
|
|
1747
2090
|
}
|
|
1748
2091
|
}, [editor]);
|
|
1749
|
-
const handleRedo = (0,
|
|
2092
|
+
const handleRedo = (0, import_react8.useCallback)(() => {
|
|
1750
2093
|
try {
|
|
1751
2094
|
editor?.redo?.();
|
|
1752
2095
|
} catch (err) {
|
|
1753
2096
|
console.error("Redo failed:", err);
|
|
1754
2097
|
}
|
|
1755
2098
|
}, [editor]);
|
|
1756
|
-
const
|
|
2099
|
+
const handleMouseDown2 = (0, import_react8.useCallback)((e) => {
|
|
1757
2100
|
e.preventDefault();
|
|
1758
2101
|
}, []);
|
|
1759
|
-
return /* @__PURE__ */ (0,
|
|
1760
|
-
/* @__PURE__ */ (0,
|
|
2102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
2103
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1761
2104
|
"button",
|
|
1762
2105
|
{
|
|
1763
2106
|
className: "lumir-toolbar-btn",
|
|
1764
2107
|
onClick: handleUndo,
|
|
1765
|
-
onMouseDown:
|
|
2108
|
+
onMouseDown: handleMouseDown2,
|
|
1766
2109
|
title: "\uC2E4\uD589 \uCDE8\uC18C",
|
|
1767
2110
|
type: "button",
|
|
1768
2111
|
children: Icons.undo
|
|
1769
2112
|
}
|
|
1770
2113
|
),
|
|
1771
|
-
/* @__PURE__ */ (0,
|
|
2114
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1772
2115
|
"button",
|
|
1773
2116
|
{
|
|
1774
2117
|
className: "lumir-toolbar-btn",
|
|
1775
2118
|
onClick: handleRedo,
|
|
1776
|
-
onMouseDown:
|
|
2119
|
+
onMouseDown: handleMouseDown2,
|
|
1777
2120
|
title: "\uB2E4\uC2DC \uC2E4\uD589",
|
|
1778
2121
|
type: "button",
|
|
1779
2122
|
children: Icons.redo
|
|
@@ -1783,8 +2126,8 @@ var UndoRedoButtons = ({ editor }) => {
|
|
|
1783
2126
|
};
|
|
1784
2127
|
|
|
1785
2128
|
// src/components/FloatingMenu/components/TextStyleButton.tsx
|
|
1786
|
-
var
|
|
1787
|
-
var
|
|
2129
|
+
var import_react9 = require("react");
|
|
2130
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1788
2131
|
var iconMap = {
|
|
1789
2132
|
bold: Icons.bold,
|
|
1790
2133
|
italic: Icons.italic,
|
|
@@ -1810,22 +2153,22 @@ var TextStyleButton = ({
|
|
|
1810
2153
|
}
|
|
1811
2154
|
};
|
|
1812
2155
|
const isActive = getIsActive();
|
|
1813
|
-
const handleClick = (0,
|
|
2156
|
+
const handleClick = (0, import_react9.useCallback)(() => {
|
|
1814
2157
|
try {
|
|
1815
2158
|
editor?.toggleStyles?.({ [style]: true });
|
|
1816
2159
|
} catch (err) {
|
|
1817
2160
|
console.error(`Toggle ${style} failed:`, err);
|
|
1818
2161
|
}
|
|
1819
2162
|
}, [editor, style]);
|
|
1820
|
-
const
|
|
2163
|
+
const handleMouseDown2 = (0, import_react9.useCallback)((e) => {
|
|
1821
2164
|
e.preventDefault();
|
|
1822
2165
|
}, []);
|
|
1823
|
-
return /* @__PURE__ */ (0,
|
|
2166
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1824
2167
|
"button",
|
|
1825
2168
|
{
|
|
1826
2169
|
className: cn("lumir-toolbar-btn", isActive && "is-active"),
|
|
1827
2170
|
onClick: handleClick,
|
|
1828
|
-
onMouseDown:
|
|
2171
|
+
onMouseDown: handleMouseDown2,
|
|
1829
2172
|
title: titleMap[style],
|
|
1830
2173
|
type: "button",
|
|
1831
2174
|
children: iconMap[style]
|
|
@@ -1834,7 +2177,7 @@ var TextStyleButton = ({
|
|
|
1834
2177
|
};
|
|
1835
2178
|
|
|
1836
2179
|
// src/components/FloatingMenu/components/AlignButton.tsx
|
|
1837
|
-
var
|
|
2180
|
+
var import_react10 = require("react");
|
|
1838
2181
|
|
|
1839
2182
|
// src/utils/prosemirror-table-utils.ts
|
|
1840
2183
|
function getSelectedCellPositions(editor) {
|
|
@@ -1893,9 +2236,44 @@ function getFirstSelectedCellAttr(editor, attr) {
|
|
|
1893
2236
|
const node = tiptap.state.doc.nodeAt(positions[0]);
|
|
1894
2237
|
return node?.attrs?.[attr];
|
|
1895
2238
|
}
|
|
2239
|
+
function findTableNodePos(tiptap, blockId) {
|
|
2240
|
+
let tablePos = -1;
|
|
2241
|
+
tiptap.state.doc.descendants((node, pos) => {
|
|
2242
|
+
if (tablePos !== -1) return false;
|
|
2243
|
+
if (node.type.name === "blockContainer" && node.attrs?.id === blockId && node.firstChild?.type.name === "table") {
|
|
2244
|
+
tablePos = pos + 1;
|
|
2245
|
+
return false;
|
|
2246
|
+
}
|
|
2247
|
+
return void 0;
|
|
2248
|
+
});
|
|
2249
|
+
return tablePos;
|
|
2250
|
+
}
|
|
2251
|
+
function setTableAlignment(editor, blockId, alignment) {
|
|
2252
|
+
const tiptap = editor?._tiptapEditor;
|
|
2253
|
+
if (!tiptap || !blockId) return false;
|
|
2254
|
+
const tablePos = findTableNodePos(tiptap, blockId);
|
|
2255
|
+
if (tablePos < 0) return false;
|
|
2256
|
+
const node = tiptap.state.doc.nodeAt(tablePos);
|
|
2257
|
+
if (!node || node.type.name !== "table") return false;
|
|
2258
|
+
tiptap.view?.dispatch(
|
|
2259
|
+
tiptap.state.tr.setNodeMarkup(tablePos, void 0, {
|
|
2260
|
+
...node.attrs,
|
|
2261
|
+
tableAlignment: alignment
|
|
2262
|
+
})
|
|
2263
|
+
);
|
|
2264
|
+
return true;
|
|
2265
|
+
}
|
|
2266
|
+
function getTableAlignment(editor, blockId) {
|
|
2267
|
+
const tiptap = editor?._tiptapEditor;
|
|
2268
|
+
if (!tiptap || !blockId) return "left";
|
|
2269
|
+
const tablePos = findTableNodePos(tiptap, blockId);
|
|
2270
|
+
if (tablePos < 0) return "left";
|
|
2271
|
+
const node = tiptap.state.doc.nodeAt(tablePos);
|
|
2272
|
+
return node?.attrs?.tableAlignment || "left";
|
|
2273
|
+
}
|
|
1896
2274
|
|
|
1897
2275
|
// src/components/FloatingMenu/components/AlignButton.tsx
|
|
1898
|
-
var
|
|
2276
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1899
2277
|
var iconMap2 = {
|
|
1900
2278
|
left: Icons.alignLeft,
|
|
1901
2279
|
center: Icons.alignCenter,
|
|
@@ -1922,7 +2300,7 @@ var AlignButton = ({
|
|
|
1922
2300
|
}
|
|
1923
2301
|
};
|
|
1924
2302
|
const isActive = getCurrentAlignment() === alignment;
|
|
1925
|
-
const handleClick = (0,
|
|
2303
|
+
const handleClick = (0, import_react10.useCallback)(() => {
|
|
1926
2304
|
try {
|
|
1927
2305
|
if (setSelectedCellsAttr(editor, "textAlignment", alignment)) {
|
|
1928
2306
|
return;
|
|
@@ -1935,15 +2313,15 @@ var AlignButton = ({
|
|
|
1935
2313
|
console.error(`Set alignment ${alignment} failed:`, err);
|
|
1936
2314
|
}
|
|
1937
2315
|
}, [editor, alignment]);
|
|
1938
|
-
const
|
|
2316
|
+
const handleMouseDown2 = (0, import_react10.useCallback)((e) => {
|
|
1939
2317
|
e.preventDefault();
|
|
1940
2318
|
}, []);
|
|
1941
|
-
return /* @__PURE__ */ (0,
|
|
2319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1942
2320
|
"button",
|
|
1943
2321
|
{
|
|
1944
2322
|
className: cn("lumir-toolbar-btn", isActive && "is-active"),
|
|
1945
2323
|
onClick: handleClick,
|
|
1946
|
-
onMouseDown:
|
|
2324
|
+
onMouseDown: handleMouseDown2,
|
|
1947
2325
|
title: titleMap2[alignment],
|
|
1948
2326
|
type: "button",
|
|
1949
2327
|
children: iconMap2[alignment]
|
|
@@ -1952,8 +2330,8 @@ var AlignButton = ({
|
|
|
1952
2330
|
};
|
|
1953
2331
|
|
|
1954
2332
|
// src/components/FloatingMenu/components/ListButton.tsx
|
|
1955
|
-
var
|
|
1956
|
-
var
|
|
2333
|
+
var import_react11 = require("react");
|
|
2334
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1957
2335
|
var iconMap3 = {
|
|
1958
2336
|
bullet: Icons.bulletList,
|
|
1959
2337
|
numbered: Icons.numberedList
|
|
@@ -1973,7 +2351,7 @@ var ListButton = ({ editor, type }) => {
|
|
|
1973
2351
|
}
|
|
1974
2352
|
};
|
|
1975
2353
|
const isActive = getIsActive();
|
|
1976
|
-
const handleClick = (0,
|
|
2354
|
+
const handleClick = (0, import_react11.useCallback)(() => {
|
|
1977
2355
|
try {
|
|
1978
2356
|
const block = editor?.getTextCursorPosition()?.block;
|
|
1979
2357
|
if (block && editor?.updateBlock) {
|
|
@@ -1985,15 +2363,15 @@ var ListButton = ({ editor, type }) => {
|
|
|
1985
2363
|
console.error(`List toggle failed:`, err);
|
|
1986
2364
|
}
|
|
1987
2365
|
}, [editor, type]);
|
|
1988
|
-
const
|
|
2366
|
+
const handleMouseDown2 = (0, import_react11.useCallback)((e) => {
|
|
1989
2367
|
e.preventDefault();
|
|
1990
2368
|
}, []);
|
|
1991
|
-
return /* @__PURE__ */ (0,
|
|
2369
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1992
2370
|
"button",
|
|
1993
2371
|
{
|
|
1994
2372
|
className: cn("lumir-toolbar-btn", isActive && "is-active"),
|
|
1995
2373
|
onClick: handleClick,
|
|
1996
|
-
onMouseDown:
|
|
2374
|
+
onMouseDown: handleMouseDown2,
|
|
1997
2375
|
title: titleMap3[type],
|
|
1998
2376
|
type: "button",
|
|
1999
2377
|
children: iconMap3[type]
|
|
@@ -2002,13 +2380,13 @@ var ListButton = ({ editor, type }) => {
|
|
|
2002
2380
|
};
|
|
2003
2381
|
|
|
2004
2382
|
// src/components/FloatingMenu/components/ImageButton.tsx
|
|
2005
|
-
var
|
|
2006
|
-
var
|
|
2383
|
+
var import_react12 = require("react");
|
|
2384
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2007
2385
|
var ImageButton = ({
|
|
2008
2386
|
editor,
|
|
2009
2387
|
onImageUpload
|
|
2010
2388
|
}) => {
|
|
2011
|
-
const handleClick = (0,
|
|
2389
|
+
const handleClick = (0, import_react12.useCallback)(() => {
|
|
2012
2390
|
if (onImageUpload) {
|
|
2013
2391
|
onImageUpload();
|
|
2014
2392
|
} else {
|
|
@@ -2033,15 +2411,15 @@ var ImageButton = ({
|
|
|
2033
2411
|
input.click();
|
|
2034
2412
|
}
|
|
2035
2413
|
}, [editor, onImageUpload]);
|
|
2036
|
-
const
|
|
2414
|
+
const handleMouseDown2 = (0, import_react12.useCallback)((e) => {
|
|
2037
2415
|
e.preventDefault();
|
|
2038
2416
|
}, []);
|
|
2039
|
-
return /* @__PURE__ */ (0,
|
|
2417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2040
2418
|
"button",
|
|
2041
2419
|
{
|
|
2042
2420
|
className: "lumir-toolbar-btn",
|
|
2043
2421
|
onClick: handleClick,
|
|
2044
|
-
onMouseDown:
|
|
2422
|
+
onMouseDown: handleMouseDown2,
|
|
2045
2423
|
title: "\uC774\uBBF8\uC9C0 \uC0BD\uC785",
|
|
2046
2424
|
type: "button",
|
|
2047
2425
|
children: Icons.image
|
|
@@ -2050,7 +2428,7 @@ var ImageButton = ({
|
|
|
2050
2428
|
};
|
|
2051
2429
|
|
|
2052
2430
|
// src/components/FloatingMenu/components/ColorButton.tsx
|
|
2053
|
-
var
|
|
2431
|
+
var import_react13 = require("react");
|
|
2054
2432
|
|
|
2055
2433
|
// src/constants/colors.ts
|
|
2056
2434
|
var TEXT_COLORS = [
|
|
@@ -2084,13 +2462,13 @@ var getHexFromColorValue = (value, type) => {
|
|
|
2084
2462
|
};
|
|
2085
2463
|
|
|
2086
2464
|
// src/components/FloatingMenu/components/ColorButton.tsx
|
|
2087
|
-
var
|
|
2465
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2088
2466
|
var ColorButton = ({ editor, type }) => {
|
|
2089
|
-
const [isOpen, setIsOpen] = (0,
|
|
2090
|
-
const [currentColor, setCurrentColor] = (0,
|
|
2091
|
-
const dropdownRef = (0,
|
|
2467
|
+
const [isOpen, setIsOpen] = (0, import_react13.useState)(false);
|
|
2468
|
+
const [currentColor, setCurrentColor] = (0, import_react13.useState)("default");
|
|
2469
|
+
const dropdownRef = (0, import_react13.useRef)(null);
|
|
2092
2470
|
const colors = type === "text" ? TEXT_COLORS : BACKGROUND_COLORS;
|
|
2093
|
-
const getCurrentColor = (0,
|
|
2471
|
+
const getCurrentColor = (0, import_react13.useCallback)(() => {
|
|
2094
2472
|
try {
|
|
2095
2473
|
if (isInTableCell(editor)) {
|
|
2096
2474
|
const attr = type === "text" ? "textColor" : "backgroundColor";
|
|
@@ -2106,13 +2484,13 @@ var ColorButton = ({ editor, type }) => {
|
|
|
2106
2484
|
}
|
|
2107
2485
|
return "default";
|
|
2108
2486
|
}, [editor, type]);
|
|
2109
|
-
(0,
|
|
2487
|
+
(0, import_react13.useEffect)(() => {
|
|
2110
2488
|
if (isOpen) {
|
|
2111
2489
|
const color = getCurrentColor();
|
|
2112
2490
|
setCurrentColor(color);
|
|
2113
2491
|
}
|
|
2114
2492
|
}, [isOpen, getCurrentColor]);
|
|
2115
|
-
(0,
|
|
2493
|
+
(0, import_react13.useEffect)(() => {
|
|
2116
2494
|
const handleClickOutside = (e) => {
|
|
2117
2495
|
if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
|
|
2118
2496
|
setIsOpen(false);
|
|
@@ -2121,7 +2499,7 @@ var ColorButton = ({ editor, type }) => {
|
|
|
2121
2499
|
document.addEventListener("mousedown", handleClickOutside);
|
|
2122
2500
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2123
2501
|
}, []);
|
|
2124
|
-
const handleColorSelect = (0,
|
|
2502
|
+
const handleColorSelect = (0, import_react13.useCallback)(
|
|
2125
2503
|
(color) => {
|
|
2126
2504
|
try {
|
|
2127
2505
|
if (!editor) return;
|
|
@@ -2140,21 +2518,21 @@ var ColorButton = ({ editor, type }) => {
|
|
|
2140
2518
|
},
|
|
2141
2519
|
[editor, type]
|
|
2142
2520
|
);
|
|
2143
|
-
const
|
|
2521
|
+
const handleMouseDown2 = (0, import_react13.useCallback)((e) => {
|
|
2144
2522
|
e.preventDefault();
|
|
2145
2523
|
}, []);
|
|
2146
|
-
return /* @__PURE__ */ (0,
|
|
2147
|
-
/* @__PURE__ */ (0,
|
|
2524
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "lumir-dropdown-wrapper", ref: dropdownRef, children: [
|
|
2525
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2148
2526
|
"button",
|
|
2149
2527
|
{
|
|
2150
2528
|
className: "lumir-toolbar-btn lumir-color-btn",
|
|
2151
2529
|
onClick: () => setIsOpen(!isOpen),
|
|
2152
|
-
onMouseDown:
|
|
2530
|
+
onMouseDown: handleMouseDown2,
|
|
2153
2531
|
title: type === "text" ? "\uD14D\uC2A4\uD2B8 \uC0C9\uC0C1" : "\uBC30\uACBD \uC0C9\uC0C1",
|
|
2154
2532
|
type: "button",
|
|
2155
2533
|
children: [
|
|
2156
2534
|
type === "text" ? Icons.textColor : Icons.bgColor,
|
|
2157
|
-
/* @__PURE__ */ (0,
|
|
2535
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2158
2536
|
"span",
|
|
2159
2537
|
{
|
|
2160
2538
|
className: "lumir-color-indicator",
|
|
@@ -2166,7 +2544,7 @@ var ColorButton = ({ editor, type }) => {
|
|
|
2166
2544
|
]
|
|
2167
2545
|
}
|
|
2168
2546
|
),
|
|
2169
|
-
isOpen && /* @__PURE__ */ (0,
|
|
2547
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "lumir-dropdown-menu lumir-color-menu", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "lumir-color-grid", children: colors.map((color) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2170
2548
|
"button",
|
|
2171
2549
|
{
|
|
2172
2550
|
className: cn(
|
|
@@ -2174,7 +2552,7 @@ var ColorButton = ({ editor, type }) => {
|
|
|
2174
2552
|
currentColor === color.value && "is-active"
|
|
2175
2553
|
),
|
|
2176
2554
|
onClick: () => handleColorSelect(color.value),
|
|
2177
|
-
onMouseDown:
|
|
2555
|
+
onMouseDown: handleMouseDown2,
|
|
2178
2556
|
title: color.name,
|
|
2179
2557
|
style: { backgroundColor: color.hex },
|
|
2180
2558
|
type: "button"
|
|
@@ -2184,9 +2562,101 @@ var ColorButton = ({ editor, type }) => {
|
|
|
2184
2562
|
] });
|
|
2185
2563
|
};
|
|
2186
2564
|
|
|
2565
|
+
// src/components/FloatingMenu/components/FontSizeButton.tsx
|
|
2566
|
+
var import_react14 = require("react");
|
|
2567
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2568
|
+
var DEFAULT_LABEL = "\uAE30\uBCF8";
|
|
2569
|
+
var toLabel = (size) => size.replace(/px$/, "");
|
|
2570
|
+
var FontSizeButton = ({ editor }) => {
|
|
2571
|
+
const [isOpen, setIsOpen] = (0, import_react14.useState)(false);
|
|
2572
|
+
const dropdownRef = (0, import_react14.useRef)(null);
|
|
2573
|
+
const getCurrentSize = () => {
|
|
2574
|
+
try {
|
|
2575
|
+
return editor?.getActiveStyles?.()?.fontSize || "";
|
|
2576
|
+
} catch {
|
|
2577
|
+
return "";
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
const currentSize = getCurrentSize();
|
|
2581
|
+
(0, import_react14.useEffect)(() => {
|
|
2582
|
+
const handleClickOutside = (e) => {
|
|
2583
|
+
if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
|
|
2584
|
+
setIsOpen(false);
|
|
2585
|
+
}
|
|
2586
|
+
};
|
|
2587
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
2588
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2589
|
+
}, []);
|
|
2590
|
+
const handleSizeSelect = (0, import_react14.useCallback)(
|
|
2591
|
+
(size) => {
|
|
2592
|
+
try {
|
|
2593
|
+
if (!editor) return;
|
|
2594
|
+
if (size === "") {
|
|
2595
|
+
editor.removeStyles?.({ fontSize: "" });
|
|
2596
|
+
} else {
|
|
2597
|
+
editor.addStyles?.({ fontSize: size });
|
|
2598
|
+
}
|
|
2599
|
+
setIsOpen(false);
|
|
2600
|
+
setTimeout(() => editor.focus?.());
|
|
2601
|
+
} catch (err) {
|
|
2602
|
+
console.error("Font size apply failed:", err);
|
|
2603
|
+
}
|
|
2604
|
+
},
|
|
2605
|
+
[editor]
|
|
2606
|
+
);
|
|
2607
|
+
const handleMouseDown2 = (0, import_react14.useCallback)((e) => {
|
|
2608
|
+
e.preventDefault();
|
|
2609
|
+
}, []);
|
|
2610
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "lumir-dropdown-wrapper", ref: dropdownRef, children: [
|
|
2611
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2612
|
+
"button",
|
|
2613
|
+
{
|
|
2614
|
+
className: "lumir-dropdown-btn lumir-font-size-btn",
|
|
2615
|
+
onClick: () => setIsOpen(!isOpen),
|
|
2616
|
+
onMouseDown: handleMouseDown2,
|
|
2617
|
+
title: "\uAE00\uC790 \uD06C\uAE30",
|
|
2618
|
+
type: "button",
|
|
2619
|
+
children: [
|
|
2620
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "lumir-font-size-label", children: currentSize ? toLabel(currentSize) : DEFAULT_LABEL }),
|
|
2621
|
+
Icons.expandMore
|
|
2622
|
+
]
|
|
2623
|
+
}
|
|
2624
|
+
),
|
|
2625
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "lumir-dropdown-menu lumir-font-size-menu", children: [
|
|
2626
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2627
|
+
"button",
|
|
2628
|
+
{
|
|
2629
|
+
className: cn(
|
|
2630
|
+
"lumir-dropdown-item",
|
|
2631
|
+
currentSize === "" && "is-active"
|
|
2632
|
+
),
|
|
2633
|
+
onClick: () => handleSizeSelect(""),
|
|
2634
|
+
onMouseDown: handleMouseDown2,
|
|
2635
|
+
type: "button",
|
|
2636
|
+
children: DEFAULT_LABEL
|
|
2637
|
+
}
|
|
2638
|
+
),
|
|
2639
|
+
FONT_SIZE_PRESETS.map((size) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2640
|
+
"button",
|
|
2641
|
+
{
|
|
2642
|
+
className: cn(
|
|
2643
|
+
"lumir-dropdown-item",
|
|
2644
|
+
currentSize === size && "is-active"
|
|
2645
|
+
),
|
|
2646
|
+
onClick: () => handleSizeSelect(size),
|
|
2647
|
+
onMouseDown: handleMouseDown2,
|
|
2648
|
+
type: "button",
|
|
2649
|
+
children: toLabel(size)
|
|
2650
|
+
},
|
|
2651
|
+
size
|
|
2652
|
+
))
|
|
2653
|
+
] })
|
|
2654
|
+
] });
|
|
2655
|
+
};
|
|
2656
|
+
|
|
2187
2657
|
// src/components/FloatingMenu/components/LinkButton.tsx
|
|
2188
|
-
var
|
|
2189
|
-
var
|
|
2658
|
+
var import_react15 = require("react");
|
|
2659
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2190
2660
|
var isDangerousProtocol = (url) => {
|
|
2191
2661
|
const trimmedUrl = url.trim().toLowerCase();
|
|
2192
2662
|
const dangerousPatterns = [
|
|
@@ -2212,13 +2682,13 @@ var normalizeUrl = (url) => {
|
|
|
2212
2682
|
return `https://${trimmedUrl}`;
|
|
2213
2683
|
};
|
|
2214
2684
|
var LinkButton = ({ editor }) => {
|
|
2215
|
-
const [isOpen, setIsOpen] = (0,
|
|
2216
|
-
const [linkUrl, setLinkUrl] = (0,
|
|
2217
|
-
const [errorMsg, setErrorMsg] = (0,
|
|
2218
|
-
const dropdownRef = (0,
|
|
2219
|
-
const inputRef = (0,
|
|
2220
|
-
const hasSelectionRef = (0,
|
|
2221
|
-
(0,
|
|
2685
|
+
const [isOpen, setIsOpen] = (0, import_react15.useState)(false);
|
|
2686
|
+
const [linkUrl, setLinkUrl] = (0, import_react15.useState)("");
|
|
2687
|
+
const [errorMsg, setErrorMsg] = (0, import_react15.useState)(null);
|
|
2688
|
+
const dropdownRef = (0, import_react15.useRef)(null);
|
|
2689
|
+
const inputRef = (0, import_react15.useRef)(null);
|
|
2690
|
+
const hasSelectionRef = (0, import_react15.useRef)(false);
|
|
2691
|
+
(0, import_react15.useEffect)(() => {
|
|
2222
2692
|
const handleClickOutside = (e) => {
|
|
2223
2693
|
if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
|
|
2224
2694
|
setIsOpen(false);
|
|
@@ -2229,7 +2699,7 @@ var LinkButton = ({ editor }) => {
|
|
|
2229
2699
|
document.addEventListener("mousedown", handleClickOutside);
|
|
2230
2700
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2231
2701
|
}, []);
|
|
2232
|
-
(0,
|
|
2702
|
+
(0, import_react15.useEffect)(() => {
|
|
2233
2703
|
if (isOpen && inputRef.current) {
|
|
2234
2704
|
try {
|
|
2235
2705
|
const selectedText = editor?.getSelectedText?.() || "";
|
|
@@ -2240,7 +2710,7 @@ var LinkButton = ({ editor }) => {
|
|
|
2240
2710
|
setTimeout(() => inputRef.current?.focus(), 0);
|
|
2241
2711
|
}
|
|
2242
2712
|
}, [isOpen, editor]);
|
|
2243
|
-
const handleSubmit = (0,
|
|
2713
|
+
const handleSubmit = (0, import_react15.useCallback)(
|
|
2244
2714
|
(e) => {
|
|
2245
2715
|
e?.preventDefault();
|
|
2246
2716
|
setErrorMsg(null);
|
|
@@ -2267,15 +2737,15 @@ var LinkButton = ({ editor }) => {
|
|
|
2267
2737
|
},
|
|
2268
2738
|
[editor, linkUrl]
|
|
2269
2739
|
);
|
|
2270
|
-
const handleCancel = (0,
|
|
2740
|
+
const handleCancel = (0, import_react15.useCallback)(() => {
|
|
2271
2741
|
setIsOpen(false);
|
|
2272
2742
|
setLinkUrl("");
|
|
2273
2743
|
setErrorMsg(null);
|
|
2274
2744
|
}, []);
|
|
2275
|
-
const
|
|
2745
|
+
const handleMouseDown2 = (0, import_react15.useCallback)((e) => {
|
|
2276
2746
|
e.preventDefault();
|
|
2277
2747
|
}, []);
|
|
2278
|
-
const handleKeyDown = (0,
|
|
2748
|
+
const handleKeyDown = (0, import_react15.useCallback)(
|
|
2279
2749
|
(e) => {
|
|
2280
2750
|
if (e.key === "Enter") {
|
|
2281
2751
|
handleSubmit();
|
|
@@ -2285,20 +2755,20 @@ var LinkButton = ({ editor }) => {
|
|
|
2285
2755
|
},
|
|
2286
2756
|
[handleSubmit, handleCancel]
|
|
2287
2757
|
);
|
|
2288
|
-
return /* @__PURE__ */ (0,
|
|
2289
|
-
/* @__PURE__ */ (0,
|
|
2758
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "lumir-dropdown-wrapper", ref: dropdownRef, children: [
|
|
2759
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2290
2760
|
"button",
|
|
2291
2761
|
{
|
|
2292
2762
|
className: "lumir-toolbar-btn",
|
|
2293
2763
|
onClick: () => setIsOpen(!isOpen),
|
|
2294
|
-
onMouseDown:
|
|
2764
|
+
onMouseDown: handleMouseDown2,
|
|
2295
2765
|
title: "\uB9C1\uD06C \uC0BD\uC785",
|
|
2296
2766
|
type: "button",
|
|
2297
2767
|
children: Icons.link
|
|
2298
2768
|
}
|
|
2299
2769
|
),
|
|
2300
|
-
isOpen && /* @__PURE__ */ (0,
|
|
2301
|
-
/* @__PURE__ */ (0,
|
|
2770
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "lumir-dropdown-menu lumir-link-menu", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("form", { onSubmit: handleSubmit, className: "lumir-link-form", children: [
|
|
2771
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2302
2772
|
"input",
|
|
2303
2773
|
{
|
|
2304
2774
|
ref: inputRef,
|
|
@@ -2311,10 +2781,10 @@ var LinkButton = ({ editor }) => {
|
|
|
2311
2781
|
setErrorMsg(null);
|
|
2312
2782
|
},
|
|
2313
2783
|
onKeyDown: handleKeyDown,
|
|
2314
|
-
onMouseDown:
|
|
2784
|
+
onMouseDown: handleMouseDown2
|
|
2315
2785
|
}
|
|
2316
2786
|
),
|
|
2317
|
-
errorMsg && /* @__PURE__ */ (0,
|
|
2787
|
+
errorMsg && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2318
2788
|
"div",
|
|
2319
2789
|
{
|
|
2320
2790
|
style: {
|
|
@@ -2326,23 +2796,23 @@ var LinkButton = ({ editor }) => {
|
|
|
2326
2796
|
children: errorMsg
|
|
2327
2797
|
}
|
|
2328
2798
|
),
|
|
2329
|
-
/* @__PURE__ */ (0,
|
|
2330
|
-
/* @__PURE__ */ (0,
|
|
2799
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "lumir-link-actions", children: [
|
|
2800
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2331
2801
|
"button",
|
|
2332
2802
|
{
|
|
2333
2803
|
type: "button",
|
|
2334
2804
|
className: "lumir-link-btn lumir-link-cancel",
|
|
2335
2805
|
onClick: handleCancel,
|
|
2336
|
-
onMouseDown:
|
|
2806
|
+
onMouseDown: handleMouseDown2,
|
|
2337
2807
|
children: "\uCDE8\uC18C"
|
|
2338
2808
|
}
|
|
2339
2809
|
),
|
|
2340
|
-
/* @__PURE__ */ (0,
|
|
2810
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2341
2811
|
"button",
|
|
2342
2812
|
{
|
|
2343
2813
|
type: "submit",
|
|
2344
2814
|
className: "lumir-link-btn lumir-link-submit",
|
|
2345
|
-
onMouseDown:
|
|
2815
|
+
onMouseDown: handleMouseDown2,
|
|
2346
2816
|
disabled: !linkUrl.trim(),
|
|
2347
2817
|
children: "\uD655\uC778"
|
|
2348
2818
|
}
|
|
@@ -2353,10 +2823,10 @@ var LinkButton = ({ editor }) => {
|
|
|
2353
2823
|
};
|
|
2354
2824
|
|
|
2355
2825
|
// src/components/FloatingMenu/components/TableButton.tsx
|
|
2356
|
-
var
|
|
2357
|
-
var
|
|
2826
|
+
var import_react16 = require("react");
|
|
2827
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2358
2828
|
var TableButton = ({ editor }) => {
|
|
2359
|
-
const handleClick = (0,
|
|
2829
|
+
const handleClick = (0, import_react16.useCallback)(() => {
|
|
2360
2830
|
try {
|
|
2361
2831
|
const block = editor?.getTextCursorPosition()?.block;
|
|
2362
2832
|
if (!block || !editor?.insertBlocks) return;
|
|
@@ -2378,15 +2848,15 @@ var TableButton = ({ editor }) => {
|
|
|
2378
2848
|
console.error("Table insert failed:", err);
|
|
2379
2849
|
}
|
|
2380
2850
|
}, [editor]);
|
|
2381
|
-
const
|
|
2851
|
+
const handleMouseDown2 = (0, import_react16.useCallback)((e) => {
|
|
2382
2852
|
e.preventDefault();
|
|
2383
2853
|
}, []);
|
|
2384
|
-
return /* @__PURE__ */ (0,
|
|
2854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2385
2855
|
"button",
|
|
2386
2856
|
{
|
|
2387
2857
|
className: "lumir-toolbar-btn",
|
|
2388
2858
|
onClick: handleClick,
|
|
2389
|
-
onMouseDown:
|
|
2859
|
+
onMouseDown: handleMouseDown2,
|
|
2390
2860
|
title: "\uD14C\uC774\uBE14 \uC0BD\uC785",
|
|
2391
2861
|
type: "button",
|
|
2392
2862
|
children: Icons.table
|
|
@@ -2395,13 +2865,13 @@ var TableButton = ({ editor }) => {
|
|
|
2395
2865
|
};
|
|
2396
2866
|
|
|
2397
2867
|
// src/components/FloatingMenu/components/HTMLImportButton.tsx
|
|
2398
|
-
var
|
|
2399
|
-
var
|
|
2868
|
+
var import_react17 = require("react");
|
|
2869
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2400
2870
|
var HTMLImportButton = ({
|
|
2401
2871
|
editor
|
|
2402
2872
|
}) => {
|
|
2403
|
-
const fileInputRef = (0,
|
|
2404
|
-
const handleFileUpload = (0,
|
|
2873
|
+
const fileInputRef = (0, import_react17.useRef)(null);
|
|
2874
|
+
const handleFileUpload = (0, import_react17.useCallback)(
|
|
2405
2875
|
(e) => {
|
|
2406
2876
|
const file = e.target.files?.[0];
|
|
2407
2877
|
if (!file) return;
|
|
@@ -2437,14 +2907,14 @@ var HTMLImportButton = ({
|
|
|
2437
2907
|
},
|
|
2438
2908
|
[editor]
|
|
2439
2909
|
);
|
|
2440
|
-
const handleClick = (0,
|
|
2910
|
+
const handleClick = (0, import_react17.useCallback)(() => {
|
|
2441
2911
|
fileInputRef.current?.click();
|
|
2442
2912
|
}, []);
|
|
2443
|
-
const
|
|
2913
|
+
const handleMouseDown2 = (0, import_react17.useCallback)((e) => {
|
|
2444
2914
|
e.preventDefault();
|
|
2445
2915
|
}, []);
|
|
2446
|
-
return /* @__PURE__ */ (0,
|
|
2447
|
-
/* @__PURE__ */ (0,
|
|
2916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
2917
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2448
2918
|
"input",
|
|
2449
2919
|
{
|
|
2450
2920
|
ref: fileInputRef,
|
|
@@ -2454,12 +2924,12 @@ var HTMLImportButton = ({
|
|
|
2454
2924
|
style: { display: "none" }
|
|
2455
2925
|
}
|
|
2456
2926
|
),
|
|
2457
|
-
/* @__PURE__ */ (0,
|
|
2927
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2458
2928
|
"button",
|
|
2459
2929
|
{
|
|
2460
2930
|
className: "lumir-toolbar-btn",
|
|
2461
2931
|
onClick: handleClick,
|
|
2462
|
-
onMouseDown:
|
|
2932
|
+
onMouseDown: handleMouseDown2,
|
|
2463
2933
|
title: "HTML Import",
|
|
2464
2934
|
type: "button",
|
|
2465
2935
|
children: Icons.htmlFile
|
|
@@ -2469,8 +2939,8 @@ var HTMLImportButton = ({
|
|
|
2469
2939
|
};
|
|
2470
2940
|
|
|
2471
2941
|
// src/components/FloatingMenu/components/BlockTypeSelect.tsx
|
|
2472
|
-
var
|
|
2473
|
-
var
|
|
2942
|
+
var import_react18 = require("react");
|
|
2943
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2474
2944
|
var blockTypeCategories = [
|
|
2475
2945
|
{
|
|
2476
2946
|
category: "Headings",
|
|
@@ -2500,8 +2970,8 @@ var blockTypes = blockTypeCategories.flatMap(
|
|
|
2500
2970
|
(cat) => cat.items
|
|
2501
2971
|
);
|
|
2502
2972
|
var BlockTypeSelect = ({ editor }) => {
|
|
2503
|
-
const [isOpen, setIsOpen] = (0,
|
|
2504
|
-
const dropdownRef = (0,
|
|
2973
|
+
const [isOpen, setIsOpen] = (0, import_react18.useState)(false);
|
|
2974
|
+
const dropdownRef = (0, import_react18.useRef)(null);
|
|
2505
2975
|
const getCurrentBlock = () => {
|
|
2506
2976
|
try {
|
|
2507
2977
|
return editor?.getTextCursorPosition()?.block;
|
|
@@ -2513,7 +2983,7 @@ var BlockTypeSelect = ({ editor }) => {
|
|
|
2513
2983
|
const currentType = currentBlock?.type || "paragraph";
|
|
2514
2984
|
const currentLevel = currentBlock?.props?.level;
|
|
2515
2985
|
const isCurrentToggle = currentType === "heading" && currentBlock?.props?.isToggleable === true;
|
|
2516
|
-
(0,
|
|
2986
|
+
(0, import_react18.useEffect)(() => {
|
|
2517
2987
|
const handleClickOutside = (e) => {
|
|
2518
2988
|
if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
|
|
2519
2989
|
setIsOpen(false);
|
|
@@ -2542,7 +3012,7 @@ var BlockTypeSelect = ({ editor }) => {
|
|
|
2542
3012
|
console.error("Block type change failed:", err);
|
|
2543
3013
|
}
|
|
2544
3014
|
};
|
|
2545
|
-
const
|
|
3015
|
+
const handleMouseDown2 = (0, import_react18.useCallback)((e) => {
|
|
2546
3016
|
e.preventDefault();
|
|
2547
3017
|
}, []);
|
|
2548
3018
|
const getCurrentLabel = () => {
|
|
@@ -2573,24 +3043,24 @@ var BlockTypeSelect = ({ editor }) => {
|
|
|
2573
3043
|
}
|
|
2574
3044
|
return currentType === bt.type;
|
|
2575
3045
|
};
|
|
2576
|
-
return /* @__PURE__ */ (0,
|
|
2577
|
-
/* @__PURE__ */ (0,
|
|
3046
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "lumir-dropdown-wrapper", ref: dropdownRef, children: [
|
|
3047
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2578
3048
|
"button",
|
|
2579
3049
|
{
|
|
2580
3050
|
className: "lumir-dropdown-btn lumir-block-type-btn",
|
|
2581
3051
|
onClick: () => setIsOpen(!isOpen),
|
|
2582
|
-
onMouseDown:
|
|
3052
|
+
onMouseDown: handleMouseDown2,
|
|
2583
3053
|
type: "button",
|
|
2584
3054
|
children: [
|
|
2585
|
-
/* @__PURE__ */ (0,
|
|
2586
|
-
/* @__PURE__ */ (0,
|
|
3055
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "lumir-block-icon", children: BlockTypeIcons[getCurrentIcon()] }),
|
|
3056
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "lumir-block-label", children: getCurrentLabel() }),
|
|
2587
3057
|
Icons.expandMore
|
|
2588
3058
|
]
|
|
2589
3059
|
}
|
|
2590
3060
|
),
|
|
2591
|
-
isOpen && /* @__PURE__ */ (0,
|
|
2592
|
-
/* @__PURE__ */ (0,
|
|
2593
|
-
category.items.map((bt) => /* @__PURE__ */ (0,
|
|
3061
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "lumir-dropdown-menu lumir-block-menu", children: blockTypeCategories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "lumir-block-category", children: [
|
|
3062
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "lumir-block-category-title", children: category.category }),
|
|
3063
|
+
category.items.map((bt) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2594
3064
|
"button",
|
|
2595
3065
|
{
|
|
2596
3066
|
className: cn(
|
|
@@ -2598,10 +3068,10 @@ var BlockTypeSelect = ({ editor }) => {
|
|
|
2598
3068
|
isActiveItem(bt) && "is-active"
|
|
2599
3069
|
),
|
|
2600
3070
|
onClick: () => handleTypeChange(bt.type, bt.level, bt.isToggle),
|
|
2601
|
-
onMouseDown:
|
|
3071
|
+
onMouseDown: handleMouseDown2,
|
|
2602
3072
|
children: [
|
|
2603
|
-
/* @__PURE__ */ (0,
|
|
2604
|
-
/* @__PURE__ */ (0,
|
|
3073
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "lumir-block-icon", children: BlockTypeIcons[bt.icon] }),
|
|
3074
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "lumir-block-item-title", children: bt.label })
|
|
2605
3075
|
]
|
|
2606
3076
|
},
|
|
2607
3077
|
bt.icon
|
|
@@ -2611,7 +3081,7 @@ var BlockTypeSelect = ({ editor }) => {
|
|
|
2611
3081
|
};
|
|
2612
3082
|
|
|
2613
3083
|
// src/components/FloatingMenu/index.tsx
|
|
2614
|
-
var
|
|
3084
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2615
3085
|
var COMPACT_BREAKPOINT = 700;
|
|
2616
3086
|
var MINIMIZED_BREAKPOINT = 400;
|
|
2617
3087
|
var FloatingMenu = ({
|
|
@@ -2620,12 +3090,12 @@ var FloatingMenu = ({
|
|
|
2620
3090
|
className,
|
|
2621
3091
|
onImageUpload
|
|
2622
3092
|
}) => {
|
|
2623
|
-
const wrapperRef = (0,
|
|
2624
|
-
const [isCompact, setIsCompact] = (0,
|
|
2625
|
-
const [isMinimizable, setIsMinimizable] = (0,
|
|
2626
|
-
const [isMinimized, setIsMinimized] = (0,
|
|
2627
|
-
const [, setSelectionTick] = (0,
|
|
2628
|
-
(0,
|
|
3093
|
+
const wrapperRef = (0, import_react19.useRef)(null);
|
|
3094
|
+
const [isCompact, setIsCompact] = (0, import_react19.useState)(false);
|
|
3095
|
+
const [isMinimizable, setIsMinimizable] = (0, import_react19.useState)(false);
|
|
3096
|
+
const [isMinimized, setIsMinimized] = (0, import_react19.useState)(false);
|
|
3097
|
+
const [, setSelectionTick] = (0, import_react19.useState)(0);
|
|
3098
|
+
(0, import_react19.useEffect)(() => {
|
|
2629
3099
|
if (!editor) return;
|
|
2630
3100
|
let debounceTimer = null;
|
|
2631
3101
|
const DEBOUNCE_DELAY = 150;
|
|
@@ -2649,7 +3119,7 @@ var FloatingMenu = ({
|
|
|
2649
3119
|
unsubscribeContent?.();
|
|
2650
3120
|
};
|
|
2651
3121
|
}, [editor]);
|
|
2652
|
-
(0,
|
|
3122
|
+
(0, import_react19.useEffect)(() => {
|
|
2653
3123
|
const checkWidth = () => {
|
|
2654
3124
|
if (wrapperRef.current) {
|
|
2655
3125
|
const width = wrapperRef.current.offsetWidth;
|
|
@@ -2664,8 +3134,8 @@ var FloatingMenu = ({
|
|
|
2664
3134
|
}
|
|
2665
3135
|
return () => resizeObserver.disconnect();
|
|
2666
3136
|
}, []);
|
|
2667
|
-
const MinimizedLayout = () => /* @__PURE__ */ (0,
|
|
2668
|
-
/* @__PURE__ */ (0,
|
|
3137
|
+
const MinimizedLayout = () => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
3138
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2669
3139
|
"button",
|
|
2670
3140
|
{
|
|
2671
3141
|
className: "lumir-toolbar-button lumir-toggle-button",
|
|
@@ -2676,117 +3146,120 @@ var FloatingMenu = ({
|
|
|
2676
3146
|
children: isMinimized ? Icons.chevronRight : Icons.chevronLeft
|
|
2677
3147
|
}
|
|
2678
3148
|
),
|
|
2679
|
-
!isMinimized && /* @__PURE__ */ (0,
|
|
2680
|
-
/* @__PURE__ */ (0,
|
|
2681
|
-
/* @__PURE__ */ (0,
|
|
2682
|
-
/* @__PURE__ */ (0,
|
|
2683
|
-
/* @__PURE__ */ (0,
|
|
2684
|
-
/* @__PURE__ */ (0,
|
|
2685
|
-
/* @__PURE__ */ (0,
|
|
2686
|
-
/* @__PURE__ */ (0,
|
|
2687
|
-
/* @__PURE__ */ (0,
|
|
2688
|
-
/* @__PURE__ */ (0,
|
|
2689
|
-
/* @__PURE__ */ (0,
|
|
3149
|
+
!isMinimized && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
3150
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3151
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(UndoRedoButtons, { editor }),
|
|
3152
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3153
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "lumir-toolbar-group", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BlockTypeSelect, { editor }) }),
|
|
3154
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3155
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3156
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextStyleButton, { editor, style: "bold" }),
|
|
3157
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextStyleButton, { editor, style: "italic" }),
|
|
3158
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextStyleButton, { editor, style: "underline" }),
|
|
3159
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextStyleButton, { editor, style: "strike" })
|
|
2690
3160
|
] }),
|
|
2691
|
-
/* @__PURE__ */ (0,
|
|
2692
|
-
/* @__PURE__ */ (0,
|
|
2693
|
-
/* @__PURE__ */ (0,
|
|
2694
|
-
/* @__PURE__ */ (0,
|
|
2695
|
-
/* @__PURE__ */ (0,
|
|
3161
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3162
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3163
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AlignButton, { editor, alignment: "left" }),
|
|
3164
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AlignButton, { editor, alignment: "center" }),
|
|
3165
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AlignButton, { editor, alignment: "right" })
|
|
2696
3166
|
] }),
|
|
2697
|
-
/* @__PURE__ */ (0,
|
|
2698
|
-
/* @__PURE__ */ (0,
|
|
2699
|
-
/* @__PURE__ */ (0,
|
|
2700
|
-
/* @__PURE__ */ (0,
|
|
3167
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3168
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3169
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ListButton, { editor, type: "bullet" }),
|
|
3170
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ListButton, { editor, type: "numbered" })
|
|
2701
3171
|
] }),
|
|
2702
|
-
/* @__PURE__ */ (0,
|
|
2703
|
-
/* @__PURE__ */ (0,
|
|
2704
|
-
/* @__PURE__ */ (0,
|
|
2705
|
-
/* @__PURE__ */ (0,
|
|
3172
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3173
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3174
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FontSizeButton, { editor }),
|
|
3175
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ColorButton, { editor, type: "text" }),
|
|
3176
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ColorButton, { editor, type: "background" })
|
|
2706
3177
|
] }),
|
|
2707
|
-
/* @__PURE__ */ (0,
|
|
2708
|
-
/* @__PURE__ */ (0,
|
|
2709
|
-
/* @__PURE__ */ (0,
|
|
2710
|
-
/* @__PURE__ */ (0,
|
|
2711
|
-
/* @__PURE__ */ (0,
|
|
2712
|
-
/* @__PURE__ */ (0,
|
|
3178
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3179
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3180
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ImageButton, { editor, onImageUpload }),
|
|
3181
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(LinkButton, { editor }),
|
|
3182
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TableButton, { editor }),
|
|
3183
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(HTMLImportButton, { editor })
|
|
2713
3184
|
] })
|
|
2714
3185
|
] })
|
|
2715
3186
|
] });
|
|
2716
|
-
const SingleRowLayout = () => /* @__PURE__ */ (0,
|
|
2717
|
-
/* @__PURE__ */ (0,
|
|
2718
|
-
/* @__PURE__ */ (0,
|
|
2719
|
-
/* @__PURE__ */ (0,
|
|
2720
|
-
/* @__PURE__ */ (0,
|
|
2721
|
-
/* @__PURE__ */ (0,
|
|
2722
|
-
/* @__PURE__ */ (0,
|
|
2723
|
-
/* @__PURE__ */ (0,
|
|
2724
|
-
/* @__PURE__ */ (0,
|
|
2725
|
-
/* @__PURE__ */ (0,
|
|
3187
|
+
const SingleRowLayout = () => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
3188
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(UndoRedoButtons, { editor }),
|
|
3189
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3190
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "lumir-toolbar-group", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BlockTypeSelect, { editor }) }),
|
|
3191
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3192
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3193
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextStyleButton, { editor, style: "bold" }),
|
|
3194
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextStyleButton, { editor, style: "italic" }),
|
|
3195
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextStyleButton, { editor, style: "underline" }),
|
|
3196
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextStyleButton, { editor, style: "strike" })
|
|
2726
3197
|
] }),
|
|
2727
|
-
/* @__PURE__ */ (0,
|
|
2728
|
-
/* @__PURE__ */ (0,
|
|
2729
|
-
/* @__PURE__ */ (0,
|
|
2730
|
-
/* @__PURE__ */ (0,
|
|
2731
|
-
/* @__PURE__ */ (0,
|
|
3198
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3199
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3200
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AlignButton, { editor, alignment: "left" }),
|
|
3201
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AlignButton, { editor, alignment: "center" }),
|
|
3202
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AlignButton, { editor, alignment: "right" })
|
|
2732
3203
|
] }),
|
|
2733
|
-
/* @__PURE__ */ (0,
|
|
2734
|
-
/* @__PURE__ */ (0,
|
|
2735
|
-
/* @__PURE__ */ (0,
|
|
2736
|
-
/* @__PURE__ */ (0,
|
|
3204
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3205
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3206
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ListButton, { editor, type: "bullet" }),
|
|
3207
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ListButton, { editor, type: "numbered" })
|
|
2737
3208
|
] }),
|
|
2738
|
-
/* @__PURE__ */ (0,
|
|
2739
|
-
/* @__PURE__ */ (0,
|
|
2740
|
-
/* @__PURE__ */ (0,
|
|
2741
|
-
/* @__PURE__ */ (0,
|
|
3209
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3210
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3211
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FontSizeButton, { editor }),
|
|
3212
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ColorButton, { editor, type: "text" }),
|
|
3213
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ColorButton, { editor, type: "background" })
|
|
2742
3214
|
] }),
|
|
2743
|
-
/* @__PURE__ */ (0,
|
|
2744
|
-
/* @__PURE__ */ (0,
|
|
2745
|
-
/* @__PURE__ */ (0,
|
|
2746
|
-
/* @__PURE__ */ (0,
|
|
2747
|
-
/* @__PURE__ */ (0,
|
|
2748
|
-
/* @__PURE__ */ (0,
|
|
3215
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3216
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3217
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ImageButton, { editor, onImageUpload }),
|
|
3218
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(LinkButton, { editor }),
|
|
3219
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TableButton, { editor }),
|
|
3220
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(HTMLImportButton, { editor })
|
|
2749
3221
|
] })
|
|
2750
3222
|
] });
|
|
2751
|
-
const TwoRowLayout = () => /* @__PURE__ */ (0,
|
|
2752
|
-
/* @__PURE__ */ (0,
|
|
2753
|
-
/* @__PURE__ */ (0,
|
|
2754
|
-
/* @__PURE__ */ (0,
|
|
2755
|
-
/* @__PURE__ */ (0,
|
|
2756
|
-
/* @__PURE__ */ (0,
|
|
2757
|
-
/* @__PURE__ */ (0,
|
|
2758
|
-
/* @__PURE__ */ (0,
|
|
2759
|
-
/* @__PURE__ */ (0,
|
|
3223
|
+
const TwoRowLayout = () => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
3224
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-row", children: [
|
|
3225
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(UndoRedoButtons, { editor }),
|
|
3226
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3227
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3228
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextStyleButton, { editor, style: "bold" }),
|
|
3229
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextStyleButton, { editor, style: "italic" }),
|
|
3230
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextStyleButton, { editor, style: "underline" }),
|
|
3231
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextStyleButton, { editor, style: "strike" })
|
|
2760
3232
|
] }),
|
|
2761
|
-
/* @__PURE__ */ (0,
|
|
2762
|
-
/* @__PURE__ */ (0,
|
|
2763
|
-
/* @__PURE__ */ (0,
|
|
2764
|
-
/* @__PURE__ */ (0,
|
|
2765
|
-
/* @__PURE__ */ (0,
|
|
3233
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3234
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3235
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AlignButton, { editor, alignment: "left" }),
|
|
3236
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AlignButton, { editor, alignment: "center" }),
|
|
3237
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AlignButton, { editor, alignment: "right" })
|
|
2766
3238
|
] }),
|
|
2767
|
-
/* @__PURE__ */ (0,
|
|
2768
|
-
/* @__PURE__ */ (0,
|
|
2769
|
-
/* @__PURE__ */ (0,
|
|
2770
|
-
/* @__PURE__ */ (0,
|
|
3239
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3240
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3241
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ListButton, { editor, type: "bullet" }),
|
|
3242
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ListButton, { editor, type: "numbered" })
|
|
2771
3243
|
] })
|
|
2772
3244
|
] }),
|
|
2773
|
-
/* @__PURE__ */ (0,
|
|
2774
|
-
/* @__PURE__ */ (0,
|
|
2775
|
-
/* @__PURE__ */ (0,
|
|
2776
|
-
/* @__PURE__ */ (0,
|
|
2777
|
-
/* @__PURE__ */ (0,
|
|
2778
|
-
/* @__PURE__ */ (0,
|
|
3245
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-row", children: [
|
|
3246
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "lumir-toolbar-group", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BlockTypeSelect, { editor }) }),
|
|
3247
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3248
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3249
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FontSizeButton, { editor }),
|
|
3250
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ColorButton, { editor, type: "text" }),
|
|
3251
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ColorButton, { editor, type: "background" })
|
|
2779
3252
|
] }),
|
|
2780
|
-
/* @__PURE__ */ (0,
|
|
2781
|
-
/* @__PURE__ */ (0,
|
|
2782
|
-
/* @__PURE__ */ (0,
|
|
2783
|
-
/* @__PURE__ */ (0,
|
|
2784
|
-
/* @__PURE__ */ (0,
|
|
2785
|
-
/* @__PURE__ */ (0,
|
|
3253
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToolbarDivider, {}),
|
|
3254
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "lumir-toolbar-group", children: [
|
|
3255
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ImageButton, { editor, onImageUpload }),
|
|
3256
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(LinkButton, { editor }),
|
|
3257
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TableButton, { editor }),
|
|
3258
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(HTMLImportButton, { editor })
|
|
2786
3259
|
] })
|
|
2787
3260
|
] })
|
|
2788
3261
|
] });
|
|
2789
|
-
return /* @__PURE__ */ (0,
|
|
3262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2790
3263
|
"div",
|
|
2791
3264
|
{
|
|
2792
3265
|
ref: wrapperRef,
|
|
@@ -2796,7 +3269,7 @@ var FloatingMenu = ({
|
|
|
2796
3269
|
className
|
|
2797
3270
|
),
|
|
2798
3271
|
"data-position": position,
|
|
2799
|
-
children: /* @__PURE__ */ (0,
|
|
3272
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2800
3273
|
"div",
|
|
2801
3274
|
{
|
|
2802
3275
|
className: cn(
|
|
@@ -2805,7 +3278,7 @@ var FloatingMenu = ({
|
|
|
2805
3278
|
isMinimizable && "is-minimizable",
|
|
2806
3279
|
isMinimized && "is-minimized"
|
|
2807
3280
|
),
|
|
2808
|
-
children: isMinimizable ? /* @__PURE__ */ (0,
|
|
3281
|
+
children: isMinimizable ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MinimizedLayout, {}) : isCompact ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TwoRowLayout, {}) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SingleRowLayout, {})
|
|
2809
3282
|
}
|
|
2810
3283
|
)
|
|
2811
3284
|
}
|
|
@@ -2905,8 +3378,8 @@ var LumirEditorError = class _LumirEditorError extends Error {
|
|
|
2905
3378
|
};
|
|
2906
3379
|
|
|
2907
3380
|
// src/extensions/VerticalAlignmentExtension.ts
|
|
2908
|
-
var
|
|
2909
|
-
var VerticalAlignmentExtension =
|
|
3381
|
+
var import_core4 = require("@tiptap/core");
|
|
3382
|
+
var VerticalAlignmentExtension = import_core4.Extension.create({
|
|
2910
3383
|
name: "verticalAlignment",
|
|
2911
3384
|
addGlobalAttributes() {
|
|
2912
3385
|
return [
|
|
@@ -2936,19 +3409,593 @@ var VerticalAlignmentExtension = import_core2.Extension.create({
|
|
|
2936
3409
|
}
|
|
2937
3410
|
});
|
|
2938
3411
|
|
|
2939
|
-
// src/
|
|
2940
|
-
var
|
|
3412
|
+
// src/extensions/RowHeightExtension.ts
|
|
3413
|
+
var import_core5 = require("@tiptap/core");
|
|
2941
3414
|
|
|
2942
|
-
// src/
|
|
2943
|
-
var
|
|
2944
|
-
var
|
|
2945
|
-
var
|
|
2946
|
-
|
|
3415
|
+
// src/extensions/rowResizing.ts
|
|
3416
|
+
var import_prosemirror_state3 = require("prosemirror-state");
|
|
3417
|
+
var import_prosemirror_view2 = require("prosemirror-view");
|
|
3418
|
+
var import_prosemirror_tables = require("prosemirror-tables");
|
|
3419
|
+
|
|
3420
|
+
// src/constants/limits.ts
|
|
3421
|
+
var MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
3422
|
+
var MAX_VIDEO_FILE_SIZE = 100 * 1024 * 1024;
|
|
3423
|
+
var BLOCKED_EXTENSIONS = [".svg", ".svgz"];
|
|
3424
|
+
var ALLOWED_VIDEO_MIME_TYPES = /* @__PURE__ */ new Set([
|
|
3425
|
+
"video/mp4",
|
|
3426
|
+
"video/webm",
|
|
3427
|
+
"video/ogg",
|
|
3428
|
+
"video/quicktime"
|
|
3429
|
+
// .mov
|
|
3430
|
+
]);
|
|
3431
|
+
var ALLOWED_VIDEO_EXTENSIONS = [
|
|
3432
|
+
".mp4",
|
|
3433
|
+
".webm",
|
|
3434
|
+
".ogg",
|
|
3435
|
+
".mov"
|
|
3436
|
+
];
|
|
3437
|
+
var ROW_RESIZE_MIN_HEIGHT = 24;
|
|
3438
|
+
var ROW_RESIZE_HANDLE_WIDTH = 5;
|
|
3439
|
+
|
|
3440
|
+
// src/extensions/rowResizing.ts
|
|
3441
|
+
var rowResizingPluginKey = new import_prosemirror_state3.PluginKey(
|
|
3442
|
+
"lumirRowResizing"
|
|
3443
|
+
);
|
|
3444
|
+
var RowResizeState = class _RowResizeState {
|
|
3445
|
+
constructor(activeHandle, dragging) {
|
|
3446
|
+
this.activeHandle = activeHandle;
|
|
3447
|
+
this.dragging = dragging;
|
|
3448
|
+
}
|
|
3449
|
+
apply(tr) {
|
|
3450
|
+
const action = tr.getMeta(rowResizingPluginKey);
|
|
3451
|
+
if (action && action.setHandle != null) {
|
|
3452
|
+
return new _RowResizeState(action.setHandle, null);
|
|
3453
|
+
}
|
|
3454
|
+
if (action && action.setDragging !== void 0) {
|
|
3455
|
+
return new _RowResizeState(this.activeHandle, action.setDragging);
|
|
3456
|
+
}
|
|
3457
|
+
if (this.activeHandle > -1 && tr.docChanged) {
|
|
3458
|
+
let handle = tr.mapping.map(this.activeHandle, -1);
|
|
3459
|
+
if (!(0, import_prosemirror_tables.pointsAtCell)(tr.doc.resolve(handle))) {
|
|
3460
|
+
handle = -1;
|
|
3461
|
+
}
|
|
3462
|
+
return new _RowResizeState(handle, this.dragging);
|
|
3463
|
+
}
|
|
3464
|
+
return this;
|
|
3465
|
+
}
|
|
3466
|
+
};
|
|
3467
|
+
function rowResizing({
|
|
3468
|
+
handleWidth = ROW_RESIZE_HANDLE_WIDTH,
|
|
3469
|
+
minHeight = ROW_RESIZE_MIN_HEIGHT
|
|
3470
|
+
} = {}) {
|
|
3471
|
+
return new import_prosemirror_state3.Plugin({
|
|
3472
|
+
key: rowResizingPluginKey,
|
|
3473
|
+
state: {
|
|
3474
|
+
init() {
|
|
3475
|
+
return new RowResizeState(-1, null);
|
|
3476
|
+
},
|
|
3477
|
+
apply(tr, prev) {
|
|
3478
|
+
return prev.apply(tr);
|
|
3479
|
+
}
|
|
3480
|
+
},
|
|
3481
|
+
props: {
|
|
3482
|
+
attributes: (state) => {
|
|
3483
|
+
const pluginState = rowResizingPluginKey.getState(state);
|
|
3484
|
+
return pluginState && pluginState.activeHandle > -1 ? { class: "row-resize-cursor" } : {};
|
|
3485
|
+
},
|
|
3486
|
+
handleDOMEvents: {
|
|
3487
|
+
mousemove: (view, event) => {
|
|
3488
|
+
handleMouseMove(view, event, handleWidth);
|
|
3489
|
+
},
|
|
3490
|
+
mouseleave: (view) => {
|
|
3491
|
+
handleMouseLeave(view);
|
|
3492
|
+
},
|
|
3493
|
+
mousedown: (view, event) => {
|
|
3494
|
+
handleMouseDown(view, event, minHeight);
|
|
3495
|
+
}
|
|
3496
|
+
},
|
|
3497
|
+
decorations: (state) => {
|
|
3498
|
+
const pluginState = rowResizingPluginKey.getState(state);
|
|
3499
|
+
if (pluginState && pluginState.activeHandle > -1) {
|
|
3500
|
+
return handleDecorations(state, pluginState);
|
|
3501
|
+
}
|
|
3502
|
+
return void 0;
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3505
|
+
});
|
|
3506
|
+
}
|
|
3507
|
+
function handleMouseMove(view, event, handleWidth) {
|
|
3508
|
+
if (!view.editable) {
|
|
3509
|
+
return;
|
|
3510
|
+
}
|
|
3511
|
+
const pluginState = rowResizingPluginKey.getState(view.state);
|
|
3512
|
+
if (!pluginState) {
|
|
3513
|
+
return;
|
|
3514
|
+
}
|
|
3515
|
+
if (!pluginState.dragging) {
|
|
3516
|
+
const target = domCellAround(event.target);
|
|
3517
|
+
let cell = -1;
|
|
3518
|
+
if (target) {
|
|
3519
|
+
const { top, bottom } = target.getBoundingClientRect();
|
|
3520
|
+
if (event.clientY - top <= handleWidth) {
|
|
3521
|
+
cell = edgeCell(view, event, "top", handleWidth);
|
|
3522
|
+
} else if (bottom - event.clientY <= handleWidth) {
|
|
3523
|
+
cell = edgeCell(view, event, "bottom", handleWidth);
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
if (cell !== pluginState.activeHandle) {
|
|
3527
|
+
updateHandle(view, cell);
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
function handleMouseLeave(view) {
|
|
3532
|
+
if (!view.editable) {
|
|
3533
|
+
return;
|
|
3534
|
+
}
|
|
3535
|
+
const pluginState = rowResizingPluginKey.getState(view.state);
|
|
3536
|
+
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) {
|
|
3537
|
+
updateHandle(view, -1);
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
function handleMouseDown(view, event, minHeight) {
|
|
3541
|
+
if (!view.editable) {
|
|
3542
|
+
return false;
|
|
3543
|
+
}
|
|
3544
|
+
const win = view.dom.ownerDocument.defaultView ?? window;
|
|
3545
|
+
const pluginState = rowResizingPluginKey.getState(view.state);
|
|
3546
|
+
if (!pluginState || pluginState.activeHandle === -1 || pluginState.dragging) {
|
|
3547
|
+
return false;
|
|
3548
|
+
}
|
|
3549
|
+
const startHeight = currentRowHeight(view, pluginState.activeHandle);
|
|
3550
|
+
setDragging(view, {
|
|
3551
|
+
startY: event.clientY,
|
|
3552
|
+
startHeight,
|
|
3553
|
+
currentHeight: startHeight
|
|
3554
|
+
});
|
|
3555
|
+
function finish(finishEvent) {
|
|
3556
|
+
win.removeEventListener("mouseup", finish);
|
|
3557
|
+
win.removeEventListener("mousemove", move);
|
|
3558
|
+
const ps = rowResizingPluginKey.getState(view.state);
|
|
3559
|
+
if (ps?.dragging) {
|
|
3560
|
+
const finalHeight = draggedHeight(ps.dragging, finishEvent, minHeight);
|
|
3561
|
+
setDragging(view, null);
|
|
3562
|
+
commitRowHeight(view, ps.activeHandle, finalHeight);
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
function move(moveEvent) {
|
|
3566
|
+
if (moveEvent.buttons === 0 || moveEvent.buttons === void 0 && !moveEvent.which) {
|
|
3567
|
+
return finish(moveEvent);
|
|
3568
|
+
}
|
|
3569
|
+
const ps = rowResizingPluginKey.getState(view.state);
|
|
3570
|
+
if (!ps?.dragging) {
|
|
3571
|
+
return;
|
|
3572
|
+
}
|
|
3573
|
+
const h = draggedHeight(ps.dragging, moveEvent, minHeight);
|
|
3574
|
+
if (h !== ps.dragging.currentHeight) {
|
|
3575
|
+
setDragging(view, { ...ps.dragging, currentHeight: h });
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
win.addEventListener("mouseup", finish);
|
|
3579
|
+
win.addEventListener("mousemove", move);
|
|
3580
|
+
event.preventDefault();
|
|
3581
|
+
return true;
|
|
3582
|
+
}
|
|
3583
|
+
function setDragging(view, dragging) {
|
|
3584
|
+
view.dispatch(
|
|
3585
|
+
view.state.tr.setMeta(rowResizingPluginKey, { setDragging: dragging })
|
|
3586
|
+
);
|
|
3587
|
+
}
|
|
3588
|
+
function currentRowHeight(view, cellPos) {
|
|
3589
|
+
const info = targetRowInfo(view, cellPos);
|
|
3590
|
+
const tr = rowTrElement(view, cellPos, info.row);
|
|
3591
|
+
return tr ? tr.offsetHeight : ROW_RESIZE_MIN_HEIGHT;
|
|
3592
|
+
}
|
|
3593
|
+
function commitRowHeight(view, cellPos, height) {
|
|
3594
|
+
const { table, map, start, row } = targetRowInfo(view, cellPos);
|
|
3595
|
+
const tr = view.state.tr;
|
|
3596
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3597
|
+
for (let col = 0; col < map.width; col++) {
|
|
3598
|
+
const cellRelPos = map.map[row * map.width + col];
|
|
3599
|
+
if (seen.has(cellRelPos)) {
|
|
3600
|
+
continue;
|
|
3601
|
+
}
|
|
3602
|
+
seen.add(cellRelPos);
|
|
3603
|
+
const rect = map.findCell(cellRelPos);
|
|
3604
|
+
if (rect.bottom - 1 !== row) {
|
|
3605
|
+
continue;
|
|
3606
|
+
}
|
|
3607
|
+
const node = table.nodeAt(cellRelPos);
|
|
3608
|
+
if (!node || node.attrs.rowHeight === height) {
|
|
3609
|
+
continue;
|
|
3610
|
+
}
|
|
3611
|
+
tr.setNodeMarkup(start + cellRelPos, void 0, {
|
|
3612
|
+
...node.attrs,
|
|
3613
|
+
rowHeight: height
|
|
3614
|
+
});
|
|
3615
|
+
}
|
|
3616
|
+
if (tr.docChanged) {
|
|
3617
|
+
view.dispatch(tr);
|
|
3618
|
+
}
|
|
3619
|
+
}
|
|
3620
|
+
function targetRowInfo(view, cellPos) {
|
|
3621
|
+
const $cell = view.state.doc.resolve(cellPos);
|
|
3622
|
+
const table = $cell.node(-1);
|
|
3623
|
+
const map = import_prosemirror_tables.TableMap.get(table);
|
|
3624
|
+
const start = $cell.start(-1);
|
|
3625
|
+
const rect = map.findCell($cell.pos - start);
|
|
3626
|
+
return { table, map, start, row: rect.bottom - 1, $cell };
|
|
3627
|
+
}
|
|
3628
|
+
function rowTrElement(view, cellPos, row) {
|
|
3629
|
+
let dom = view.nodeDOM(cellPos);
|
|
3630
|
+
while (dom && dom.nodeName !== "TABLE") {
|
|
3631
|
+
dom = dom.parentNode;
|
|
3632
|
+
}
|
|
3633
|
+
if (!dom) {
|
|
3634
|
+
return null;
|
|
3635
|
+
}
|
|
3636
|
+
return dom.rows[row] ?? null;
|
|
3637
|
+
}
|
|
3638
|
+
function domCellAround(target) {
|
|
3639
|
+
let node = target;
|
|
3640
|
+
while (node && node.nodeName !== "TD" && node.nodeName !== "TH") {
|
|
3641
|
+
node = node.classList?.contains("ProseMirror") ? null : node.parentNode;
|
|
3642
|
+
}
|
|
3643
|
+
return node;
|
|
3644
|
+
}
|
|
3645
|
+
function edgeCell(view, event, side, handleWidth) {
|
|
3646
|
+
const offset2 = side === "bottom" ? -handleWidth : handleWidth;
|
|
3647
|
+
const found = view.posAtCoords({
|
|
3648
|
+
left: event.clientX,
|
|
3649
|
+
top: event.clientY + offset2
|
|
3650
|
+
});
|
|
3651
|
+
if (!found) {
|
|
3652
|
+
return -1;
|
|
3653
|
+
}
|
|
3654
|
+
const $cell = (0, import_prosemirror_tables.cellAround)(view.state.doc.resolve(found.pos));
|
|
3655
|
+
if (!$cell) {
|
|
3656
|
+
return -1;
|
|
3657
|
+
}
|
|
3658
|
+
if (side === "bottom") {
|
|
3659
|
+
return $cell.pos;
|
|
3660
|
+
}
|
|
3661
|
+
const map = import_prosemirror_tables.TableMap.get($cell.node(-1));
|
|
3662
|
+
const start = $cell.start(-1);
|
|
3663
|
+
const index = map.map.indexOf($cell.pos - start);
|
|
3664
|
+
return index < map.width ? -1 : start + map.map[index - map.width];
|
|
3665
|
+
}
|
|
3666
|
+
function updateHandle(view, value) {
|
|
3667
|
+
view.dispatch(
|
|
3668
|
+
view.state.tr.setMeta(rowResizingPluginKey, { setHandle: value })
|
|
3669
|
+
);
|
|
3670
|
+
}
|
|
3671
|
+
function draggedHeight(dragging, event, minHeight) {
|
|
3672
|
+
const offset2 = event.clientY - dragging.startY;
|
|
3673
|
+
return Math.max(minHeight, dragging.startHeight + offset2);
|
|
3674
|
+
}
|
|
3675
|
+
function handleDecorations(state, pluginState) {
|
|
3676
|
+
const decorations = [];
|
|
3677
|
+
const $cell = state.doc.resolve(pluginState.activeHandle);
|
|
3678
|
+
const table = $cell.node(-1);
|
|
3679
|
+
if (!table) {
|
|
3680
|
+
return import_prosemirror_view2.DecorationSet.empty;
|
|
3681
|
+
}
|
|
3682
|
+
const map = import_prosemirror_tables.TableMap.get(table);
|
|
3683
|
+
const start = $cell.start(-1);
|
|
3684
|
+
const row = map.findCell($cell.pos - start).bottom - 1;
|
|
3685
|
+
const dragging = pluginState.dragging;
|
|
3686
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3687
|
+
for (let col = 0; col < map.width; col++) {
|
|
3688
|
+
const cellRelPos = map.map[row * map.width + col];
|
|
3689
|
+
if (seen.has(cellRelPos)) {
|
|
3690
|
+
continue;
|
|
3691
|
+
}
|
|
3692
|
+
seen.add(cellRelPos);
|
|
3693
|
+
if (map.findCell(cellRelPos).bottom - 1 !== row) {
|
|
3694
|
+
continue;
|
|
3695
|
+
}
|
|
3696
|
+
const node = table.nodeAt(cellRelPos);
|
|
3697
|
+
if (!node) {
|
|
3698
|
+
continue;
|
|
3699
|
+
}
|
|
3700
|
+
const from = start + cellRelPos;
|
|
3701
|
+
const to = from + node.nodeSize;
|
|
3702
|
+
if (dragging) {
|
|
3703
|
+
decorations.push(
|
|
3704
|
+
import_prosemirror_view2.Decoration.node(from, to, {
|
|
3705
|
+
class: "row-resize-dragging",
|
|
3706
|
+
style: `height: ${dragging.currentHeight}px`
|
|
3707
|
+
})
|
|
3708
|
+
);
|
|
3709
|
+
}
|
|
3710
|
+
const handle = document.createElement("div");
|
|
3711
|
+
handle.className = "row-resize-handle";
|
|
3712
|
+
decorations.push(import_prosemirror_view2.Decoration.widget(to - 1, handle));
|
|
3713
|
+
}
|
|
3714
|
+
return import_prosemirror_view2.DecorationSet.create(state.doc, decorations);
|
|
3715
|
+
}
|
|
3716
|
+
|
|
3717
|
+
// src/extensions/tableCellAttrPreserve.ts
|
|
3718
|
+
var import_prosemirror_state4 = require("prosemirror-state");
|
|
3719
|
+
var tableCellAttrPreserveKey = new import_prosemirror_state4.PluginKey(
|
|
3720
|
+
"lumirTableCellAttrPreserve"
|
|
3721
|
+
);
|
|
3722
|
+
var PRESERVED_ATTRS = [
|
|
3723
|
+
{ name: "rowHeight", default: null },
|
|
3724
|
+
{ name: "verticalAlignment", default: "top" }
|
|
3725
|
+
];
|
|
3726
|
+
function isMeaningful(attrName, value, def) {
|
|
3727
|
+
if (value === null || value === void 0) {
|
|
3728
|
+
return false;
|
|
3729
|
+
}
|
|
3730
|
+
return value !== def;
|
|
3731
|
+
}
|
|
3732
|
+
function meaningfulAttrs(node) {
|
|
3733
|
+
let out = null;
|
|
3734
|
+
for (const { name, default: def } of PRESERVED_ATTRS) {
|
|
3735
|
+
const v = node.attrs?.[name];
|
|
3736
|
+
if (isMeaningful(name, v, def)) {
|
|
3737
|
+
(out ?? (out = {}))[name] = v;
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
return out;
|
|
3741
|
+
}
|
|
3742
|
+
function collectCellAttrs(doc) {
|
|
3743
|
+
const result = /* @__PURE__ */ new Map();
|
|
3744
|
+
doc.descendants((node) => {
|
|
3745
|
+
if (node.type.name !== "blockContainer") {
|
|
3746
|
+
return void 0;
|
|
3747
|
+
}
|
|
3748
|
+
const id = node.attrs?.id;
|
|
3749
|
+
const table = node.firstChild;
|
|
3750
|
+
if (!id || table?.type.name !== "table") {
|
|
3751
|
+
return void 0;
|
|
3752
|
+
}
|
|
3753
|
+
const cells = /* @__PURE__ */ new Map();
|
|
3754
|
+
let rowIndex = 0;
|
|
3755
|
+
table.forEach((rowNode) => {
|
|
3756
|
+
if (rowNode.type.name === "tableRow") {
|
|
3757
|
+
let cellIndex = 0;
|
|
3758
|
+
rowNode.forEach((cellNode) => {
|
|
3759
|
+
const attrs = meaningfulAttrs(cellNode);
|
|
3760
|
+
if (attrs) {
|
|
3761
|
+
cells.set(`${rowIndex}:${cellIndex}`, attrs);
|
|
3762
|
+
}
|
|
3763
|
+
cellIndex++;
|
|
3764
|
+
});
|
|
3765
|
+
rowIndex++;
|
|
3766
|
+
}
|
|
3767
|
+
});
|
|
3768
|
+
if (cells.size > 0) {
|
|
3769
|
+
result.set(id, cells);
|
|
3770
|
+
}
|
|
3771
|
+
return false;
|
|
3772
|
+
});
|
|
3773
|
+
return result;
|
|
3774
|
+
}
|
|
3775
|
+
function tableCellAttrPreserve() {
|
|
3776
|
+
return new import_prosemirror_state4.Plugin({
|
|
3777
|
+
key: tableCellAttrPreserveKey,
|
|
3778
|
+
appendTransaction(transactions, oldState, newState) {
|
|
3779
|
+
if (!transactions.some((tr2) => tr2.docChanged)) {
|
|
3780
|
+
return null;
|
|
3781
|
+
}
|
|
3782
|
+
const oldMap = collectCellAttrs(oldState.doc);
|
|
3783
|
+
if (oldMap.size === 0) {
|
|
3784
|
+
return null;
|
|
3785
|
+
}
|
|
3786
|
+
const tr = newState.tr;
|
|
3787
|
+
let changed = false;
|
|
3788
|
+
let curTableCells = null;
|
|
3789
|
+
let curRowIndex = -1;
|
|
3790
|
+
let curCellIndex = 0;
|
|
3791
|
+
newState.doc.descendants((node, pos) => {
|
|
3792
|
+
const name = node.type.name;
|
|
3793
|
+
if (name === "blockContainer") {
|
|
3794
|
+
const id = node.attrs?.id;
|
|
3795
|
+
const table = node.firstChild;
|
|
3796
|
+
if (id && table?.type.name === "table" && oldMap.has(id)) {
|
|
3797
|
+
curTableCells = oldMap.get(id);
|
|
3798
|
+
curRowIndex = -1;
|
|
3799
|
+
} else {
|
|
3800
|
+
curTableCells = null;
|
|
3801
|
+
}
|
|
3802
|
+
return void 0;
|
|
3803
|
+
}
|
|
3804
|
+
if (!curTableCells) {
|
|
3805
|
+
return void 0;
|
|
3806
|
+
}
|
|
3807
|
+
if (name === "tableRow") {
|
|
3808
|
+
curRowIndex++;
|
|
3809
|
+
curCellIndex = 0;
|
|
3810
|
+
return void 0;
|
|
3811
|
+
}
|
|
3812
|
+
if (name === "tableCell" || name === "tableHeader") {
|
|
3813
|
+
const wanted = curTableCells.get(`${curRowIndex}:${curCellIndex}`);
|
|
3814
|
+
curCellIndex++;
|
|
3815
|
+
if (wanted) {
|
|
3816
|
+
const patch = {};
|
|
3817
|
+
let needs = false;
|
|
3818
|
+
for (const { name: attrName, default: def } of PRESERVED_ATTRS) {
|
|
3819
|
+
if (!(attrName in wanted)) {
|
|
3820
|
+
continue;
|
|
3821
|
+
}
|
|
3822
|
+
const cur = node.attrs?.[attrName];
|
|
3823
|
+
if (cur === null || cur === void 0 || cur === def) {
|
|
3824
|
+
patch[attrName] = wanted[attrName];
|
|
3825
|
+
needs = true;
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
if (needs) {
|
|
3829
|
+
tr.setNodeMarkup(pos, void 0, { ...node.attrs, ...patch });
|
|
3830
|
+
changed = true;
|
|
3831
|
+
}
|
|
3832
|
+
}
|
|
3833
|
+
return false;
|
|
3834
|
+
}
|
|
3835
|
+
return void 0;
|
|
3836
|
+
});
|
|
3837
|
+
return changed ? tr : null;
|
|
3838
|
+
}
|
|
3839
|
+
});
|
|
3840
|
+
}
|
|
3841
|
+
|
|
3842
|
+
// src/extensions/RowHeightExtension.ts
|
|
3843
|
+
var RowHeightExtension = import_core5.Extension.create({
|
|
3844
|
+
name: "rowHeight",
|
|
3845
|
+
addOptions() {
|
|
3846
|
+
return { resizable: true };
|
|
3847
|
+
},
|
|
3848
|
+
addGlobalAttributes() {
|
|
3849
|
+
return [
|
|
3850
|
+
{
|
|
3851
|
+
types: ["tableCell", "tableHeader"],
|
|
3852
|
+
attributes: {
|
|
3853
|
+
rowHeight: {
|
|
3854
|
+
default: null,
|
|
3855
|
+
parseHTML: (element) => {
|
|
3856
|
+
const fromStyle = parseInt(element.style?.height ?? "", 10);
|
|
3857
|
+
if (Number.isFinite(fromStyle) && fromStyle > 0) {
|
|
3858
|
+
return fromStyle;
|
|
3859
|
+
}
|
|
3860
|
+
const fromAttr = parseInt(
|
|
3861
|
+
element.getAttribute("data-row-height") ?? "",
|
|
3862
|
+
10
|
|
3863
|
+
);
|
|
3864
|
+
return Number.isFinite(fromAttr) && fromAttr > 0 ? fromAttr : null;
|
|
3865
|
+
},
|
|
3866
|
+
renderHTML: (attributes) => {
|
|
3867
|
+
const h = attributes.rowHeight;
|
|
3868
|
+
if (!h || typeof h !== "number") {
|
|
3869
|
+
return {};
|
|
3870
|
+
}
|
|
3871
|
+
return { style: `height: ${h}px` };
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
];
|
|
3877
|
+
},
|
|
3878
|
+
addProseMirrorPlugins() {
|
|
3879
|
+
const plugins = [tableCellAttrPreserve()];
|
|
3880
|
+
if (this.options.resizable) {
|
|
3881
|
+
plugins.push(rowResizing());
|
|
3882
|
+
}
|
|
3883
|
+
return plugins;
|
|
3884
|
+
}
|
|
3885
|
+
});
|
|
3886
|
+
|
|
3887
|
+
// src/extensions/TableAlignmentExtension.ts
|
|
3888
|
+
var import_core6 = require("@tiptap/core");
|
|
3889
|
+
var import_prosemirror_state5 = require("prosemirror-state");
|
|
3890
|
+
var import_prosemirror_view3 = require("prosemirror-view");
|
|
3891
|
+
var tableAlignmentDecoKey = new import_prosemirror_state5.PluginKey("lumirTableAlignmentDeco");
|
|
3892
|
+
function tableAlignmentDecorationPlugin() {
|
|
3893
|
+
return new import_prosemirror_state5.Plugin({
|
|
3894
|
+
key: tableAlignmentDecoKey,
|
|
3895
|
+
props: {
|
|
3896
|
+
decorations(state) {
|
|
3897
|
+
const decorations = [];
|
|
3898
|
+
state.doc.descendants((node, pos) => {
|
|
3899
|
+
if (node.type.name === "table") {
|
|
3900
|
+
const align = node.attrs.tableAlignment;
|
|
3901
|
+
if (align && align !== "left") {
|
|
3902
|
+
decorations.push(
|
|
3903
|
+
import_prosemirror_view3.Decoration.node(pos, pos + node.nodeSize, {
|
|
3904
|
+
"data-table-alignment": align
|
|
3905
|
+
})
|
|
3906
|
+
);
|
|
3907
|
+
}
|
|
3908
|
+
return false;
|
|
3909
|
+
}
|
|
3910
|
+
return void 0;
|
|
3911
|
+
});
|
|
3912
|
+
return import_prosemirror_view3.DecorationSet.create(state.doc, decorations);
|
|
3913
|
+
}
|
|
3914
|
+
}
|
|
3915
|
+
});
|
|
3916
|
+
}
|
|
3917
|
+
var TableAlignmentExtension = import_core6.Extension.create({
|
|
3918
|
+
name: "tableAlignment",
|
|
3919
|
+
addGlobalAttributes() {
|
|
3920
|
+
return [
|
|
3921
|
+
{
|
|
3922
|
+
types: ["table"],
|
|
3923
|
+
attributes: {
|
|
3924
|
+
tableAlignment: {
|
|
3925
|
+
default: "left",
|
|
3926
|
+
parseHTML: (element) => element.getAttribute("data-table-alignment") || "left",
|
|
3927
|
+
renderHTML: (attributes) => {
|
|
3928
|
+
if (!attributes.tableAlignment || attributes.tableAlignment === "left") {
|
|
3929
|
+
return {};
|
|
3930
|
+
}
|
|
3931
|
+
return { "data-table-alignment": attributes.tableAlignment };
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
];
|
|
3937
|
+
},
|
|
3938
|
+
addProseMirrorPlugins() {
|
|
3939
|
+
return [tableAlignmentDecorationPlugin()];
|
|
3940
|
+
}
|
|
3941
|
+
});
|
|
3942
|
+
|
|
3943
|
+
// src/blocks/columns/insertColumns.ts
|
|
3944
|
+
var import_prosemirror_state6 = require("prosemirror-state");
|
|
3945
|
+
function insertTwoColumns(editor) {
|
|
3946
|
+
const tiptap = editor?._tiptapEditor;
|
|
3947
|
+
if (!tiptap) {
|
|
3948
|
+
return false;
|
|
3949
|
+
}
|
|
3950
|
+
const { state, schema: schema2 } = tiptap;
|
|
3951
|
+
const { blockContainer, paragraph, column, columnList } = schema2.nodes;
|
|
3952
|
+
if (!blockContainer || !paragraph || !column || !columnList) {
|
|
3953
|
+
return false;
|
|
3954
|
+
}
|
|
3955
|
+
const $from = state.selection.$from;
|
|
3956
|
+
for (let d = $from.depth; d > 0; d--) {
|
|
3957
|
+
const name = $from.node(d).type.name;
|
|
3958
|
+
if (name === "column" || name === "columnList") {
|
|
3959
|
+
return false;
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
let depth = $from.depth;
|
|
3963
|
+
while (depth > 0 && $from.node(depth).type.name !== "blockContainer") {
|
|
3964
|
+
depth--;
|
|
3965
|
+
}
|
|
3966
|
+
if (depth === 0) {
|
|
3967
|
+
return false;
|
|
3968
|
+
}
|
|
3969
|
+
const insertPos = $from.after(depth);
|
|
3970
|
+
const mkBlock = () => blockContainer.create(null, paragraph.create());
|
|
3971
|
+
const mkColumn = () => column.create(null, mkBlock());
|
|
3972
|
+
const list = columnList.create(null, [mkColumn(), mkColumn()]);
|
|
3973
|
+
try {
|
|
3974
|
+
let tr = state.tr.insert(insertPos, list);
|
|
3975
|
+
try {
|
|
3976
|
+
tr = tr.setSelection(import_prosemirror_state6.TextSelection.create(tr.doc, insertPos + 4));
|
|
3977
|
+
} catch {
|
|
3978
|
+
}
|
|
3979
|
+
tiptap.view.dispatch(tr.scrollIntoView());
|
|
3980
|
+
return true;
|
|
3981
|
+
} catch {
|
|
3982
|
+
return false;
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3985
|
+
|
|
3986
|
+
// src/components/CustomFormattingToolbar.tsx
|
|
3987
|
+
var import_react30 = require("@blocknote/react");
|
|
3988
|
+
|
|
3989
|
+
// src/components/TextAlignButtonWithVA.tsx
|
|
3990
|
+
var import_core7 = require("@blocknote/core");
|
|
3991
|
+
var import_react20 = require("react");
|
|
3992
|
+
var import_react21 = require("@blocknote/react");
|
|
3993
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2947
3994
|
var icons = {
|
|
2948
|
-
left: /* @__PURE__ */ (0,
|
|
2949
|
-
center: /* @__PURE__ */ (0,
|
|
2950
|
-
right: /* @__PURE__ */ (0,
|
|
2951
|
-
justify: /* @__PURE__ */ (0,
|
|
3995
|
+
left: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", width: "18", height: "18", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z" }) }),
|
|
3996
|
+
center: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", width: "18", height: "18", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z" }) }),
|
|
3997
|
+
right: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", width: "18", height: "18", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z" }) }),
|
|
3998
|
+
justify: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", width: "18", height: "18", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zM3 3v2h18V3H3z" }) })
|
|
2952
3999
|
};
|
|
2953
4000
|
var tooltipMap = {
|
|
2954
4001
|
left: "\uC67C\uCABD \uC815\uB82C",
|
|
@@ -2957,12 +4004,12 @@ var tooltipMap = {
|
|
|
2957
4004
|
justify: "\uC591\uCABD \uC815\uB82C"
|
|
2958
4005
|
};
|
|
2959
4006
|
var TextAlignButtonWithVA = (props) => {
|
|
2960
|
-
const Components = (0,
|
|
2961
|
-
const editor = (0,
|
|
2962
|
-
const selectedBlocks = (0,
|
|
2963
|
-
const textAlignment = (0,
|
|
4007
|
+
const Components = (0, import_react21.useComponentsContext)();
|
|
4008
|
+
const editor = (0, import_react21.useBlockNoteEditor)();
|
|
4009
|
+
const selectedBlocks = (0, import_react21.useSelectedBlocks)(editor);
|
|
4010
|
+
const textAlignment = (0, import_react20.useMemo)(() => {
|
|
2964
4011
|
const block = selectedBlocks[0];
|
|
2965
|
-
if ((0,
|
|
4012
|
+
if ((0, import_core7.checkBlockHasDefaultProp)("textAlignment", block, editor)) {
|
|
2966
4013
|
return block.props.textAlignment;
|
|
2967
4014
|
}
|
|
2968
4015
|
if (block.type === "table") {
|
|
@@ -2971,7 +4018,7 @@ var TextAlignButtonWithVA = (props) => {
|
|
|
2971
4018
|
return;
|
|
2972
4019
|
}
|
|
2973
4020
|
const allCellsInTable = cellSelection.cells.map(
|
|
2974
|
-
({ row, col }) => (0,
|
|
4021
|
+
({ row, col }) => (0, import_core7.mapTableCell)(
|
|
2975
4022
|
block.content.rows[row].cells[col]
|
|
2976
4023
|
).props.textAlignment
|
|
2977
4024
|
);
|
|
@@ -2982,7 +4029,7 @@ var TextAlignButtonWithVA = (props) => {
|
|
|
2982
4029
|
}
|
|
2983
4030
|
return;
|
|
2984
4031
|
}, [editor, selectedBlocks]);
|
|
2985
|
-
const setTextAlignment = (0,
|
|
4032
|
+
const setTextAlignment = (0, import_react20.useCallback)(
|
|
2986
4033
|
(newAlignment) => {
|
|
2987
4034
|
editor.focus();
|
|
2988
4035
|
for (const block of selectedBlocks) {
|
|
@@ -3003,7 +4050,7 @@ var TextAlignButtonWithVA = (props) => {
|
|
|
3003
4050
|
}
|
|
3004
4051
|
}
|
|
3005
4052
|
tiptap.view?.dispatch(tr);
|
|
3006
|
-
} else if ((0,
|
|
4053
|
+
} else if ((0, import_core7.checkBlockTypeHasDefaultProp)("textAlignment", block.type, editor)) {
|
|
3007
4054
|
editor.updateBlock(block, {
|
|
3008
4055
|
props: { textAlignment: newAlignment }
|
|
3009
4056
|
});
|
|
@@ -3012,7 +4059,7 @@ var TextAlignButtonWithVA = (props) => {
|
|
|
3012
4059
|
},
|
|
3013
4060
|
[editor, selectedBlocks]
|
|
3014
4061
|
);
|
|
3015
|
-
const show = (0,
|
|
4062
|
+
const show = (0, import_react20.useMemo)(() => {
|
|
3016
4063
|
return !!selectedBlocks.find(
|
|
3017
4064
|
(block) => "textAlignment" in block.props || block.type === "table" && block.children
|
|
3018
4065
|
);
|
|
@@ -3020,7 +4067,7 @@ var TextAlignButtonWithVA = (props) => {
|
|
|
3020
4067
|
if (!show || !editor.isEditable) {
|
|
3021
4068
|
return null;
|
|
3022
4069
|
}
|
|
3023
|
-
return /* @__PURE__ */ (0,
|
|
4070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3024
4071
|
Components.FormattingToolbar.Button,
|
|
3025
4072
|
{
|
|
3026
4073
|
className: "bn-button",
|
|
@@ -3035,21 +4082,21 @@ var TextAlignButtonWithVA = (props) => {
|
|
|
3035
4082
|
};
|
|
3036
4083
|
|
|
3037
4084
|
// src/components/VerticalAlignButton.tsx
|
|
3038
|
-
var
|
|
3039
|
-
var
|
|
3040
|
-
var
|
|
4085
|
+
var import_react22 = require("react");
|
|
4086
|
+
var import_react23 = require("@blocknote/react");
|
|
4087
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3041
4088
|
var icons2 = {
|
|
3042
|
-
top: /* @__PURE__ */ (0,
|
|
3043
|
-
/* @__PURE__ */ (0,
|
|
3044
|
-
/* @__PURE__ */ (0,
|
|
4089
|
+
top: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
|
|
4090
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("rect", { x: "2", y: "2", width: "12", height: "12", rx: "1" }),
|
|
4091
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("line", { x1: "5", y1: "5", x2: "11", y2: "5" })
|
|
3045
4092
|
] }),
|
|
3046
|
-
middle: /* @__PURE__ */ (0,
|
|
3047
|
-
/* @__PURE__ */ (0,
|
|
3048
|
-
/* @__PURE__ */ (0,
|
|
4093
|
+
middle: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
|
|
4094
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("rect", { x: "2", y: "2", width: "12", height: "12", rx: "1" }),
|
|
4095
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("line", { x1: "5", y1: "8", x2: "11", y2: "8" })
|
|
3049
4096
|
] }),
|
|
3050
|
-
bottom: /* @__PURE__ */ (0,
|
|
3051
|
-
/* @__PURE__ */ (0,
|
|
3052
|
-
/* @__PURE__ */ (0,
|
|
4097
|
+
bottom: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
|
|
4098
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("rect", { x: "2", y: "2", width: "12", height: "12", rx: "1" }),
|
|
4099
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("line", { x1: "5", y1: "11", x2: "11", y2: "11" })
|
|
3053
4100
|
] })
|
|
3054
4101
|
};
|
|
3055
4102
|
var tooltips = {
|
|
@@ -3071,13 +4118,13 @@ function getCurrentVerticalAlignment(editor) {
|
|
|
3071
4118
|
return alignments.every((a) => a === first) ? first : void 0;
|
|
3072
4119
|
}
|
|
3073
4120
|
var VerticalAlignButton = (props) => {
|
|
3074
|
-
const Components = (0,
|
|
3075
|
-
const editor = (0,
|
|
3076
|
-
const selectedBlocks = (0,
|
|
3077
|
-
const currentAlignment = (0,
|
|
4121
|
+
const Components = (0, import_react23.useComponentsContext)();
|
|
4122
|
+
const editor = (0, import_react23.useBlockNoteEditor)();
|
|
4123
|
+
const selectedBlocks = (0, import_react23.useSelectedBlocks)(editor);
|
|
4124
|
+
const currentAlignment = (0, import_react22.useMemo)(() => {
|
|
3078
4125
|
return getCurrentVerticalAlignment(editor);
|
|
3079
4126
|
}, [editor, selectedBlocks]);
|
|
3080
|
-
const setVerticalAlignment = (0,
|
|
4127
|
+
const setVerticalAlignment = (0, import_react22.useCallback)(
|
|
3081
4128
|
(alignment) => {
|
|
3082
4129
|
const tiptap = editor._tiptapEditor;
|
|
3083
4130
|
if (!tiptap) return;
|
|
@@ -3099,13 +4146,13 @@ var VerticalAlignButton = (props) => {
|
|
|
3099
4146
|
},
|
|
3100
4147
|
[editor]
|
|
3101
4148
|
);
|
|
3102
|
-
const isInTable = (0,
|
|
4149
|
+
const isInTable = (0, import_react22.useMemo)(() => {
|
|
3103
4150
|
return selectedBlocks.some((block) => block.type === "table");
|
|
3104
4151
|
}, [selectedBlocks]);
|
|
3105
4152
|
if (!isInTable || !editor.isEditable) {
|
|
3106
4153
|
return null;
|
|
3107
4154
|
}
|
|
3108
|
-
return /* @__PURE__ */ (0,
|
|
4155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3109
4156
|
Components.FormattingToolbar.Button,
|
|
3110
4157
|
{
|
|
3111
4158
|
className: "bn-button",
|
|
@@ -3119,11 +4166,167 @@ var VerticalAlignButton = (props) => {
|
|
|
3119
4166
|
);
|
|
3120
4167
|
};
|
|
3121
4168
|
|
|
4169
|
+
// src/components/TableAlignButton.tsx
|
|
4170
|
+
var import_react24 = require("react");
|
|
4171
|
+
var import_react25 = require("@blocknote/react");
|
|
4172
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
4173
|
+
var icons3 = {
|
|
4174
|
+
left: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.4", children: [
|
|
4175
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("rect", { x: "1.5", y: "4", width: "7", height: "8", rx: "1", fill: "currentColor", stroke: "none" }),
|
|
4176
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("line", { x1: "1.5", y1: "1.5", x2: "14.5", y2: "1.5" }),
|
|
4177
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("line", { x1: "1.5", y1: "14.5", x2: "14.5", y2: "14.5" })
|
|
4178
|
+
] }),
|
|
4179
|
+
center: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.4", children: [
|
|
4180
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("rect", { x: "4.5", y: "4", width: "7", height: "8", rx: "1", fill: "currentColor", stroke: "none" }),
|
|
4181
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("line", { x1: "1.5", y1: "1.5", x2: "14.5", y2: "1.5" }),
|
|
4182
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("line", { x1: "1.5", y1: "14.5", x2: "14.5", y2: "14.5" })
|
|
4183
|
+
] }),
|
|
4184
|
+
right: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.4", children: [
|
|
4185
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("rect", { x: "7.5", y: "4", width: "7", height: "8", rx: "1", fill: "currentColor", stroke: "none" }),
|
|
4186
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("line", { x1: "1.5", y1: "1.5", x2: "14.5", y2: "1.5" }),
|
|
4187
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("line", { x1: "1.5", y1: "14.5", x2: "14.5", y2: "14.5" })
|
|
4188
|
+
] })
|
|
4189
|
+
};
|
|
4190
|
+
var tooltips2 = {
|
|
4191
|
+
left: "\uD45C \uC67C\uCABD \uC815\uB82C",
|
|
4192
|
+
center: "\uD45C \uAC00\uC6B4\uB370 \uC815\uB82C",
|
|
4193
|
+
right: "\uD45C \uC624\uB978\uCABD \uC815\uB82C"
|
|
4194
|
+
};
|
|
4195
|
+
var TableAlignButton = (props) => {
|
|
4196
|
+
const Components = (0, import_react25.useComponentsContext)();
|
|
4197
|
+
const editor = (0, import_react25.useBlockNoteEditor)();
|
|
4198
|
+
const selectedBlocks = (0, import_react25.useSelectedBlocks)(editor);
|
|
4199
|
+
const tableBlock = (0, import_react24.useMemo)(
|
|
4200
|
+
() => selectedBlocks.find((block) => block.type === "table"),
|
|
4201
|
+
[selectedBlocks]
|
|
4202
|
+
);
|
|
4203
|
+
const current = (0, import_react24.useMemo)(() => {
|
|
4204
|
+
if (!tableBlock?.id) return "left";
|
|
4205
|
+
return getTableAlignment(editor, tableBlock.id);
|
|
4206
|
+
}, [editor, tableBlock, selectedBlocks]);
|
|
4207
|
+
const apply = (0, import_react24.useCallback)(() => {
|
|
4208
|
+
if (!tableBlock?.id) return;
|
|
4209
|
+
editor.focus();
|
|
4210
|
+
setTableAlignment(editor, tableBlock.id, props.alignment);
|
|
4211
|
+
}, [editor, tableBlock, props.alignment]);
|
|
4212
|
+
if (!tableBlock || !editor.isEditable) {
|
|
4213
|
+
return null;
|
|
4214
|
+
}
|
|
4215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
4216
|
+
Components.FormattingToolbar.Button,
|
|
4217
|
+
{
|
|
4218
|
+
className: "bn-button",
|
|
4219
|
+
"data-test": `tableAlign${props.alignment.charAt(0).toUpperCase() + props.alignment.slice(1)}`,
|
|
4220
|
+
onClick: apply,
|
|
4221
|
+
isSelected: current === props.alignment,
|
|
4222
|
+
label: tooltips2[props.alignment],
|
|
4223
|
+
mainTooltip: tooltips2[props.alignment],
|
|
4224
|
+
icon: icons3[props.alignment]
|
|
4225
|
+
}
|
|
4226
|
+
);
|
|
4227
|
+
};
|
|
4228
|
+
|
|
4229
|
+
// src/components/FontSizeButton.tsx
|
|
4230
|
+
var import_react26 = require("@blocknote/react");
|
|
4231
|
+
var import_react27 = require("react");
|
|
4232
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
4233
|
+
var DEFAULT_LABEL2 = "\uAE30\uBCF8";
|
|
4234
|
+
var toLabel2 = (size) => size.replace(/px$/, "");
|
|
4235
|
+
function FontSizeIcon({ size }) {
|
|
4236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
4237
|
+
"span",
|
|
4238
|
+
{
|
|
4239
|
+
style: {
|
|
4240
|
+
pointerEvents: "none",
|
|
4241
|
+
fontSize: "12px",
|
|
4242
|
+
fontWeight: 600,
|
|
4243
|
+
lineHeight: "20px",
|
|
4244
|
+
whiteSpace: "nowrap"
|
|
4245
|
+
},
|
|
4246
|
+
children: size ? toLabel2(size) : "\uAC00A"
|
|
4247
|
+
}
|
|
4248
|
+
);
|
|
4249
|
+
}
|
|
4250
|
+
function FontSizeButton2() {
|
|
4251
|
+
const Components = (0, import_react26.useComponentsContext)();
|
|
4252
|
+
const editor = (0, import_react26.useBlockNoteEditor)();
|
|
4253
|
+
const ed = editor;
|
|
4254
|
+
const styleSchema = editor.schema.styleSchema;
|
|
4255
|
+
const fontSizeInSchema = styleSchema.fontSize?.type === "fontSize" && styleSchema.fontSize?.propSchema === "string";
|
|
4256
|
+
const selectedBlocks = (0, import_react26.useSelectedBlocks)(editor);
|
|
4257
|
+
const [currentSize, setCurrentSize] = (0, import_react27.useState)(
|
|
4258
|
+
fontSizeInSchema ? ed.getActiveStyles().fontSize || "" : ""
|
|
4259
|
+
);
|
|
4260
|
+
(0, import_react26.useEditorContentOrSelectionChange)(() => {
|
|
4261
|
+
if (fontSizeInSchema) {
|
|
4262
|
+
setCurrentSize(ed.getActiveStyles().fontSize || "");
|
|
4263
|
+
}
|
|
4264
|
+
}, editor);
|
|
4265
|
+
const setFontSize = (0, import_react27.useCallback)(
|
|
4266
|
+
(size) => {
|
|
4267
|
+
size === "" ? ed.removeStyles({ fontSize: "" }) : ed.addStyles({ fontSize: size });
|
|
4268
|
+
setTimeout(() => editor.focus());
|
|
4269
|
+
},
|
|
4270
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4271
|
+
[editor]
|
|
4272
|
+
);
|
|
4273
|
+
const show = (0, import_react27.useMemo)(() => {
|
|
4274
|
+
if (!fontSizeInSchema) {
|
|
4275
|
+
return false;
|
|
4276
|
+
}
|
|
4277
|
+
for (const block of selectedBlocks) {
|
|
4278
|
+
if (block.content !== void 0) {
|
|
4279
|
+
return true;
|
|
4280
|
+
}
|
|
4281
|
+
}
|
|
4282
|
+
return false;
|
|
4283
|
+
}, [fontSizeInSchema, selectedBlocks]);
|
|
4284
|
+
if (!show || !editor.isEditable) {
|
|
4285
|
+
return null;
|
|
4286
|
+
}
|
|
4287
|
+
const tooltip = "\uAE00\uC790 \uD06C\uAE30";
|
|
4288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Components.Generic.Menu.Root, { children: [
|
|
4289
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Components.Generic.Menu.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
4290
|
+
Components.FormattingToolbar.Button,
|
|
4291
|
+
{
|
|
4292
|
+
className: "bn-button",
|
|
4293
|
+
"data-test": "font-size",
|
|
4294
|
+
label: tooltip,
|
|
4295
|
+
mainTooltip: tooltip,
|
|
4296
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FontSizeIcon, { size: currentSize })
|
|
4297
|
+
}
|
|
4298
|
+
) }),
|
|
4299
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Components.Generic.Menu.Dropdown, { className: "bn-menu-dropdown", children: [
|
|
4300
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Components.Generic.Menu.Label, { children: "\uAE00\uC790 \uD06C\uAE30" }),
|
|
4301
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
4302
|
+
Components.Generic.Menu.Item,
|
|
4303
|
+
{
|
|
4304
|
+
onClick: () => setFontSize(""),
|
|
4305
|
+
checked: currentSize === "",
|
|
4306
|
+
"data-test": "font-size-default",
|
|
4307
|
+
children: DEFAULT_LABEL2
|
|
4308
|
+
},
|
|
4309
|
+
"font-size-default"
|
|
4310
|
+
),
|
|
4311
|
+
FONT_SIZE_PRESETS.map((size) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
4312
|
+
Components.Generic.Menu.Item,
|
|
4313
|
+
{
|
|
4314
|
+
onClick: () => setFontSize(size),
|
|
4315
|
+
checked: currentSize === size,
|
|
4316
|
+
"data-test": "font-size-" + toLabel2(size),
|
|
4317
|
+
children: toLabel2(size)
|
|
4318
|
+
},
|
|
4319
|
+
"font-size-" + size
|
|
4320
|
+
))
|
|
4321
|
+
] })
|
|
4322
|
+
] });
|
|
4323
|
+
}
|
|
4324
|
+
|
|
3122
4325
|
// src/components/color/LumirColorControls.tsx
|
|
3123
|
-
var
|
|
3124
|
-
var
|
|
3125
|
-
var
|
|
3126
|
-
var
|
|
4326
|
+
var import_core8 = require("@blocknote/core");
|
|
4327
|
+
var import_react28 = require("@blocknote/react");
|
|
4328
|
+
var import_react29 = require("react");
|
|
4329
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3127
4330
|
var COLORS = [
|
|
3128
4331
|
"default",
|
|
3129
4332
|
"gray",
|
|
@@ -3140,7 +4343,7 @@ function ColorIcon(props) {
|
|
|
3140
4343
|
const textColor = props.textColor || "default";
|
|
3141
4344
|
const backgroundColor = props.backgroundColor || "default";
|
|
3142
4345
|
const size = props.size || 16;
|
|
3143
|
-
return /* @__PURE__ */ (0,
|
|
4346
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3144
4347
|
"div",
|
|
3145
4348
|
{
|
|
3146
4349
|
className: "bn-color-icon",
|
|
@@ -3159,7 +4362,7 @@ function ColorIcon(props) {
|
|
|
3159
4362
|
);
|
|
3160
4363
|
}
|
|
3161
4364
|
function CellFillIcon({ size = 18 }) {
|
|
3162
|
-
return /* @__PURE__ */ (0,
|
|
4365
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3163
4366
|
"svg",
|
|
3164
4367
|
{
|
|
3165
4368
|
width: size,
|
|
@@ -3168,17 +4371,17 @@ function CellFillIcon({ size = 18 }) {
|
|
|
3168
4371
|
fill: "currentColor",
|
|
3169
4372
|
style: { pointerEvents: "none" },
|
|
3170
4373
|
"aria-hidden": "true",
|
|
3171
|
-
children: /* @__PURE__ */ (0,
|
|
4374
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: "M16.56 8.94 7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.59-.59 1.54 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.58.59-1.53 0-2.12zM5.21 10 10 5.21 14.79 10H5.21zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5z" })
|
|
3172
4375
|
}
|
|
3173
4376
|
);
|
|
3174
4377
|
}
|
|
3175
4378
|
function LumirColorPicker(props) {
|
|
3176
|
-
const Components = (0,
|
|
3177
|
-
const dict = (0,
|
|
3178
|
-
return /* @__PURE__ */ (0,
|
|
3179
|
-
props.text ? /* @__PURE__ */ (0,
|
|
3180
|
-
/* @__PURE__ */ (0,
|
|
3181
|
-
COLORS.map((color) => /* @__PURE__ */ (0,
|
|
4379
|
+
const Components = (0, import_react28.useComponentsContext)();
|
|
4380
|
+
const dict = (0, import_react28.useDictionary)();
|
|
4381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
4382
|
+
props.text ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
4383
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Components.Generic.Menu.Label, { children: props.textTitle ?? dict.color_picker.text_title }),
|
|
4384
|
+
COLORS.map((color) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3182
4385
|
Components.Generic.Menu.Item,
|
|
3183
4386
|
{
|
|
3184
4387
|
onClick: () => {
|
|
@@ -3186,16 +4389,16 @@ function LumirColorPicker(props) {
|
|
|
3186
4389
|
props.text.setColor(color);
|
|
3187
4390
|
},
|
|
3188
4391
|
"data-test": "text-color-" + color,
|
|
3189
|
-
icon: /* @__PURE__ */ (0,
|
|
4392
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ColorIcon, { textColor: color, size: props.iconSize }),
|
|
3190
4393
|
checked: props.text.color === color,
|
|
3191
4394
|
children: dict.color_picker.colors[color]
|
|
3192
4395
|
},
|
|
3193
4396
|
"text-color-" + color
|
|
3194
4397
|
))
|
|
3195
4398
|
] }) : null,
|
|
3196
|
-
props.background ? /* @__PURE__ */ (0,
|
|
3197
|
-
/* @__PURE__ */ (0,
|
|
3198
|
-
COLORS.map((color) => /* @__PURE__ */ (0,
|
|
4399
|
+
props.background ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
4400
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Components.Generic.Menu.Label, { children: props.backgroundTitle ?? dict.color_picker.background_title }),
|
|
4401
|
+
COLORS.map((color) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3199
4402
|
Components.Generic.Menu.Item,
|
|
3200
4403
|
{
|
|
3201
4404
|
onClick: () => {
|
|
@@ -3203,7 +4406,7 @@ function LumirColorPicker(props) {
|
|
|
3203
4406
|
props.background.setColor(color);
|
|
3204
4407
|
},
|
|
3205
4408
|
"data-test": "background-color-" + color,
|
|
3206
|
-
icon: /* @__PURE__ */ (0,
|
|
4409
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ColorIcon, { backgroundColor: color, size: props.iconSize }),
|
|
3207
4410
|
checked: props.background.color === color,
|
|
3208
4411
|
children: dict.color_picker.colors[color]
|
|
3209
4412
|
},
|
|
@@ -3213,20 +4416,20 @@ function LumirColorPicker(props) {
|
|
|
3213
4416
|
] });
|
|
3214
4417
|
}
|
|
3215
4418
|
function LumirColorStyleButton() {
|
|
3216
|
-
const Components = (0,
|
|
3217
|
-
const editor = (0,
|
|
4419
|
+
const Components = (0, import_react28.useComponentsContext)();
|
|
4420
|
+
const editor = (0, import_react28.useBlockNoteEditor)();
|
|
3218
4421
|
const ed = editor;
|
|
3219
4422
|
const styleSchema = editor.schema.styleSchema;
|
|
3220
4423
|
const textColorInSchema = styleSchema.textColor?.type === "textColor" && styleSchema.textColor?.propSchema === "string";
|
|
3221
4424
|
const backgroundColorInSchema = styleSchema.backgroundColor?.type === "backgroundColor" && styleSchema.backgroundColor?.propSchema === "string";
|
|
3222
|
-
const selectedBlocks = (0,
|
|
3223
|
-
const [currentTextColor, setCurrentTextColor] = (0,
|
|
4425
|
+
const selectedBlocks = (0, import_react28.useSelectedBlocks)(editor);
|
|
4426
|
+
const [currentTextColor, setCurrentTextColor] = (0, import_react29.useState)(
|
|
3224
4427
|
textColorInSchema ? ed.getActiveStyles().textColor || "default" : "default"
|
|
3225
4428
|
);
|
|
3226
|
-
const [currentBackgroundColor, setCurrentBackgroundColor] = (0,
|
|
4429
|
+
const [currentBackgroundColor, setCurrentBackgroundColor] = (0, import_react29.useState)(
|
|
3227
4430
|
backgroundColorInSchema ? ed.getActiveStyles().backgroundColor || "default" : "default"
|
|
3228
4431
|
);
|
|
3229
|
-
(0,
|
|
4432
|
+
(0, import_react28.useEditorContentOrSelectionChange)(() => {
|
|
3230
4433
|
const active = ed.getActiveStyles();
|
|
3231
4434
|
if (textColorInSchema) {
|
|
3232
4435
|
setCurrentTextColor(active.textColor || "default");
|
|
@@ -3235,7 +4438,7 @@ function LumirColorStyleButton() {
|
|
|
3235
4438
|
setCurrentBackgroundColor(active.backgroundColor || "default");
|
|
3236
4439
|
}
|
|
3237
4440
|
}, editor);
|
|
3238
|
-
const setTextColor = (0,
|
|
4441
|
+
const setTextColor = (0, import_react29.useCallback)(
|
|
3239
4442
|
(color) => {
|
|
3240
4443
|
color === "default" ? ed.removeStyles({ textColor: color }) : ed.addStyles({ textColor: color });
|
|
3241
4444
|
setTimeout(() => editor.focus());
|
|
@@ -3243,7 +4446,7 @@ function LumirColorStyleButton() {
|
|
|
3243
4446
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3244
4447
|
[editor]
|
|
3245
4448
|
);
|
|
3246
|
-
const setBackgroundColor = (0,
|
|
4449
|
+
const setBackgroundColor = (0, import_react29.useCallback)(
|
|
3247
4450
|
(color) => {
|
|
3248
4451
|
color === "default" ? ed.removeStyles({ backgroundColor: color }) : ed.addStyles({ backgroundColor: color });
|
|
3249
4452
|
setTimeout(() => editor.focus());
|
|
@@ -3251,7 +4454,7 @@ function LumirColorStyleButton() {
|
|
|
3251
4454
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3252
4455
|
[editor]
|
|
3253
4456
|
);
|
|
3254
|
-
const show = (0,
|
|
4457
|
+
const show = (0, import_react29.useMemo)(() => {
|
|
3255
4458
|
if (!textColorInSchema && !backgroundColorInSchema) {
|
|
3256
4459
|
return false;
|
|
3257
4460
|
}
|
|
@@ -3266,15 +4469,15 @@ function LumirColorStyleButton() {
|
|
|
3266
4469
|
return null;
|
|
3267
4470
|
}
|
|
3268
4471
|
const tooltip = "\uD14D\uC2A4\uD2B8 \uC0C9\xB7\uBC30\uACBD";
|
|
3269
|
-
return /* @__PURE__ */ (0,
|
|
3270
|
-
/* @__PURE__ */ (0,
|
|
4472
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Components.Generic.Menu.Root, { children: [
|
|
4473
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Components.Generic.Menu.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3271
4474
|
Components.FormattingToolbar.Button,
|
|
3272
4475
|
{
|
|
3273
4476
|
className: "bn-button",
|
|
3274
4477
|
"data-test": "colors",
|
|
3275
4478
|
label: tooltip,
|
|
3276
4479
|
mainTooltip: tooltip,
|
|
3277
|
-
icon: /* @__PURE__ */ (0,
|
|
4480
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3278
4481
|
ColorIcon,
|
|
3279
4482
|
{
|
|
3280
4483
|
textColor: currentTextColor,
|
|
@@ -3284,11 +4487,11 @@ function LumirColorStyleButton() {
|
|
|
3284
4487
|
)
|
|
3285
4488
|
}
|
|
3286
4489
|
) }),
|
|
3287
|
-
/* @__PURE__ */ (0,
|
|
4490
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3288
4491
|
Components.Generic.Menu.Dropdown,
|
|
3289
4492
|
{
|
|
3290
4493
|
className: "bn-menu-dropdown bn-color-picker-dropdown",
|
|
3291
|
-
children: /* @__PURE__ */ (0,
|
|
4494
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3292
4495
|
LumirColorPicker,
|
|
3293
4496
|
{
|
|
3294
4497
|
textTitle: "\uD14D\uC2A4\uD2B8 \uC0C9",
|
|
@@ -3302,18 +4505,18 @@ function LumirColorStyleButton() {
|
|
|
3302
4505
|
] });
|
|
3303
4506
|
}
|
|
3304
4507
|
function LumirCellColorToolbarButton() {
|
|
3305
|
-
const Components = (0,
|
|
3306
|
-
const editor = (0,
|
|
3307
|
-
const selectedBlocks = (0,
|
|
3308
|
-
const isMultiCell = (0,
|
|
4508
|
+
const Components = (0, import_react28.useComponentsContext)();
|
|
4509
|
+
const editor = (0, import_react28.useBlockNoteEditor)();
|
|
4510
|
+
const selectedBlocks = (0, import_react28.useSelectedBlocks)(editor);
|
|
4511
|
+
const isMultiCell = (0, import_react29.useMemo)(() => {
|
|
3309
4512
|
if (selectedBlocks.length !== 1 || selectedBlocks[0].type !== "table") {
|
|
3310
4513
|
return false;
|
|
3311
4514
|
}
|
|
3312
4515
|
const cs = editor.tableHandles?.getCellSelection();
|
|
3313
4516
|
return !!cs && cs.cells.length > 1;
|
|
3314
4517
|
}, [editor, selectedBlocks]);
|
|
3315
|
-
const stashRef = (0,
|
|
3316
|
-
const applyBackground = (0,
|
|
4518
|
+
const stashRef = (0, import_react29.useRef)([]);
|
|
4519
|
+
const applyBackground = (0, import_react29.useCallback)(
|
|
3317
4520
|
(color) => {
|
|
3318
4521
|
const live = getSelectedCellPositions(editor);
|
|
3319
4522
|
const positions = live.length > 0 ? live : stashRef.current;
|
|
@@ -3326,7 +4529,7 @@ function LumirCellColorToolbarButton() {
|
|
|
3326
4529
|
return null;
|
|
3327
4530
|
}
|
|
3328
4531
|
const tooltip = "\uC140 \uBC30\uACBD\uC0C9";
|
|
3329
|
-
return /* @__PURE__ */ (0,
|
|
4532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
3330
4533
|
Components.Generic.Menu.Root,
|
|
3331
4534
|
{
|
|
3332
4535
|
onOpenChange: (open) => {
|
|
@@ -3335,21 +4538,21 @@ function LumirCellColorToolbarButton() {
|
|
|
3335
4538
|
}
|
|
3336
4539
|
},
|
|
3337
4540
|
children: [
|
|
3338
|
-
/* @__PURE__ */ (0,
|
|
4541
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Components.Generic.Menu.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3339
4542
|
Components.FormattingToolbar.Button,
|
|
3340
4543
|
{
|
|
3341
4544
|
className: "bn-button",
|
|
3342
4545
|
"data-test": "cell-colors",
|
|
3343
4546
|
label: tooltip,
|
|
3344
4547
|
mainTooltip: tooltip,
|
|
3345
|
-
icon: /* @__PURE__ */ (0,
|
|
4548
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CellFillIcon, { size: 18 })
|
|
3346
4549
|
}
|
|
3347
4550
|
) }),
|
|
3348
|
-
/* @__PURE__ */ (0,
|
|
4551
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3349
4552
|
Components.Generic.Menu.Dropdown,
|
|
3350
4553
|
{
|
|
3351
4554
|
className: "bn-menu-dropdown bn-color-picker-dropdown",
|
|
3352
|
-
children: /* @__PURE__ */ (0,
|
|
4555
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3353
4556
|
LumirColorPicker,
|
|
3354
4557
|
{
|
|
3355
4558
|
backgroundTitle: "\uC140 \uBC30\uACBD",
|
|
@@ -3363,12 +4566,12 @@ function LumirCellColorToolbarButton() {
|
|
|
3363
4566
|
);
|
|
3364
4567
|
}
|
|
3365
4568
|
function LumirCellColorPickerButton(props) {
|
|
3366
|
-
const Components = (0,
|
|
3367
|
-
const editor = (0,
|
|
4569
|
+
const Components = (0, import_react28.useComponentsContext)();
|
|
4570
|
+
const editor = (0, import_react28.useBlockNoteEditor)();
|
|
3368
4571
|
const updateColor = (color, type) => {
|
|
3369
4572
|
const newTable = props.block.content.rows.map((row) => ({
|
|
3370
4573
|
...row,
|
|
3371
|
-
cells: row.cells.map((cell) => (0,
|
|
4574
|
+
cells: row.cells.map((cell) => (0, import_core8.mapTableCell)(cell))
|
|
3372
4575
|
}));
|
|
3373
4576
|
if (type === "text") {
|
|
3374
4577
|
newTable[props.rowIndex].cells[props.colIndex].props.textColor = color;
|
|
@@ -3385,25 +4588,25 @@ function LumirCellColorPickerButton(props) {
|
|
|
3385
4588
|
if (!currentCell || editor.settings.tables.cellTextColor === false && editor.settings.tables.cellBackgroundColor === false) {
|
|
3386
4589
|
return null;
|
|
3387
4590
|
}
|
|
3388
|
-
return /* @__PURE__ */ (0,
|
|
3389
|
-
/* @__PURE__ */ (0,
|
|
3390
|
-
/* @__PURE__ */ (0,
|
|
4591
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Components.Generic.Menu.Root, { position: "right", sub: true, children: [
|
|
4592
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Components.Generic.Menu.Trigger, { sub: true, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Components.Generic.Menu.Item, { className: "bn-menu-item", subTrigger: true, children: "\uC140 \uC0C9\xB7\uBC30\uACBD" }) }),
|
|
4593
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3391
4594
|
Components.Generic.Menu.Dropdown,
|
|
3392
4595
|
{
|
|
3393
4596
|
sub: true,
|
|
3394
4597
|
className: "bn-menu-dropdown bn-color-picker-dropdown",
|
|
3395
|
-
children: /* @__PURE__ */ (0,
|
|
4598
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3396
4599
|
LumirColorPicker,
|
|
3397
4600
|
{
|
|
3398
4601
|
iconSize: 18,
|
|
3399
4602
|
textTitle: "\uC140 \uAE00\uC790\uC0C9",
|
|
3400
4603
|
backgroundTitle: "\uC140 \uBC30\uACBD",
|
|
3401
4604
|
text: editor.settings.tables.cellTextColor ? {
|
|
3402
|
-
color: (0,
|
|
4605
|
+
color: (0, import_core8.isTableCell)(currentCell) ? currentCell.props.textColor : "default",
|
|
3403
4606
|
setColor: (color) => updateColor(color, "text")
|
|
3404
4607
|
} : void 0,
|
|
3405
4608
|
background: editor.settings.tables.cellBackgroundColor ? {
|
|
3406
|
-
color: (0,
|
|
4609
|
+
color: (0, import_core8.isTableCell)(currentCell) ? currentCell.props.backgroundColor : "default",
|
|
3407
4610
|
setColor: (color) => updateColor(color, "background")
|
|
3408
4611
|
} : void 0
|
|
3409
4612
|
}
|
|
@@ -3413,21 +4616,21 @@ function LumirCellColorPickerButton(props) {
|
|
|
3413
4616
|
] });
|
|
3414
4617
|
}
|
|
3415
4618
|
function LumirTableCellMenu(props) {
|
|
3416
|
-
const Components = (0,
|
|
3417
|
-
return /* @__PURE__ */ (0,
|
|
4619
|
+
const Components = (0, import_react28.useComponentsContext)();
|
|
4620
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3418
4621
|
Components.Generic.Menu.Dropdown,
|
|
3419
4622
|
{
|
|
3420
4623
|
className: "bn-menu-dropdown bn-drag-handle-menu",
|
|
3421
|
-
children: props.children || /* @__PURE__ */ (0,
|
|
3422
|
-
/* @__PURE__ */ (0,
|
|
3423
|
-
|
|
4624
|
+
children: props.children || /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
4625
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
4626
|
+
import_react28.SplitButton,
|
|
3424
4627
|
{
|
|
3425
4628
|
block: props.block,
|
|
3426
4629
|
rowIndex: props.rowIndex,
|
|
3427
4630
|
colIndex: props.colIndex
|
|
3428
4631
|
}
|
|
3429
4632
|
),
|
|
3430
|
-
/* @__PURE__ */ (0,
|
|
4633
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3431
4634
|
LumirCellColorPickerButton,
|
|
3432
4635
|
{
|
|
3433
4636
|
block: props.block,
|
|
@@ -3441,95 +4644,164 @@ function LumirTableCellMenu(props) {
|
|
|
3441
4644
|
}
|
|
3442
4645
|
|
|
3443
4646
|
// src/components/CustomFormattingToolbar.tsx
|
|
3444
|
-
var
|
|
4647
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3445
4648
|
var CustomFormattingToolbar = () => {
|
|
3446
|
-
return /* @__PURE__ */ (0,
|
|
3447
|
-
/* @__PURE__ */ (0,
|
|
3448
|
-
/* @__PURE__ */ (0,
|
|
3449
|
-
/* @__PURE__ */ (0,
|
|
3450
|
-
/* @__PURE__ */ (0,
|
|
3451
|
-
/* @__PURE__ */ (0,
|
|
3452
|
-
/* @__PURE__ */ (0,
|
|
3453
|
-
/* @__PURE__ */ (0,
|
|
3454
|
-
/* @__PURE__ */ (0,
|
|
3455
|
-
/* @__PURE__ */ (0,
|
|
3456
|
-
/* @__PURE__ */ (0,
|
|
3457
|
-
|
|
4649
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react30.FormattingToolbar, { children: [
|
|
4650
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react30.BlockTypeSelect, {}, "blockTypeSelect"),
|
|
4651
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react30.TableCellMergeButton, {}, "tableCellMergeButton"),
|
|
4652
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react30.FileCaptionButton, {}, "fileCaptionButton"),
|
|
4653
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react30.FileReplaceButton, {}, "replaceFileButton"),
|
|
4654
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react30.FileRenameButton, {}, "fileRenameButton"),
|
|
4655
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react30.FileDeleteButton, {}, "fileDeleteButton"),
|
|
4656
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react30.FileDownloadButton, {}, "fileDownloadButton"),
|
|
4657
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react30.FilePreviewButton, {}, "filePreviewButton"),
|
|
4658
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react30.BasicTextStyleButton, { basicTextStyle: "bold" }, "boldStyleButton"),
|
|
4659
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4660
|
+
import_react30.BasicTextStyleButton,
|
|
3458
4661
|
{
|
|
3459
4662
|
basicTextStyle: "italic"
|
|
3460
4663
|
},
|
|
3461
4664
|
"italicStyleButton"
|
|
3462
4665
|
),
|
|
3463
|
-
/* @__PURE__ */ (0,
|
|
3464
|
-
|
|
4666
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4667
|
+
import_react30.BasicTextStyleButton,
|
|
3465
4668
|
{
|
|
3466
4669
|
basicTextStyle: "underline"
|
|
3467
4670
|
},
|
|
3468
4671
|
"underlineStyleButton"
|
|
3469
4672
|
),
|
|
3470
|
-
/* @__PURE__ */ (0,
|
|
3471
|
-
|
|
4673
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4674
|
+
import_react30.BasicTextStyleButton,
|
|
3472
4675
|
{
|
|
3473
4676
|
basicTextStyle: "strike"
|
|
3474
4677
|
},
|
|
3475
4678
|
"strikeStyleButton"
|
|
3476
4679
|
),
|
|
3477
|
-
/* @__PURE__ */ (0,
|
|
3478
|
-
/* @__PURE__ */ (0,
|
|
4680
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TextAlignButtonWithVA, { textAlignment: "left" }, "textAlignLeftButton"),
|
|
4681
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3479
4682
|
TextAlignButtonWithVA,
|
|
3480
4683
|
{
|
|
3481
4684
|
textAlignment: "center"
|
|
3482
4685
|
},
|
|
3483
4686
|
"textAlignCenterButton"
|
|
3484
4687
|
),
|
|
3485
|
-
/* @__PURE__ */ (0,
|
|
3486
|
-
/* @__PURE__ */ (0,
|
|
4688
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TextAlignButtonWithVA, { textAlignment: "right" }, "textAlignRightButton"),
|
|
4689
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3487
4690
|
VerticalAlignButton,
|
|
3488
4691
|
{
|
|
3489
4692
|
verticalAlignment: "top"
|
|
3490
4693
|
},
|
|
3491
4694
|
"verticalAlignTop"
|
|
3492
4695
|
),
|
|
3493
|
-
/* @__PURE__ */ (0,
|
|
4696
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3494
4697
|
VerticalAlignButton,
|
|
3495
4698
|
{
|
|
3496
4699
|
verticalAlignment: "middle"
|
|
3497
4700
|
},
|
|
3498
4701
|
"verticalAlignMiddle"
|
|
3499
4702
|
),
|
|
3500
|
-
/* @__PURE__ */ (0,
|
|
4703
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3501
4704
|
VerticalAlignButton,
|
|
3502
4705
|
{
|
|
3503
4706
|
verticalAlignment: "bottom"
|
|
3504
4707
|
},
|
|
3505
4708
|
"verticalAlignBottom"
|
|
3506
4709
|
),
|
|
3507
|
-
/* @__PURE__ */ (0,
|
|
3508
|
-
/* @__PURE__ */ (0,
|
|
3509
|
-
/* @__PURE__ */ (0,
|
|
3510
|
-
/* @__PURE__ */ (0,
|
|
3511
|
-
/* @__PURE__ */ (0,
|
|
4710
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TableAlignButton, { alignment: "left" }, "tableAlignLeft"),
|
|
4711
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TableAlignButton, { alignment: "center" }, "tableAlignCenter"),
|
|
4712
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TableAlignButton, { alignment: "right" }, "tableAlignRight"),
|
|
4713
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(FontSizeButton2, {}, "fontSizeButton"),
|
|
4714
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(LumirColorStyleButton, {}, "colorStyleButton"),
|
|
4715
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(LumirCellColorToolbarButton, {}, "cellColorButton"),
|
|
4716
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react30.NestBlockButton, {}, "nestBlockButton"),
|
|
4717
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react30.UnnestBlockButton, {}, "unnestBlockButton"),
|
|
4718
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react30.CreateLinkButton, {}, "createLinkButton")
|
|
4719
|
+
] });
|
|
4720
|
+
};
|
|
4721
|
+
|
|
4722
|
+
// src/components/LumirDragHandleMenu.tsx
|
|
4723
|
+
var import_react31 = require("@blocknote/react");
|
|
4724
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
4725
|
+
var TABLE_ALIGN_ICONS = {
|
|
4726
|
+
left: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.4", children: [
|
|
4727
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: "1.5", y: "4", width: "7", height: "8", rx: "1", fill: "currentColor", stroke: "none" }),
|
|
4728
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("line", { x1: "1.5", y1: "1.5", x2: "14.5", y2: "1.5" }),
|
|
4729
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("line", { x1: "1.5", y1: "14.5", x2: "14.5", y2: "14.5" })
|
|
4730
|
+
] }),
|
|
4731
|
+
center: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.4", children: [
|
|
4732
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: "4.5", y: "4", width: "7", height: "8", rx: "1", fill: "currentColor", stroke: "none" }),
|
|
4733
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("line", { x1: "1.5", y1: "1.5", x2: "14.5", y2: "1.5" }),
|
|
4734
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("line", { x1: "1.5", y1: "14.5", x2: "14.5", y2: "14.5" })
|
|
4735
|
+
] }),
|
|
4736
|
+
right: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.4", children: [
|
|
4737
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: "7.5", y: "4", width: "7", height: "8", rx: "1", fill: "currentColor", stroke: "none" }),
|
|
4738
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("line", { x1: "1.5", y1: "1.5", x2: "14.5", y2: "1.5" }),
|
|
4739
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("line", { x1: "1.5", y1: "14.5", x2: "14.5", y2: "14.5" })
|
|
4740
|
+
] })
|
|
4741
|
+
};
|
|
4742
|
+
var TABLE_ALIGN_LABELS = {
|
|
4743
|
+
left: "\uD45C \uC67C\uCABD \uC815\uB82C",
|
|
4744
|
+
center: "\uD45C \uAC00\uC6B4\uB370 \uC815\uB82C",
|
|
4745
|
+
right: "\uD45C \uC624\uB978\uCABD \uC815\uB82C"
|
|
4746
|
+
};
|
|
4747
|
+
function TableAlignmentItems(props) {
|
|
4748
|
+
const Components = (0, import_react31.useComponentsContext)();
|
|
4749
|
+
const editor = (0, import_react31.useBlockNoteEditor)();
|
|
4750
|
+
if (props.block?.type !== "table" || !props.block?.id) {
|
|
4751
|
+
return null;
|
|
4752
|
+
}
|
|
4753
|
+
const current = getTableAlignment(editor, props.block.id);
|
|
4754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: ["left", "center", "right"].map((align) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4755
|
+
Components.Generic.Menu.Item,
|
|
4756
|
+
{
|
|
4757
|
+
icon: TABLE_ALIGN_ICONS[align],
|
|
4758
|
+
checked: current === align,
|
|
4759
|
+
onClick: () => {
|
|
4760
|
+
setTableAlignment(editor, props.block.id, align);
|
|
4761
|
+
editor.setTextCursorPosition(props.block.id);
|
|
4762
|
+
},
|
|
4763
|
+
children: TABLE_ALIGN_LABELS[align]
|
|
4764
|
+
},
|
|
4765
|
+
`tableAlign-${align}`
|
|
4766
|
+
)) });
|
|
4767
|
+
}
|
|
4768
|
+
var LumirDragHandleMenu = (props) => {
|
|
4769
|
+
const dict = (0, import_react31.useDictionary)();
|
|
4770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react31.DragHandleMenu, { ...props, children: [
|
|
4771
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react31.RemoveBlockItem, { ...props, children: dict.drag_handle.delete_menuitem }),
|
|
4772
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react31.BlockColorsItem, { ...props, children: dict.drag_handle.colors_menuitem }),
|
|
4773
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react31.TableRowHeaderItem, { ...props, children: dict.drag_handle.header_row_menuitem }),
|
|
4774
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react31.TableColumnHeaderItem, { ...props, children: dict.drag_handle.header_column_menuitem }),
|
|
4775
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TableAlignmentItems, { block: props.block })
|
|
3512
4776
|
] });
|
|
3513
4777
|
};
|
|
3514
4778
|
|
|
3515
4779
|
// src/components/LumirTableHandlesController.tsx
|
|
3516
|
-
var
|
|
3517
|
-
var
|
|
3518
|
-
var
|
|
4780
|
+
var import_react34 = require("@blocknote/react");
|
|
4781
|
+
var import_react35 = require("@floating-ui/react");
|
|
4782
|
+
var import_react36 = require("react");
|
|
3519
4783
|
|
|
3520
4784
|
// src/components/hooks/useFocusedCellHandlePositioning.ts
|
|
3521
|
-
var
|
|
3522
|
-
var
|
|
4785
|
+
var import_react32 = require("@floating-ui/react");
|
|
4786
|
+
var import_react33 = require("react");
|
|
3523
4787
|
function useFocusedCellHandlePositioning(cellEl, tbodyEl, orientation, show) {
|
|
3524
|
-
const { refs, floatingStyles, context } = (0,
|
|
4788
|
+
const { refs, floatingStyles, context, update } = (0, import_react32.useFloating)({
|
|
3525
4789
|
open: show,
|
|
3526
4790
|
placement: orientation === "row" ? "left" : orientation === "col" ? "top" : "right",
|
|
3527
4791
|
// col/row: 가장자리 선(zero-size)에, cell: 셀 우측 보더에 14px hit-area 중앙 정렬(-7).
|
|
3528
|
-
middleware: [(0,
|
|
3529
|
-
whileElementsMounted:
|
|
4792
|
+
middleware: [(0, import_react32.offset)(-7)],
|
|
4793
|
+
whileElementsMounted: import_react32.autoUpdate
|
|
3530
4794
|
});
|
|
3531
|
-
const { isMounted, styles } = (0,
|
|
3532
|
-
(0,
|
|
4795
|
+
const { isMounted, styles } = (0, import_react32.useTransitionStyles)(context);
|
|
4796
|
+
(0, import_react33.useEffect)(() => {
|
|
4797
|
+
if (!show || !tbodyEl) {
|
|
4798
|
+
return;
|
|
4799
|
+
}
|
|
4800
|
+
const ro = new ResizeObserver(() => update());
|
|
4801
|
+
ro.observe(tbodyEl);
|
|
4802
|
+
return () => ro.disconnect();
|
|
4803
|
+
}, [show, tbodyEl, update]);
|
|
4804
|
+
(0, import_react33.useEffect)(() => {
|
|
3533
4805
|
if (!cellEl) {
|
|
3534
4806
|
refs.setReference(null);
|
|
3535
4807
|
return;
|
|
@@ -3549,7 +4821,7 @@ function useFocusedCellHandlePositioning(cellEl, tbodyEl, orientation, show) {
|
|
|
3549
4821
|
}
|
|
3550
4822
|
});
|
|
3551
4823
|
}, [cellEl, tbodyEl, orientation, refs]);
|
|
3552
|
-
return (0,
|
|
4824
|
+
return (0, import_react33.useMemo)(
|
|
3553
4825
|
() => ({
|
|
3554
4826
|
isMounted,
|
|
3555
4827
|
ref: refs.setFloating,
|
|
@@ -3564,7 +4836,7 @@ function useFocusedCellHandlePositioning(cellEl, tbodyEl, orientation, show) {
|
|
|
3564
4836
|
}
|
|
3565
4837
|
|
|
3566
4838
|
// src/components/LumirTableHandlesController.tsx
|
|
3567
|
-
var
|
|
4839
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3568
4840
|
function syncCoreHoverToFocusedCell(cellEl) {
|
|
3569
4841
|
const r = cellEl.getBoundingClientRect();
|
|
3570
4842
|
cellEl.dispatchEvent(
|
|
@@ -3578,15 +4850,15 @@ function syncCoreHoverToFocusedCell(cellEl) {
|
|
|
3578
4850
|
);
|
|
3579
4851
|
}
|
|
3580
4852
|
function LumirTableHandlesController() {
|
|
3581
|
-
const editor = (0,
|
|
3582
|
-
const [focused, setFocused] = (0,
|
|
3583
|
-
const [menuContainerRef, setMenuContainerRef] = (0,
|
|
3584
|
-
const [overlayEl, setOverlayEl] = (0,
|
|
3585
|
-
const [openMenu, setOpenMenu] = (0,
|
|
3586
|
-
const frozenRef = (0,
|
|
3587
|
-
const menuOpenRef = (0,
|
|
3588
|
-
const draggingRef = (0,
|
|
3589
|
-
const recompute = (0,
|
|
4853
|
+
const editor = (0, import_react34.useBlockNoteEditor)();
|
|
4854
|
+
const [focused, setFocused] = (0, import_react36.useState)(null);
|
|
4855
|
+
const [menuContainerRef, setMenuContainerRef] = (0, import_react36.useState)(null);
|
|
4856
|
+
const [overlayEl, setOverlayEl] = (0, import_react36.useState)(null);
|
|
4857
|
+
const [openMenu, setOpenMenu] = (0, import_react36.useState)(null);
|
|
4858
|
+
const frozenRef = (0, import_react36.useRef)(false);
|
|
4859
|
+
const menuOpenRef = (0, import_react36.useRef)(false);
|
|
4860
|
+
const draggingRef = (0, import_react36.useRef)(false);
|
|
4861
|
+
const recompute = (0, import_react36.useCallback)(() => {
|
|
3590
4862
|
if (frozenRef.current) {
|
|
3591
4863
|
return;
|
|
3592
4864
|
}
|
|
@@ -3634,11 +4906,11 @@ function LumirTableHandlesController() {
|
|
|
3634
4906
|
widgetContainer
|
|
3635
4907
|
});
|
|
3636
4908
|
}, [editor]);
|
|
3637
|
-
(0,
|
|
3638
|
-
(0,
|
|
4909
|
+
(0, import_react34.useEditorContentOrSelectionChange)(recompute, editor);
|
|
4910
|
+
(0, import_react36.useEffect)(() => {
|
|
3639
4911
|
recompute();
|
|
3640
4912
|
}, [recompute]);
|
|
3641
|
-
(0,
|
|
4913
|
+
(0, import_react36.useEffect)(() => {
|
|
3642
4914
|
const onUp = () => {
|
|
3643
4915
|
requestAnimationFrame(() => {
|
|
3644
4916
|
if (!menuOpenRef.current && !draggingRef.current && frozenRef.current) {
|
|
@@ -3650,7 +4922,7 @@ function LumirTableHandlesController() {
|
|
|
3650
4922
|
window.addEventListener("pointerup", onUp);
|
|
3651
4923
|
return () => window.removeEventListener("pointerup", onUp);
|
|
3652
4924
|
}, [recompute]);
|
|
3653
|
-
(0,
|
|
4925
|
+
(0, import_react36.useEffect)(() => {
|
|
3654
4926
|
const f = focused;
|
|
3655
4927
|
if (!f || !overlayEl) {
|
|
3656
4928
|
return;
|
|
@@ -3675,7 +4947,13 @@ function LumirTableHandlesController() {
|
|
|
3675
4947
|
overlayEl.style.height = `${bottom - top}px`;
|
|
3676
4948
|
};
|
|
3677
4949
|
update();
|
|
3678
|
-
|
|
4950
|
+
const stopAutoUpdate = (0, import_react35.autoUpdate)(f.cellEl, overlayEl, update);
|
|
4951
|
+
const ro = new ResizeObserver(update);
|
|
4952
|
+
ro.observe(f.tbodyEl);
|
|
4953
|
+
return () => {
|
|
4954
|
+
stopAutoUpdate();
|
|
4955
|
+
ro.disconnect();
|
|
4956
|
+
};
|
|
3679
4957
|
}, [focused, overlayEl, openMenu]);
|
|
3680
4958
|
const cellEl = focused?.cellEl ?? null;
|
|
3681
4959
|
const tbodyEl = focused?.tbodyEl ?? null;
|
|
@@ -3689,21 +4967,21 @@ function LumirTableHandlesController() {
|
|
|
3689
4967
|
show
|
|
3690
4968
|
);
|
|
3691
4969
|
const th = editor.tableHandles;
|
|
3692
|
-
const coreState = (0,
|
|
4970
|
+
const coreState = (0, import_react34.useUIPluginState)(
|
|
3693
4971
|
editor.tableHandles.onUpdate.bind(editor.tableHandles)
|
|
3694
4972
|
);
|
|
3695
|
-
const { addOrRemoveColumnsButton, addOrRemoveRowsButton } = (0,
|
|
4973
|
+
const { addOrRemoveColumnsButton, addOrRemoveRowsButton } = (0, import_react34.useExtendButtonsPositioning)(
|
|
3696
4974
|
coreState?.showAddOrRemoveColumnsButton || false,
|
|
3697
4975
|
coreState?.showAddOrRemoveRowsButton || false,
|
|
3698
4976
|
coreState?.referencePosTable || null
|
|
3699
4977
|
);
|
|
3700
|
-
const onStartExtend = (0,
|
|
4978
|
+
const onStartExtend = (0, import_react36.useCallback)(() => {
|
|
3701
4979
|
editor.tableHandles?.freezeHandles();
|
|
3702
4980
|
}, [editor]);
|
|
3703
|
-
const onEndExtend = (0,
|
|
4981
|
+
const onEndExtend = (0, import_react36.useCallback)(() => {
|
|
3704
4982
|
editor.tableHandles?.unfreezeHandles();
|
|
3705
4983
|
}, [editor]);
|
|
3706
|
-
const menuHandlers = (0,
|
|
4984
|
+
const menuHandlers = (0, import_react36.useMemo)(() => {
|
|
3707
4985
|
const mk = (kind) => ({
|
|
3708
4986
|
freeze: () => {
|
|
3709
4987
|
menuOpenRef.current = true;
|
|
@@ -3721,10 +4999,10 @@ function LumirTableHandlesController() {
|
|
|
3721
4999
|
});
|
|
3722
5000
|
return { col: mk("col"), row: mk("row"), cell: mk("cell") };
|
|
3723
5001
|
}, [editor, recompute]);
|
|
3724
|
-
const onGutterPointerDown = (0,
|
|
5002
|
+
const onGutterPointerDown = (0, import_react36.useCallback)(() => {
|
|
3725
5003
|
frozenRef.current = true;
|
|
3726
5004
|
}, []);
|
|
3727
|
-
const onGutterPointerEnter = (0,
|
|
5005
|
+
const onGutterPointerEnter = (0, import_react36.useCallback)(
|
|
3728
5006
|
(e) => {
|
|
3729
5007
|
if (e.buttons === 0 && focused) {
|
|
3730
5008
|
syncCoreHoverToFocusedCell(focused.cellEl);
|
|
@@ -3732,7 +5010,7 @@ function LumirTableHandlesController() {
|
|
|
3732
5010
|
},
|
|
3733
5011
|
[focused]
|
|
3734
5012
|
);
|
|
3735
|
-
const makeDragStart = (0,
|
|
5013
|
+
const makeDragStart = (0, import_react36.useCallback)(
|
|
3736
5014
|
(dir) => (e) => {
|
|
3737
5015
|
draggingRef.current = true;
|
|
3738
5016
|
frozenRef.current = true;
|
|
@@ -3744,19 +5022,19 @@ function LumirTableHandlesController() {
|
|
|
3744
5022
|
},
|
|
3745
5023
|
[editor]
|
|
3746
5024
|
);
|
|
3747
|
-
const onDragEnd = (0,
|
|
5025
|
+
const onDragEnd = (0, import_react36.useCallback)(() => {
|
|
3748
5026
|
editor.tableHandles?.dragEnd();
|
|
3749
5027
|
draggingRef.current = false;
|
|
3750
5028
|
frozenRef.current = false;
|
|
3751
5029
|
recompute();
|
|
3752
5030
|
}, [editor, recompute]);
|
|
3753
|
-
const noop = (0,
|
|
5031
|
+
const noop = (0, import_react36.useCallback)(() => {
|
|
3754
5032
|
}, []);
|
|
3755
|
-
return /* @__PURE__ */ (0,
|
|
3756
|
-
/* @__PURE__ */ (0,
|
|
3757
|
-
th && focused && menuContainerRef && /* @__PURE__ */ (0,
|
|
3758
|
-
/* @__PURE__ */ (0,
|
|
3759
|
-
colHandle.isMounted && /* @__PURE__ */ (0,
|
|
5033
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
5034
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { ref: setMenuContainerRef }),
|
|
5035
|
+
th && focused && menuContainerRef && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_react35.FloatingPortal, { root: focused.widgetContainer, children: [
|
|
5036
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { ref: setOverlayEl, className: "lumir-tbl-cell-focus" }),
|
|
5037
|
+
colHandle.isMounted && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3760
5038
|
"div",
|
|
3761
5039
|
{
|
|
3762
5040
|
ref: colHandle.ref,
|
|
@@ -3765,9 +5043,9 @@ function LumirTableHandlesController() {
|
|
|
3765
5043
|
onPointerEnter: onGutterPointerEnter,
|
|
3766
5044
|
onPointerDown: onGutterPointerDown,
|
|
3767
5045
|
children: [
|
|
3768
|
-
/* @__PURE__ */ (0,
|
|
3769
|
-
/* @__PURE__ */ (0,
|
|
3770
|
-
|
|
5046
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "lumir-tbl-gutter" }),
|
|
5047
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "lumir-tbl-grip", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5048
|
+
import_react34.TableHandle,
|
|
3771
5049
|
{
|
|
3772
5050
|
editor,
|
|
3773
5051
|
orientation: "column",
|
|
@@ -3785,7 +5063,7 @@ function LumirTableHandlesController() {
|
|
|
3785
5063
|
]
|
|
3786
5064
|
}
|
|
3787
5065
|
),
|
|
3788
|
-
rowHandle.isMounted && /* @__PURE__ */ (0,
|
|
5066
|
+
rowHandle.isMounted && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3789
5067
|
"div",
|
|
3790
5068
|
{
|
|
3791
5069
|
ref: rowHandle.ref,
|
|
@@ -3794,9 +5072,9 @@ function LumirTableHandlesController() {
|
|
|
3794
5072
|
onPointerEnter: onGutterPointerEnter,
|
|
3795
5073
|
onPointerDown: onGutterPointerDown,
|
|
3796
5074
|
children: [
|
|
3797
|
-
/* @__PURE__ */ (0,
|
|
3798
|
-
/* @__PURE__ */ (0,
|
|
3799
|
-
|
|
5075
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "lumir-tbl-gutter" }),
|
|
5076
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "lumir-tbl-grip", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5077
|
+
import_react34.TableHandle,
|
|
3800
5078
|
{
|
|
3801
5079
|
editor,
|
|
3802
5080
|
orientation: "row",
|
|
@@ -3814,7 +5092,7 @@ function LumirTableHandlesController() {
|
|
|
3814
5092
|
]
|
|
3815
5093
|
}
|
|
3816
5094
|
),
|
|
3817
|
-
cellHandle.isMounted && openMenu !== "col" && openMenu !== "row" && /* @__PURE__ */ (0,
|
|
5095
|
+
cellHandle.isMounted && openMenu !== "col" && openMenu !== "row" && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3818
5096
|
"div",
|
|
3819
5097
|
{
|
|
3820
5098
|
ref: cellHandle.ref,
|
|
@@ -3822,9 +5100,9 @@ function LumirTableHandlesController() {
|
|
|
3822
5100
|
className: "lumir-tbl-gutter-wrap lumir-tbl-gutter-wrap--cell" + (openMenu === "cell" ? " lumir-tbl-gutter-wrap--active" : ""),
|
|
3823
5101
|
onPointerDown: onGutterPointerDown,
|
|
3824
5102
|
children: [
|
|
3825
|
-
/* @__PURE__ */ (0,
|
|
3826
|
-
/* @__PURE__ */ (0,
|
|
3827
|
-
|
|
5103
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "lumir-tbl-gutter" }),
|
|
5104
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "lumir-tbl-grip", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5105
|
+
import_react34.TableCellButton,
|
|
3828
5106
|
{
|
|
3829
5107
|
editor,
|
|
3830
5108
|
rowIndex: focused.rowIndex,
|
|
@@ -3840,9 +5118,9 @@ function LumirTableHandlesController() {
|
|
|
3840
5118
|
}
|
|
3841
5119
|
)
|
|
3842
5120
|
] }),
|
|
3843
|
-
th && coreState?.widgetContainer && /* @__PURE__ */ (0,
|
|
3844
|
-
/* @__PURE__ */ (0,
|
|
3845
|
-
|
|
5121
|
+
th && coreState?.widgetContainer && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_react35.FloatingPortal, { root: coreState.widgetContainer, children: [
|
|
5122
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { ref: addOrRemoveRowsButton.ref, style: addOrRemoveRowsButton.style, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5123
|
+
import_react34.ExtendButton,
|
|
3846
5124
|
{
|
|
3847
5125
|
editor,
|
|
3848
5126
|
orientation: "addOrRemoveRows",
|
|
@@ -3851,13 +5129,13 @@ function LumirTableHandlesController() {
|
|
|
3851
5129
|
onMouseUp: onEndExtend
|
|
3852
5130
|
}
|
|
3853
5131
|
) }),
|
|
3854
|
-
/* @__PURE__ */ (0,
|
|
5132
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3855
5133
|
"div",
|
|
3856
5134
|
{
|
|
3857
5135
|
ref: addOrRemoveColumnsButton.ref,
|
|
3858
5136
|
style: addOrRemoveColumnsButton.style,
|
|
3859
|
-
children: /* @__PURE__ */ (0,
|
|
3860
|
-
|
|
5137
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5138
|
+
import_react34.ExtendButton,
|
|
3861
5139
|
{
|
|
3862
5140
|
editor,
|
|
3863
5141
|
orientation: "addOrRemoveColumns",
|
|
@@ -3873,15 +5151,17 @@ function LumirTableHandlesController() {
|
|
|
3873
5151
|
}
|
|
3874
5152
|
|
|
3875
5153
|
// src/utils/table-vertical-alignment.ts
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
if (
|
|
3882
|
-
|
|
5154
|
+
var CELL_ATTR_DEFAULTS = {
|
|
5155
|
+
verticalAlignment: "top",
|
|
5156
|
+
rowHeight: null
|
|
5157
|
+
};
|
|
5158
|
+
function isMeaningful2(attr, value) {
|
|
5159
|
+
if (value === null || value === void 0) {
|
|
5160
|
+
return false;
|
|
5161
|
+
}
|
|
5162
|
+
return value !== CELL_ATTR_DEFAULTS[attr];
|
|
3883
5163
|
}
|
|
3884
|
-
function
|
|
5164
|
+
function buildTableCellAttrMap(doc, attrs) {
|
|
3885
5165
|
const result = /* @__PURE__ */ new Map();
|
|
3886
5166
|
doc.descendants((node) => {
|
|
3887
5167
|
if (node.type.name === "blockContainer") {
|
|
@@ -3894,9 +5174,15 @@ function buildTableVerticalAlignmentMap(doc) {
|
|
|
3894
5174
|
if (rowNode.type.name === "tableRow") {
|
|
3895
5175
|
let colIndex = 0;
|
|
3896
5176
|
rowNode.forEach((cellNode) => {
|
|
3897
|
-
const
|
|
3898
|
-
|
|
3899
|
-
|
|
5177
|
+
const props = {};
|
|
5178
|
+
for (const attr of attrs) {
|
|
5179
|
+
const value = cellNode.attrs?.[attr];
|
|
5180
|
+
if (isMeaningful2(attr, value)) {
|
|
5181
|
+
props[attr] = value;
|
|
5182
|
+
}
|
|
5183
|
+
}
|
|
5184
|
+
if (Object.keys(props).length > 0) {
|
|
5185
|
+
cells.push({ row: rowIndex, col: colIndex, props });
|
|
3900
5186
|
}
|
|
3901
5187
|
colIndex++;
|
|
3902
5188
|
});
|
|
@@ -3912,18 +5198,21 @@ function buildTableVerticalAlignmentMap(doc) {
|
|
|
3912
5198
|
});
|
|
3913
5199
|
return result;
|
|
3914
5200
|
}
|
|
3915
|
-
function patchBlocks(blocks,
|
|
5201
|
+
function patchBlocks(blocks, cellAttrMap) {
|
|
3916
5202
|
return blocks.map((block) => {
|
|
3917
5203
|
if (block.type !== "table" || !block.id || !block.content) {
|
|
3918
5204
|
if (block.children && block.children.length > 0) {
|
|
3919
5205
|
return {
|
|
3920
5206
|
...block,
|
|
3921
|
-
children: patchBlocks(
|
|
5207
|
+
children: patchBlocks(
|
|
5208
|
+
block.children,
|
|
5209
|
+
cellAttrMap
|
|
5210
|
+
)
|
|
3922
5211
|
};
|
|
3923
5212
|
}
|
|
3924
5213
|
return block;
|
|
3925
5214
|
}
|
|
3926
|
-
const cells =
|
|
5215
|
+
const cells = cellAttrMap.get(block.id);
|
|
3927
5216
|
if (!cells || cells.length === 0) {
|
|
3928
5217
|
return block;
|
|
3929
5218
|
}
|
|
@@ -3936,11 +5225,13 @@ function patchBlocks(blocks, tableVAMap) {
|
|
|
3936
5225
|
const match = cells.find(
|
|
3937
5226
|
(c) => c.row === rowIndex && c.col === colIndex
|
|
3938
5227
|
);
|
|
3939
|
-
if (!match)
|
|
5228
|
+
if (!match) {
|
|
5229
|
+
return cell;
|
|
5230
|
+
}
|
|
3940
5231
|
if (cell && typeof cell === "object" && cell.type === "tableCell") {
|
|
3941
5232
|
return {
|
|
3942
5233
|
...cell,
|
|
3943
|
-
props: { ...cell.props,
|
|
5234
|
+
props: { ...cell.props, ...match.props }
|
|
3944
5235
|
};
|
|
3945
5236
|
}
|
|
3946
5237
|
return cell;
|
|
@@ -3953,6 +5244,161 @@ function patchBlocks(blocks, tableVAMap) {
|
|
|
3953
5244
|
};
|
|
3954
5245
|
});
|
|
3955
5246
|
}
|
|
5247
|
+
function injectTableCellAttrs(blocks, editor, attrs) {
|
|
5248
|
+
const tiptap = editor?._tiptapEditor;
|
|
5249
|
+
if (!tiptap) {
|
|
5250
|
+
return blocks;
|
|
5251
|
+
}
|
|
5252
|
+
const { doc } = tiptap.state;
|
|
5253
|
+
const cellAttrMap = buildTableCellAttrMap(doc, attrs);
|
|
5254
|
+
if (cellAttrMap.size === 0) {
|
|
5255
|
+
return blocks;
|
|
5256
|
+
}
|
|
5257
|
+
return patchBlocks(blocks, cellAttrMap);
|
|
5258
|
+
}
|
|
5259
|
+
var TABLE_BLOCK_ATTR_DEFAULTS = {
|
|
5260
|
+
tableAlignment: "left"
|
|
5261
|
+
};
|
|
5262
|
+
function buildTableBlockAttrMap(doc, attrs) {
|
|
5263
|
+
const result = /* @__PURE__ */ new Map();
|
|
5264
|
+
doc.descendants((node) => {
|
|
5265
|
+
if (node.type.name === "blockContainer") {
|
|
5266
|
+
const blockId = node.attrs?.id;
|
|
5267
|
+
const contentNode = node.firstChild;
|
|
5268
|
+
if (blockId && contentNode?.type.name === "table") {
|
|
5269
|
+
const props = {};
|
|
5270
|
+
for (const attr of attrs) {
|
|
5271
|
+
const value = contentNode.attrs?.[attr];
|
|
5272
|
+
if (value !== null && value !== void 0 && value !== TABLE_BLOCK_ATTR_DEFAULTS[attr]) {
|
|
5273
|
+
props[attr] = value;
|
|
5274
|
+
}
|
|
5275
|
+
}
|
|
5276
|
+
if (Object.keys(props).length > 0) {
|
|
5277
|
+
result.set(blockId, props);
|
|
5278
|
+
}
|
|
5279
|
+
}
|
|
5280
|
+
return false;
|
|
5281
|
+
}
|
|
5282
|
+
return void 0;
|
|
5283
|
+
});
|
|
5284
|
+
return result;
|
|
5285
|
+
}
|
|
5286
|
+
function patchTableBlockProps(blocks, attrMap) {
|
|
5287
|
+
return blocks.map((block) => {
|
|
5288
|
+
if (block.type === "table" && block.id && attrMap.has(block.id)) {
|
|
5289
|
+
return {
|
|
5290
|
+
...block,
|
|
5291
|
+
props: { ...block.props, ...attrMap.get(block.id) }
|
|
5292
|
+
};
|
|
5293
|
+
}
|
|
5294
|
+
if (block.children && block.children.length > 0) {
|
|
5295
|
+
return {
|
|
5296
|
+
...block,
|
|
5297
|
+
children: patchTableBlockProps(
|
|
5298
|
+
block.children,
|
|
5299
|
+
attrMap
|
|
5300
|
+
)
|
|
5301
|
+
};
|
|
5302
|
+
}
|
|
5303
|
+
return block;
|
|
5304
|
+
});
|
|
5305
|
+
}
|
|
5306
|
+
function injectTableBlockAttrs(blocks, editor) {
|
|
5307
|
+
const tiptap = editor?._tiptapEditor;
|
|
5308
|
+
if (!tiptap) {
|
|
5309
|
+
return blocks;
|
|
5310
|
+
}
|
|
5311
|
+
const { doc } = tiptap.state;
|
|
5312
|
+
const attrMap = buildTableBlockAttrMap(doc, ["tableAlignment"]);
|
|
5313
|
+
if (attrMap.size === 0) {
|
|
5314
|
+
return blocks;
|
|
5315
|
+
}
|
|
5316
|
+
return patchTableBlockProps(blocks, attrMap);
|
|
5317
|
+
}
|
|
5318
|
+
|
|
5319
|
+
// src/utils/font-size-serialization.ts
|
|
5320
|
+
function mapPreservingRef(arr, fn) {
|
|
5321
|
+
let changed = false;
|
|
5322
|
+
const next = arr.map((item) => {
|
|
5323
|
+
const mapped = fn(item);
|
|
5324
|
+
if (mapped !== item) changed = true;
|
|
5325
|
+
return mapped;
|
|
5326
|
+
});
|
|
5327
|
+
return changed ? next : arr;
|
|
5328
|
+
}
|
|
5329
|
+
function mapStyledItem(item, dir) {
|
|
5330
|
+
if (!item || typeof item !== "object" || item.type !== "text") {
|
|
5331
|
+
return item;
|
|
5332
|
+
}
|
|
5333
|
+
if (dir === "lower") {
|
|
5334
|
+
const fs2 = item.styles?.fontSize;
|
|
5335
|
+
if (fs2 == null) return item;
|
|
5336
|
+
const { fontSize: _removed, ...restStyles } = item.styles;
|
|
5337
|
+
return { ...item, styles: restStyles, fontSize: fs2 };
|
|
5338
|
+
}
|
|
5339
|
+
const fs = item.fontSize;
|
|
5340
|
+
if (fs == null) return item;
|
|
5341
|
+
const { fontSize: _lifted, ...rest } = item;
|
|
5342
|
+
return { ...rest, styles: { ...item.styles ?? {}, fontSize: fs } };
|
|
5343
|
+
}
|
|
5344
|
+
function mapInlineItem(node, dir) {
|
|
5345
|
+
if (!node || typeof node !== "object") return node;
|
|
5346
|
+
if (node.type === "link" && Array.isArray(node.content)) {
|
|
5347
|
+
const content = mapPreservingRef(
|
|
5348
|
+
node.content,
|
|
5349
|
+
(n) => mapStyledItem(n, dir)
|
|
5350
|
+
);
|
|
5351
|
+
return content === node.content ? node : { ...node, content };
|
|
5352
|
+
}
|
|
5353
|
+
return mapStyledItem(node, dir);
|
|
5354
|
+
}
|
|
5355
|
+
function mapCell(cell, dir) {
|
|
5356
|
+
if (cell && typeof cell === "object" && cell.type === "tableCell") {
|
|
5357
|
+
if (!Array.isArray(cell.content)) return cell;
|
|
5358
|
+
const content = mapPreservingRef(
|
|
5359
|
+
cell.content,
|
|
5360
|
+
(n) => mapInlineItem(n, dir)
|
|
5361
|
+
);
|
|
5362
|
+
return content === cell.content ? cell : { ...cell, content };
|
|
5363
|
+
}
|
|
5364
|
+
if (Array.isArray(cell)) {
|
|
5365
|
+
return mapPreservingRef(cell, (n) => mapInlineItem(n, dir));
|
|
5366
|
+
}
|
|
5367
|
+
return cell;
|
|
5368
|
+
}
|
|
5369
|
+
function mapBlock(block, dir) {
|
|
5370
|
+
if (!block || typeof block !== "object") return block;
|
|
5371
|
+
let next = block;
|
|
5372
|
+
const content = block.content;
|
|
5373
|
+
if (Array.isArray(content)) {
|
|
5374
|
+
const mapped = mapPreservingRef(content, (n) => mapInlineItem(n, dir));
|
|
5375
|
+
if (mapped !== content) next = { ...next, content: mapped };
|
|
5376
|
+
} else if (content && typeof content === "object" && content.type === "tableContent" && Array.isArray(content.rows)) {
|
|
5377
|
+
const rows = mapPreservingRef(content.rows, (row) => {
|
|
5378
|
+
if (!row || !Array.isArray(row.cells)) return row;
|
|
5379
|
+
const cells = mapPreservingRef(
|
|
5380
|
+
row.cells,
|
|
5381
|
+
(cell) => mapCell(cell, dir)
|
|
5382
|
+
);
|
|
5383
|
+
return cells === row.cells ? row : { ...row, cells };
|
|
5384
|
+
});
|
|
5385
|
+
if (rows !== content.rows) next = { ...next, content: { ...content, rows } };
|
|
5386
|
+
}
|
|
5387
|
+
if (Array.isArray(block.children) && block.children.length > 0) {
|
|
5388
|
+
const children = mapPreservingRef(
|
|
5389
|
+
block.children,
|
|
5390
|
+
(b) => mapBlock(b, dir)
|
|
5391
|
+
);
|
|
5392
|
+
if (children !== block.children) next = { ...next, children };
|
|
5393
|
+
}
|
|
5394
|
+
return next;
|
|
5395
|
+
}
|
|
5396
|
+
function lowerFontSize(blocks) {
|
|
5397
|
+
return mapPreservingRef(blocks, (b) => mapBlock(b, "lower"));
|
|
5398
|
+
}
|
|
5399
|
+
function liftFontSize(blocks) {
|
|
5400
|
+
return mapPreservingRef(blocks, (b) => mapBlock(b, "lift"));
|
|
5401
|
+
}
|
|
3956
5402
|
|
|
3957
5403
|
// src/utils/excel-paste.ts
|
|
3958
5404
|
var NAMED_COLORS = {
|
|
@@ -4183,26 +5629,8 @@ function normalizeExcelTableHtml(html) {
|
|
|
4183
5629
|
}
|
|
4184
5630
|
}
|
|
4185
5631
|
|
|
4186
|
-
// src/constants/limits.ts
|
|
4187
|
-
var MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
4188
|
-
var MAX_VIDEO_FILE_SIZE = 100 * 1024 * 1024;
|
|
4189
|
-
var BLOCKED_EXTENSIONS = [".svg", ".svgz"];
|
|
4190
|
-
var ALLOWED_VIDEO_MIME_TYPES = /* @__PURE__ */ new Set([
|
|
4191
|
-
"video/mp4",
|
|
4192
|
-
"video/webm",
|
|
4193
|
-
"video/ogg",
|
|
4194
|
-
"video/quicktime"
|
|
4195
|
-
// .mov
|
|
4196
|
-
]);
|
|
4197
|
-
var ALLOWED_VIDEO_EXTENSIONS = [
|
|
4198
|
-
".mp4",
|
|
4199
|
-
".webm",
|
|
4200
|
-
".ogg",
|
|
4201
|
-
".mov"
|
|
4202
|
-
];
|
|
4203
|
-
|
|
4204
5632
|
// src/components/LumirEditor.tsx
|
|
4205
|
-
var
|
|
5633
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
4206
5634
|
var DEBUG_LOG = (loc, msg, data) => {
|
|
4207
5635
|
const p = fetch("http://127.0.0.1:7686/ingest/1f8ee1c5-0cf0-4ae7-91ed-5ea7ed17130a", {
|
|
4208
5636
|
method: "POST",
|
|
@@ -4367,6 +5795,12 @@ var isVideoFile = (file, maxSize) => {
|
|
|
4367
5795
|
});
|
|
4368
5796
|
return result;
|
|
4369
5797
|
};
|
|
5798
|
+
var isSuppressiblePopupSelection = (editor, selection) => {
|
|
5799
|
+
if (!selection) return false;
|
|
5800
|
+
if (selection.node) return false;
|
|
5801
|
+
if (isInTableCell(editor)) return false;
|
|
5802
|
+
return true;
|
|
5803
|
+
};
|
|
4370
5804
|
var isHtmlFile = (file) => {
|
|
4371
5805
|
return file.size > 0 && (file.type === "text/html" || file.name?.toLowerCase().endsWith(".html") || file.name?.toLowerCase().endsWith(".htm"));
|
|
4372
5806
|
};
|
|
@@ -4427,9 +5861,9 @@ var findBlockWithLink = (blocks, targetUrl) => {
|
|
|
4427
5861
|
return null;
|
|
4428
5862
|
};
|
|
4429
5863
|
var ConvertToPreviewButton = ({ url }) => {
|
|
4430
|
-
const editor = (0,
|
|
4431
|
-
const Components = (0,
|
|
4432
|
-
return /* @__PURE__ */ (0,
|
|
5864
|
+
const editor = (0, import_react38.useBlockNoteEditor)();
|
|
5865
|
+
const Components = (0, import_react38.useComponentsContext)();
|
|
5866
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4433
5867
|
Components.LinkToolbar.Button,
|
|
4434
5868
|
{
|
|
4435
5869
|
className: "bn-button",
|
|
@@ -4448,29 +5882,29 @@ var ConvertToPreviewButton = ({ url }) => {
|
|
|
4448
5882
|
console.error("Convert to link preview failed:", err);
|
|
4449
5883
|
}
|
|
4450
5884
|
},
|
|
4451
|
-
icon: /* @__PURE__ */ (0,
|
|
4452
|
-
/* @__PURE__ */ (0,
|
|
4453
|
-
/* @__PURE__ */ (0,
|
|
4454
|
-
/* @__PURE__ */ (0,
|
|
5885
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
5886
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("rect", { x: "1", y: "3", width: "14", height: "10", rx: "2", stroke: "currentColor", strokeWidth: "1.5", fill: "none" }),
|
|
5887
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("line", { x1: "1", y1: "9", x2: "15", y2: "9", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
5888
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("circle", { cx: "5", cy: "6.5", r: "1.5", stroke: "currentColor", strokeWidth: "1", fill: "none" })
|
|
4455
5889
|
] })
|
|
4456
5890
|
}
|
|
4457
5891
|
);
|
|
4458
5892
|
};
|
|
4459
5893
|
var CustomLinkToolbar = (props) => {
|
|
4460
|
-
const editor = (0,
|
|
4461
|
-
const Components = (0,
|
|
5894
|
+
const editor = (0, import_react38.useBlockNoteEditor)();
|
|
5895
|
+
const Components = (0, import_react38.useComponentsContext)();
|
|
4462
5896
|
const hasLinkPreview = !!editor?._linkPreviewApiEndpoint;
|
|
4463
|
-
return /* @__PURE__ */ (0,
|
|
5897
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
4464
5898
|
Components.LinkToolbar.Root,
|
|
4465
5899
|
{
|
|
4466
5900
|
className: "bn-toolbar bn-link-toolbar",
|
|
4467
5901
|
onMouseEnter: props.stopHideTimer,
|
|
4468
5902
|
onMouseLeave: props.startHideTimer,
|
|
4469
5903
|
children: [
|
|
4470
|
-
/* @__PURE__ */ (0,
|
|
4471
|
-
/* @__PURE__ */ (0,
|
|
4472
|
-
/* @__PURE__ */ (0,
|
|
4473
|
-
hasLinkPreview && /* @__PURE__ */ (0,
|
|
5904
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react38.EditLinkButton, { url: props.url, text: props.text, editLink: props.editLink }),
|
|
5905
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react38.OpenLinkButton, { url: props.url }),
|
|
5906
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react38.DeleteLinkButton, { deleteLink: props.deleteLink }),
|
|
5907
|
+
hasLinkPreview && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ConvertToPreviewButton, { url: props.url })
|
|
4474
5908
|
]
|
|
4475
5909
|
}
|
|
4476
5910
|
);
|
|
@@ -4514,13 +5948,13 @@ function LumirEditor({
|
|
|
4514
5948
|
onError,
|
|
4515
5949
|
onImageDelete
|
|
4516
5950
|
}) {
|
|
4517
|
-
const [isUploading, setIsUploading] = (0,
|
|
4518
|
-
const [uploadProgress, setUploadProgress] = (0,
|
|
4519
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
4520
|
-
const floatingMenuFileInputRef = (0,
|
|
4521
|
-
const floatingMenuBlockRef = (0,
|
|
4522
|
-
const floatingMenuUploadStartTimeRef = (0,
|
|
4523
|
-
const handleError = (0,
|
|
5951
|
+
const [isUploading, setIsUploading] = (0, import_react37.useState)(false);
|
|
5952
|
+
const [uploadProgress, setUploadProgress] = (0, import_react37.useState)(null);
|
|
5953
|
+
const [errorMessage, setErrorMessage] = (0, import_react37.useState)(null);
|
|
5954
|
+
const floatingMenuFileInputRef = (0, import_react37.useRef)(null);
|
|
5955
|
+
const floatingMenuBlockRef = (0, import_react37.useRef)(null);
|
|
5956
|
+
const floatingMenuUploadStartTimeRef = (0, import_react37.useRef)(0);
|
|
5957
|
+
const handleError = (0, import_react37.useCallback)(
|
|
4524
5958
|
(error) => {
|
|
4525
5959
|
onError?.(error);
|
|
4526
5960
|
setErrorMessage(error.getUserMessage());
|
|
@@ -4528,10 +5962,12 @@ function LumirEditor({
|
|
|
4528
5962
|
},
|
|
4529
5963
|
[onError]
|
|
4530
5964
|
);
|
|
4531
|
-
const validatedContent = (0,
|
|
4532
|
-
return
|
|
5965
|
+
const validatedContent = (0, import_react37.useMemo)(() => {
|
|
5966
|
+
return liftFontSize(
|
|
5967
|
+
ContentUtils.validateContent(initialContent, initialEmptyBlocks)
|
|
5968
|
+
);
|
|
4533
5969
|
}, [initialContent, initialEmptyBlocks]);
|
|
4534
|
-
const tableConfig = (0,
|
|
5970
|
+
const tableConfig = (0, import_react37.useMemo)(() => {
|
|
4535
5971
|
return EditorConfig.getDefaultTableConfig(tables);
|
|
4536
5972
|
}, [
|
|
4537
5973
|
tables?.splitCells,
|
|
@@ -4539,10 +5975,10 @@ function LumirEditor({
|
|
|
4539
5975
|
tables?.cellTextColor,
|
|
4540
5976
|
tables?.headers
|
|
4541
5977
|
]);
|
|
4542
|
-
const headingConfig = (0,
|
|
5978
|
+
const headingConfig = (0, import_react37.useMemo)(() => {
|
|
4543
5979
|
return EditorConfig.getDefaultHeadingConfig(heading);
|
|
4544
5980
|
}, [heading?.levels?.join(",") ?? ""]);
|
|
4545
|
-
const disabledExtensions = (0,
|
|
5981
|
+
const disabledExtensions = (0, import_react37.useMemo)(() => {
|
|
4546
5982
|
return EditorConfig.getDisabledExtensions(
|
|
4547
5983
|
disableExtensions,
|
|
4548
5984
|
allowVideoUpload,
|
|
@@ -4550,18 +5986,18 @@ function LumirEditor({
|
|
|
4550
5986
|
allowFileUpload
|
|
4551
5987
|
);
|
|
4552
5988
|
}, [disableExtensions, allowVideoUpload, allowAudioUpload, allowFileUpload]);
|
|
4553
|
-
(0,
|
|
5989
|
+
(0, import_react37.useEffect)(() => {
|
|
4554
5990
|
DEBUG_LOG("LumirEditor:init:disabledExtensions", "snapshot", {
|
|
4555
5991
|
allowVideoUpload,
|
|
4556
5992
|
hasVideoInDisabled: disabledExtensions.includes("video"),
|
|
4557
5993
|
disabledList: disabledExtensions.slice(0, 15)
|
|
4558
5994
|
});
|
|
4559
5995
|
}, [allowVideoUpload, disabledExtensions]);
|
|
4560
|
-
const fileNameTransformRef = (0,
|
|
4561
|
-
(0,
|
|
5996
|
+
const fileNameTransformRef = (0, import_react37.useRef)(s3Upload?.fileNameTransform);
|
|
5997
|
+
(0, import_react37.useEffect)(() => {
|
|
4562
5998
|
fileNameTransformRef.current = s3Upload?.fileNameTransform;
|
|
4563
5999
|
}, [s3Upload?.fileNameTransform]);
|
|
4564
|
-
const memoizedS3Upload = (0,
|
|
6000
|
+
const memoizedS3Upload = (0, import_react37.useMemo)(() => {
|
|
4565
6001
|
if (!s3Upload) return void 0;
|
|
4566
6002
|
return {
|
|
4567
6003
|
apiEndpoint: s3Upload.apiEndpoint,
|
|
@@ -4590,7 +6026,7 @@ function LumirEditor({
|
|
|
4590
6026
|
s3Upload?.maxRetries,
|
|
4591
6027
|
s3Upload?.onProgress
|
|
4592
6028
|
]);
|
|
4593
|
-
const editor = (0,
|
|
6029
|
+
const editor = (0, import_react38.useCreateBlockNote)(
|
|
4594
6030
|
{
|
|
4595
6031
|
// HTML 미리보기 블록이 포함된 커스텀 스키마 사용
|
|
4596
6032
|
schema,
|
|
@@ -4612,7 +6048,14 @@ function LumirEditor({
|
|
|
4612
6048
|
// 확장 비활성: 비디오/오디오/파일 제어
|
|
4613
6049
|
disableExtensions: disabledExtensions,
|
|
4614
6050
|
_tiptapOptions: {
|
|
4615
|
-
extensions: [
|
|
6051
|
+
extensions: [
|
|
6052
|
+
VerticalAlignmentExtension,
|
|
6053
|
+
// 행 높이 attr 등록은 항상(저장된 높이 렌더), 드래그 리사이즈 UI는
|
|
6054
|
+
// tableHandles prop으로 게이트(기존 grip 컨트롤러와 동일 게이트).
|
|
6055
|
+
RowHeightExtension.configure({ resizable: tableHandles }),
|
|
6056
|
+
// 표 블록 정렬(좌/가운데/우) attr.
|
|
6057
|
+
TableAlignmentExtension
|
|
6058
|
+
]
|
|
4616
6059
|
},
|
|
4617
6060
|
placeholders: placeholder ? { default: placeholder, emptyDocument: placeholder } : void 0,
|
|
4618
6061
|
tabBehavior,
|
|
@@ -4788,33 +6231,65 @@ function LumirEditor({
|
|
|
4788
6231
|
memoizedS3Upload,
|
|
4789
6232
|
allowVideoUpload,
|
|
4790
6233
|
linkPreview?.apiEndpoint,
|
|
4791
|
-
placeholder
|
|
6234
|
+
placeholder,
|
|
6235
|
+
// tableHandles 변경 시 RowHeightExtension의 resizable 게이트가 반영되도록 재생성
|
|
6236
|
+
tableHandles
|
|
4792
6237
|
]
|
|
4793
6238
|
);
|
|
4794
6239
|
if (editor && linkPreview?.apiEndpoint) {
|
|
4795
6240
|
editor._linkPreviewApiEndpoint = linkPreview.apiEndpoint;
|
|
4796
6241
|
}
|
|
4797
|
-
|
|
6242
|
+
if (editor) {
|
|
6243
|
+
try {
|
|
6244
|
+
const view = editor.prosemirrorView;
|
|
6245
|
+
if (view) {
|
|
6246
|
+
view.__lumirEditor = editor;
|
|
6247
|
+
}
|
|
6248
|
+
} catch {
|
|
6249
|
+
}
|
|
6250
|
+
}
|
|
6251
|
+
(0, import_react37.useEffect)(() => {
|
|
4798
6252
|
if (editor) {
|
|
4799
6253
|
editor.isEditable = editable;
|
|
4800
6254
|
}
|
|
4801
6255
|
}, [editor, editable]);
|
|
4802
|
-
(0,
|
|
6256
|
+
(0, import_react37.useEffect)(() => {
|
|
6257
|
+
if (!editor || !floatingMenu) return;
|
|
6258
|
+
const ft = editor.formattingToolbar;
|
|
6259
|
+
if (!ft?.onUpdate) return;
|
|
6260
|
+
const unsubscribe = ft.onUpdate((state) => {
|
|
6261
|
+
if (!state?.show) return;
|
|
6262
|
+
const selection = editor._tiptapEditor?.state?.selection;
|
|
6263
|
+
if (isSuppressiblePopupSelection(editor, selection)) {
|
|
6264
|
+
ft.closeMenu();
|
|
6265
|
+
}
|
|
6266
|
+
});
|
|
6267
|
+
return unsubscribe;
|
|
6268
|
+
}, [editor, floatingMenu]);
|
|
6269
|
+
(0, import_react37.useEffect)(() => {
|
|
4803
6270
|
if (!editor || !onContentChange) return;
|
|
4804
6271
|
const handleContentChange = () => {
|
|
4805
6272
|
const blocks = editor.topLevelBlocks;
|
|
4806
|
-
const patched =
|
|
6273
|
+
const patched = lowerFontSize(
|
|
6274
|
+
injectTableBlockAttrs(
|
|
6275
|
+
injectTableCellAttrs(blocks, editor, [
|
|
6276
|
+
"verticalAlignment",
|
|
6277
|
+
"rowHeight"
|
|
6278
|
+
]),
|
|
6279
|
+
editor
|
|
6280
|
+
)
|
|
6281
|
+
);
|
|
4807
6282
|
onContentChange(patched);
|
|
4808
6283
|
};
|
|
4809
6284
|
return editor.onEditorContentChange(handleContentChange);
|
|
4810
6285
|
}, [editor, onContentChange]);
|
|
4811
|
-
const previousMediaUrlsRef = (0,
|
|
4812
|
-
(0,
|
|
6286
|
+
const previousMediaUrlsRef = (0, import_react37.useRef)(/* @__PURE__ */ new Set());
|
|
6287
|
+
(0, import_react37.useEffect)(() => {
|
|
4813
6288
|
if (!editor) return;
|
|
4814
6289
|
const initialBlocks = editor.topLevelBlocks;
|
|
4815
6290
|
previousMediaUrlsRef.current = extractMediaUrls(initialBlocks);
|
|
4816
6291
|
}, [editor]);
|
|
4817
|
-
(0,
|
|
6292
|
+
(0, import_react37.useEffect)(() => {
|
|
4818
6293
|
if (!editor || !onImageDelete) return;
|
|
4819
6294
|
const handleMediaDeleteCheck = () => {
|
|
4820
6295
|
const currentBlocks = editor.topLevelBlocks;
|
|
@@ -4828,7 +6303,7 @@ function LumirEditor({
|
|
|
4828
6303
|
};
|
|
4829
6304
|
return editor.onEditorContentChange(handleMediaDeleteCheck);
|
|
4830
6305
|
}, [editor, onImageDelete]);
|
|
4831
|
-
(0,
|
|
6306
|
+
(0, import_react37.useEffect)(() => {
|
|
4832
6307
|
const el = editor?.domElement;
|
|
4833
6308
|
if (!el) return;
|
|
4834
6309
|
const handleDragOver = (e) => {
|
|
@@ -4959,20 +6434,20 @@ function LumirEditor({
|
|
|
4959
6434
|
el.removeEventListener("drop", handleDrop, { capture: true });
|
|
4960
6435
|
};
|
|
4961
6436
|
}, [editor, allowVideoUpload]);
|
|
4962
|
-
const computedSideMenu = (0,
|
|
6437
|
+
const computedSideMenu = (0, import_react37.useMemo)(() => {
|
|
4963
6438
|
return sideMenuAddButton ? sideMenu : false;
|
|
4964
6439
|
}, [sideMenuAddButton, sideMenu]);
|
|
4965
|
-
const DragHandleOnlySideMenu = (0,
|
|
4966
|
-
return (props) => /* @__PURE__ */ (0,
|
|
6440
|
+
const DragHandleOnlySideMenu = (0, import_react37.useMemo)(() => {
|
|
6441
|
+
return (props) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react38.SideMenu, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react38.DragHandleButton, { ...props, dragHandleMenu: LumirDragHandleMenu }) });
|
|
4967
6442
|
}, []);
|
|
4968
|
-
return /* @__PURE__ */ (0,
|
|
6443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
4969
6444
|
"div",
|
|
4970
6445
|
{
|
|
4971
6446
|
className: cn("lumirEditor", className),
|
|
4972
6447
|
style: { position: "relative", display: "flex", flexDirection: "column" },
|
|
4973
6448
|
children: [
|
|
4974
|
-
floatingMenu && editor && /* @__PURE__ */ (0,
|
|
4975
|
-
/* @__PURE__ */ (0,
|
|
6449
|
+
floatingMenu && editor && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
6450
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4976
6451
|
"input",
|
|
4977
6452
|
{
|
|
4978
6453
|
ref: floatingMenuFileInputRef,
|
|
@@ -5043,7 +6518,7 @@ function LumirEditor({
|
|
|
5043
6518
|
}
|
|
5044
6519
|
}
|
|
5045
6520
|
),
|
|
5046
|
-
/* @__PURE__ */ (0,
|
|
6521
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5047
6522
|
FloatingMenu,
|
|
5048
6523
|
{
|
|
5049
6524
|
editor,
|
|
@@ -5075,7 +6550,7 @@ function LumirEditor({
|
|
|
5075
6550
|
}
|
|
5076
6551
|
)
|
|
5077
6552
|
] }),
|
|
5078
|
-
/* @__PURE__ */ (0,
|
|
6553
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
5079
6554
|
import_mantine.BlockNoteView,
|
|
5080
6555
|
{
|
|
5081
6556
|
editor,
|
|
@@ -5090,21 +6565,21 @@ function LumirEditor({
|
|
|
5090
6565
|
tableHandles: false,
|
|
5091
6566
|
onSelectionChange,
|
|
5092
6567
|
children: [
|
|
5093
|
-
tableHandles && /* @__PURE__ */ (0,
|
|
5094
|
-
formattingToolbar && /* @__PURE__ */ (0,
|
|
5095
|
-
|
|
6568
|
+
tableHandles && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(LumirTableHandlesController, {}),
|
|
6569
|
+
formattingToolbar && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
6570
|
+
import_react38.FormattingToolbarController,
|
|
5096
6571
|
{
|
|
5097
6572
|
formattingToolbar: CustomFormattingToolbar
|
|
5098
6573
|
}
|
|
5099
6574
|
),
|
|
5100
|
-
linkToolbar && (linkPreview?.apiEndpoint ? /* @__PURE__ */ (0,
|
|
5101
|
-
/* @__PURE__ */ (0,
|
|
5102
|
-
|
|
6575
|
+
linkToolbar && (linkPreview?.apiEndpoint ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react38.LinkToolbarController, { linkToolbar: CustomLinkToolbar }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react38.LinkToolbarController, {})),
|
|
6576
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
6577
|
+
import_react38.SuggestionMenuController,
|
|
5103
6578
|
{
|
|
5104
6579
|
triggerCharacter: "/",
|
|
5105
|
-
getItems: (0,
|
|
6580
|
+
getItems: (0, import_react37.useCallback)(
|
|
5106
6581
|
async (query) => {
|
|
5107
|
-
const items = (0,
|
|
6582
|
+
const items = (0, import_react38.getDefaultReactSlashMenuItems)(editor);
|
|
5108
6583
|
const filtered = items.filter((item) => {
|
|
5109
6584
|
const key = (item?.key || "").toString().toLowerCase();
|
|
5110
6585
|
const title = (item?.title || "").toString().toLowerCase();
|
|
@@ -5146,7 +6621,7 @@ function LumirEditor({
|
|
|
5146
6621
|
},
|
|
5147
6622
|
aliases: ["html", "preview", "\uC6F9", "\uC6F9\uD398\uC774\uC9C0"],
|
|
5148
6623
|
group: "Embeds",
|
|
5149
|
-
icon: /* @__PURE__ */ (0,
|
|
6624
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
5150
6625
|
"svg",
|
|
5151
6626
|
{
|
|
5152
6627
|
width: "18",
|
|
@@ -5158,19 +6633,45 @@ function LumirEditor({
|
|
|
5158
6633
|
strokeLinecap: "round",
|
|
5159
6634
|
strokeLinejoin: "round",
|
|
5160
6635
|
children: [
|
|
5161
|
-
/* @__PURE__ */ (0,
|
|
5162
|
-
/* @__PURE__ */ (0,
|
|
6636
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("polyline", { points: "16 18 22 12 16 6" }),
|
|
6637
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("polyline", { points: "8 6 2 12 8 18" })
|
|
5163
6638
|
]
|
|
5164
6639
|
}
|
|
5165
6640
|
),
|
|
5166
6641
|
subtext: "HTML \uD30C\uC77C\uC744 \uBBF8\uB9AC\uBCF4\uAE30\uB85C \uC0BD\uC785"
|
|
5167
6642
|
};
|
|
5168
|
-
const
|
|
6643
|
+
const columnItem = {
|
|
6644
|
+
title: "2\uB2E8 \uCEEC\uB7FC",
|
|
6645
|
+
onItemClick: () => {
|
|
6646
|
+
insertTwoColumns(editor);
|
|
6647
|
+
},
|
|
6648
|
+
aliases: ["columns", "column", "2col", "\uB2E8", "\uCEEC\uB7FC", "\uB2E4\uB2E8", "\uBD84\uD560"],
|
|
6649
|
+
group: "Basic blocks",
|
|
6650
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
6651
|
+
"svg",
|
|
6652
|
+
{
|
|
6653
|
+
width: "18",
|
|
6654
|
+
height: "18",
|
|
6655
|
+
viewBox: "0 0 24 24",
|
|
6656
|
+
fill: "none",
|
|
6657
|
+
stroke: "currentColor",
|
|
6658
|
+
strokeWidth: "2",
|
|
6659
|
+
strokeLinecap: "round",
|
|
6660
|
+
strokeLinejoin: "round",
|
|
6661
|
+
children: [
|
|
6662
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("rect", { x: "3", y: "4", width: "7", height: "16", rx: "1" }),
|
|
6663
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("rect", { x: "14", y: "4", width: "7", height: "16", rx: "1" })
|
|
6664
|
+
]
|
|
6665
|
+
}
|
|
6666
|
+
),
|
|
6667
|
+
subtext: "\uBE14\uB85D\uC744 \uC88C\uC6B0 2\uB2E8\uC73C\uB85C \uBC30\uCE58"
|
|
6668
|
+
};
|
|
6669
|
+
const allItems = [...filtered, htmlPreviewItem, columnItem];
|
|
5169
6670
|
if (linkPreview?.apiEndpoint) {
|
|
5170
6671
|
allItems.push({
|
|
5171
6672
|
title: "Link Preview",
|
|
5172
6673
|
onItemClick: () => {
|
|
5173
|
-
(0,
|
|
6674
|
+
(0, import_core9.insertOrUpdateBlock)(editor, {
|
|
5174
6675
|
type: "linkPreview",
|
|
5175
6676
|
props: { url: "" }
|
|
5176
6677
|
});
|
|
@@ -5184,7 +6685,7 @@ function LumirEditor({
|
|
|
5184
6685
|
"\uD504\uB9AC\uBDF0"
|
|
5185
6686
|
],
|
|
5186
6687
|
group: "Embeds",
|
|
5187
|
-
icon: /* @__PURE__ */ (0,
|
|
6688
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
5188
6689
|
"svg",
|
|
5189
6690
|
{
|
|
5190
6691
|
width: "18",
|
|
@@ -5196,8 +6697,8 @@ function LumirEditor({
|
|
|
5196
6697
|
strokeLinecap: "round",
|
|
5197
6698
|
strokeLinejoin: "round",
|
|
5198
6699
|
children: [
|
|
5199
|
-
/* @__PURE__ */ (0,
|
|
5200
|
-
/* @__PURE__ */ (0,
|
|
6700
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
|
|
6701
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
5201
6702
|
]
|
|
5202
6703
|
}
|
|
5203
6704
|
),
|
|
@@ -5233,21 +6734,21 @@ function LumirEditor({
|
|
|
5233
6734
|
)
|
|
5234
6735
|
}
|
|
5235
6736
|
),
|
|
5236
|
-
!sideMenuAddButton && /* @__PURE__ */ (0,
|
|
6737
|
+
!sideMenuAddButton && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react38.SideMenuController, { sideMenu: DragHandleOnlySideMenu })
|
|
5237
6738
|
]
|
|
5238
6739
|
}
|
|
5239
6740
|
),
|
|
5240
|
-
isUploading && /* @__PURE__ */ (0,
|
|
5241
|
-
/* @__PURE__ */ (0,
|
|
5242
|
-
uploadProgress !== null && /* @__PURE__ */ (0,
|
|
6741
|
+
isUploading && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "lumirEditor-upload-overlay", children: [
|
|
6742
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "lumirEditor-spinner" }),
|
|
6743
|
+
uploadProgress !== null && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { className: "lumirEditor-upload-progress", children: [
|
|
5243
6744
|
uploadProgress,
|
|
5244
6745
|
"%"
|
|
5245
6746
|
] })
|
|
5246
6747
|
] }),
|
|
5247
|
-
errorMessage && /* @__PURE__ */ (0,
|
|
5248
|
-
/* @__PURE__ */ (0,
|
|
5249
|
-
/* @__PURE__ */ (0,
|
|
5250
|
-
/* @__PURE__ */ (0,
|
|
6748
|
+
errorMessage && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "lumirEditor-error-toast", children: [
|
|
6749
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "lumirEditor-error-icon", children: "\u26A0\uFE0F" }),
|
|
6750
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "lumirEditor-error-message", children: errorMessage }),
|
|
6751
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
5251
6752
|
"button",
|
|
5252
6753
|
{
|
|
5253
6754
|
className: "lumirEditor-error-close",
|
|
@@ -5266,7 +6767,10 @@ function LumirEditor({
|
|
|
5266
6767
|
BACKGROUND_COLORS,
|
|
5267
6768
|
ContentUtils,
|
|
5268
6769
|
EditorConfig,
|
|
6770
|
+
FONT_SIZE_PRESETS,
|
|
5269
6771
|
FloatingMenu,
|
|
6772
|
+
FontSize,
|
|
6773
|
+
FontSizeButton,
|
|
5270
6774
|
HtmlPreviewBlock,
|
|
5271
6775
|
HtmlPreviewSchema,
|
|
5272
6776
|
LinkPreviewBlock,
|
|
@@ -5277,6 +6781,8 @@ function LumirEditor({
|
|
|
5277
6781
|
cn,
|
|
5278
6782
|
createS3Uploader,
|
|
5279
6783
|
fetchLinkMetadata,
|
|
5280
|
-
getHexFromColorValue
|
|
6784
|
+
getHexFromColorValue,
|
|
6785
|
+
liftFontSize,
|
|
6786
|
+
lowerFontSize
|
|
5281
6787
|
});
|
|
5282
6788
|
//# sourceMappingURL=index.js.map
|