@tarviks/lexical-rich-editor 1.3.7 → 1.3.9
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 +3 -116
- package/dist/index.css.map +1 -1
- package/dist/index.js +59 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -358,6 +358,7 @@ var init_ImageComponent = __esm({
|
|
|
358
358
|
};
|
|
359
359
|
img3.onerror = () => {
|
|
360
360
|
imageCache.add(src);
|
|
361
|
+
resolve(null);
|
|
361
362
|
};
|
|
362
363
|
});
|
|
363
364
|
}
|
|
@@ -417,6 +418,7 @@ var init_ImageComponent = __esm({
|
|
|
417
418
|
node.remove();
|
|
418
419
|
}
|
|
419
420
|
});
|
|
421
|
+
return true;
|
|
420
422
|
}
|
|
421
423
|
return false;
|
|
422
424
|
},
|
|
@@ -586,6 +588,7 @@ var init_ImageComponent = __esm({
|
|
|
586
588
|
{
|
|
587
589
|
draggable,
|
|
588
590
|
style: { position: "relative", display: "inline-block" },
|
|
591
|
+
onClick: (e) => onClick(e.nativeEvent),
|
|
589
592
|
children: [
|
|
590
593
|
isLoadError ? /* @__PURE__ */ jsx(BrokenImage, {}) : /* @__PURE__ */ jsx(
|
|
591
594
|
LazyImage,
|
|
@@ -863,6 +866,10 @@ var init_InlineImageComponent = __esm({
|
|
|
863
866
|
imageCache2.add(src);
|
|
864
867
|
resolve(null);
|
|
865
868
|
};
|
|
869
|
+
img3.onerror = () => {
|
|
870
|
+
imageCache2.add(src);
|
|
871
|
+
resolve(null);
|
|
872
|
+
};
|
|
866
873
|
});
|
|
867
874
|
}
|
|
868
875
|
};
|
|
@@ -907,6 +914,7 @@ var init_InlineImageComponent = __esm({
|
|
|
907
914
|
}
|
|
908
915
|
});
|
|
909
916
|
}
|
|
917
|
+
return true;
|
|
910
918
|
}
|
|
911
919
|
return false;
|
|
912
920
|
},
|
|
@@ -1026,34 +1034,42 @@ var init_InlineImageComponent = __esm({
|
|
|
1026
1034
|
};
|
|
1027
1035
|
const draggable = !isResizing;
|
|
1028
1036
|
const isFocused = (isSelected || isResizing) && isEditable;
|
|
1029
|
-
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsxs(
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1037
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsxs(
|
|
1038
|
+
"span",
|
|
1039
|
+
{
|
|
1040
|
+
draggable,
|
|
1041
|
+
style: { position: "relative", display: "inline-block" },
|
|
1042
|
+
onClick: (e) => onClick(e.nativeEvent),
|
|
1043
|
+
children: [
|
|
1044
|
+
/* @__PURE__ */ jsx(
|
|
1045
|
+
LazyImage2,
|
|
1046
|
+
{
|
|
1047
|
+
className: isFocused ? `focused ${$isNodeSelection(selection) ? "draggable" : ""}` : null,
|
|
1048
|
+
src,
|
|
1049
|
+
altText,
|
|
1050
|
+
imageRef,
|
|
1051
|
+
width,
|
|
1052
|
+
height,
|
|
1053
|
+
position
|
|
1054
|
+
}
|
|
1055
|
+
),
|
|
1056
|
+
$isNodeSelection(selection) && isFocused && /* @__PURE__ */ jsx(
|
|
1057
|
+
ImageResizer_default,
|
|
1058
|
+
{
|
|
1059
|
+
showCaption: false,
|
|
1060
|
+
setShowCaption: () => {
|
|
1061
|
+
},
|
|
1062
|
+
captionsEnabled: false,
|
|
1063
|
+
editor,
|
|
1064
|
+
buttonRef,
|
|
1065
|
+
imageRef,
|
|
1066
|
+
onResizeStart,
|
|
1067
|
+
onResizeEnd
|
|
1068
|
+
}
|
|
1069
|
+
)
|
|
1070
|
+
]
|
|
1071
|
+
}
|
|
1072
|
+
) });
|
|
1057
1073
|
};
|
|
1058
1074
|
InlineImageComponent_default = InlineImageComponent;
|
|
1059
1075
|
}
|
|
@@ -2934,6 +2950,7 @@ var ALLOWED_ATTRS = /* @__PURE__ */ new Set([
|
|
|
2934
2950
|
"allowfullscreen"
|
|
2935
2951
|
]);
|
|
2936
2952
|
var DANGEROUS_URL = /^\s*(javascript|data\s*:|vbscript)/i;
|
|
2953
|
+
var SAFE_IMAGE_DATA_URL = /^\s*data:image\/[a-z0-9.+-]+;base64,/i;
|
|
2937
2954
|
function sanitizeElement(el) {
|
|
2938
2955
|
for (const child of Array.from(el.children)) {
|
|
2939
2956
|
sanitizeElement(child);
|
|
@@ -2965,7 +2982,8 @@ function sanitizeElement(el) {
|
|
|
2965
2982
|
continue;
|
|
2966
2983
|
}
|
|
2967
2984
|
if (lname === "href" || lname === "src") {
|
|
2968
|
-
|
|
2985
|
+
const isSafeImageDataUrl = tag === "img" && lname === "src" && SAFE_IMAGE_DATA_URL.test(value);
|
|
2986
|
+
if (DANGEROUS_URL.test(value) && !isSafeImageDataUrl) {
|
|
2969
2987
|
el.removeAttribute(name);
|
|
2970
2988
|
}
|
|
2971
2989
|
}
|
|
@@ -3356,6 +3374,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLink
|
|
|
3356
3374
|
href: sanitizeUrl(linkUrl),
|
|
3357
3375
|
target: "_blank",
|
|
3358
3376
|
rel: "noopener noreferrer",
|
|
3377
|
+
onMouseDown: preventDefault,
|
|
3359
3378
|
style: {
|
|
3360
3379
|
padding: "0 8px",
|
|
3361
3380
|
overflow: "hidden",
|
|
@@ -4130,11 +4149,6 @@ var InlineImagePlugin = () => {
|
|
|
4130
4149
|
if ($isRootOrShadowRoot(imageNode.getParentOrThrow())) {
|
|
4131
4150
|
$wrapNodeInElement(imageNode, $createParagraphNode).selectEnd();
|
|
4132
4151
|
}
|
|
4133
|
-
const parent = imageNode.getParent();
|
|
4134
|
-
if (parent && typeof parent.setFormat === "function") {
|
|
4135
|
-
const fmt = payload.position === "right" ? "right" : payload.position === "full" ? "center" : "left";
|
|
4136
|
-
parent.setFormat(fmt);
|
|
4137
|
-
}
|
|
4138
4152
|
return true;
|
|
4139
4153
|
},
|
|
4140
4154
|
COMMAND_PRIORITY_EDITOR
|
|
@@ -5087,6 +5101,7 @@ function SpellCheckPlugin({
|
|
|
5087
5101
|
}
|
|
5088
5102
|
function TableActionMenuPlugin({ disabled = false }) {
|
|
5089
5103
|
const [editor] = useLexicalComposerContext();
|
|
5104
|
+
const portalContainer = useFloatingPortalContainer(editor);
|
|
5090
5105
|
const [isInTable, setIsInTable] = React9.useState(false);
|
|
5091
5106
|
const [anchorRect, setAnchorRect] = React9.useState(null);
|
|
5092
5107
|
const [contentRight, setContentRight] = React9.useState(null);
|
|
@@ -5220,7 +5235,10 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5220
5235
|
position: "fixed",
|
|
5221
5236
|
top,
|
|
5222
5237
|
left,
|
|
5223
|
-
|
|
5238
|
+
// Matches the other floating surfaces (see FloatingPortal.ts): must clear
|
|
5239
|
+
// Fluent's Panel/Modal Layer host (z-index 1000000), otherwise this
|
|
5240
|
+
// button renders behind the modal chrome in a full-page/Panel view.
|
|
5241
|
+
zIndex: 10000010
|
|
5224
5242
|
};
|
|
5225
5243
|
}, [anchorRect, contentRight]);
|
|
5226
5244
|
const dangerStyle = {
|
|
@@ -5263,7 +5281,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5263
5281
|
if (tableNode) tableNode.remove();
|
|
5264
5282
|
});
|
|
5265
5283
|
};
|
|
5266
|
-
if (!canShow || !handleStyle) return null;
|
|
5284
|
+
if (!canShow || !handleStyle || !portalContainer) return null;
|
|
5267
5285
|
return createPortal(
|
|
5268
5286
|
/* @__PURE__ */ jsx("div", { style: handleStyle, className: "aoTableActionHandleRoot", "data-lexical-editor-portal": "true", children: /* @__PURE__ */ jsxs(Menu, { open, onOpenChange: (_, data) => {
|
|
5269
5287
|
openRef.current = data.open;
|
|
@@ -5320,7 +5338,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5320
5338
|
] })
|
|
5321
5339
|
] }) })
|
|
5322
5340
|
] }) }),
|
|
5323
|
-
|
|
5341
|
+
portalContainer
|
|
5324
5342
|
);
|
|
5325
5343
|
}
|
|
5326
5344
|
var MIN_ROW_HEIGHT = 33;
|
|
@@ -6019,6 +6037,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
6019
6037
|
"div",
|
|
6020
6038
|
{
|
|
6021
6039
|
ref: svRef,
|
|
6040
|
+
"data-testid": "color-sv-box",
|
|
6022
6041
|
onPointerDown: handleSVPointerDown,
|
|
6023
6042
|
onPointerMove: handleSVPointerMove,
|
|
6024
6043
|
style: {
|
|
@@ -6076,6 +6095,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
6076
6095
|
"div",
|
|
6077
6096
|
{
|
|
6078
6097
|
ref: hueRef,
|
|
6098
|
+
"data-testid": "color-hue-bar",
|
|
6079
6099
|
onPointerDown: handleHuePointerDown,
|
|
6080
6100
|
onPointerMove: handleHuePointerMove,
|
|
6081
6101
|
style: {
|
|
@@ -6125,6 +6145,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
6125
6145
|
/* @__PURE__ */ jsx(
|
|
6126
6146
|
TextField,
|
|
6127
6147
|
{
|
|
6148
|
+
"data-testid": "color-hex-input",
|
|
6128
6149
|
value: hexText,
|
|
6129
6150
|
onChange: handleHexChange,
|
|
6130
6151
|
onBlur: handleHexBlur,
|
|
@@ -6608,7 +6629,7 @@ var TableItemPlugin = ({ disabled }) => {
|
|
|
6608
6629
|
const col = Number(columns);
|
|
6609
6630
|
if (!row || !col) return;
|
|
6610
6631
|
editor.update(() => {
|
|
6611
|
-
const tableNode = $createTableNodeWithDimensions(row, col, true);
|
|
6632
|
+
const tableNode = $createTableNodeWithDimensions(row, col, { columns: false, rows: true });
|
|
6612
6633
|
$insertNodeToNearestRoot(tableNode);
|
|
6613
6634
|
});
|
|
6614
6635
|
setRows("");
|