@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.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
5
5
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
6
6
|
import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
|
|
7
7
|
import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
|
|
8
|
-
import { createCommand, DecoratorNode, COMMAND_PRIORITY_HIGH, TextNode, ElementNode, SELECTION_CHANGE_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, $getSelection, $isRangeSelection, $findMatchingParent, COMMAND_PRIORITY_LOW, KEY_DOWN_COMMAND, $getNodeByKey, $createRangeSelection, $setSelection, $createParagraphNode, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_EDITOR, PASTE_COMMAND, DRAGSTART_COMMAND, DRAGOVER_COMMAND, DROP_COMMAND, $getRoot, $createTextNode, $
|
|
8
|
+
import { createCommand, $isTextNode, DecoratorNode, COMMAND_PRIORITY_HIGH, TextNode, ElementNode, SELECTION_CHANGE_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, $getSelection, $isRangeSelection, $findMatchingParent, COMMAND_PRIORITY_LOW, KEY_DOWN_COMMAND, $getNodeByKey, $createRangeSelection, $setSelection, $createParagraphNode, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_EDITOR, PASTE_COMMAND, DRAGSTART_COMMAND, DRAGOVER_COMMAND, DROP_COMMAND, $getRoot, $createTextNode, $isElementNode, FORMAT_ELEMENT_COMMAND, CLICK_COMMAND, $isNodeSelection, $applyNodeReplacement, FORMAT_TEXT_COMMAND, $isDecoratorNode, $getNearestNodeFromDOMNode, COMMAND_PRIORITY_CRITICAL, REDO_COMMAND, UNDO_COMMAND, getDOMSelection, KEY_ESCAPE_COMMAND, isHTMLElement, getDOMSelectionFromTarget, $isLineBreakNode, SKIP_SELECTION_FOCUS_TAG, createEditor, KEY_ENTER_COMMAND } from 'lexical';
|
|
9
9
|
import { mergeStyleSets, Stack, css, useTheme, Callout, TextField } from '@fluentui/react';
|
|
10
10
|
import { makeStyles, FluentProvider, webLightTheme, Menu, MenuTrigger, MenuPopover, MenuList, MenuGroup, MenuGroupHeader, MenuItem, MenuDivider, Dropdown, Option, Button, ToolbarDivider, MenuItemRadio, Field, Input, MessageBar, MessageBarBody, Popover, PopoverSurface, PopoverTrigger } from '@fluentui/react-components';
|
|
11
11
|
import { CodeHighlightNode, CodeNode, $isCodeHighlightNode } from '@lexical/code';
|
|
@@ -2209,6 +2209,48 @@ function $createYouTubeNode(videoID, width = DEFAULT_WIDTH, height = DEFAULT_HEI
|
|
|
2209
2209
|
function $isYouTubeNode(node) {
|
|
2210
2210
|
return node instanceof YouTubeNode;
|
|
2211
2211
|
}
|
|
2212
|
+
var PRESERVED_STYLE_PROPS = [
|
|
2213
|
+
["fontFamily", "font-family"],
|
|
2214
|
+
["fontSize", "font-size"],
|
|
2215
|
+
["color", "color"],
|
|
2216
|
+
["backgroundColor", "background-color"]
|
|
2217
|
+
];
|
|
2218
|
+
var $convertSpanElementWithStyle = (domNode) => {
|
|
2219
|
+
const style = domNode.style;
|
|
2220
|
+
const cssParts = [];
|
|
2221
|
+
for (const [domProp, cssProp] of PRESERVED_STYLE_PROPS) {
|
|
2222
|
+
const value = style[domProp];
|
|
2223
|
+
if (value) cssParts.push(`${cssProp}: ${value}`);
|
|
2224
|
+
}
|
|
2225
|
+
const cssText = cssParts.length > 0 ? `${cssParts.join("; ")};` : "";
|
|
2226
|
+
const fontWeight = style.fontWeight;
|
|
2227
|
+
const textDecoration = style.textDecoration.split(" ");
|
|
2228
|
+
const hasBoldFontWeight = fontWeight === "700" || fontWeight === "bold";
|
|
2229
|
+
const hasLinethroughTextDecoration = textDecoration.includes("line-through");
|
|
2230
|
+
const hasItalicFontStyle = style.fontStyle === "italic";
|
|
2231
|
+
const hasUnderlineTextDecoration = textDecoration.includes("underline");
|
|
2232
|
+
const verticalAlign = style.verticalAlign;
|
|
2233
|
+
return {
|
|
2234
|
+
node: null,
|
|
2235
|
+
forChild: (lexicalNode) => {
|
|
2236
|
+
if (!$isTextNode(lexicalNode)) return lexicalNode;
|
|
2237
|
+
if (cssText) lexicalNode.setStyle(cssText);
|
|
2238
|
+
if (hasBoldFontWeight && !lexicalNode.hasFormat("bold")) lexicalNode.toggleFormat("bold");
|
|
2239
|
+
if (hasLinethroughTextDecoration && !lexicalNode.hasFormat("strikethrough")) lexicalNode.toggleFormat("strikethrough");
|
|
2240
|
+
if (hasItalicFontStyle && !lexicalNode.hasFormat("italic")) lexicalNode.toggleFormat("italic");
|
|
2241
|
+
if (hasUnderlineTextDecoration && !lexicalNode.hasFormat("underline")) lexicalNode.toggleFormat("underline");
|
|
2242
|
+
if (verticalAlign === "sub" && !lexicalNode.hasFormat("subscript")) lexicalNode.toggleFormat("subscript");
|
|
2243
|
+
if (verticalAlign === "super" && !lexicalNode.hasFormat("superscript")) lexicalNode.toggleFormat("superscript");
|
|
2244
|
+
return lexicalNode;
|
|
2245
|
+
}
|
|
2246
|
+
};
|
|
2247
|
+
};
|
|
2248
|
+
var preserveTextStyleImportMap = {
|
|
2249
|
+
span: () => ({
|
|
2250
|
+
conversion: $convertSpanElementWithStyle,
|
|
2251
|
+
priority: 0
|
|
2252
|
+
})
|
|
2253
|
+
};
|
|
2212
2254
|
var normalize = (s) => (s ?? "").replace(/\s+/g, " ").trim();
|
|
2213
2255
|
function readContextWindow(maxChars = 300, cursorIndex) {
|
|
2214
2256
|
const full = normalize($getRoot().getTextContent());
|
|
@@ -5149,16 +5191,18 @@ function getScrollClipAncestor(el) {
|
|
|
5149
5191
|
}
|
|
5150
5192
|
return null;
|
|
5151
5193
|
}
|
|
5194
|
+
var BUTTON_VERTICAL_FOOTPRINT = 34;
|
|
5152
5195
|
function isRectVisible(rect, cellDom) {
|
|
5153
5196
|
if (rect.width === 0 && rect.height === 0) return false;
|
|
5154
|
-
if (rect.bottom <= 0 || rect.top >= window.innerHeight) return false;
|
|
5155
|
-
if (rect.right <= 0 || rect.left >= window.innerWidth) return false;
|
|
5156
5197
|
const clipAncestor = getScrollClipAncestor(cellDom);
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5198
|
+
const containerRect = clipAncestor?.getBoundingClientRect();
|
|
5199
|
+
const visibleTop = containerRect ? Math.max(0, containerRect.top) : 0;
|
|
5200
|
+
const visibleBottom = containerRect ? Math.min(window.innerHeight, containerRect.bottom) : window.innerHeight;
|
|
5201
|
+
const visibleLeft = containerRect ? Math.max(0, containerRect.left) : 0;
|
|
5202
|
+
const visibleRight = containerRect ? Math.min(window.innerWidth, containerRect.right) : window.innerWidth;
|
|
5203
|
+
if (rect.top < visibleTop) return false;
|
|
5204
|
+
if (rect.top + BUTTON_VERTICAL_FOOTPRINT > visibleBottom) return false;
|
|
5205
|
+
if (rect.left >= visibleRight || rect.right <= visibleLeft) return false;
|
|
5162
5206
|
return true;
|
|
5163
5207
|
}
|
|
5164
5208
|
function TableActionMenuPlugin({ disabled = false }) {
|
|
@@ -8266,7 +8310,10 @@ var ContentEditorComponent = forwardRef(
|
|
|
8266
8310
|
AutocompleteNode,
|
|
8267
8311
|
SpellErrorNode,
|
|
8268
8312
|
HtmlBlockNode
|
|
8269
|
-
]
|
|
8313
|
+
],
|
|
8314
|
+
html: {
|
|
8315
|
+
import: preserveTextStyleImportMap
|
|
8316
|
+
}
|
|
8270
8317
|
};
|
|
8271
8318
|
props.onBeforeInitialize?.(config);
|
|
8272
8319
|
return config;
|