@tarviks/lexical-rich-editor 1.3.8 → 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.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("span", { draggable, style: { position: "relative", display: "inline-block" }, children: [
1030
- /* @__PURE__ */ jsx(
1031
- LazyImage2,
1032
- {
1033
- className: isFocused ? `focused ${$isNodeSelection(selection) ? "draggable" : ""}` : null,
1034
- src,
1035
- altText,
1036
- imageRef,
1037
- width,
1038
- height,
1039
- position
1040
- }
1041
- ),
1042
- $isNodeSelection(selection) && isFocused && /* @__PURE__ */ jsx(
1043
- ImageResizer_default,
1044
- {
1045
- showCaption: false,
1046
- setShowCaption: () => {
1047
- },
1048
- captionsEnabled: false,
1049
- editor,
1050
- buttonRef,
1051
- imageRef,
1052
- onResizeStart,
1053
- onResizeEnd
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
- if (DANGEROUS_URL.test(value)) {
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
  }
@@ -4131,11 +4149,6 @@ var InlineImagePlugin = () => {
4131
4149
  if ($isRootOrShadowRoot(imageNode.getParentOrThrow())) {
4132
4150
  $wrapNodeInElement(imageNode, $createParagraphNode).selectEnd();
4133
4151
  }
4134
- const parent = imageNode.getParent();
4135
- if (parent && typeof parent.setFormat === "function") {
4136
- const fmt = payload.position === "right" ? "right" : payload.position === "full" ? "center" : "left";
4137
- parent.setFormat(fmt);
4138
- }
4139
4152
  return true;
4140
4153
  },
4141
4154
  COMMAND_PRIORITY_EDITOR
@@ -5088,6 +5101,7 @@ function SpellCheckPlugin({
5088
5101
  }
5089
5102
  function TableActionMenuPlugin({ disabled = false }) {
5090
5103
  const [editor] = useLexicalComposerContext();
5104
+ const portalContainer = useFloatingPortalContainer(editor);
5091
5105
  const [isInTable, setIsInTable] = React9.useState(false);
5092
5106
  const [anchorRect, setAnchorRect] = React9.useState(null);
5093
5107
  const [contentRight, setContentRight] = React9.useState(null);
@@ -5221,7 +5235,10 @@ function TableActionMenuPlugin({ disabled = false }) {
5221
5235
  position: "fixed",
5222
5236
  top,
5223
5237
  left,
5224
- zIndex: 9999
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
5225
5242
  };
5226
5243
  }, [anchorRect, contentRight]);
5227
5244
  const dangerStyle = {
@@ -5264,7 +5281,7 @@ function TableActionMenuPlugin({ disabled = false }) {
5264
5281
  if (tableNode) tableNode.remove();
5265
5282
  });
5266
5283
  };
5267
- if (!canShow || !handleStyle) return null;
5284
+ if (!canShow || !handleStyle || !portalContainer) return null;
5268
5285
  return createPortal(
5269
5286
  /* @__PURE__ */ jsx("div", { style: handleStyle, className: "aoTableActionHandleRoot", "data-lexical-editor-portal": "true", children: /* @__PURE__ */ jsxs(Menu, { open, onOpenChange: (_, data) => {
5270
5287
  openRef.current = data.open;
@@ -5321,7 +5338,7 @@ function TableActionMenuPlugin({ disabled = false }) {
5321
5338
  ] })
5322
5339
  ] }) })
5323
5340
  ] }) }),
5324
- document.body
5341
+ portalContainer
5325
5342
  );
5326
5343
  }
5327
5344
  var MIN_ROW_HEIGHT = 33;
@@ -6020,6 +6037,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
6020
6037
  "div",
6021
6038
  {
6022
6039
  ref: svRef,
6040
+ "data-testid": "color-sv-box",
6023
6041
  onPointerDown: handleSVPointerDown,
6024
6042
  onPointerMove: handleSVPointerMove,
6025
6043
  style: {
@@ -6077,6 +6095,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
6077
6095
  "div",
6078
6096
  {
6079
6097
  ref: hueRef,
6098
+ "data-testid": "color-hue-bar",
6080
6099
  onPointerDown: handleHuePointerDown,
6081
6100
  onPointerMove: handleHuePointerMove,
6082
6101
  style: {
@@ -6126,6 +6145,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
6126
6145
  /* @__PURE__ */ jsx(
6127
6146
  TextField,
6128
6147
  {
6148
+ "data-testid": "color-hex-input",
6129
6149
  value: hexText,
6130
6150
  onChange: handleHexChange,
6131
6151
  onBlur: handleHexBlur,
@@ -6609,7 +6629,7 @@ var TableItemPlugin = ({ disabled }) => {
6609
6629
  const col = Number(columns);
6610
6630
  if (!row || !col) return;
6611
6631
  editor.update(() => {
6612
- const tableNode = $createTableNodeWithDimensions(row, col, true);
6632
+ const tableNode = $createTableNodeWithDimensions(row, col, { columns: false, rows: true });
6613
6633
  $insertNodeToNearestRoot(tableNode);
6614
6634
  });
6615
6635
  setRows("");