@mhamz.01/easyflow-texteditor 0.1.156 → 0.1.158
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 +60 -36
- package/dist/index.css.map +1 -1
- package/dist/index.js +71 -115
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -115
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7326,23 +7326,32 @@ function ColorPicker({ type = "text" }) {
|
|
|
7326
7326
|
(value) => {
|
|
7327
7327
|
if (!editor) return;
|
|
7328
7328
|
const { state } = editor;
|
|
7329
|
-
const { $from
|
|
7329
|
+
const { $from } = state.selection;
|
|
7330
7330
|
editor.chain().focus().setColor(value).run();
|
|
7331
|
-
const
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7331
|
+
const tr = editor.state.tr;
|
|
7332
|
+
let trDirty = false;
|
|
7333
|
+
for (let depth = $from.depth; depth >= 1; depth--) {
|
|
7334
|
+
const node = $from.node(depth);
|
|
7335
|
+
const pos = $from.before(depth);
|
|
7336
|
+
const supportsColor = [
|
|
7337
|
+
"paragraph",
|
|
7338
|
+
"heading",
|
|
7339
|
+
"listItem",
|
|
7340
|
+
"taskItem",
|
|
7341
|
+
"blockquote"
|
|
7342
|
+
].includes(node.type.name);
|
|
7343
|
+
if (supportsColor && node.attrs.color !== value) {
|
|
7344
|
+
tr.setNodeMarkup(pos, void 0, {
|
|
7345
|
+
...node.attrs,
|
|
7346
|
+
color: value
|
|
7347
|
+
});
|
|
7348
|
+
trDirty = true;
|
|
7349
|
+
}
|
|
7350
|
+
if (node.type.name === "listItem" || node.type.name === "taskItem") {
|
|
7351
|
+
break;
|
|
7352
|
+
}
|
|
7353
|
+
}
|
|
7354
|
+
if (trDirty) {
|
|
7346
7355
|
editor.view.dispatch(tr);
|
|
7347
7356
|
}
|
|
7348
7357
|
setTimeout(() => {
|
|
@@ -7423,7 +7432,7 @@ function ColorPicker({ type = "text" }) {
|
|
|
7423
7432
|
{
|
|
7424
7433
|
className: "flex flex-col gap-3",
|
|
7425
7434
|
onMouseDown: (e) => e.stopPropagation(),
|
|
7426
|
-
onMouseUp: (
|
|
7435
|
+
onMouseUp: (e) => e.stopPropagation(),
|
|
7427
7436
|
onPointerDown: (e) => e.stopPropagation(),
|
|
7428
7437
|
onPointerUp: (e) => e.stopPropagation(),
|
|
7429
7438
|
onClick: (e) => e.stopPropagation(),
|
|
@@ -7852,50 +7861,8 @@ var ColorBlock = import_core5.Extension.create({
|
|
|
7852
7861
|
];
|
|
7853
7862
|
}
|
|
7854
7863
|
});
|
|
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
7864
|
var stylePersistenceKey = new import_state5.PluginKey("stylePersistence");
|
|
7865
|
+
var STYLED_NODES = ["paragraph", "heading", "listItem", "taskItem", "blockquote"];
|
|
7899
7866
|
var StylePersistence = import_core5.Extension.create({
|
|
7900
7867
|
name: "stylePersistence",
|
|
7901
7868
|
addOptions() {
|
|
@@ -7923,8 +7890,7 @@ var StylePersistence = import_core5.Extension.create({
|
|
|
7923
7890
|
);
|
|
7924
7891
|
let isInCodeBlock = false;
|
|
7925
7892
|
for (let depth = $from.depth; depth > 0; depth--) {
|
|
7926
|
-
|
|
7927
|
-
if (node.type.name === "codeBlock") {
|
|
7893
|
+
if ($from.node(depth).type.name === "codeBlock") {
|
|
7928
7894
|
isInCodeBlock = true;
|
|
7929
7895
|
break;
|
|
7930
7896
|
}
|
|
@@ -7932,16 +7898,17 @@ var StylePersistence = import_core5.Extension.create({
|
|
|
7932
7898
|
if (hasExcludedMarks || isInCodeBlock) {
|
|
7933
7899
|
return value;
|
|
7934
7900
|
}
|
|
7935
|
-
|
|
7936
|
-
let
|
|
7937
|
-
let
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
if (!color && textStyleMark?.attrs.color) {
|
|
7943
|
-
color = textStyleMark.attrs.color;
|
|
7901
|
+
let font = null;
|
|
7902
|
+
let color = null;
|
|
7903
|
+
for (let depth = $from.depth; depth >= 1; depth--) {
|
|
7904
|
+
const node = $from.node(depth);
|
|
7905
|
+
if (!font && node.attrs?.fontFamily) font = node.attrs.fontFamily;
|
|
7906
|
+
if (!color && node.attrs?.color) color = node.attrs.color;
|
|
7907
|
+
if (font && color) break;
|
|
7944
7908
|
}
|
|
7909
|
+
const textStyleMark = marks.find((m) => m.type.name === "textStyle");
|
|
7910
|
+
if (!font && textStyleMark?.attrs.fontFamily) font = textStyleMark.attrs.fontFamily;
|
|
7911
|
+
if (!color && textStyleMark?.attrs.color) color = textStyleMark.attrs.color;
|
|
7945
7912
|
return {
|
|
7946
7913
|
lastFont: font || value.lastFont,
|
|
7947
7914
|
lastColor: color || value.lastColor
|
|
@@ -7957,15 +7924,13 @@ var StylePersistence = import_core5.Extension.create({
|
|
|
7957
7924
|
return null;
|
|
7958
7925
|
}
|
|
7959
7926
|
const { $from } = newState.selection;
|
|
7960
|
-
const parentNode = $from.parent;
|
|
7961
7927
|
const marks = $from.marks();
|
|
7962
7928
|
const hasExcludedMarks = marks.some(
|
|
7963
7929
|
(mark) => excludedMarks.includes(mark.type.name)
|
|
7964
7930
|
);
|
|
7965
7931
|
let isInCodeBlock = false;
|
|
7966
7932
|
for (let depth = $from.depth; depth > 0; depth--) {
|
|
7967
|
-
|
|
7968
|
-
if (node.type.name === "codeBlock") {
|
|
7933
|
+
if ($from.node(depth).type.name === "codeBlock") {
|
|
7969
7934
|
isInCodeBlock = true;
|
|
7970
7935
|
break;
|
|
7971
7936
|
}
|
|
@@ -7973,32 +7938,30 @@ var StylePersistence = import_core5.Extension.create({
|
|
|
7973
7938
|
if (hasExcludedMarks || isInCodeBlock) {
|
|
7974
7939
|
return null;
|
|
7975
7940
|
}
|
|
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
7941
|
const tr = newState.tr;
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
const pos = $from.before(depth);
|
|
7942
|
+
let trDirty = false;
|
|
7943
|
+
for (let depth = $from.depth; depth >= 1; depth--) {
|
|
7997
7944
|
const node = $from.node(depth);
|
|
7945
|
+
if (!STYLED_NODES.includes(node.type.name)) continue;
|
|
7946
|
+
const pos = $from.before(depth);
|
|
7947
|
+
const needsFont = !node.attrs.fontFamily && pluginState.lastFont;
|
|
7948
|
+
const needsColor = !node.attrs.color && pluginState.lastColor;
|
|
7949
|
+
if (!needsFont && !needsColor) {
|
|
7950
|
+
break;
|
|
7951
|
+
}
|
|
7998
7952
|
const newAttrs = { ...node.attrs };
|
|
7999
7953
|
if (needsFont) newAttrs.fontFamily = pluginState.lastFont;
|
|
8000
7954
|
if (needsColor) newAttrs.color = pluginState.lastColor;
|
|
8001
7955
|
tr.setNodeMarkup(pos, void 0, newAttrs);
|
|
7956
|
+
trDirty = true;
|
|
7957
|
+
if (node.type.name === "listItem" || node.type.name === "taskItem") {
|
|
7958
|
+
break;
|
|
7959
|
+
}
|
|
7960
|
+
}
|
|
7961
|
+
if (!trDirty) {
|
|
7962
|
+
return null;
|
|
7963
|
+
}
|
|
7964
|
+
try {
|
|
8002
7965
|
const storedMarks = newState.storedMarks || $from.marks();
|
|
8003
7966
|
const filteredMarks = storedMarks.filter(
|
|
8004
7967
|
(mark) => mark.type.name !== "textStyle" && !excludedMarks.includes(mark.type.name)
|
|
@@ -8011,11 +7974,9 @@ var StylePersistence = import_core5.Extension.create({
|
|
|
8011
7974
|
newState.schema.marks.textStyle.create(textStyleAttrs)
|
|
8012
7975
|
];
|
|
8013
7976
|
tr.setStoredMarks(newMarks);
|
|
8014
|
-
|
|
8015
|
-
} catch (error) {
|
|
8016
|
-
console.error("StylePersistence error:", error);
|
|
8017
|
-
return null;
|
|
7977
|
+
} catch (e) {
|
|
8018
7978
|
}
|
|
7979
|
+
return tr;
|
|
8019
7980
|
},
|
|
8020
7981
|
props: {
|
|
8021
7982
|
handleKeyDown(view, event) {
|
|
@@ -8023,33 +7984,28 @@ var StylePersistence = import_core5.Extension.create({
|
|
|
8023
7984
|
const { state } = view;
|
|
8024
7985
|
const { $from } = state.selection;
|
|
8025
7986
|
const marks = $from.marks();
|
|
8026
|
-
|
|
8027
|
-
(mark) => excludedMarks.includes(mark.type.name)
|
|
8028
|
-
);
|
|
8029
|
-
if (hasExcludedMarks) {
|
|
7987
|
+
if (marks.some((mark) => excludedMarks.includes(mark.type.name))) {
|
|
8030
7988
|
return false;
|
|
8031
7989
|
}
|
|
8032
7990
|
let isInCodeBlock = false;
|
|
8033
7991
|
for (let depth = $from.depth; depth > 0; depth--) {
|
|
8034
|
-
|
|
8035
|
-
if (node.type.name === "codeBlock") {
|
|
7992
|
+
if ($from.node(depth).type.name === "codeBlock") {
|
|
8036
7993
|
isInCodeBlock = true;
|
|
8037
7994
|
break;
|
|
8038
7995
|
}
|
|
8039
7996
|
}
|
|
8040
|
-
if (isInCodeBlock)
|
|
8041
|
-
|
|
7997
|
+
if (isInCodeBlock) return false;
|
|
7998
|
+
let font = null;
|
|
7999
|
+
let color = null;
|
|
8000
|
+
for (let depth = $from.depth; depth >= 1; depth--) {
|
|
8001
|
+
const node = $from.node(depth);
|
|
8002
|
+
if (!font && node.attrs?.fontFamily) font = node.attrs.fontFamily;
|
|
8003
|
+
if (!color && node.attrs?.color) color = node.attrs.color;
|
|
8004
|
+
if (font && color) break;
|
|
8042
8005
|
}
|
|
8043
|
-
const parentNode = $from.parent;
|
|
8044
|
-
let font = parentNode.attrs.fontFamily;
|
|
8045
|
-
let color = parentNode.attrs.color;
|
|
8046
8006
|
const textStyleMark = marks.find((m) => m.type.name === "textStyle");
|
|
8047
|
-
if (!font && textStyleMark?.attrs.fontFamily)
|
|
8048
|
-
|
|
8049
|
-
}
|
|
8050
|
-
if (!color && textStyleMark?.attrs.color) {
|
|
8051
|
-
color = textStyleMark.attrs.color;
|
|
8052
|
-
}
|
|
8007
|
+
if (!font && textStyleMark?.attrs.fontFamily) font = textStyleMark.attrs.fontFamily;
|
|
8008
|
+
if (!color && textStyleMark?.attrs.color) color = textStyleMark.attrs.color;
|
|
8053
8009
|
if (font || color) {
|
|
8054
8010
|
const pluginState = stylePersistenceKey.getState(state);
|
|
8055
8011
|
pluginState.lastFont = font || pluginState.lastFont;
|