@tarviks/lexical-rich-editor 1.3.11 → 1.3.12
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.js +55 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2230,6 +2230,48 @@ function $createYouTubeNode(videoID, width = DEFAULT_WIDTH, height = DEFAULT_HEI
|
|
|
2230
2230
|
function $isYouTubeNode(node) {
|
|
2231
2231
|
return node instanceof YouTubeNode;
|
|
2232
2232
|
}
|
|
2233
|
+
var PRESERVED_STYLE_PROPS = [
|
|
2234
|
+
["fontFamily", "font-family"],
|
|
2235
|
+
["fontSize", "font-size"],
|
|
2236
|
+
["color", "color"],
|
|
2237
|
+
["backgroundColor", "background-color"]
|
|
2238
|
+
];
|
|
2239
|
+
var $convertSpanElementWithStyle = (domNode) => {
|
|
2240
|
+
const style = domNode.style;
|
|
2241
|
+
const cssParts = [];
|
|
2242
|
+
for (const [domProp, cssProp] of PRESERVED_STYLE_PROPS) {
|
|
2243
|
+
const value = style[domProp];
|
|
2244
|
+
if (value) cssParts.push(`${cssProp}: ${value}`);
|
|
2245
|
+
}
|
|
2246
|
+
const cssText = cssParts.length > 0 ? `${cssParts.join("; ")};` : "";
|
|
2247
|
+
const fontWeight = style.fontWeight;
|
|
2248
|
+
const textDecoration = style.textDecoration.split(" ");
|
|
2249
|
+
const hasBoldFontWeight = fontWeight === "700" || fontWeight === "bold";
|
|
2250
|
+
const hasLinethroughTextDecoration = textDecoration.includes("line-through");
|
|
2251
|
+
const hasItalicFontStyle = style.fontStyle === "italic";
|
|
2252
|
+
const hasUnderlineTextDecoration = textDecoration.includes("underline");
|
|
2253
|
+
const verticalAlign = style.verticalAlign;
|
|
2254
|
+
return {
|
|
2255
|
+
node: null,
|
|
2256
|
+
forChild: (lexicalNode) => {
|
|
2257
|
+
if (!lexical.$isTextNode(lexicalNode)) return lexicalNode;
|
|
2258
|
+
if (cssText) lexicalNode.setStyle(cssText);
|
|
2259
|
+
if (hasBoldFontWeight && !lexicalNode.hasFormat("bold")) lexicalNode.toggleFormat("bold");
|
|
2260
|
+
if (hasLinethroughTextDecoration && !lexicalNode.hasFormat("strikethrough")) lexicalNode.toggleFormat("strikethrough");
|
|
2261
|
+
if (hasItalicFontStyle && !lexicalNode.hasFormat("italic")) lexicalNode.toggleFormat("italic");
|
|
2262
|
+
if (hasUnderlineTextDecoration && !lexicalNode.hasFormat("underline")) lexicalNode.toggleFormat("underline");
|
|
2263
|
+
if (verticalAlign === "sub" && !lexicalNode.hasFormat("subscript")) lexicalNode.toggleFormat("subscript");
|
|
2264
|
+
if (verticalAlign === "super" && !lexicalNode.hasFormat("superscript")) lexicalNode.toggleFormat("superscript");
|
|
2265
|
+
return lexicalNode;
|
|
2266
|
+
}
|
|
2267
|
+
};
|
|
2268
|
+
};
|
|
2269
|
+
var preserveTextStyleImportMap = {
|
|
2270
|
+
span: () => ({
|
|
2271
|
+
conversion: $convertSpanElementWithStyle,
|
|
2272
|
+
priority: 0
|
|
2273
|
+
})
|
|
2274
|
+
};
|
|
2233
2275
|
var normalize = (s) => (s ?? "").replace(/\s+/g, " ").trim();
|
|
2234
2276
|
function readContextWindow(maxChars = 300, cursorIndex) {
|
|
2235
2277
|
const full = normalize(lexical.$getRoot().getTextContent());
|
|
@@ -5170,16 +5212,18 @@ function getScrollClipAncestor(el) {
|
|
|
5170
5212
|
}
|
|
5171
5213
|
return null;
|
|
5172
5214
|
}
|
|
5215
|
+
var BUTTON_VERTICAL_FOOTPRINT = 34;
|
|
5173
5216
|
function isRectVisible(rect, cellDom) {
|
|
5174
5217
|
if (rect.width === 0 && rect.height === 0) return false;
|
|
5175
|
-
if (rect.bottom <= 0 || rect.top >= window.innerHeight) return false;
|
|
5176
|
-
if (rect.right <= 0 || rect.left >= window.innerWidth) return false;
|
|
5177
5218
|
const clipAncestor = getScrollClipAncestor(cellDom);
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5219
|
+
const containerRect = clipAncestor?.getBoundingClientRect();
|
|
5220
|
+
const visibleTop = containerRect ? Math.max(0, containerRect.top) : 0;
|
|
5221
|
+
const visibleBottom = containerRect ? Math.min(window.innerHeight, containerRect.bottom) : window.innerHeight;
|
|
5222
|
+
const visibleLeft = containerRect ? Math.max(0, containerRect.left) : 0;
|
|
5223
|
+
const visibleRight = containerRect ? Math.min(window.innerWidth, containerRect.right) : window.innerWidth;
|
|
5224
|
+
if (rect.top < visibleTop) return false;
|
|
5225
|
+
if (rect.top + BUTTON_VERTICAL_FOOTPRINT > visibleBottom) return false;
|
|
5226
|
+
if (rect.left >= visibleRight || rect.right <= visibleLeft) return false;
|
|
5183
5227
|
return true;
|
|
5184
5228
|
}
|
|
5185
5229
|
function TableActionMenuPlugin({ disabled = false }) {
|
|
@@ -8287,7 +8331,10 @@ var ContentEditorComponent = React9.forwardRef(
|
|
|
8287
8331
|
AutocompleteNode,
|
|
8288
8332
|
SpellErrorNode,
|
|
8289
8333
|
HtmlBlockNode
|
|
8290
|
-
]
|
|
8334
|
+
],
|
|
8335
|
+
html: {
|
|
8336
|
+
import: preserveTextStyleImportMap
|
|
8337
|
+
}
|
|
8291
8338
|
};
|
|
8292
8339
|
props.onBeforeInitialize?.(config);
|
|
8293
8340
|
return config;
|