@cyberyozh/text-editor 0.5.1 → 0.5.2
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/editor.d.mts +2 -2
- package/dist/editor.d.ts +2 -2
- package/dist/editor.js +115 -207
- package/dist/editor.js.map +1 -1
- package/dist/editor.mjs +108 -200
- package/dist/editor.mjs.map +1 -1
- package/dist/render.js +128 -220
- package/dist/render.js.map +1 -1
- package/dist/render.mjs +108 -200
- package/dist/render.mjs.map +1 -1
- package/package.json +35 -34
- package/src/editor/commands/items.ts +1 -6
- package/src/extensions/base/compatibility.ts +3 -1
- package/src/extensions/base/myth-reality.ts +0 -1
package/dist/render.mjs
CHANGED
|
@@ -2003,40 +2003,25 @@ import Superscript from "@tiptap/extension-superscript";
|
|
|
2003
2003
|
import TextAlign from "@tiptap/extension-text-align";
|
|
2004
2004
|
|
|
2005
2005
|
// node_modules/@tiptap/extension-text-style/dist/index.js
|
|
2006
|
-
import { Mark as Mark2, mergeAttributes as mergeAttributes7 } from "@tiptap/core";
|
|
2007
|
-
import { Extension, getStyleProperty } from "@tiptap/core";
|
|
2008
|
-
import { Extension as Extension2, getStyleProperty as getStyleProperty2 } from "@tiptap/core";
|
|
2009
|
-
import { Extension as Extension3, getStyleProperty as getStyleProperty3 } from "@tiptap/core";
|
|
2010
|
-
import { Extension as Extension4, getStyleProperty as getStyleProperty4 } from "@tiptap/core";
|
|
2011
|
-
import { Extension as Extension5, getStyleProperty as getStyleProperty5 } from "@tiptap/core";
|
|
2012
|
-
import { Extension as Extension6 } from "@tiptap/core";
|
|
2006
|
+
import { Extension, Mark as Mark2, getStyleProperty, mergeAttributes as mergeAttributes7 } from "@tiptap/core";
|
|
2013
2007
|
var MAX_FIND_CHILD_SPAN_DEPTH = 20;
|
|
2014
2008
|
var findChildSpans = (element, depth = 0) => {
|
|
2015
2009
|
const childSpans = [];
|
|
2016
|
-
if (!element.children.length || depth > MAX_FIND_CHILD_SPAN_DEPTH)
|
|
2017
|
-
return childSpans;
|
|
2018
|
-
}
|
|
2010
|
+
if (!element.children.length || depth > MAX_FIND_CHILD_SPAN_DEPTH) return childSpans;
|
|
2019
2011
|
Array.from(element.children).forEach((child) => {
|
|
2020
|
-
if (child.tagName === "SPAN")
|
|
2021
|
-
|
|
2022
|
-
} else if (child.children.length) {
|
|
2023
|
-
childSpans.push(...findChildSpans(child, depth + 1));
|
|
2024
|
-
}
|
|
2012
|
+
if (child.tagName === "SPAN") childSpans.push(child);
|
|
2013
|
+
else if (child.children.length) childSpans.push(...findChildSpans(child, depth + 1));
|
|
2025
2014
|
});
|
|
2026
2015
|
return childSpans;
|
|
2027
2016
|
};
|
|
2028
2017
|
var mergeNestedSpanStyles = (element) => {
|
|
2029
|
-
if (!element.children.length)
|
|
2030
|
-
return;
|
|
2031
|
-
}
|
|
2018
|
+
if (!element.children.length) return;
|
|
2032
2019
|
const childSpans = findChildSpans(element);
|
|
2033
|
-
if (!childSpans)
|
|
2034
|
-
return;
|
|
2035
|
-
}
|
|
2020
|
+
if (!childSpans) return;
|
|
2036
2021
|
childSpans.forEach((childSpan) => {
|
|
2037
|
-
var
|
|
2022
|
+
var _childSpan$parentElem;
|
|
2038
2023
|
const childStyle = childSpan.getAttribute("style");
|
|
2039
|
-
const closestParentSpanStyleOfChild = (
|
|
2024
|
+
const closestParentSpanStyleOfChild = (_childSpan$parentElem = childSpan.parentElement) === null || _childSpan$parentElem === void 0 || (_childSpan$parentElem = _childSpan$parentElem.closest("span")) === null || _childSpan$parentElem === void 0 ? void 0 : _childSpan$parentElem.getAttribute("style");
|
|
2040
2025
|
childSpan.setAttribute("style", `${closestParentSpanStyleOfChild};${childStyle}`);
|
|
2041
2026
|
});
|
|
2042
2027
|
};
|
|
@@ -2050,25 +2035,22 @@ var TextStyle = Mark2.create({
|
|
|
2050
2035
|
};
|
|
2051
2036
|
},
|
|
2052
2037
|
parseHTML() {
|
|
2053
|
-
return [
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
return false;
|
|
2061
|
-
}
|
|
2062
|
-
if (this.options.mergeNestedSpanStyles) {
|
|
2063
|
-
mergeNestedSpanStyles(element);
|
|
2064
|
-
}
|
|
2065
|
-
return {};
|
|
2066
|
-
}
|
|
2038
|
+
return [{
|
|
2039
|
+
tag: "span",
|
|
2040
|
+
consuming: false,
|
|
2041
|
+
getAttrs: (element) => {
|
|
2042
|
+
if (!element.hasAttribute("style")) return false;
|
|
2043
|
+
if (this.options.mergeNestedSpanStyles) mergeNestedSpanStyles(element);
|
|
2044
|
+
return {};
|
|
2067
2045
|
}
|
|
2068
|
-
];
|
|
2046
|
+
}];
|
|
2069
2047
|
},
|
|
2070
2048
|
renderHTML({ HTMLAttributes }) {
|
|
2071
|
-
return [
|
|
2049
|
+
return [
|
|
2050
|
+
"span",
|
|
2051
|
+
mergeAttributes7(this.options.HTMLAttributes, HTMLAttributes),
|
|
2052
|
+
0
|
|
2053
|
+
];
|
|
2072
2054
|
},
|
|
2073
2055
|
addCommands() {
|
|
2074
2056
|
return {
|
|
@@ -2078,12 +2060,8 @@ var TextStyle = Mark2.create({
|
|
|
2078
2060
|
removeEmptyTextStyle: () => ({ tr: tr2 }) => {
|
|
2079
2061
|
const { selection } = tr2;
|
|
2080
2062
|
tr2.doc.nodesBetween(selection.from, selection.to, (node, pos) => {
|
|
2081
|
-
if (node.
|
|
2082
|
-
|
|
2083
|
-
}
|
|
2084
|
-
if (!node.marks.filter((mark) => mark.type === this.type).some((mark) => Object.values(mark.attrs).some((value) => !!value))) {
|
|
2085
|
-
tr2.removeMark(pos, pos + node.nodeSize, this.type);
|
|
2086
|
-
}
|
|
2063
|
+
if (!node.isInline) return true;
|
|
2064
|
+
if (!node.marks.filter((mark) => mark.type === this.type).some((mark) => Object.values(mark.attrs).some((value) => !!value))) tr2.removeMark(pos, pos + node.nodeSize, this.type);
|
|
2087
2065
|
});
|
|
2088
2066
|
return true;
|
|
2089
2067
|
}
|
|
@@ -2093,34 +2071,24 @@ var TextStyle = Mark2.create({
|
|
|
2093
2071
|
var BackgroundColor = Extension.create({
|
|
2094
2072
|
name: "backgroundColor",
|
|
2095
2073
|
addOptions() {
|
|
2096
|
-
return {
|
|
2097
|
-
types: ["textStyle"]
|
|
2098
|
-
};
|
|
2074
|
+
return { types: ["textStyle"] };
|
|
2099
2075
|
},
|
|
2100
2076
|
addGlobalAttributes() {
|
|
2101
|
-
return [
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
if (!attributes.backgroundColor) {
|
|
2114
|
-
return {};
|
|
2115
|
-
}
|
|
2116
|
-
return {
|
|
2117
|
-
style: `background-color: ${attributes.backgroundColor}`
|
|
2118
|
-
};
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2077
|
+
return [{
|
|
2078
|
+
types: this.options.types,
|
|
2079
|
+
attributes: { backgroundColor: {
|
|
2080
|
+
default: null,
|
|
2081
|
+
parseHTML: (element) => {
|
|
2082
|
+
var _getStyleProperty;
|
|
2083
|
+
const value = (_getStyleProperty = getStyleProperty(element, "background-color")) !== null && _getStyleProperty !== void 0 ? _getStyleProperty : element.style.backgroundColor;
|
|
2084
|
+
return value === null || value === void 0 ? void 0 : value.replace(/['"]+/g, "");
|
|
2085
|
+
},
|
|
2086
|
+
renderHTML: (attributes) => {
|
|
2087
|
+
if (!attributes.backgroundColor) return {};
|
|
2088
|
+
return { style: `background-color: ${attributes.backgroundColor}` };
|
|
2121
2089
|
}
|
|
2122
|
-
}
|
|
2123
|
-
];
|
|
2090
|
+
} }
|
|
2091
|
+
}];
|
|
2124
2092
|
},
|
|
2125
2093
|
addCommands() {
|
|
2126
2094
|
return {
|
|
@@ -2133,37 +2101,27 @@ var BackgroundColor = Extension.create({
|
|
|
2133
2101
|
};
|
|
2134
2102
|
}
|
|
2135
2103
|
});
|
|
2136
|
-
var Color =
|
|
2104
|
+
var Color = Extension.create({
|
|
2137
2105
|
name: "color",
|
|
2138
2106
|
addOptions() {
|
|
2139
|
-
return {
|
|
2140
|
-
types: ["textStyle"]
|
|
2141
|
-
};
|
|
2107
|
+
return { types: ["textStyle"] };
|
|
2142
2108
|
},
|
|
2143
2109
|
addGlobalAttributes() {
|
|
2144
|
-
return [
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
if (!attributes.color) {
|
|
2157
|
-
return {};
|
|
2158
|
-
}
|
|
2159
|
-
return {
|
|
2160
|
-
style: `color: ${attributes.color}`
|
|
2161
|
-
};
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2110
|
+
return [{
|
|
2111
|
+
types: this.options.types,
|
|
2112
|
+
attributes: { color: {
|
|
2113
|
+
default: null,
|
|
2114
|
+
parseHTML: (element) => {
|
|
2115
|
+
var _getStyleProperty;
|
|
2116
|
+
const value = (_getStyleProperty = getStyleProperty(element, "color")) !== null && _getStyleProperty !== void 0 ? _getStyleProperty : element.style.color;
|
|
2117
|
+
return value === null || value === void 0 ? void 0 : value.replace(/['"]+/g, "");
|
|
2118
|
+
},
|
|
2119
|
+
renderHTML: (attributes) => {
|
|
2120
|
+
if (!attributes.color) return {};
|
|
2121
|
+
return { style: `color: ${attributes.color}` };
|
|
2164
2122
|
}
|
|
2165
|
-
}
|
|
2166
|
-
];
|
|
2123
|
+
} }
|
|
2124
|
+
}];
|
|
2167
2125
|
},
|
|
2168
2126
|
addCommands() {
|
|
2169
2127
|
return {
|
|
@@ -2176,40 +2134,26 @@ var Color = Extension2.create({
|
|
|
2176
2134
|
};
|
|
2177
2135
|
}
|
|
2178
2136
|
});
|
|
2179
|
-
var FontFamily =
|
|
2137
|
+
var FontFamily = Extension.create({
|
|
2180
2138
|
name: "fontFamily",
|
|
2181
2139
|
addOptions() {
|
|
2182
|
-
return {
|
|
2183
|
-
types: ["textStyle"]
|
|
2184
|
-
};
|
|
2140
|
+
return { types: ["textStyle"] };
|
|
2185
2141
|
},
|
|
2186
2142
|
addGlobalAttributes() {
|
|
2187
|
-
return [
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
var _a;
|
|
2199
|
-
return (_a = getStyleProperty3(element, "font-family")) != null ? _a : element.style.fontFamily;
|
|
2200
|
-
},
|
|
2201
|
-
renderHTML: (attributes) => {
|
|
2202
|
-
if (!attributes.fontFamily) {
|
|
2203
|
-
return {};
|
|
2204
|
-
}
|
|
2205
|
-
return {
|
|
2206
|
-
style: `font-family: ${attributes.fontFamily}`
|
|
2207
|
-
};
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2143
|
+
return [{
|
|
2144
|
+
types: this.options.types,
|
|
2145
|
+
attributes: { fontFamily: {
|
|
2146
|
+
default: null,
|
|
2147
|
+
parseHTML: (element) => {
|
|
2148
|
+
var _getStyleProperty;
|
|
2149
|
+
return (_getStyleProperty = getStyleProperty(element, "font-family")) !== null && _getStyleProperty !== void 0 ? _getStyleProperty : element.style.fontFamily;
|
|
2150
|
+
},
|
|
2151
|
+
renderHTML: (attributes) => {
|
|
2152
|
+
if (!attributes.fontFamily) return {};
|
|
2153
|
+
return { style: `font-family: ${attributes.fontFamily}` };
|
|
2210
2154
|
}
|
|
2211
|
-
}
|
|
2212
|
-
];
|
|
2155
|
+
} }
|
|
2156
|
+
}];
|
|
2213
2157
|
},
|
|
2214
2158
|
addCommands() {
|
|
2215
2159
|
return {
|
|
@@ -2222,39 +2166,26 @@ var FontFamily = Extension3.create({
|
|
|
2222
2166
|
};
|
|
2223
2167
|
}
|
|
2224
2168
|
});
|
|
2225
|
-
var FontSize =
|
|
2169
|
+
var FontSize = Extension.create({
|
|
2226
2170
|
name: "fontSize",
|
|
2227
2171
|
addOptions() {
|
|
2228
|
-
return {
|
|
2229
|
-
types: ["textStyle"]
|
|
2230
|
-
};
|
|
2172
|
+
return { types: ["textStyle"] };
|
|
2231
2173
|
},
|
|
2232
2174
|
addGlobalAttributes() {
|
|
2233
|
-
return [
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
return (_a = getStyleProperty4(element, "font-size")) != null ? _a : element.style.fontSize;
|
|
2245
|
-
},
|
|
2246
|
-
renderHTML: (attributes) => {
|
|
2247
|
-
if (!attributes.fontSize) {
|
|
2248
|
-
return {};
|
|
2249
|
-
}
|
|
2250
|
-
return {
|
|
2251
|
-
style: `font-size: ${attributes.fontSize}`
|
|
2252
|
-
};
|
|
2253
|
-
}
|
|
2254
|
-
}
|
|
2175
|
+
return [{
|
|
2176
|
+
types: this.options.types,
|
|
2177
|
+
attributes: { fontSize: {
|
|
2178
|
+
default: null,
|
|
2179
|
+
parseHTML: (element) => {
|
|
2180
|
+
var _getStyleProperty;
|
|
2181
|
+
return (_getStyleProperty = getStyleProperty(element, "font-size")) !== null && _getStyleProperty !== void 0 ? _getStyleProperty : element.style.fontSize;
|
|
2182
|
+
},
|
|
2183
|
+
renderHTML: (attributes) => {
|
|
2184
|
+
if (!attributes.fontSize) return {};
|
|
2185
|
+
return { style: `font-size: ${attributes.fontSize}` };
|
|
2255
2186
|
}
|
|
2256
|
-
}
|
|
2257
|
-
];
|
|
2187
|
+
} }
|
|
2188
|
+
}];
|
|
2258
2189
|
},
|
|
2259
2190
|
addCommands() {
|
|
2260
2191
|
return {
|
|
@@ -2267,39 +2198,26 @@ var FontSize = Extension4.create({
|
|
|
2267
2198
|
};
|
|
2268
2199
|
}
|
|
2269
2200
|
});
|
|
2270
|
-
var LineHeight =
|
|
2201
|
+
var LineHeight = Extension.create({
|
|
2271
2202
|
name: "lineHeight",
|
|
2272
2203
|
addOptions() {
|
|
2273
|
-
return {
|
|
2274
|
-
types: ["textStyle"]
|
|
2275
|
-
};
|
|
2204
|
+
return { types: ["textStyle"] };
|
|
2276
2205
|
},
|
|
2277
2206
|
addGlobalAttributes() {
|
|
2278
|
-
return [
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
return (_a = getStyleProperty5(element, "line-height")) != null ? _a : element.style.lineHeight;
|
|
2290
|
-
},
|
|
2291
|
-
renderHTML: (attributes) => {
|
|
2292
|
-
if (!attributes.lineHeight) {
|
|
2293
|
-
return {};
|
|
2294
|
-
}
|
|
2295
|
-
return {
|
|
2296
|
-
style: `line-height: ${attributes.lineHeight}`
|
|
2297
|
-
};
|
|
2298
|
-
}
|
|
2299
|
-
}
|
|
2207
|
+
return [{
|
|
2208
|
+
types: this.options.types,
|
|
2209
|
+
attributes: { lineHeight: {
|
|
2210
|
+
default: null,
|
|
2211
|
+
parseHTML: (element) => {
|
|
2212
|
+
var _getStyleProperty;
|
|
2213
|
+
return (_getStyleProperty = getStyleProperty(element, "line-height")) !== null && _getStyleProperty !== void 0 ? _getStyleProperty : element.style.lineHeight;
|
|
2214
|
+
},
|
|
2215
|
+
renderHTML: (attributes) => {
|
|
2216
|
+
if (!attributes.lineHeight) return {};
|
|
2217
|
+
return { style: `line-height: ${attributes.lineHeight}` };
|
|
2300
2218
|
}
|
|
2301
|
-
}
|
|
2302
|
-
];
|
|
2219
|
+
} }
|
|
2220
|
+
}];
|
|
2303
2221
|
},
|
|
2304
2222
|
addCommands() {
|
|
2305
2223
|
return {
|
|
@@ -2312,28 +2230,16 @@ var LineHeight = Extension5.create({
|
|
|
2312
2230
|
};
|
|
2313
2231
|
}
|
|
2314
2232
|
});
|
|
2315
|
-
var TextStyleKit =
|
|
2233
|
+
var TextStyleKit = Extension.create({
|
|
2316
2234
|
name: "textStyleKit",
|
|
2317
2235
|
addExtensions() {
|
|
2318
2236
|
const extensions = [];
|
|
2319
|
-
if (this.options.backgroundColor !== false)
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
if (this.options.
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
if (this.options.fontFamily !== false) {
|
|
2326
|
-
extensions.push(FontFamily.configure(this.options.fontFamily));
|
|
2327
|
-
}
|
|
2328
|
-
if (this.options.fontSize !== false) {
|
|
2329
|
-
extensions.push(FontSize.configure(this.options.fontSize));
|
|
2330
|
-
}
|
|
2331
|
-
if (this.options.lineHeight !== false) {
|
|
2332
|
-
extensions.push(LineHeight.configure(this.options.lineHeight));
|
|
2333
|
-
}
|
|
2334
|
-
if (this.options.textStyle !== false) {
|
|
2335
|
-
extensions.push(TextStyle.configure(this.options.textStyle));
|
|
2336
|
-
}
|
|
2237
|
+
if (this.options.backgroundColor !== false) extensions.push(BackgroundColor.configure(this.options.backgroundColor));
|
|
2238
|
+
if (this.options.color !== false) extensions.push(Color.configure(this.options.color));
|
|
2239
|
+
if (this.options.fontFamily !== false) extensions.push(FontFamily.configure(this.options.fontFamily));
|
|
2240
|
+
if (this.options.fontSize !== false) extensions.push(FontSize.configure(this.options.fontSize));
|
|
2241
|
+
if (this.options.lineHeight !== false) extensions.push(LineHeight.configure(this.options.lineHeight));
|
|
2242
|
+
if (this.options.textStyle !== false) extensions.push(TextStyle.configure(this.options.textStyle));
|
|
2337
2243
|
return extensions;
|
|
2338
2244
|
}
|
|
2339
2245
|
});
|
|
@@ -2671,7 +2577,9 @@ var BaseLegacyFigure = Image2.extend({
|
|
|
2671
2577
|
isolating: true,
|
|
2672
2578
|
selectable: false,
|
|
2673
2579
|
addOptions() {
|
|
2580
|
+
const parentOptions = this.parent?.() || {};
|
|
2674
2581
|
return {
|
|
2582
|
+
...parentOptions,
|
|
2675
2583
|
HTMLAttributes: {},
|
|
2676
2584
|
getImageById: void 0
|
|
2677
2585
|
};
|