@jvs-milkdown/crepe 1.2.16 → 1.2.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/lib/cjs/feature/block-edit/index.js +35 -16
- package/lib/cjs/feature/block-edit/index.js.map +1 -1
- package/lib/cjs/feature/toolbar/index.js +47 -16
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +210 -39
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/block-edit/index.js +36 -17
- package/lib/esm/feature/block-edit/index.js.map +1 -1
- package/lib/esm/feature/toolbar/index.js +48 -17
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +211 -40
- package/lib/esm/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/feature/block-edit/menu/component.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/outline-panel.d.ts.map +1 -1
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/feature/block-edit/menu/component.tsx +41 -17
- package/src/feature/fixed-toolbar/outline-panel.tsx +219 -32
- package/src/feature/toolbar/component.tsx +19 -0
|
@@ -2393,27 +2393,39 @@ const Menu = vue.defineComponent({
|
|
|
2393
2393
|
let activeTextColor = null;
|
|
2394
2394
|
let activeBgColor = null;
|
|
2395
2395
|
if (node && node.nodeSize > 2) {
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
if (
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2396
|
+
const schema = ctx.get(core.schemaCtx);
|
|
2397
|
+
const tcHasMark = schema.marks[textColorSchema.id];
|
|
2398
|
+
const bcHasMark = schema.marks[bgColorSchema.id];
|
|
2399
|
+
if (tcHasMark || bcHasMark) {
|
|
2400
|
+
node.descendants((childNode) => {
|
|
2401
|
+
if (childNode.isText) {
|
|
2402
|
+
if (tcHasMark && !activeTextColor) {
|
|
2403
|
+
const tcType = textColorSchema.type(ctx);
|
|
2404
|
+
const tcMark = childNode.marks.find(
|
|
2405
|
+
(m) => m.type === tcType
|
|
2406
|
+
);
|
|
2407
|
+
if (tcMark) activeTextColor = tcMark.attrs.color;
|
|
2408
|
+
}
|
|
2409
|
+
if (bcHasMark && !activeBgColor) {
|
|
2410
|
+
const bcType = bgColorSchema.type(ctx);
|
|
2411
|
+
const bcMark = childNode.marks.find(
|
|
2412
|
+
(m) => m.type === bcType
|
|
2413
|
+
);
|
|
2414
|
+
if (bcMark) activeBgColor = bcMark.attrs.color;
|
|
2415
|
+
}
|
|
2407
2416
|
}
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
}
|
|
2417
|
+
return false;
|
|
2418
|
+
});
|
|
2419
|
+
}
|
|
2411
2420
|
}
|
|
2412
2421
|
const setBlockColor = (colorValue, isBg) => {
|
|
2413
2422
|
if (pos === null || pos === void 0) return;
|
|
2414
2423
|
const { tr } = view.state;
|
|
2415
2424
|
const targetNode = tr.doc.nodeAt(pos);
|
|
2416
2425
|
if (!targetNode) return;
|
|
2426
|
+
const schema = ctx.get(core.schemaCtx);
|
|
2427
|
+
const hasMark = isBg ? schema.marks[bgColorSchema.id] : schema.marks[textColorSchema.id];
|
|
2428
|
+
if (!hasMark) return;
|
|
2417
2429
|
const markType = isBg ? bgColorSchema.type(ctx) : textColorSchema.type(ctx);
|
|
2418
2430
|
const start = pos + 1;
|
|
2419
2431
|
const end = pos + targetNode.nodeSize - 1;
|
|
@@ -2432,10 +2444,17 @@ const Menu = vue.defineComponent({
|
|
|
2432
2444
|
const { tr } = view.state;
|
|
2433
2445
|
const targetNode = tr.doc.nodeAt(pos);
|
|
2434
2446
|
if (!targetNode) return;
|
|
2447
|
+
const schema = ctx.get(core.schemaCtx);
|
|
2448
|
+
const tcHasMark = schema.marks[textColorSchema.id];
|
|
2449
|
+
const bcHasMark = schema.marks[bgColorSchema.id];
|
|
2435
2450
|
const start = pos + 1;
|
|
2436
2451
|
const end = pos + targetNode.nodeSize - 1;
|
|
2437
|
-
|
|
2438
|
-
|
|
2452
|
+
if (tcHasMark) {
|
|
2453
|
+
tr.removeMark(start, end, textColorSchema.type(ctx));
|
|
2454
|
+
}
|
|
2455
|
+
if (bcHasMark) {
|
|
2456
|
+
tr.removeMark(start, end, bgColorSchema.type(ctx));
|
|
2457
|
+
}
|
|
2439
2458
|
view.dispatch(tr);
|
|
2440
2459
|
showColorMenu.value = false;
|
|
2441
2460
|
hide();
|