@mhamz.01/easyflow-texteditor 0.1.151 → 0.1.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +24 -24
- package/dist/index.css.map +1 -1
- package/dist/index.js +363 -159
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +363 -159
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1400,6 +1400,80 @@ var import_extension_color = __toESM(require("@tiptap/extension-color"));
|
|
|
1400
1400
|
var import_extension_table = require("@tiptap/extension-table");
|
|
1401
1401
|
var import_extensions2 = require("@tiptap/extensions");
|
|
1402
1402
|
|
|
1403
|
+
// src/components/extensions/list-marker-color.tsx
|
|
1404
|
+
var import_core3 = require("@tiptap/core");
|
|
1405
|
+
var ListMarkerColor = import_core3.Extension.create({
|
|
1406
|
+
name: "listMarkerColor",
|
|
1407
|
+
addGlobalAttributes() {
|
|
1408
|
+
return [
|
|
1409
|
+
{
|
|
1410
|
+
types: ["listItem", "taskItem"],
|
|
1411
|
+
attributes: {
|
|
1412
|
+
// Inherit color attribute from ColorBlock extension
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
];
|
|
1416
|
+
},
|
|
1417
|
+
addProseMirrorPlugins() {
|
|
1418
|
+
return [];
|
|
1419
|
+
},
|
|
1420
|
+
// Add CSS to make markers inherit color
|
|
1421
|
+
addOptions() {
|
|
1422
|
+
return {
|
|
1423
|
+
// CSS will be injected into the editor
|
|
1424
|
+
};
|
|
1425
|
+
},
|
|
1426
|
+
onCreate() {
|
|
1427
|
+
if (typeof document !== "undefined") {
|
|
1428
|
+
const styleId = "tiptap-list-marker-color";
|
|
1429
|
+
if (!document.getElementById(styleId)) {
|
|
1430
|
+
const style = document.createElement("style");
|
|
1431
|
+
style.id = styleId;
|
|
1432
|
+
style.textContent = `
|
|
1433
|
+
/* Bullet list markers inherit color */
|
|
1434
|
+
.ProseMirror ul[data-type="bulletList"] > li[style*="color"]::marker,
|
|
1435
|
+
.ProseMirror ul li[style*="color"]::marker {
|
|
1436
|
+
color: inherit !important;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/* Ordered list numbers inherit color */
|
|
1440
|
+
.ProseMirror ol[data-type="orderedList"] > li[style*="color"]::marker,
|
|
1441
|
+
.ProseMirror ol li[style*="color"]::marker {
|
|
1442
|
+
color: inherit !important;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
/* Task list checkboxes inherit color */
|
|
1446
|
+
.ProseMirror ul[data-type="taskList"] > li[style*="color"] > label > input[type="checkbox"],
|
|
1447
|
+
.ProseMirror ul[data-type="taskList"] li[style*="color"] > label > input[type="checkbox"] {
|
|
1448
|
+
accent-color: currentColor;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
/* Alternative: Style the checkbox wrapper */
|
|
1452
|
+
.ProseMirror ul[data-type="taskList"] > li[style*="color"] > label,
|
|
1453
|
+
.ProseMirror ul[data-type="taskList"] li[style*="color"] > label {
|
|
1454
|
+
color: inherit;
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
/* Ensure nested lists also inherit */
|
|
1458
|
+
.ProseMirror li[style*="color"] ul > li::marker,
|
|
1459
|
+
.ProseMirror li[style*="color"] ol > li::marker {
|
|
1460
|
+
color: inherit !important;
|
|
1461
|
+
}
|
|
1462
|
+
`;
|
|
1463
|
+
document.head.appendChild(style);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
},
|
|
1467
|
+
onDestroy() {
|
|
1468
|
+
if (typeof document !== "undefined") {
|
|
1469
|
+
const styleElement = document.getElementById("tiptap-list-marker-color");
|
|
1470
|
+
if (styleElement) {
|
|
1471
|
+
styleElement.remove();
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
});
|
|
1476
|
+
|
|
1403
1477
|
// src/components/tiptap-ui-primitive/button/button.tsx
|
|
1404
1478
|
var import_react12 = require("react");
|
|
1405
1479
|
|
|
@@ -1547,7 +1621,7 @@ TooltipContent2.displayName = "TooltipContent";
|
|
|
1547
1621
|
|
|
1548
1622
|
// src/lib/tiptap-utils.ts
|
|
1549
1623
|
var import_state = require("@tiptap/pm/state");
|
|
1550
|
-
var
|
|
1624
|
+
var import_core4 = require("@tiptap/core");
|
|
1551
1625
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
1552
1626
|
var MAC_SYMBOLS = {
|
|
1553
1627
|
mod: "\u2318",
|
|
@@ -1790,7 +1864,7 @@ var FONT_SIZES = [
|
|
|
1790
1864
|
"56px",
|
|
1791
1865
|
"64px"
|
|
1792
1866
|
];
|
|
1793
|
-
var FontSizeExtension =
|
|
1867
|
+
var FontSizeExtension = import_core4.Extension.create({
|
|
1794
1868
|
name: "fontSize",
|
|
1795
1869
|
addOptions() {
|
|
1796
1870
|
return {
|
|
@@ -2902,37 +2976,98 @@ function useTiptapEditor(providedEditor) {
|
|
|
2902
2976
|
|
|
2903
2977
|
// src/hooks/mark-preservers/mark-preserver.ts
|
|
2904
2978
|
var MarkPreserver = class {
|
|
2905
|
-
static
|
|
2979
|
+
static preservedStyles = /* @__PURE__ */ new Map();
|
|
2906
2980
|
/**
|
|
2907
|
-
* Preserve
|
|
2908
|
-
* Call this in onMouseDown or onPointerDown events
|
|
2981
|
+
* Preserve current font and color before blur or node change
|
|
2909
2982
|
*/
|
|
2910
2983
|
static preserve(editor) {
|
|
2911
2984
|
if (!editor) return;
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2985
|
+
try {
|
|
2986
|
+
const { state } = editor;
|
|
2987
|
+
const { $from } = state.selection;
|
|
2988
|
+
const currentNode = $from.parent;
|
|
2989
|
+
let font = currentNode.attrs.fontFamily;
|
|
2990
|
+
let color = currentNode.attrs.color;
|
|
2991
|
+
const marks = state.storedMarks || $from.marks();
|
|
2992
|
+
const textStyleMark = marks.find((m) => m.type.name === "textStyle");
|
|
2993
|
+
if (!font && textStyleMark?.attrs.fontFamily) {
|
|
2994
|
+
font = textStyleMark.attrs.fontFamily;
|
|
2995
|
+
}
|
|
2996
|
+
if (!color && textStyleMark?.attrs.color) {
|
|
2997
|
+
color = textStyleMark.attrs.color;
|
|
2998
|
+
}
|
|
2999
|
+
if (font || color) {
|
|
3000
|
+
this.preservedStyles.set(editor, { font, color });
|
|
3001
|
+
}
|
|
3002
|
+
} catch (error) {
|
|
3003
|
+
console.debug("MarkPreserver.preserve error:", error);
|
|
2917
3004
|
}
|
|
2918
3005
|
}
|
|
2919
3006
|
/**
|
|
2920
|
-
* Restore
|
|
2921
|
-
* Call this after the editor action in onClick or in a setTimeout
|
|
3007
|
+
* Restore preserved styles to current node
|
|
2922
3008
|
*/
|
|
2923
3009
|
static restore(editor, delay = 0) {
|
|
2924
3010
|
if (!editor) return;
|
|
2925
|
-
const
|
|
2926
|
-
if (!
|
|
3011
|
+
const styles = this.preservedStyles.get(editor);
|
|
3012
|
+
if (!styles) return;
|
|
2927
3013
|
const restoreFn = () => {
|
|
2928
3014
|
if (editor.isDestroyed) {
|
|
2929
|
-
this.
|
|
3015
|
+
this.preservedStyles.delete(editor);
|
|
2930
3016
|
return;
|
|
2931
3017
|
}
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
3018
|
+
try {
|
|
3019
|
+
const { state } = editor;
|
|
3020
|
+
const { $from } = state.selection;
|
|
3021
|
+
const depth = $from.depth;
|
|
3022
|
+
const pos = $from.before(depth);
|
|
3023
|
+
const node = $from.node(depth);
|
|
3024
|
+
const supportsAttributes = [
|
|
3025
|
+
"paragraph",
|
|
3026
|
+
"heading",
|
|
3027
|
+
"listItem",
|
|
3028
|
+
"taskItem",
|
|
3029
|
+
"blockquote"
|
|
3030
|
+
].includes(node.type.name);
|
|
3031
|
+
if (!supportsAttributes) {
|
|
3032
|
+
this.preservedStyles.delete(editor);
|
|
3033
|
+
editor.commands.focus();
|
|
3034
|
+
return;
|
|
3035
|
+
}
|
|
3036
|
+
const updates = {};
|
|
3037
|
+
if (styles.font && !node.attrs.fontFamily) {
|
|
3038
|
+
updates.fontFamily = styles.font;
|
|
3039
|
+
}
|
|
3040
|
+
if (styles.color && !node.attrs.color) {
|
|
3041
|
+
updates.color = styles.color;
|
|
3042
|
+
}
|
|
3043
|
+
if (Object.keys(updates).length > 0) {
|
|
3044
|
+
const newAttrs = { ...node.attrs, ...updates };
|
|
3045
|
+
editor.view.dispatch(
|
|
3046
|
+
state.tr.setNodeMarkup(pos, void 0, newAttrs)
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
3049
|
+
const marks = state.storedMarks || $from.marks();
|
|
3050
|
+
const filteredMarks = marks.filter((mark) => mark.type.name !== "textStyle");
|
|
3051
|
+
const textStyleAttrs = {};
|
|
3052
|
+
if (styles.font) textStyleAttrs.fontFamily = styles.font;
|
|
3053
|
+
if (styles.color) textStyleAttrs.color = styles.color;
|
|
3054
|
+
const newMarks = [
|
|
3055
|
+
...filteredMarks,
|
|
3056
|
+
state.schema.marks.textStyle.create(textStyleAttrs)
|
|
3057
|
+
];
|
|
3058
|
+
setTimeout(() => {
|
|
3059
|
+
if (!editor.isDestroyed) {
|
|
3060
|
+
editor.view.dispatch(
|
|
3061
|
+
editor.state.tr.setStoredMarks(newMarks)
|
|
3062
|
+
);
|
|
3063
|
+
editor.commands.focus();
|
|
3064
|
+
}
|
|
3065
|
+
}, 0);
|
|
3066
|
+
} catch (error) {
|
|
3067
|
+
console.debug("MarkPreserver.restore error:", error);
|
|
3068
|
+
} finally {
|
|
3069
|
+
this.preservedStyles.delete(editor);
|
|
3070
|
+
}
|
|
2936
3071
|
};
|
|
2937
3072
|
if (delay > 0) {
|
|
2938
3073
|
setTimeout(restoreFn, delay);
|
|
@@ -2941,10 +3076,10 @@ var MarkPreserver = class {
|
|
|
2941
3076
|
}
|
|
2942
3077
|
}
|
|
2943
3078
|
/**
|
|
2944
|
-
* Clear preserved
|
|
3079
|
+
* Clear preserved styles
|
|
2945
3080
|
*/
|
|
2946
3081
|
static clear(editor) {
|
|
2947
|
-
this.
|
|
3082
|
+
this.preservedStyles.delete(editor);
|
|
2948
3083
|
}
|
|
2949
3084
|
};
|
|
2950
3085
|
|
|
@@ -7659,8 +7794,9 @@ function useCursorVisibility({
|
|
|
7659
7794
|
}
|
|
7660
7795
|
|
|
7661
7796
|
// src/components/extensions/font-family-block.ts
|
|
7662
|
-
var
|
|
7663
|
-
var
|
|
7797
|
+
var import_core5 = require("@tiptap/core");
|
|
7798
|
+
var import_state5 = require("@tiptap/pm/state");
|
|
7799
|
+
var FontFamilyBlock = import_core5.Extension.create({
|
|
7664
7800
|
name: "fontFamilyBlock",
|
|
7665
7801
|
addGlobalAttributes() {
|
|
7666
7802
|
return [
|
|
@@ -7688,7 +7824,7 @@ var FontFamilyBlock = import_core4.Extension.create({
|
|
|
7688
7824
|
];
|
|
7689
7825
|
}
|
|
7690
7826
|
});
|
|
7691
|
-
var ColorBlock =
|
|
7827
|
+
var ColorBlock = import_core5.Extension.create({
|
|
7692
7828
|
name: "colorBlock",
|
|
7693
7829
|
addGlobalAttributes() {
|
|
7694
7830
|
return [
|
|
@@ -7716,150 +7852,217 @@ var ColorBlock = import_core4.Extension.create({
|
|
|
7716
7852
|
];
|
|
7717
7853
|
}
|
|
7718
7854
|
});
|
|
7719
|
-
var
|
|
7855
|
+
var ListMarkerColor2 = import_core5.Extension.create({
|
|
7856
|
+
name: "listMarkerColor",
|
|
7857
|
+
onCreate() {
|
|
7858
|
+
if (typeof document !== "undefined") {
|
|
7859
|
+
const styleId = "tiptap-list-marker-color";
|
|
7860
|
+
if (!document.getElementById(styleId)) {
|
|
7861
|
+
const style = document.createElement("style");
|
|
7862
|
+
style.id = styleId;
|
|
7863
|
+
style.textContent = `
|
|
7864
|
+
/* Bullet list markers inherit color */
|
|
7865
|
+
.ProseMirror ul > li[style*="color"]::marker {
|
|
7866
|
+
color: inherit !important;
|
|
7867
|
+
}
|
|
7868
|
+
|
|
7869
|
+
/* Ordered list numbers inherit color */
|
|
7870
|
+
.ProseMirror ol > li[style*="color"]::marker {
|
|
7871
|
+
color: inherit !important;
|
|
7872
|
+
}
|
|
7873
|
+
|
|
7874
|
+
/* Task list checkboxes inherit color */
|
|
7875
|
+
.ProseMirror ul[data-type="taskList"] > li[style*="color"] > label > input[type="checkbox"] {
|
|
7876
|
+
accent-color: currentColor;
|
|
7877
|
+
}
|
|
7878
|
+
|
|
7879
|
+
/* Ensure nested lists also inherit */
|
|
7880
|
+
.ProseMirror li[style*="color"] ul > li::marker,
|
|
7881
|
+
.ProseMirror li[style*="color"] ol > li::marker {
|
|
7882
|
+
color: inherit !important;
|
|
7883
|
+
}
|
|
7884
|
+
`;
|
|
7885
|
+
document.head.appendChild(style);
|
|
7886
|
+
}
|
|
7887
|
+
}
|
|
7888
|
+
},
|
|
7889
|
+
onDestroy() {
|
|
7890
|
+
if (typeof document !== "undefined") {
|
|
7891
|
+
const styleElement = document.getElementById("tiptap-list-marker-color");
|
|
7892
|
+
if (styleElement) {
|
|
7893
|
+
styleElement.remove();
|
|
7894
|
+
}
|
|
7895
|
+
}
|
|
7896
|
+
}
|
|
7897
|
+
});
|
|
7898
|
+
var stylePersistenceKey = new import_state5.PluginKey("stylePersistence");
|
|
7899
|
+
var StylePersistence = import_core5.Extension.create({
|
|
7720
7900
|
name: "stylePersistence",
|
|
7721
7901
|
addOptions() {
|
|
7722
7902
|
return {
|
|
7723
|
-
// Marks that should NOT inherit font family or color
|
|
7724
7903
|
excludedMarks: ["code", "codeBlock"]
|
|
7725
7904
|
};
|
|
7726
7905
|
},
|
|
7727
|
-
|
|
7728
|
-
return {
|
|
7729
|
-
// Store marks temporarily when editor loses focus
|
|
7730
|
-
preservedMarks: null,
|
|
7731
|
-
// Store marks from the previous node (for Enter key handling)
|
|
7732
|
-
previousNodeMarks: null
|
|
7733
|
-
};
|
|
7734
|
-
},
|
|
7735
|
-
addKeyboardShortcuts() {
|
|
7736
|
-
return {
|
|
7737
|
-
// Handle Enter key to preserve marks when creating new paragraphs
|
|
7738
|
-
"Enter": ({ editor }) => {
|
|
7739
|
-
const { state } = editor;
|
|
7740
|
-
const { $from } = state.selection;
|
|
7741
|
-
const currentNode = $from.parent;
|
|
7742
|
-
const blockFont = currentNode.attrs.fontFamily;
|
|
7743
|
-
const blockColor = currentNode.attrs.color;
|
|
7744
|
-
if (blockFont || blockColor) {
|
|
7745
|
-
this.storage.previousNodeMarks = { blockFont, blockColor };
|
|
7746
|
-
}
|
|
7747
|
-
return false;
|
|
7748
|
-
},
|
|
7749
|
-
// Handle Shift+Enter (soft break) - same logic
|
|
7750
|
-
"Shift-Enter": ({ editor }) => {
|
|
7751
|
-
const { state } = editor;
|
|
7752
|
-
const { $from } = state.selection;
|
|
7753
|
-
const currentNode = $from.parent;
|
|
7754
|
-
const blockFont = currentNode.attrs.fontFamily;
|
|
7755
|
-
const blockColor = currentNode.attrs.color;
|
|
7756
|
-
if (blockFont || blockColor) {
|
|
7757
|
-
this.storage.previousNodeMarks = { blockFont, blockColor };
|
|
7758
|
-
}
|
|
7759
|
-
return false;
|
|
7760
|
-
}
|
|
7761
|
-
};
|
|
7762
|
-
},
|
|
7763
|
-
onSelectionUpdate({ editor }) {
|
|
7764
|
-
const excludedMarks = this.options.excludedMarks;
|
|
7765
|
-
syncStoredMarks(editor, excludedMarks, this.storage);
|
|
7766
|
-
},
|
|
7767
|
-
onFocus({ editor }) {
|
|
7768
|
-
const excludedMarks = this.options.excludedMarks;
|
|
7769
|
-
if (this.storage.preservedMarks) {
|
|
7770
|
-
editor.view.dispatch(
|
|
7771
|
-
editor.state.tr.setStoredMarks(this.storage.preservedMarks)
|
|
7772
|
-
);
|
|
7773
|
-
this.storage.preservedMarks = null;
|
|
7774
|
-
}
|
|
7775
|
-
syncStoredMarks(editor, excludedMarks, this.storage);
|
|
7776
|
-
},
|
|
7777
|
-
onBlur({ editor }) {
|
|
7778
|
-
const { state } = editor;
|
|
7779
|
-
const { $from } = state.selection;
|
|
7780
|
-
const currentMarks = state.storedMarks || $from.marks();
|
|
7781
|
-
const hasTextStyle = currentMarks.some((mark) => mark.type.name === "textStyle");
|
|
7782
|
-
if (hasTextStyle) {
|
|
7783
|
-
this.storage.preservedMarks = currentMarks;
|
|
7784
|
-
}
|
|
7785
|
-
},
|
|
7786
|
-
onCreate({ editor }) {
|
|
7787
|
-
const excludedMarks = this.options.excludedMarks;
|
|
7788
|
-
syncStoredMarks(editor, excludedMarks, this.storage);
|
|
7789
|
-
},
|
|
7790
|
-
onTransaction({ editor, transaction }) {
|
|
7791
|
-
if (!transaction.selectionSet && !transaction.docChanged) return;
|
|
7906
|
+
addProseMirrorPlugins() {
|
|
7792
7907
|
const excludedMarks = this.options.excludedMarks;
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7908
|
+
return [
|
|
7909
|
+
new import_state5.Plugin({
|
|
7910
|
+
key: stylePersistenceKey,
|
|
7911
|
+
state: {
|
|
7912
|
+
init() {
|
|
7913
|
+
return {
|
|
7914
|
+
lastFont: null,
|
|
7915
|
+
lastColor: null
|
|
7916
|
+
};
|
|
7917
|
+
},
|
|
7918
|
+
apply(tr, value, oldState, newState) {
|
|
7919
|
+
const { $from } = newState.selection;
|
|
7920
|
+
const marks = $from.marks();
|
|
7921
|
+
const hasExcludedMarks = marks.some(
|
|
7922
|
+
(mark) => excludedMarks.includes(mark.type.name)
|
|
7923
|
+
);
|
|
7924
|
+
let isInCodeBlock = false;
|
|
7925
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
7926
|
+
const node = $from.node(depth);
|
|
7927
|
+
if (node.type.name === "codeBlock") {
|
|
7928
|
+
isInCodeBlock = true;
|
|
7929
|
+
break;
|
|
7930
|
+
}
|
|
7931
|
+
}
|
|
7932
|
+
if (hasExcludedMarks || isInCodeBlock) {
|
|
7933
|
+
return value;
|
|
7934
|
+
}
|
|
7935
|
+
const parentNode = $from.parent;
|
|
7936
|
+
let font = parentNode.attrs.fontFamily;
|
|
7937
|
+
let color = parentNode.attrs.color;
|
|
7938
|
+
const textStyleMark = marks.find((m) => m.type.name === "textStyle");
|
|
7939
|
+
if (!font && textStyleMark?.attrs.fontFamily) {
|
|
7940
|
+
font = textStyleMark.attrs.fontFamily;
|
|
7941
|
+
}
|
|
7942
|
+
if (!color && textStyleMark?.attrs.color) {
|
|
7943
|
+
color = textStyleMark.attrs.color;
|
|
7944
|
+
}
|
|
7945
|
+
return {
|
|
7946
|
+
lastFont: font || value.lastFont,
|
|
7947
|
+
lastColor: color || value.lastColor
|
|
7948
|
+
};
|
|
7949
|
+
}
|
|
7950
|
+
},
|
|
7951
|
+
appendTransaction(transactions, oldState, newState) {
|
|
7952
|
+
if (!transactions.some((tr2) => tr2.docChanged)) {
|
|
7953
|
+
return null;
|
|
7954
|
+
}
|
|
7955
|
+
const pluginState = stylePersistenceKey.getState(newState);
|
|
7956
|
+
if (!pluginState.lastFont && !pluginState.lastColor) {
|
|
7957
|
+
return null;
|
|
7958
|
+
}
|
|
7959
|
+
const { $from } = newState.selection;
|
|
7960
|
+
const parentNode = $from.parent;
|
|
7961
|
+
const marks = $from.marks();
|
|
7962
|
+
const hasExcludedMarks = marks.some(
|
|
7963
|
+
(mark) => excludedMarks.includes(mark.type.name)
|
|
7964
|
+
);
|
|
7965
|
+
let isInCodeBlock = false;
|
|
7966
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
7967
|
+
const node = $from.node(depth);
|
|
7968
|
+
if (node.type.name === "codeBlock") {
|
|
7969
|
+
isInCodeBlock = true;
|
|
7970
|
+
break;
|
|
7971
|
+
}
|
|
7972
|
+
}
|
|
7973
|
+
if (hasExcludedMarks || isInCodeBlock) {
|
|
7974
|
+
return null;
|
|
7975
|
+
}
|
|
7976
|
+
const supportsAttributes = [
|
|
7977
|
+
"paragraph",
|
|
7978
|
+
"heading",
|
|
7979
|
+
"listItem",
|
|
7980
|
+
"taskItem",
|
|
7981
|
+
"blockquote"
|
|
7982
|
+
].includes(parentNode.type.name);
|
|
7983
|
+
if (!supportsAttributes) {
|
|
7984
|
+
return null;
|
|
7985
|
+
}
|
|
7986
|
+
const currentFont = parentNode.attrs.fontFamily;
|
|
7987
|
+
const currentColor = parentNode.attrs.color;
|
|
7988
|
+
const needsFont = !currentFont && pluginState.lastFont;
|
|
7989
|
+
const needsColor = !currentColor && pluginState.lastColor;
|
|
7990
|
+
if (!needsFont && !needsColor) {
|
|
7991
|
+
return null;
|
|
7992
|
+
}
|
|
7993
|
+
const tr = newState.tr;
|
|
7994
|
+
try {
|
|
7995
|
+
const depth = $from.depth;
|
|
7996
|
+
const pos = $from.before(depth);
|
|
7997
|
+
const node = $from.node(depth);
|
|
7998
|
+
const newAttrs = { ...node.attrs };
|
|
7999
|
+
if (needsFont) newAttrs.fontFamily = pluginState.lastFont;
|
|
8000
|
+
if (needsColor) newAttrs.color = pluginState.lastColor;
|
|
8001
|
+
tr.setNodeMarkup(pos, void 0, newAttrs);
|
|
8002
|
+
const storedMarks = newState.storedMarks || $from.marks();
|
|
8003
|
+
const filteredMarks = storedMarks.filter(
|
|
8004
|
+
(mark) => mark.type.name !== "textStyle" && !excludedMarks.includes(mark.type.name)
|
|
8005
|
+
);
|
|
8006
|
+
const textStyleAttrs = {};
|
|
8007
|
+
if (pluginState.lastFont) textStyleAttrs.fontFamily = pluginState.lastFont;
|
|
8008
|
+
if (pluginState.lastColor) textStyleAttrs.color = pluginState.lastColor;
|
|
8009
|
+
const newMarks = [
|
|
8010
|
+
...filteredMarks,
|
|
8011
|
+
newState.schema.marks.textStyle.create(textStyleAttrs)
|
|
8012
|
+
];
|
|
8013
|
+
tr.setStoredMarks(newMarks);
|
|
8014
|
+
return tr;
|
|
8015
|
+
} catch (error) {
|
|
8016
|
+
console.error("StylePersistence error:", error);
|
|
8017
|
+
return null;
|
|
8018
|
+
}
|
|
8019
|
+
},
|
|
8020
|
+
props: {
|
|
8021
|
+
handleKeyDown(view, event) {
|
|
8022
|
+
if (event.key === "Enter") {
|
|
8023
|
+
const { state } = view;
|
|
8024
|
+
const { $from } = state.selection;
|
|
8025
|
+
const marks = $from.marks();
|
|
8026
|
+
const hasExcludedMarks = marks.some(
|
|
8027
|
+
(mark) => excludedMarks.includes(mark.type.name)
|
|
8028
|
+
);
|
|
8029
|
+
if (hasExcludedMarks) {
|
|
8030
|
+
return false;
|
|
8031
|
+
}
|
|
8032
|
+
let isInCodeBlock = false;
|
|
8033
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
8034
|
+
const node = $from.node(depth);
|
|
8035
|
+
if (node.type.name === "codeBlock") {
|
|
8036
|
+
isInCodeBlock = true;
|
|
8037
|
+
break;
|
|
8038
|
+
}
|
|
8039
|
+
}
|
|
8040
|
+
if (isInCodeBlock) {
|
|
8041
|
+
return false;
|
|
8042
|
+
}
|
|
8043
|
+
const parentNode = $from.parent;
|
|
8044
|
+
let font = parentNode.attrs.fontFamily;
|
|
8045
|
+
let color = parentNode.attrs.color;
|
|
8046
|
+
const textStyleMark = marks.find((m) => m.type.name === "textStyle");
|
|
8047
|
+
if (!font && textStyleMark?.attrs.fontFamily) {
|
|
8048
|
+
font = textStyleMark.attrs.fontFamily;
|
|
8049
|
+
}
|
|
8050
|
+
if (!color && textStyleMark?.attrs.color) {
|
|
8051
|
+
color = textStyleMark.attrs.color;
|
|
8052
|
+
}
|
|
8053
|
+
if (font || color) {
|
|
8054
|
+
const pluginState = stylePersistenceKey.getState(state);
|
|
8055
|
+
pluginState.lastFont = font || pluginState.lastFont;
|
|
8056
|
+
pluginState.lastColor = color || pluginState.lastColor;
|
|
8057
|
+
}
|
|
8058
|
+
}
|
|
8059
|
+
return false;
|
|
8060
|
+
}
|
|
8061
|
+
}
|
|
8062
|
+
})
|
|
8063
|
+
];
|
|
7798
8064
|
}
|
|
7799
8065
|
});
|
|
7800
|
-
function syncStoredMarks(editor, excludedMarks, storage) {
|
|
7801
|
-
const { state } = editor;
|
|
7802
|
-
const { $from } = state.selection;
|
|
7803
|
-
const marks = $from.marks();
|
|
7804
|
-
const hasExcludedMarks = marks.some(
|
|
7805
|
-
(mark) => excludedMarks.includes(mark.type.name)
|
|
7806
|
-
);
|
|
7807
|
-
let isInCodeBlock = false;
|
|
7808
|
-
for (let depth = $from.depth; depth > 0; depth--) {
|
|
7809
|
-
const node = $from.node(depth);
|
|
7810
|
-
if (node.type.name === "codeBlock") {
|
|
7811
|
-
isInCodeBlock = true;
|
|
7812
|
-
break;
|
|
7813
|
-
}
|
|
7814
|
-
}
|
|
7815
|
-
if (hasExcludedMarks || isInCodeBlock) {
|
|
7816
|
-
return;
|
|
7817
|
-
}
|
|
7818
|
-
const parentNode = $from.parent;
|
|
7819
|
-
let blockFont = parentNode.attrs.fontFamily;
|
|
7820
|
-
let blockColor = parentNode.attrs.color;
|
|
7821
|
-
if ((!blockFont || !blockColor) && storage?.previousNodeMarks) {
|
|
7822
|
-
if (!blockFont && storage.previousNodeMarks.blockFont) {
|
|
7823
|
-
blockFont = storage.previousNodeMarks.blockFont;
|
|
7824
|
-
}
|
|
7825
|
-
if (!blockColor && storage.previousNodeMarks.blockColor) {
|
|
7826
|
-
blockColor = storage.previousNodeMarks.blockColor;
|
|
7827
|
-
}
|
|
7828
|
-
if (blockFont || blockColor) {
|
|
7829
|
-
const depth = $from.depth;
|
|
7830
|
-
const nodePos = $from.before(depth);
|
|
7831
|
-
const node = $from.node(depth);
|
|
7832
|
-
const newAttrs = { ...node.attrs };
|
|
7833
|
-
if (blockFont) newAttrs.fontFamily = blockFont;
|
|
7834
|
-
if (blockColor) newAttrs.color = blockColor;
|
|
7835
|
-
const tr = state.tr.setNodeMarkup(nodePos, void 0, newAttrs);
|
|
7836
|
-
editor.view.dispatch(tr);
|
|
7837
|
-
}
|
|
7838
|
-
storage.previousNodeMarks = null;
|
|
7839
|
-
}
|
|
7840
|
-
if (!blockFont && !blockColor) {
|
|
7841
|
-
return;
|
|
7842
|
-
}
|
|
7843
|
-
const storedMarks = state.storedMarks || $from.marks();
|
|
7844
|
-
const existingTextStyle = storedMarks.find((mark) => mark.type.name === "textStyle");
|
|
7845
|
-
const needsUpdate = !existingTextStyle || blockFont && existingTextStyle.attrs.fontFamily !== blockFont || blockColor && existingTextStyle.attrs.color !== blockColor;
|
|
7846
|
-
if (!needsUpdate) {
|
|
7847
|
-
return;
|
|
7848
|
-
}
|
|
7849
|
-
const filteredMarks = storedMarks.filter(
|
|
7850
|
-
(mark) => mark.type.name !== "textStyle" && !excludedMarks.includes(mark.type.name)
|
|
7851
|
-
);
|
|
7852
|
-
const textStyleAttrs = {};
|
|
7853
|
-
if (blockFont) textStyleAttrs.fontFamily = blockFont;
|
|
7854
|
-
if (blockColor) textStyleAttrs.color = blockColor;
|
|
7855
|
-
const newMarks = [
|
|
7856
|
-
...filteredMarks,
|
|
7857
|
-
state.schema.marks.textStyle.create(textStyleAttrs)
|
|
7858
|
-
];
|
|
7859
|
-
editor.view.dispatch(
|
|
7860
|
-
state.tr.setStoredMarks(newMarks)
|
|
7861
|
-
);
|
|
7862
|
-
}
|
|
7863
8066
|
|
|
7864
8067
|
// src/components/tiptap-templates/simple/simple-editor.tsx
|
|
7865
8068
|
var import_jsx_runtime81 = require("react/jsx-runtime");
|
|
@@ -7971,6 +8174,7 @@ function SimpleEditor() {
|
|
|
7971
8174
|
import_extension_superscript.Superscript,
|
|
7972
8175
|
import_extension_subscript.Subscript,
|
|
7973
8176
|
import_extensions.Selection,
|
|
8177
|
+
ListMarkerColor,
|
|
7974
8178
|
FontFamilyBlock,
|
|
7975
8179
|
ColorBlock,
|
|
7976
8180
|
StylePersistence,
|