@crystallize/design-system 1.12.0 → 1.13.0
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/CHANGELOG.md +7 -0
- package/dist/draggable-block-menu-KKHDNKJA.svg +1 -0
- package/dist/index.css +565 -1025
- package/dist/index.d.ts +1 -0
- package/dist/index.js +517 -515
- package/dist/index.mjs +398 -396
- package/package.json +6 -7
- package/src/button/Button.stories.tsx +1 -0
- package/src/card/card.stories.tsx +1 -0
- package/src/checkbox/checkbox.stories.tsx +1 -1
- package/src/checkbox/checkbox.tsx +1 -1
- package/src/colors/Colors.stories.tsx +3 -3
- package/src/dialog/config.tsx +1 -1
- package/src/dialog/index.tsx +1 -1
- package/src/dropdown-menu/dropdown-menu-item.tsx +2 -2
- package/src/dropdown-menu/dropdown-menu-label.tsx +1 -1
- package/src/icon-button/IconButton.stories.tsx +1 -0
- package/src/iconography/Icon.stories.tsx +1 -0
- package/src/inline-radio/inline-radio.stories.tsx +3 -3
- package/src/inline-radio/inline-radio.tsx +2 -2
- package/src/input/input.tsx +1 -1
- package/src/input-with-label/input-with-label.tsx +1 -1
- package/src/label/label.stories.tsx +1 -0
- package/src/progress/Progress.stories.tsx +2 -1
- package/src/progress/progress.tsx +1 -1
- package/src/radio/radio.stories.tsx +1 -1
- package/src/radio/radio.tsx +1 -1
- package/src/rich-text-editor/plugins/ActionsPlugin/index.css +3 -0
- package/src/rich-text-editor/plugins/ActionsPlugin/index.tsx +1 -2
- package/src/rich-text-editor/plugins/AutoLinkPlugin/index.tsx +1 -1
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/CopyButton/index.tsx +6 -2
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx +10 -6
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/index.css +32 -17
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/index.tsx +3 -4
- package/src/rich-text-editor/plugins/DimensionsDetectorPlugin/index.tsx +49 -0
- package/src/rich-text-editor/plugins/DraggableBlockPlugin/index.css +14 -14
- package/src/rich-text-editor/plugins/DraggableBlockPlugin/index.tsx +4 -4
- package/src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.css +87 -21
- package/src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.tsx +11 -17
- package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.css +10 -2
- package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +17 -17
- package/src/rich-text-editor/plugins/LinkPlugin/index.tsx +1 -1
- package/src/rich-text-editor/plugins/ListMaxIndentLevelPlugin/index.ts +10 -21
- package/src/rich-text-editor/plugins/TableActionMenuPlugin/index.css +6 -0
- package/src/rich-text-editor/plugins/TableActionMenuPlugin/index.tsx +2 -2
- package/src/rich-text-editor/plugins/ToolbarPlugin/index.css +115 -0
- package/src/rich-text-editor/plugins/ToolbarPlugin/index.tsx +57 -78
- package/src/rich-text-editor/plugins/ToolbarPlugin/insert-table.tsx +5 -5
- package/src/rich-text-editor/rich-text-editor-icons.css +213 -0
- package/src/rich-text-editor/rich-text-editor.css +33 -913
- package/src/rich-text-editor/rich-text-editor.stories.tsx +11 -0
- package/src/rich-text-editor/rich-text-editor.tsx +13 -27
- package/src/rich-text-editor/themes/CrystallizeRTEditorTheme.ts +1 -1
- package/src/rich-text-editor/ui/LinkPreview.tsx +7 -8
- package/src/rich-text-editor/utils/getSelectedNode.ts +4 -5
- package/src/rich-text-editor/utils/point.ts +4 -7
- package/src/rich-text-editor/utils/rect.ts +18 -41
- package/src/rich-text-editor/utils/url.ts +1 -2
- package/src/select/select-root.tsx +1 -1
- package/src/select/select.stories.tsx +1 -1
- package/src/select/select.ts +0 -1
- package/src/slider/Slider.stories.tsx +2 -1
- package/src/slider/slider.tsx +2 -2
- package/src/spinner/Spinner.stories.tsx +1 -0
- package/src/spinner/index.tsx +1 -1
- package/src/tag/Tag.stories.tsx +1 -0
- package/dist/camera-CR7D2PNH.svg +0 -1
- package/dist/clipboard-OSEFDF25.svg +0 -1
- package/dist/gear-ICMT4NTP.svg +0 -1
- package/dist/journal-code-XUT44HDV.svg +0 -1
- package/dist/lock-WCYOZOHW.svg +0 -1
- package/dist/lock-fill-JZSKOSHK.svg +0 -1
- package/dist/pencil-fill-STFSC26F.svg +0 -1
- package/dist/plug-HGGGEVS3.svg +0 -1
- package/dist/plug-fill-OTG3U4TN.svg +0 -1
- package/src/rich-text-editor/hooks/useReport.ts +0 -64
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.css +0 -14
- package/src/rich-text-editor/ui/LinkPreview.css +0 -57
- package/src/rich-text-editor/utils/isMobileWidth.ts +0 -7
- package/src/rich-text-editor/utils/joinClasses.ts +0 -13
- package/src/rich-text-editor/utils/swipe.ts +0 -127
package/dist/index.js
CHANGED
|
@@ -63,8 +63,8 @@ var import_react2 = require("react");
|
|
|
63
63
|
var import_class_variance_authority2 = require("class-variance-authority");
|
|
64
64
|
|
|
65
65
|
// src/spinner/index.tsx
|
|
66
|
-
var import_class_variance_authority = require("class-variance-authority");
|
|
67
66
|
var import_react = require("react");
|
|
67
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
68
68
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
69
69
|
var realSize = 40;
|
|
70
70
|
var Spinner = (0, import_react.forwardRef)(
|
|
@@ -233,8 +233,8 @@ var import_class_variance_authority7 = require("class-variance-authority");
|
|
|
233
233
|
var import_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
|
|
234
234
|
|
|
235
235
|
// src/dropdown-menu/dropdown-menu-item.tsx
|
|
236
|
-
var DropdownMenuPrimitive = __toESM(require("@radix-ui/react-dropdown-menu"));
|
|
237
236
|
var import_class_variance_authority4 = require("class-variance-authority");
|
|
237
|
+
var DropdownMenuPrimitive = __toESM(require("@radix-ui/react-dropdown-menu"));
|
|
238
238
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
239
239
|
function DropdownMenuItem({ children, className, ...delegated }) {
|
|
240
240
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DropdownMenuPrimitive.Item, { ...delegated, className: (0, import_class_variance_authority4.cx)("c-dropdown-menu-item", className), children });
|
|
@@ -363,8 +363,8 @@ var Avatar = (0, import_react3.forwardRef)(({ name, size, className, ...delegate
|
|
|
363
363
|
Avatar.displayName = "Avatar";
|
|
364
364
|
|
|
365
365
|
// src/checkbox/checkbox.tsx
|
|
366
|
-
var CheckboxPrimitive = __toESM(require("@radix-ui/react-checkbox"));
|
|
367
366
|
var import_react4 = require("react");
|
|
367
|
+
var CheckboxPrimitive = __toESM(require("@radix-ui/react-checkbox"));
|
|
368
368
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
369
369
|
var Checkbox = (0, import_react4.forwardRef)((props, ref) => {
|
|
370
370
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckboxPrimitive.Root, { ...props, ref, className: "c-checkbox", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckboxPrimitive.Indicator, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("svg", { viewBox: "0 0 9 9", fill: "none", className: "c-checkbox__svg", children: [
|
|
@@ -386,8 +386,8 @@ var Checkbox = (0, import_react4.forwardRef)((props, ref) => {
|
|
|
386
386
|
});
|
|
387
387
|
Checkbox.displayName = "Checkbox";
|
|
388
388
|
|
|
389
|
-
// src/dialog/
|
|
390
|
-
var
|
|
389
|
+
// src/dialog/config.tsx
|
|
390
|
+
var import_react_dom = require("react-dom");
|
|
391
391
|
|
|
392
392
|
// src/dialog/dialog.tsx
|
|
393
393
|
var import_class_variance_authority9 = require("class-variance-authority");
|
|
@@ -3775,9 +3775,6 @@ DialogBase.Content = DialogContent;
|
|
|
3775
3775
|
DialogBase.Overlay = DialogPrimitive.Overlay;
|
|
3776
3776
|
DialogBase.Close = DialogPrimitive.Close;
|
|
3777
3777
|
|
|
3778
|
-
// src/dialog/config.tsx
|
|
3779
|
-
var import_react_dom = require("react-dom");
|
|
3780
|
-
|
|
3781
3778
|
// src/dialog/confirm-dialog.tsx
|
|
3782
3779
|
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
3783
3780
|
function ConfirmDialog({
|
|
@@ -3842,6 +3839,9 @@ function ConfirmDialog({
|
|
|
3842
3839
|
) });
|
|
3843
3840
|
}
|
|
3844
3841
|
|
|
3842
|
+
// src/dialog/destroyFns.ts
|
|
3843
|
+
var destroyFns = [];
|
|
3844
|
+
|
|
3845
3845
|
// src/dialog/config.tsx
|
|
3846
3846
|
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
3847
3847
|
function confirm(config) {
|
|
@@ -4013,8 +4013,8 @@ var IconButton = (0, import_react59.forwardRef)(
|
|
|
4013
4013
|
IconButton.displayName = "Button";
|
|
4014
4014
|
|
|
4015
4015
|
// src/inline-radio/inline-radio.tsx
|
|
4016
|
-
var RadioGroupPrimitive = __toESM(require("@radix-ui/react-radio-group"));
|
|
4017
4016
|
var import_class_variance_authority11 = require("class-variance-authority");
|
|
4017
|
+
var RadioGroupPrimitive = __toESM(require("@radix-ui/react-radio-group"));
|
|
4018
4018
|
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
4019
4019
|
var inlineRadioGroupStyles = (0, import_class_variance_authority11.cva)("c-inline-radio-group", {
|
|
4020
4020
|
variants: {
|
|
@@ -4044,34 +4044,12 @@ var InlineRadio = {
|
|
|
4044
4044
|
var import_react63 = require("react");
|
|
4045
4045
|
var import_class_variance_authority14 = require("class-variance-authority");
|
|
4046
4046
|
|
|
4047
|
-
// src/
|
|
4048
|
-
var import_class_variance_authority12 = require("class-variance-authority");
|
|
4047
|
+
// src/iconography/triangle.tsx
|
|
4049
4048
|
var import_react60 = require("react");
|
|
4050
4049
|
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
4051
|
-
var
|
|
4052
|
-
variants: {},
|
|
4053
|
-
defaultVariants: {}
|
|
4054
|
-
});
|
|
4055
|
-
var Input = (0, import_react60.forwardRef)(({ className, ...delegated }, ref) => {
|
|
4056
|
-
return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("input", { ref, className: inputStyles({ className }), type: "text", ...delegated });
|
|
4057
|
-
});
|
|
4058
|
-
Input.displayName = "Input";
|
|
4059
|
-
|
|
4060
|
-
// src/label/label.tsx
|
|
4061
|
-
var import_react61 = require("react");
|
|
4062
|
-
var import_class_variance_authority13 = require("class-variance-authority");
|
|
4063
|
-
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
4064
|
-
var Label2 = (0, import_react61.forwardRef)(({ className, ...delegated }, ref) => {
|
|
4065
|
-
return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("label", { ref, className: (0, import_class_variance_authority13.cx)("c-label", className), ...delegated });
|
|
4066
|
-
});
|
|
4067
|
-
Label2.displayName = "Label";
|
|
4068
|
-
|
|
4069
|
-
// src/iconography/triangle.tsx
|
|
4070
|
-
var import_react62 = require("react");
|
|
4071
|
-
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
4072
|
-
var Triangle = (0, import_react62.forwardRef)((delegated, ref) => {
|
|
4050
|
+
var Triangle = (0, import_react60.forwardRef)((delegated, ref) => {
|
|
4073
4051
|
const { width = 20, height = 20, ...rest } = delegated;
|
|
4074
|
-
return /* @__PURE__ */ (0,
|
|
4052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
4075
4053
|
"svg",
|
|
4076
4054
|
{
|
|
4077
4055
|
viewBox: "0 0 17 15",
|
|
@@ -4081,11 +4059,33 @@ var Triangle = (0, import_react62.forwardRef)((delegated, ref) => {
|
|
|
4081
4059
|
fill: "none",
|
|
4082
4060
|
xmlns: "http://www.w3.org/2000/svg",
|
|
4083
4061
|
...rest,
|
|
4084
|
-
children: /* @__PURE__ */ (0,
|
|
4062
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("path", { d: "M15.463 1.2L8.5 12.685 1.537 1.2h13.925zM1.353.896s0 0 0 0h0z", stroke: "currentColor", strokeWidth: 2.4 })
|
|
4085
4063
|
}
|
|
4086
4064
|
);
|
|
4087
4065
|
});
|
|
4088
4066
|
|
|
4067
|
+
// src/input/input.tsx
|
|
4068
|
+
var import_react61 = require("react");
|
|
4069
|
+
var import_class_variance_authority12 = require("class-variance-authority");
|
|
4070
|
+
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
4071
|
+
var inputStyles = (0, import_class_variance_authority12.cva)(["c-input"], {
|
|
4072
|
+
variants: {},
|
|
4073
|
+
defaultVariants: {}
|
|
4074
|
+
});
|
|
4075
|
+
var Input = (0, import_react61.forwardRef)(({ className, ...delegated }, ref) => {
|
|
4076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("input", { ref, className: inputStyles({ className }), type: "text", ...delegated });
|
|
4077
|
+
});
|
|
4078
|
+
Input.displayName = "Input";
|
|
4079
|
+
|
|
4080
|
+
// src/label/label.tsx
|
|
4081
|
+
var import_react62 = require("react");
|
|
4082
|
+
var import_class_variance_authority13 = require("class-variance-authority");
|
|
4083
|
+
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
4084
|
+
var Label2 = (0, import_react62.forwardRef)(({ className, ...delegated }, ref) => {
|
|
4085
|
+
return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("label", { ref, className: (0, import_class_variance_authority13.cx)("c-label", className), ...delegated });
|
|
4086
|
+
});
|
|
4087
|
+
Label2.displayName = "Label";
|
|
4088
|
+
|
|
4089
4089
|
// src/input-with-label/input-with-label.tsx
|
|
4090
4090
|
var import_jsx_runtime74 = require("react/jsx-runtime");
|
|
4091
4091
|
var inputWithLabelStyles = (0, import_class_variance_authority14.cva)(["c-input-with-label"], {
|
|
@@ -4124,8 +4124,8 @@ var InputWithLabel = (0, import_react63.forwardRef)(
|
|
|
4124
4124
|
InputWithLabel.displayName = "InputWithLabel";
|
|
4125
4125
|
|
|
4126
4126
|
// src/progress/progress.tsx
|
|
4127
|
-
var ProgressPrimitives = __toESM(require("@radix-ui/react-progress"));
|
|
4128
4127
|
var import_class_variance_authority15 = require("class-variance-authority");
|
|
4128
|
+
var ProgressPrimitives = __toESM(require("@radix-ui/react-progress"));
|
|
4129
4129
|
var import_jsx_runtime75 = require("react/jsx-runtime");
|
|
4130
4130
|
function Progress({ className, value }) {
|
|
4131
4131
|
return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ProgressPrimitives.Root, { className: (0, import_class_variance_authority15.cx)(className, "c-progress-root"), value, children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
@@ -4163,8 +4163,8 @@ SelectItem.displayName = "SelectItem";
|
|
|
4163
4163
|
|
|
4164
4164
|
// src/select/select-root.tsx
|
|
4165
4165
|
var import_react65 = require("react");
|
|
4166
|
-
var SelectPrimitives2 = __toESM(require("@radix-ui/react-select"));
|
|
4167
4166
|
var import_class_variance_authority16 = require("class-variance-authority");
|
|
4167
|
+
var SelectPrimitives2 = __toESM(require("@radix-ui/react-select"));
|
|
4168
4168
|
var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
4169
4169
|
var selectTriggerStyles = (0, import_class_variance_authority16.cva)("c-select-trigger", {
|
|
4170
4170
|
variants: {
|
|
@@ -4203,9 +4203,9 @@ var Select = {
|
|
|
4203
4203
|
};
|
|
4204
4204
|
|
|
4205
4205
|
// src/slider/slider.tsx
|
|
4206
|
-
var SliderPrimitive = __toESM(require("@radix-ui/react-slider"));
|
|
4207
|
-
var import_class_variance_authority17 = require("class-variance-authority");
|
|
4208
4206
|
var import_react66 = require("react");
|
|
4207
|
+
var import_class_variance_authority17 = require("class-variance-authority");
|
|
4208
|
+
var SliderPrimitive = __toESM(require("@radix-ui/react-slider"));
|
|
4209
4209
|
var import_jsx_runtime79 = require("react/jsx-runtime");
|
|
4210
4210
|
var Slider = (0, import_react66.forwardRef)(({ className, transparentRange, ...delegated }, ref) => {
|
|
4211
4211
|
return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(SliderPrimitive.Root, { className: (0, import_class_variance_authority17.cx)("c-slider-root", className), ref, ...delegated, children: [
|
|
@@ -4258,7 +4258,7 @@ function Tag({ children, className, variant, size, prepend, onRemove, ...delegat
|
|
|
4258
4258
|
}
|
|
4259
4259
|
|
|
4260
4260
|
// src/rich-text-editor/rich-text-editor.tsx
|
|
4261
|
-
var
|
|
4261
|
+
var import_react84 = require("react");
|
|
4262
4262
|
var import_LexicalAutoFocusPlugin = require("@lexical/react/LexicalAutoFocusPlugin");
|
|
4263
4263
|
var import_LexicalClearEditorPlugin = require("@lexical/react/LexicalClearEditorPlugin");
|
|
4264
4264
|
var import_LexicalComposer = require("@lexical/react/LexicalComposer");
|
|
@@ -4800,8 +4800,8 @@ var BaseNodes = [
|
|
|
4800
4800
|
];
|
|
4801
4801
|
|
|
4802
4802
|
// src/rich-text-editor/plugins/AutoLinkPlugin/index.tsx
|
|
4803
|
-
var import_LexicalAutoLinkPlugin = require("@lexical/react/LexicalAutoLinkPlugin");
|
|
4804
4803
|
var React = require("react");
|
|
4804
|
+
var import_LexicalAutoLinkPlugin = require("@lexical/react/LexicalAutoLinkPlugin");
|
|
4805
4805
|
var import_jsx_runtime83 = require("react/jsx-runtime");
|
|
4806
4806
|
var URL_MATCHER = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
|
4807
4807
|
var EMAIL_MATCHER = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
|
|
@@ -4876,7 +4876,7 @@ function CopyButton({ editor, getCodeDOMNode }) {
|
|
|
4876
4876
|
console.error("Failed to copy: ", err);
|
|
4877
4877
|
}
|
|
4878
4878
|
}
|
|
4879
|
-
return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("button", { className: "
|
|
4879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("button", { className: "c-rte-code-button", onClick: handleClick, "aria-label": tr("actionCopyCode"), children: isCopyCompleted ? /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("i", { className: "c-rte-code-button__icon c-rte-icon-success" }) : /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("i", { className: "c-rte-code-button__icon c-rte-icon-copy" }) });
|
|
4880
4880
|
}
|
|
4881
4881
|
|
|
4882
4882
|
// src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx
|
|
@@ -4970,19 +4970,19 @@ function PrettierButton({ lang, editor, getCodeDOMNode }) {
|
|
|
4970
4970
|
setTipsVisible(false);
|
|
4971
4971
|
}
|
|
4972
4972
|
}
|
|
4973
|
-
return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)("div", { className: "prettier-wrapper", children: [
|
|
4973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)("div", { className: "c-rte-prettier-wrapper", children: [
|
|
4974
4974
|
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
|
|
4975
4975
|
"button",
|
|
4976
4976
|
{
|
|
4977
|
-
className: "
|
|
4977
|
+
className: "c-rte-code-button",
|
|
4978
4978
|
onClick: handleClick,
|
|
4979
4979
|
onMouseEnter: handleMouseEnter,
|
|
4980
4980
|
onMouseLeave: handleMouseLeave,
|
|
4981
4981
|
"aria-label": tr("actionFormatCode"),
|
|
4982
|
-
children: syntaxError ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("i", { className: "
|
|
4982
|
+
children: syntaxError ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("i", { className: "c-rte-code-button__icon c-rte-icon-prettier-error" }) : /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("i", { className: "c-rte-code-button__icon c-rte-icon-prettier" })
|
|
4983
4983
|
}
|
|
4984
4984
|
),
|
|
4985
|
-
tipsVisible ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("pre", { className: "code-error-tips", children: syntaxError }) : null
|
|
4985
|
+
tipsVisible ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("pre", { className: "c-rte-code-error-tips", children: syntaxError }) : null
|
|
4986
4986
|
] });
|
|
4987
4987
|
}
|
|
4988
4988
|
|
|
@@ -5064,8 +5064,8 @@ function CodeActionMenuContainer({ anchorElem }) {
|
|
|
5064
5064
|
});
|
|
5065
5065
|
const normalizedLang = (0, import_code6.normalizeCodeLang)(lang);
|
|
5066
5066
|
const codeFriendlyName = (0, import_code6.getLanguageFriendlyName)(lang);
|
|
5067
|
-
return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_jsx_runtime86.Fragment, { children: isShown ? /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("div", { className: "code-action-menu-container", style: { ...position }, children: [
|
|
5068
|
-
/* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: "code-highlight-language", children: codeFriendlyName }),
|
|
5067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_jsx_runtime86.Fragment, { children: isShown ? /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("div", { className: "c-rte-code-action-menu-container", style: { ...position }, children: [
|
|
5068
|
+
/* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: "c-rte-code-highlight-language", children: codeFriendlyName }),
|
|
5069
5069
|
/* @__PURE__ */ (0, import_jsx_runtime86.jsx)(CopyButton, { editor, getCodeDOMNode }),
|
|
5070
5070
|
canBePrettier(normalizedLang) ? /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(PrettierButton, { editor, getCodeDOMNode, lang: normalizedLang }) : null
|
|
5071
5071
|
] }) : null });
|
|
@@ -5074,7 +5074,7 @@ function getMouseInfo(event) {
|
|
|
5074
5074
|
const target = event.target;
|
|
5075
5075
|
if (target && target instanceof HTMLElement) {
|
|
5076
5076
|
const codeDOMNode = target.closest("code.CrystallizeRTEditorTheme__code");
|
|
5077
|
-
const isOutside = !(codeDOMNode || target.closest("div.code-action-menu-container"));
|
|
5077
|
+
const isOutside = !(codeDOMNode || target.closest("div.c-rte-code-action-menu-container"));
|
|
5078
5078
|
return { codeDOMNode, isOutside };
|
|
5079
5079
|
} else {
|
|
5080
5080
|
return { codeDOMNode: null, isOutside: true };
|
|
@@ -5098,20 +5098,54 @@ function CodeHighlightPlugin() {
|
|
|
5098
5098
|
return null;
|
|
5099
5099
|
}
|
|
5100
5100
|
|
|
5101
|
+
// src/rich-text-editor/plugins/DimensionsDetectorPlugin/index.tsx
|
|
5102
|
+
var import_react73 = require("react");
|
|
5103
|
+
var import_jsx_runtime87 = require("react/jsx-runtime");
|
|
5104
|
+
function DimensionDetectorPlugin({ onChange }) {
|
|
5105
|
+
const [dimensions, setDimensions] = (0, import_react73.useState)();
|
|
5106
|
+
const ref = (0, import_react73.useRef)(null);
|
|
5107
|
+
(0, import_react73.useEffect)(() => {
|
|
5108
|
+
if (ref.current) {
|
|
5109
|
+
const el = ref.current;
|
|
5110
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
5111
|
+
const [first] = entries;
|
|
5112
|
+
if (first) {
|
|
5113
|
+
const [contentBox] = first.contentBoxSize;
|
|
5114
|
+
if (contentBox) {
|
|
5115
|
+
const width = contentBox.inlineSize;
|
|
5116
|
+
setDimensions({
|
|
5117
|
+
width,
|
|
5118
|
+
isSmallWidth: width < 600
|
|
5119
|
+
});
|
|
5120
|
+
}
|
|
5121
|
+
}
|
|
5122
|
+
});
|
|
5123
|
+
resizeObserver.observe(el);
|
|
5124
|
+
return () => resizeObserver.disconnect();
|
|
5125
|
+
}
|
|
5126
|
+
}, []);
|
|
5127
|
+
(0, import_react73.useEffect)(() => {
|
|
5128
|
+
if (dimensions) {
|
|
5129
|
+
onChange(dimensions);
|
|
5130
|
+
}
|
|
5131
|
+
}, [dimensions, onChange]);
|
|
5132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { ref, style: { height: 1, marginTop: -1 } });
|
|
5133
|
+
}
|
|
5134
|
+
|
|
5101
5135
|
// src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.tsx
|
|
5102
|
-
var
|
|
5136
|
+
var import_react75 = require("react");
|
|
5103
5137
|
var React4 = require("react");
|
|
5104
|
-
var
|
|
5138
|
+
var import_lexical8 = require("lexical");
|
|
5105
5139
|
var import_react_dom3 = require("react-dom");
|
|
5106
5140
|
var import_link4 = require("@lexical/link");
|
|
5107
5141
|
var import_LexicalComposerContext4 = require("@lexical/react/LexicalComposerContext");
|
|
5108
5142
|
var import_utils = require("@lexical/utils");
|
|
5109
5143
|
|
|
5110
5144
|
// src/rich-text-editor/ui/LinkPreview.tsx
|
|
5111
|
-
var
|
|
5145
|
+
var import_react74 = require("react");
|
|
5112
5146
|
var import_lexical7 = require("lexical");
|
|
5113
5147
|
var import_LexicalComposerContext3 = require("@lexical/react/LexicalComposerContext");
|
|
5114
|
-
var
|
|
5148
|
+
var import_jsx_runtime88 = require("react/jsx-runtime");
|
|
5115
5149
|
var PREVIEW_CACHE = {};
|
|
5116
5150
|
var URL_MATCHER2 = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
|
5117
5151
|
function useSuspenseRequest(url) {
|
|
@@ -5135,12 +5169,12 @@ function useSuspenseRequest(url) {
|
|
|
5135
5169
|
function LinkPreviewContent({
|
|
5136
5170
|
url
|
|
5137
5171
|
}) {
|
|
5138
|
-
const [textContent, setTextContent] = (0,
|
|
5172
|
+
const [textContent, setTextContent] = (0, import_react74.useState)("");
|
|
5139
5173
|
const { preview } = useSuspenseRequest(url);
|
|
5140
5174
|
const [editor] = (0, import_LexicalComposerContext3.useLexicalComposerContext)();
|
|
5141
5175
|
const tr = useTr();
|
|
5142
5176
|
const hasPreview = preview !== null && preview.google?.title;
|
|
5143
|
-
(0,
|
|
5177
|
+
(0, import_react74.useEffect)(() => {
|
|
5144
5178
|
editor.update(() => {
|
|
5145
5179
|
const sel = (0, import_lexical7.$getSelection)();
|
|
5146
5180
|
const nodes = sel?.getNodes();
|
|
@@ -5168,18 +5202,18 @@ function LinkPreviewContent({
|
|
|
5168
5202
|
if (!hasPreview) {
|
|
5169
5203
|
return null;
|
|
5170
5204
|
}
|
|
5171
|
-
return /* @__PURE__ */ (0,
|
|
5172
|
-
preview.google.image && /* @__PURE__ */ (0,
|
|
5173
|
-
preview.google.title && /* @__PURE__ */ (0,
|
|
5174
|
-
preview.google.description && /* @__PURE__ */ (0,
|
|
5175
|
-
textContent && textContent !== preview.google.title ? /* @__PURE__ */ (0,
|
|
5205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("div", { className: "c-rte-link-preview", children: [
|
|
5206
|
+
preview.google.image && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "c-rte-link-preview-image-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("img", { src: preview.google.image, alt: preview.google.title, className: "c-rte-link-preview-image" }) }),
|
|
5207
|
+
preview.google.title && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "c-rte-link-preview-title", children: preview.google.title }),
|
|
5208
|
+
preview.google.description && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "c-rte-link-preview-description", children: preview.google.description }),
|
|
5209
|
+
textContent && textContent !== preview.google.title ? /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Button, { className: "c-rte-link-preview__replace-text-btn", onClick: useTitleForText, children: tr("linkPreviewReplaceTextWithTitle") }) : null
|
|
5176
5210
|
] });
|
|
5177
5211
|
}
|
|
5178
5212
|
function Glimmer(props) {
|
|
5179
|
-
return /* @__PURE__ */ (0,
|
|
5213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
|
|
5180
5214
|
"div",
|
|
5181
5215
|
{
|
|
5182
|
-
className: "
|
|
5216
|
+
className: "c-rte-link-preview-glimmer",
|
|
5183
5217
|
...props,
|
|
5184
5218
|
style: {
|
|
5185
5219
|
animationDelay: String((props.index || 0) * 300),
|
|
@@ -5191,22 +5225,21 @@ function Glimmer(props) {
|
|
|
5191
5225
|
function LinkPreview({
|
|
5192
5226
|
url
|
|
5193
5227
|
}) {
|
|
5194
|
-
return /* @__PURE__ */ (0,
|
|
5195
|
-
|
|
5228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
|
|
5229
|
+
import_react74.Suspense,
|
|
5196
5230
|
{
|
|
5197
|
-
fallback: /* @__PURE__ */ (0,
|
|
5198
|
-
/* @__PURE__ */ (0,
|
|
5199
|
-
/* @__PURE__ */ (0,
|
|
5200
|
-
/* @__PURE__ */ (0,
|
|
5231
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(import_jsx_runtime88.Fragment, { children: [
|
|
5232
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Glimmer, { style: { height: "80px" }, index: 0 }),
|
|
5233
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Glimmer, { style: { width: "60%" }, index: 1 }),
|
|
5234
|
+
/* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Glimmer, { style: { width: "80%" }, index: 2 })
|
|
5201
5235
|
] }),
|
|
5202
|
-
children: /* @__PURE__ */ (0,
|
|
5236
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(LinkPreviewContent, { url })
|
|
5203
5237
|
}
|
|
5204
5238
|
);
|
|
5205
5239
|
}
|
|
5206
5240
|
|
|
5207
5241
|
// src/rich-text-editor/utils/getSelectedNode.ts
|
|
5208
5242
|
var import_selection = require("@lexical/selection");
|
|
5209
|
-
var import_lexical8 = require("lexical");
|
|
5210
5243
|
function getSelectedNode(selection) {
|
|
5211
5244
|
const anchor = selection.anchor;
|
|
5212
5245
|
const focus = selection.focus;
|
|
@@ -5267,24 +5300,24 @@ function validateUrl(url) {
|
|
|
5267
5300
|
}
|
|
5268
5301
|
|
|
5269
5302
|
// src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.tsx
|
|
5270
|
-
var
|
|
5303
|
+
var import_jsx_runtime89 = require("react/jsx-runtime");
|
|
5271
5304
|
function FloatingLinkEditor({
|
|
5272
5305
|
editor,
|
|
5273
5306
|
isLink,
|
|
5274
5307
|
setIsLink,
|
|
5275
5308
|
anchorElem
|
|
5276
5309
|
}) {
|
|
5277
|
-
const editorRef = (0,
|
|
5278
|
-
const inputRef = (0,
|
|
5279
|
-
const [linkUrl, setLinkUrl] = (0,
|
|
5280
|
-
const [rel, setRel] = (0,
|
|
5281
|
-
const [target, setTarget] = (0,
|
|
5282
|
-
const [isEditMode, setEditMode] = (0,
|
|
5283
|
-
const [lastSelection, setLastSelection] = (0,
|
|
5310
|
+
const editorRef = (0, import_react75.useRef)(null);
|
|
5311
|
+
const inputRef = (0, import_react75.useRef)(null);
|
|
5312
|
+
const [linkUrl, setLinkUrl] = (0, import_react75.useState)("");
|
|
5313
|
+
const [rel, setRel] = (0, import_react75.useState)(null);
|
|
5314
|
+
const [target, setTarget] = (0, import_react75.useState)(null);
|
|
5315
|
+
const [isEditMode, setEditMode] = (0, import_react75.useState)(false);
|
|
5316
|
+
const [lastSelection, setLastSelection] = (0, import_react75.useState)(null);
|
|
5284
5317
|
const tr = useTr();
|
|
5285
|
-
const updateLinkEditor = (0,
|
|
5286
|
-
const selection = (0,
|
|
5287
|
-
if ((0,
|
|
5318
|
+
const updateLinkEditor = (0, import_react75.useCallback)(() => {
|
|
5319
|
+
const selection = (0, import_lexical8.$getSelection)();
|
|
5320
|
+
if ((0, import_lexical8.$isRangeSelection)(selection)) {
|
|
5288
5321
|
const node = getSelectedNode(selection);
|
|
5289
5322
|
const parent2 = node.getParent();
|
|
5290
5323
|
if ((0, import_link4.$isLinkNode)(parent2)) {
|
|
@@ -5332,7 +5365,7 @@ function FloatingLinkEditor({
|
|
|
5332
5365
|
}
|
|
5333
5366
|
return true;
|
|
5334
5367
|
}, [anchorElem, editor]);
|
|
5335
|
-
(0,
|
|
5368
|
+
(0, import_react75.useEffect)(() => {
|
|
5336
5369
|
const scrollerElem = anchorElem.parentElement;
|
|
5337
5370
|
const update = () => {
|
|
5338
5371
|
editor.getEditorState().read(() => {
|
|
@@ -5350,7 +5383,7 @@ function FloatingLinkEditor({
|
|
|
5350
5383
|
}
|
|
5351
5384
|
};
|
|
5352
5385
|
}, [anchorElem.parentElement, editor, updateLinkEditor]);
|
|
5353
|
-
(0,
|
|
5386
|
+
(0, import_react75.useEffect)(() => {
|
|
5354
5387
|
return (0, import_utils.mergeRegister)(
|
|
5355
5388
|
editor.registerUpdateListener(({ editorState }) => {
|
|
5356
5389
|
editorState.read(() => {
|
|
@@ -5358,15 +5391,15 @@ function FloatingLinkEditor({
|
|
|
5358
5391
|
});
|
|
5359
5392
|
}),
|
|
5360
5393
|
editor.registerCommand(
|
|
5361
|
-
|
|
5394
|
+
import_lexical8.SELECTION_CHANGE_COMMAND,
|
|
5362
5395
|
() => {
|
|
5363
5396
|
updateLinkEditor();
|
|
5364
5397
|
return true;
|
|
5365
5398
|
},
|
|
5366
|
-
|
|
5399
|
+
import_lexical8.COMMAND_PRIORITY_LOW
|
|
5367
5400
|
),
|
|
5368
5401
|
editor.registerCommand(
|
|
5369
|
-
|
|
5402
|
+
import_lexical8.KEY_ESCAPE_COMMAND,
|
|
5370
5403
|
() => {
|
|
5371
5404
|
if (isLink) {
|
|
5372
5405
|
setIsLink(false);
|
|
@@ -5374,22 +5407,22 @@ function FloatingLinkEditor({
|
|
|
5374
5407
|
}
|
|
5375
5408
|
return false;
|
|
5376
5409
|
},
|
|
5377
|
-
|
|
5410
|
+
import_lexical8.COMMAND_PRIORITY_HIGH
|
|
5378
5411
|
)
|
|
5379
5412
|
);
|
|
5380
5413
|
}, [editor, updateLinkEditor, setIsLink, isLink]);
|
|
5381
|
-
(0,
|
|
5414
|
+
(0, import_react75.useEffect)(() => {
|
|
5382
5415
|
editor.getEditorState().read(() => {
|
|
5383
5416
|
updateLinkEditor();
|
|
5384
5417
|
});
|
|
5385
5418
|
}, [editor, updateLinkEditor]);
|
|
5386
|
-
(0,
|
|
5419
|
+
(0, import_react75.useEffect)(() => {
|
|
5387
5420
|
if (isEditMode && inputRef.current) {
|
|
5388
5421
|
inputRef.current.focus();
|
|
5389
5422
|
}
|
|
5390
5423
|
}, [isEditMode]);
|
|
5391
|
-
return /* @__PURE__ */ (0,
|
|
5392
|
-
/* @__PURE__ */ (0,
|
|
5424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { ref: editorRef, className: "c-rte-link-editor", children: isEditMode ? /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { children: [
|
|
5425
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "c-rte-link-editor-input-group", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
5393
5426
|
InputWithLabel,
|
|
5394
5427
|
{
|
|
5395
5428
|
label: tr("linkEditorLink"),
|
|
@@ -5398,7 +5431,7 @@ function FloatingLinkEditor({
|
|
|
5398
5431
|
onChange: (e) => setLinkUrl(e.target.value)
|
|
5399
5432
|
}
|
|
5400
5433
|
) }),
|
|
5401
|
-
/* @__PURE__ */ (0,
|
|
5434
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "c-rte-link-editor-input-group", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
5402
5435
|
InputWithLabel,
|
|
5403
5436
|
{
|
|
5404
5437
|
label: tr("linkEditorRel"),
|
|
@@ -5407,7 +5440,7 @@ function FloatingLinkEditor({
|
|
|
5407
5440
|
onChange: (e) => setRel(e.target.value)
|
|
5408
5441
|
}
|
|
5409
5442
|
) }),
|
|
5410
|
-
/* @__PURE__ */ (0,
|
|
5443
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "c-rte-link-editor-input-group", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
5411
5444
|
InputWithLabel,
|
|
5412
5445
|
{
|
|
5413
5446
|
label: tr("linkEditorTarget"),
|
|
@@ -5416,7 +5449,7 @@ function FloatingLinkEditor({
|
|
|
5416
5449
|
onChange: (e) => setTarget(e.target.value)
|
|
5417
5450
|
}
|
|
5418
5451
|
) }),
|
|
5419
|
-
/* @__PURE__ */ (0,
|
|
5452
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "c-rte-link-editor-button-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
5420
5453
|
Button,
|
|
5421
5454
|
{
|
|
5422
5455
|
onClick: () => {
|
|
@@ -5434,16 +5467,16 @@ function FloatingLinkEditor({
|
|
|
5434
5467
|
children: tr("linkEditorCommit")
|
|
5435
5468
|
}
|
|
5436
5469
|
) })
|
|
5437
|
-
] }) : /* @__PURE__ */ (0,
|
|
5438
|
-
/* @__PURE__ */ (0,
|
|
5439
|
-
/* @__PURE__ */ (0,
|
|
5440
|
-
/* @__PURE__ */ (0,
|
|
5441
|
-
rel || target ? /* @__PURE__ */ (0,
|
|
5442
|
-
rel && /* @__PURE__ */ (0,
|
|
5443
|
-
target && /* @__PURE__ */ (0,
|
|
5470
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(import_jsx_runtime89.Fragment, { children: [
|
|
5471
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: "c-rte-link-editor-link-input", children: [
|
|
5472
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: "c-rte-link-editor-link-preview", children: [
|
|
5473
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)("a", { href: linkUrl, target: "_blank", rel: "noopener noreferrer", children: linkUrl }),
|
|
5474
|
+
rel || target ? /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: "c-rte-link-editor-preview-attrs", children: [
|
|
5475
|
+
rel && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "c-rte-link-editor-preview-attr", children: rel }),
|
|
5476
|
+
target && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "c-rte-link-editor-preview-attr", children: target })
|
|
5444
5477
|
] }) : null
|
|
5445
5478
|
] }),
|
|
5446
|
-
/* @__PURE__ */ (0,
|
|
5479
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
5447
5480
|
IconButton,
|
|
5448
5481
|
{
|
|
5449
5482
|
size: "sm",
|
|
@@ -5451,19 +5484,19 @@ function FloatingLinkEditor({
|
|
|
5451
5484
|
onMouseDown: (event) => event.preventDefault(),
|
|
5452
5485
|
onClick: () => setEditMode(true),
|
|
5453
5486
|
"aria-label": tr("linkEditorEdit"),
|
|
5454
|
-
children: /* @__PURE__ */ (0,
|
|
5487
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(Icon.Edit, {})
|
|
5455
5488
|
}
|
|
5456
5489
|
) })
|
|
5457
5490
|
] }),
|
|
5458
|
-
/* @__PURE__ */ (0,
|
|
5491
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(LinkPreview, { url: linkUrl }) })
|
|
5459
5492
|
] }) });
|
|
5460
5493
|
}
|
|
5461
5494
|
function useFloatingLinkEditorToolbar(editor, anchorElem) {
|
|
5462
|
-
const [activeEditor, setActiveEditor] = (0,
|
|
5463
|
-
const [isLink, setIsLink] = (0,
|
|
5464
|
-
const updateToolbar = (0,
|
|
5465
|
-
const selection = (0,
|
|
5466
|
-
if ((0,
|
|
5495
|
+
const [activeEditor, setActiveEditor] = (0, import_react75.useState)(editor);
|
|
5496
|
+
const [isLink, setIsLink] = (0, import_react75.useState)(false);
|
|
5497
|
+
const updateToolbar = (0, import_react75.useCallback)(() => {
|
|
5498
|
+
const selection = (0, import_lexical8.$getSelection)();
|
|
5499
|
+
if ((0, import_lexical8.$isRangeSelection)(selection)) {
|
|
5467
5500
|
const node = getSelectedNode(selection);
|
|
5468
5501
|
const linkParent = (0, import_utils.$findMatchingParent)(node, import_link4.$isLinkNode);
|
|
5469
5502
|
const autoLinkParent = (0, import_utils.$findMatchingParent)(node, import_link4.$isAutoLinkNode);
|
|
@@ -5474,19 +5507,19 @@ function useFloatingLinkEditorToolbar(editor, anchorElem) {
|
|
|
5474
5507
|
}
|
|
5475
5508
|
}
|
|
5476
5509
|
}, []);
|
|
5477
|
-
(0,
|
|
5510
|
+
(0, import_react75.useEffect)(() => {
|
|
5478
5511
|
return editor.registerCommand(
|
|
5479
|
-
|
|
5512
|
+
import_lexical8.SELECTION_CHANGE_COMMAND,
|
|
5480
5513
|
(_payload, newEditor) => {
|
|
5481
5514
|
updateToolbar();
|
|
5482
5515
|
setActiveEditor(newEditor);
|
|
5483
5516
|
return false;
|
|
5484
5517
|
},
|
|
5485
|
-
|
|
5518
|
+
import_lexical8.COMMAND_PRIORITY_CRITICAL
|
|
5486
5519
|
);
|
|
5487
5520
|
}, [editor, updateToolbar]);
|
|
5488
5521
|
return isLink ? (0, import_react_dom3.createPortal)(
|
|
5489
|
-
/* @__PURE__ */ (0,
|
|
5522
|
+
/* @__PURE__ */ (0, import_jsx_runtime89.jsx)(FloatingLinkEditor, { editor: activeEditor, isLink, anchorElem, setIsLink }),
|
|
5490
5523
|
anchorElem
|
|
5491
5524
|
) : null;
|
|
5492
5525
|
}
|
|
@@ -5498,9 +5531,9 @@ function FloatingLinkEditorPlugin({
|
|
|
5498
5531
|
}
|
|
5499
5532
|
|
|
5500
5533
|
// src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx
|
|
5501
|
-
var
|
|
5534
|
+
var import_react76 = require("react");
|
|
5502
5535
|
var React5 = require("react");
|
|
5503
|
-
var
|
|
5536
|
+
var import_lexical9 = require("lexical");
|
|
5504
5537
|
var import_react_dom4 = require("react-dom");
|
|
5505
5538
|
var import_code8 = require("@lexical/code");
|
|
5506
5539
|
var import_link5 = require("@lexical/link");
|
|
@@ -5540,7 +5573,7 @@ function getDOMRangeRect(nativeSelection, rootElement) {
|
|
|
5540
5573
|
}
|
|
5541
5574
|
|
|
5542
5575
|
// src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx
|
|
5543
|
-
var
|
|
5576
|
+
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
5544
5577
|
function TextFormatFloatingToolbar({
|
|
5545
5578
|
editor,
|
|
5546
5579
|
anchorElem,
|
|
@@ -5553,17 +5586,17 @@ function TextFormatFloatingToolbar({
|
|
|
5553
5586
|
isSubscript,
|
|
5554
5587
|
isSuperscript
|
|
5555
5588
|
}) {
|
|
5556
|
-
const popupCharStylesEditorRef = (0,
|
|
5589
|
+
const popupCharStylesEditorRef = (0, import_react76.useRef)(null);
|
|
5557
5590
|
const tr = useTr();
|
|
5558
|
-
const insertLink = (0,
|
|
5591
|
+
const insertLink = (0, import_react76.useCallback)(() => {
|
|
5559
5592
|
if (!isLink) {
|
|
5560
5593
|
editor.dispatchCommand(import_link5.TOGGLE_LINK_COMMAND, "https://");
|
|
5561
5594
|
} else {
|
|
5562
5595
|
editor.dispatchCommand(import_link5.TOGGLE_LINK_COMMAND, null);
|
|
5563
5596
|
}
|
|
5564
5597
|
}, [editor, isLink]);
|
|
5565
|
-
const updateTextFormatFloatingToolbar = (0,
|
|
5566
|
-
const selection = (0,
|
|
5598
|
+
const updateTextFormatFloatingToolbar = (0, import_react76.useCallback)(() => {
|
|
5599
|
+
const selection = (0, import_lexical9.$getSelection)();
|
|
5567
5600
|
const popupCharStylesEditorElem = popupCharStylesEditorRef.current;
|
|
5568
5601
|
const nativeSelection = window.getSelection();
|
|
5569
5602
|
if (popupCharStylesEditorElem === null) {
|
|
@@ -5575,7 +5608,7 @@ function TextFormatFloatingToolbar({
|
|
|
5575
5608
|
setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElem);
|
|
5576
5609
|
}
|
|
5577
5610
|
}, [editor, anchorElem]);
|
|
5578
|
-
(0,
|
|
5611
|
+
(0, import_react76.useEffect)(() => {
|
|
5579
5612
|
const scrollerElem = anchorElem.parentElement;
|
|
5580
5613
|
const update = () => {
|
|
5581
5614
|
editor.getEditorState().read(() => {
|
|
@@ -5593,7 +5626,7 @@ function TextFormatFloatingToolbar({
|
|
|
5593
5626
|
}
|
|
5594
5627
|
};
|
|
5595
5628
|
}, [editor, updateTextFormatFloatingToolbar, anchorElem]);
|
|
5596
|
-
(0,
|
|
5629
|
+
(0, import_react76.useEffect)(() => {
|
|
5597
5630
|
editor.getEditorState().read(() => {
|
|
5598
5631
|
updateTextFormatFloatingToolbar();
|
|
5599
5632
|
});
|
|
@@ -5604,144 +5637,144 @@ function TextFormatFloatingToolbar({
|
|
|
5604
5637
|
});
|
|
5605
5638
|
}),
|
|
5606
5639
|
editor.registerCommand(
|
|
5607
|
-
|
|
5640
|
+
import_lexical9.SELECTION_CHANGE_COMMAND,
|
|
5608
5641
|
() => {
|
|
5609
5642
|
updateTextFormatFloatingToolbar();
|
|
5610
5643
|
return false;
|
|
5611
5644
|
},
|
|
5612
|
-
|
|
5645
|
+
import_lexical9.COMMAND_PRIORITY_LOW
|
|
5613
5646
|
)
|
|
5614
5647
|
);
|
|
5615
5648
|
}, [editor, updateTextFormatFloatingToolbar]);
|
|
5616
|
-
return /* @__PURE__ */ (0,
|
|
5617
|
-
/* @__PURE__ */ (0,
|
|
5649
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { ref: popupCharStylesEditorRef, className: "c-rte-floating-text-format-tb-plugin", children: editor.isEditable() && /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_jsx_runtime90.Fragment, { children: [
|
|
5650
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5618
5651
|
IconButton,
|
|
5619
5652
|
{
|
|
5620
5653
|
onClick: () => {
|
|
5621
|
-
editor.dispatchCommand(
|
|
5654
|
+
editor.dispatchCommand(import_lexical9.FORMAT_TEXT_COMMAND, "bold");
|
|
5622
5655
|
},
|
|
5623
5656
|
style: { padding: 0, overflow: "hidden" },
|
|
5624
5657
|
title: tr(IS_APPLE ? "actionFormatAsStrongTitleApple" : "actionFormatAsStrongTitle"),
|
|
5625
5658
|
"aria-label": tr("actionFormatAsStrongLabel"),
|
|
5626
|
-
children: /* @__PURE__ */ (0,
|
|
5659
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5627
5660
|
"i",
|
|
5628
5661
|
{
|
|
5629
|
-
className: `
|
|
5662
|
+
className: `c-rte-icon-bold c-rte-floating-text-format-tb-plugin__format-icon ${isBold ? "selected" : ""}`
|
|
5630
5663
|
}
|
|
5631
5664
|
)
|
|
5632
5665
|
}
|
|
5633
5666
|
),
|
|
5634
|
-
/* @__PURE__ */ (0,
|
|
5667
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5635
5668
|
IconButton,
|
|
5636
5669
|
{
|
|
5637
5670
|
style: { padding: 0, overflow: "hidden" },
|
|
5638
5671
|
onClick: () => {
|
|
5639
|
-
editor.dispatchCommand(
|
|
5672
|
+
editor.dispatchCommand(import_lexical9.FORMAT_TEXT_COMMAND, "italic");
|
|
5640
5673
|
},
|
|
5641
5674
|
title: tr("actionFormatAsEmphasizedTitle"),
|
|
5642
5675
|
"aria-label": tr("actionFormatAsEmphasizedLabel"),
|
|
5643
|
-
children: /* @__PURE__ */ (0,
|
|
5676
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5644
5677
|
"i",
|
|
5645
5678
|
{
|
|
5646
|
-
className: `
|
|
5679
|
+
className: `c-rte-icon-italic c-rte-floating-text-format-tb-plugin__format-icon ${isItalic ? "selected" : ""}`
|
|
5647
5680
|
}
|
|
5648
5681
|
)
|
|
5649
5682
|
}
|
|
5650
5683
|
),
|
|
5651
|
-
/* @__PURE__ */ (0,
|
|
5684
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5652
5685
|
IconButton,
|
|
5653
5686
|
{
|
|
5654
5687
|
style: { padding: 0, overflow: "hidden" },
|
|
5655
5688
|
onClick: () => {
|
|
5656
|
-
editor.dispatchCommand(
|
|
5689
|
+
editor.dispatchCommand(import_lexical9.FORMAT_TEXT_COMMAND, "underline");
|
|
5657
5690
|
},
|
|
5658
5691
|
title: tr("actionFormatAsUnderlinedTitle"),
|
|
5659
5692
|
"aria-label": tr("actionFormatAsUnderlinedLabel"),
|
|
5660
|
-
children: /* @__PURE__ */ (0,
|
|
5693
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5661
5694
|
"i",
|
|
5662
5695
|
{
|
|
5663
|
-
className: `
|
|
5696
|
+
className: `c-rte-icon-underline c-rte-floating-text-format-tb-plugin__format-icon ${isUnderline ? "selected" : ""}`
|
|
5664
5697
|
}
|
|
5665
5698
|
)
|
|
5666
5699
|
}
|
|
5667
5700
|
),
|
|
5668
|
-
/* @__PURE__ */ (0,
|
|
5701
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5669
5702
|
IconButton,
|
|
5670
5703
|
{
|
|
5671
5704
|
style: { padding: 0, overflow: "hidden" },
|
|
5672
5705
|
onClick: () => {
|
|
5673
|
-
editor.dispatchCommand(
|
|
5706
|
+
editor.dispatchCommand(import_lexical9.FORMAT_TEXT_COMMAND, "strikethrough");
|
|
5674
5707
|
},
|
|
5675
5708
|
title: tr("actionFormatWithStrikethroughTitle"),
|
|
5676
5709
|
"aria-label": tr("actionFormatWithStrikethroughLabel"),
|
|
5677
|
-
children: /* @__PURE__ */ (0,
|
|
5710
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5678
5711
|
"i",
|
|
5679
5712
|
{
|
|
5680
|
-
className: `
|
|
5713
|
+
className: `c-rte-icon-strikethrough c-rte-floating-text-format-tb-plugin__format-icon ${isStrikethrough ? "selected" : ""}`
|
|
5681
5714
|
}
|
|
5682
5715
|
)
|
|
5683
5716
|
}
|
|
5684
5717
|
),
|
|
5685
|
-
/* @__PURE__ */ (0,
|
|
5718
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5686
5719
|
IconButton,
|
|
5687
5720
|
{
|
|
5688
5721
|
style: { padding: 0, overflow: "hidden" },
|
|
5689
5722
|
onClick: () => {
|
|
5690
|
-
editor.dispatchCommand(
|
|
5723
|
+
editor.dispatchCommand(import_lexical9.FORMAT_TEXT_COMMAND, "subscript");
|
|
5691
5724
|
},
|
|
5692
5725
|
title: tr("actionFormatWithSubscriptTitle"),
|
|
5693
5726
|
"aria-label": tr("actionFormatWithSubscriptLabel"),
|
|
5694
|
-
children: /* @__PURE__ */ (0,
|
|
5727
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5695
5728
|
"i",
|
|
5696
5729
|
{
|
|
5697
|
-
className: `
|
|
5730
|
+
className: `c-rte-icon-subscript c-rte-floating-text-format-tb-plugin__format-icon ${isSubscript ? "selected" : ""}`
|
|
5698
5731
|
}
|
|
5699
5732
|
)
|
|
5700
5733
|
}
|
|
5701
5734
|
),
|
|
5702
|
-
/* @__PURE__ */ (0,
|
|
5735
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5703
5736
|
IconButton,
|
|
5704
5737
|
{
|
|
5705
5738
|
style: { padding: 0, overflow: "hidden" },
|
|
5706
5739
|
onClick: () => {
|
|
5707
|
-
editor.dispatchCommand(
|
|
5740
|
+
editor.dispatchCommand(import_lexical9.FORMAT_TEXT_COMMAND, "superscript");
|
|
5708
5741
|
},
|
|
5709
5742
|
title: tr("actionFormatWithSuperscriptTitle"),
|
|
5710
5743
|
"aria-label": tr("actionFormatWithSuperscriptLabel"),
|
|
5711
|
-
children: /* @__PURE__ */ (0,
|
|
5744
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5712
5745
|
"i",
|
|
5713
5746
|
{
|
|
5714
|
-
className: `
|
|
5747
|
+
className: `c-rte-icon-superscript c-rte-floating-text-format-tb-plugin__format-icon ${isSuperscript ? "selected" : ""}`
|
|
5715
5748
|
}
|
|
5716
5749
|
)
|
|
5717
5750
|
}
|
|
5718
5751
|
),
|
|
5719
|
-
/* @__PURE__ */ (0,
|
|
5752
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5720
5753
|
IconButton,
|
|
5721
5754
|
{
|
|
5722
5755
|
style: { padding: 0, overflow: "hidden" },
|
|
5723
5756
|
onClick: () => {
|
|
5724
|
-
editor.dispatchCommand(
|
|
5757
|
+
editor.dispatchCommand(import_lexical9.FORMAT_TEXT_COMMAND, "code");
|
|
5725
5758
|
},
|
|
5726
5759
|
"aria-label": tr("actionInsertCodeBlock"),
|
|
5727
|
-
children: /* @__PURE__ */ (0,
|
|
5760
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5728
5761
|
"i",
|
|
5729
5762
|
{
|
|
5730
|
-
className: `
|
|
5763
|
+
className: `c-rte-icon-code c-rte-floating-text-format-tb-plugin__format-icon ${isCode ? "selected" : ""}`
|
|
5731
5764
|
}
|
|
5732
5765
|
)
|
|
5733
5766
|
}
|
|
5734
5767
|
),
|
|
5735
|
-
/* @__PURE__ */ (0,
|
|
5768
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5736
5769
|
IconButton,
|
|
5737
5770
|
{
|
|
5738
5771
|
style: { padding: 0, overflow: "hidden" },
|
|
5739
5772
|
onClick: insertLink,
|
|
5740
5773
|
"aria-label": tr("actionInsertlink"),
|
|
5741
|
-
children: /* @__PURE__ */ (0,
|
|
5774
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5742
5775
|
"i",
|
|
5743
5776
|
{
|
|
5744
|
-
className: `
|
|
5777
|
+
className: `c-rte-icon-link c-rte-floating-text-format-tb-plugin__format-icon ${isLink ? "selected" : ""}`
|
|
5745
5778
|
}
|
|
5746
5779
|
)
|
|
5747
5780
|
}
|
|
@@ -5749,28 +5782,28 @@ function TextFormatFloatingToolbar({
|
|
|
5749
5782
|
] }) });
|
|
5750
5783
|
}
|
|
5751
5784
|
function useFloatingTextFormatToolbar(editor, anchorElem) {
|
|
5752
|
-
const [isText, setIsText] = (0,
|
|
5753
|
-
const [isLink, setIsLink] = (0,
|
|
5754
|
-
const [isBold, setIsBold] = (0,
|
|
5755
|
-
const [isItalic, setIsItalic] = (0,
|
|
5756
|
-
const [isUnderline, setIsUnderline] = (0,
|
|
5757
|
-
const [isStrikethrough, setIsStrikethrough] = (0,
|
|
5758
|
-
const [isSubscript, setIsSubscript] = (0,
|
|
5759
|
-
const [isSuperscript, setIsSuperscript] = (0,
|
|
5760
|
-
const [isCode, setIsCode] = (0,
|
|
5761
|
-
const updatePopup = (0,
|
|
5785
|
+
const [isText, setIsText] = (0, import_react76.useState)(false);
|
|
5786
|
+
const [isLink, setIsLink] = (0, import_react76.useState)(false);
|
|
5787
|
+
const [isBold, setIsBold] = (0, import_react76.useState)(false);
|
|
5788
|
+
const [isItalic, setIsItalic] = (0, import_react76.useState)(false);
|
|
5789
|
+
const [isUnderline, setIsUnderline] = (0, import_react76.useState)(false);
|
|
5790
|
+
const [isStrikethrough, setIsStrikethrough] = (0, import_react76.useState)(false);
|
|
5791
|
+
const [isSubscript, setIsSubscript] = (0, import_react76.useState)(false);
|
|
5792
|
+
const [isSuperscript, setIsSuperscript] = (0, import_react76.useState)(false);
|
|
5793
|
+
const [isCode, setIsCode] = (0, import_react76.useState)(false);
|
|
5794
|
+
const updatePopup = (0, import_react76.useCallback)(() => {
|
|
5762
5795
|
editor.getEditorState().read(() => {
|
|
5763
5796
|
if (editor.isComposing()) {
|
|
5764
5797
|
return;
|
|
5765
5798
|
}
|
|
5766
|
-
const selection = (0,
|
|
5799
|
+
const selection = (0, import_lexical9.$getSelection)();
|
|
5767
5800
|
const nativeSelection = window.getSelection();
|
|
5768
5801
|
const rootElement = editor.getRootElement();
|
|
5769
|
-
if (nativeSelection !== null && (!(0,
|
|
5802
|
+
if (nativeSelection !== null && (!(0, import_lexical9.$isRangeSelection)(selection) || rootElement === null || !rootElement.contains(nativeSelection.anchorNode))) {
|
|
5770
5803
|
setIsText(false);
|
|
5771
5804
|
return;
|
|
5772
5805
|
}
|
|
5773
|
-
if (!(0,
|
|
5806
|
+
if (!(0, import_lexical9.$isRangeSelection)(selection)) {
|
|
5774
5807
|
return;
|
|
5775
5808
|
}
|
|
5776
5809
|
const node = getSelectedNode(selection);
|
|
@@ -5788,19 +5821,19 @@ function useFloatingTextFormatToolbar(editor, anchorElem) {
|
|
|
5788
5821
|
setIsLink(false);
|
|
5789
5822
|
}
|
|
5790
5823
|
if (!(0, import_code8.$isCodeHighlightNode)(selection.anchor.getNode()) && selection.getTextContent() !== "") {
|
|
5791
|
-
setIsText((0,
|
|
5824
|
+
setIsText((0, import_lexical9.$isTextNode)(node));
|
|
5792
5825
|
} else {
|
|
5793
5826
|
setIsText(false);
|
|
5794
5827
|
}
|
|
5795
5828
|
});
|
|
5796
5829
|
}, [editor]);
|
|
5797
|
-
(0,
|
|
5830
|
+
(0, import_react76.useEffect)(() => {
|
|
5798
5831
|
document.addEventListener("selectionchange", updatePopup);
|
|
5799
5832
|
return () => {
|
|
5800
5833
|
document.removeEventListener("selectionchange", updatePopup);
|
|
5801
5834
|
};
|
|
5802
5835
|
}, [updatePopup]);
|
|
5803
|
-
(0,
|
|
5836
|
+
(0, import_react76.useEffect)(() => {
|
|
5804
5837
|
return (0, import_utils2.mergeRegister)(
|
|
5805
5838
|
editor.registerUpdateListener(() => {
|
|
5806
5839
|
updatePopup();
|
|
@@ -5816,7 +5849,7 @@ function useFloatingTextFormatToolbar(editor, anchorElem) {
|
|
|
5816
5849
|
return null;
|
|
5817
5850
|
}
|
|
5818
5851
|
return (0, import_react_dom4.createPortal)(
|
|
5819
|
-
/* @__PURE__ */ (0,
|
|
5852
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
|
|
5820
5853
|
TextFormatFloatingToolbar,
|
|
5821
5854
|
{
|
|
5822
5855
|
editor,
|
|
@@ -5842,33 +5875,28 @@ function FloatingTextFormatToolbarPlugin({
|
|
|
5842
5875
|
}
|
|
5843
5876
|
|
|
5844
5877
|
// src/rich-text-editor/plugins/LinkPlugin/index.tsx
|
|
5845
|
-
var import_LexicalLinkPlugin = require("@lexical/react/LexicalLinkPlugin");
|
|
5846
5878
|
var React6 = require("react");
|
|
5847
|
-
var
|
|
5879
|
+
var import_LexicalLinkPlugin = require("@lexical/react/LexicalLinkPlugin");
|
|
5880
|
+
var import_jsx_runtime91 = require("react/jsx-runtime");
|
|
5848
5881
|
function LinkPlugin() {
|
|
5849
|
-
return /* @__PURE__ */ (0,
|
|
5882
|
+
return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_LexicalLinkPlugin.LinkPlugin, { validateUrl });
|
|
5850
5883
|
}
|
|
5851
5884
|
|
|
5852
5885
|
// src/rich-text-editor/plugins/ListMaxIndentLevelPlugin/index.ts
|
|
5886
|
+
var import_react77 = require("react");
|
|
5887
|
+
var import_lexical10 = require("lexical");
|
|
5853
5888
|
var import_list4 = require("@lexical/list");
|
|
5854
5889
|
var import_LexicalComposerContext6 = require("@lexical/react/LexicalComposerContext");
|
|
5855
|
-
var import_lexical11 = require("lexical");
|
|
5856
|
-
var import_react76 = require("react");
|
|
5857
5890
|
function getElementNodesInSelection(selection) {
|
|
5858
5891
|
const nodesInSelection = selection.getNodes();
|
|
5859
5892
|
if (nodesInSelection.length === 0) {
|
|
5860
|
-
return /* @__PURE__ */ new Set([
|
|
5861
|
-
selection.anchor.getNode().getParentOrThrow(),
|
|
5862
|
-
selection.focus.getNode().getParentOrThrow()
|
|
5863
|
-
]);
|
|
5893
|
+
return /* @__PURE__ */ new Set([selection.anchor.getNode().getParentOrThrow(), selection.focus.getNode().getParentOrThrow()]);
|
|
5864
5894
|
}
|
|
5865
|
-
return new Set(
|
|
5866
|
-
nodesInSelection.map((n) => (0, import_lexical11.$isElementNode)(n) ? n : n.getParentOrThrow())
|
|
5867
|
-
);
|
|
5895
|
+
return new Set(nodesInSelection.map((n) => (0, import_lexical10.$isElementNode)(n) ? n : n.getParentOrThrow()));
|
|
5868
5896
|
}
|
|
5869
5897
|
function isIndentPermitted(maxDepth) {
|
|
5870
|
-
const selection = (0,
|
|
5871
|
-
if (!(0,
|
|
5898
|
+
const selection = (0, import_lexical10.$getSelection)();
|
|
5899
|
+
if (!(0, import_lexical10.$isRangeSelection)(selection)) {
|
|
5872
5900
|
return false;
|
|
5873
5901
|
}
|
|
5874
5902
|
const elementNodesInSelection = getElementNodesInSelection(selection);
|
|
@@ -5879,9 +5907,7 @@ function isIndentPermitted(maxDepth) {
|
|
|
5879
5907
|
} else if ((0, import_list4.$isListItemNode)(elementNode)) {
|
|
5880
5908
|
const parent2 = elementNode.getParent();
|
|
5881
5909
|
if (!(0, import_list4.$isListNode)(parent2)) {
|
|
5882
|
-
throw new Error(
|
|
5883
|
-
"ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent."
|
|
5884
|
-
);
|
|
5910
|
+
throw new Error("ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent.");
|
|
5885
5911
|
}
|
|
5886
5912
|
totalDepth = Math.max((0, import_list4.$getListDepth)(parent2) + 1, totalDepth);
|
|
5887
5913
|
}
|
|
@@ -5890,19 +5916,19 @@ function isIndentPermitted(maxDepth) {
|
|
|
5890
5916
|
}
|
|
5891
5917
|
function ListMaxIndentLevelPlugin({ maxDepth }) {
|
|
5892
5918
|
const [editor] = (0, import_LexicalComposerContext6.useLexicalComposerContext)();
|
|
5893
|
-
(0,
|
|
5919
|
+
(0, import_react77.useEffect)(() => {
|
|
5894
5920
|
return editor.registerCommand(
|
|
5895
|
-
|
|
5921
|
+
import_lexical10.INDENT_CONTENT_COMMAND,
|
|
5896
5922
|
() => !isIndentPermitted(maxDepth ?? 7),
|
|
5897
|
-
|
|
5923
|
+
import_lexical10.COMMAND_PRIORITY_CRITICAL
|
|
5898
5924
|
);
|
|
5899
5925
|
}, [editor, maxDepth]);
|
|
5900
5926
|
return null;
|
|
5901
5927
|
}
|
|
5902
5928
|
|
|
5903
5929
|
// src/rich-text-editor/plugins/MaxLengthPlugin/index.tsx
|
|
5904
|
-
var
|
|
5905
|
-
var
|
|
5930
|
+
var import_react78 = require("react");
|
|
5931
|
+
var import_lexical11 = require("lexical");
|
|
5906
5932
|
var import_LexicalComposerContext7 = require("@lexical/react/LexicalComposerContext");
|
|
5907
5933
|
var import_selection2 = require("@lexical/selection");
|
|
5908
5934
|
var import_utils3 = require("@lexical/utils");
|
|
@@ -5943,12 +5969,12 @@ ${content}
|
|
|
5943
5969
|
// src/rich-text-editor/plugins/MaxLengthPlugin/index.tsx
|
|
5944
5970
|
function MaxLengthPlugin({ maxLength }) {
|
|
5945
5971
|
const [editor] = (0, import_LexicalComposerContext7.useLexicalComposerContext)();
|
|
5946
|
-
(0,
|
|
5972
|
+
(0, import_react78.useEffect)(() => {
|
|
5947
5973
|
let lastRestoredEditorState = null;
|
|
5948
5974
|
return editor.registerUpdateListener(({ editorState, prevEditorState }) => {
|
|
5949
5975
|
editor.update(() => {
|
|
5950
|
-
const selection = (0,
|
|
5951
|
-
if (!(0,
|
|
5976
|
+
const selection = (0, import_lexical11.$getSelection)();
|
|
5977
|
+
if (!(0, import_lexical11.$isRangeSelection)(selection) || !selection.isCollapsed()) {
|
|
5952
5978
|
return;
|
|
5953
5979
|
}
|
|
5954
5980
|
const prevTextContent = toText(lexicalToCrystallizeRichText({ editor, editorState: prevEditorState }));
|
|
@@ -5973,8 +5999,8 @@ function MaxLengthPlugin({ maxLength }) {
|
|
|
5973
5999
|
}
|
|
5974
6000
|
|
|
5975
6001
|
// src/rich-text-editor/plugins/TabFocusPlugin/index.tsx
|
|
5976
|
-
var
|
|
5977
|
-
var
|
|
6002
|
+
var import_react79 = require("react");
|
|
6003
|
+
var import_lexical12 = require("lexical");
|
|
5978
6004
|
var import_LexicalComposerContext8 = require("@lexical/react/LexicalComposerContext");
|
|
5979
6005
|
var COMMAND_PRIORITY_LOW3 = 1;
|
|
5980
6006
|
var TAB_TO_FOCUS_INTERVAL = 100;
|
|
@@ -5993,18 +6019,18 @@ function registerKeyTimeStampTracker() {
|
|
|
5993
6019
|
}
|
|
5994
6020
|
function TabFocusPlugin() {
|
|
5995
6021
|
const [editor] = (0, import_LexicalComposerContext8.useLexicalComposerContext)();
|
|
5996
|
-
(0,
|
|
6022
|
+
(0, import_react79.useEffect)(() => {
|
|
5997
6023
|
if (!hasRegisteredKeyDownListener) {
|
|
5998
6024
|
registerKeyTimeStampTracker();
|
|
5999
6025
|
hasRegisteredKeyDownListener = true;
|
|
6000
6026
|
}
|
|
6001
6027
|
return editor.registerCommand(
|
|
6002
|
-
|
|
6028
|
+
import_lexical12.FOCUS_COMMAND,
|
|
6003
6029
|
(event) => {
|
|
6004
|
-
const selection = (0,
|
|
6005
|
-
if ((0,
|
|
6030
|
+
const selection = (0, import_lexical12.$getSelection)();
|
|
6031
|
+
if ((0, import_lexical12.$isRangeSelection)(selection)) {
|
|
6006
6032
|
if (lastTabKeyDownTimestamp + TAB_TO_FOCUS_INTERVAL > event.timeStamp) {
|
|
6007
|
-
(0,
|
|
6033
|
+
(0, import_lexical12.$setSelection)(selection.clone());
|
|
6008
6034
|
}
|
|
6009
6035
|
}
|
|
6010
6036
|
return false;
|
|
@@ -6016,22 +6042,22 @@ function TabFocusPlugin() {
|
|
|
6016
6042
|
}
|
|
6017
6043
|
|
|
6018
6044
|
// src/rich-text-editor/plugins/TableActionMenuPlugin/index.tsx
|
|
6019
|
-
var
|
|
6020
|
-
var
|
|
6045
|
+
var import_react80 = require("react");
|
|
6046
|
+
var import_lexical13 = require("lexical");
|
|
6021
6047
|
var import_react_dom5 = require("react-dom");
|
|
6022
6048
|
var import_LexicalComposerContext9 = require("@lexical/react/LexicalComposerContext");
|
|
6023
6049
|
var import_useLexicalEditable = __toESM(require("@lexical/react/useLexicalEditable"));
|
|
6024
6050
|
var import_table4 = require("@lexical/table");
|
|
6025
|
-
var
|
|
6051
|
+
var import_jsx_runtime92 = require("react/jsx-runtime");
|
|
6026
6052
|
function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
6027
6053
|
const [editor] = (0, import_LexicalComposerContext9.useLexicalComposerContext)();
|
|
6028
|
-
const [tableCellNode, updateTableCellNode] = (0,
|
|
6029
|
-
const [selectionCounts, updateSelectionCounts] = (0,
|
|
6054
|
+
const [tableCellNode, updateTableCellNode] = (0, import_react80.useState)(_tableCellNode);
|
|
6055
|
+
const [selectionCounts, updateSelectionCounts] = (0, import_react80.useState)({
|
|
6030
6056
|
columns: 1,
|
|
6031
6057
|
rows: 1
|
|
6032
6058
|
});
|
|
6033
6059
|
const tr = useTr();
|
|
6034
|
-
(0,
|
|
6060
|
+
(0, import_react80.useEffect)(() => {
|
|
6035
6061
|
return editor.registerMutationListener(import_table4.TableCellNode, (nodeMutations) => {
|
|
6036
6062
|
const nodeUpdated = nodeMutations.get(tableCellNode.getKey()) === "updated";
|
|
6037
6063
|
if (nodeUpdated) {
|
|
@@ -6041,10 +6067,10 @@ function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
|
6041
6067
|
}
|
|
6042
6068
|
});
|
|
6043
6069
|
}, [editor, tableCellNode]);
|
|
6044
|
-
(0,
|
|
6070
|
+
(0, import_react80.useEffect)(() => {
|
|
6045
6071
|
editor.getEditorState().read(() => {
|
|
6046
|
-
const selection = (0,
|
|
6047
|
-
if ((0,
|
|
6072
|
+
const selection = (0, import_lexical13.$getSelection)();
|
|
6073
|
+
if ((0, import_lexical13.DEPRECATED_$isGridSelection)(selection)) {
|
|
6048
6074
|
const selectionShape = selection.getShape();
|
|
6049
6075
|
updateSelectionCounts({
|
|
6050
6076
|
columns: selectionShape.toX - selectionShape.fromX + 1,
|
|
@@ -6053,7 +6079,7 @@ function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
|
6053
6079
|
}
|
|
6054
6080
|
});
|
|
6055
6081
|
}, [editor]);
|
|
6056
|
-
const clearTableSelection = (0,
|
|
6082
|
+
const clearTableSelection = (0, import_react80.useCallback)(() => {
|
|
6057
6083
|
editor.update(() => {
|
|
6058
6084
|
if (tableCellNode.isAttached()) {
|
|
6059
6085
|
const tableNode = (0, import_table4.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
|
|
@@ -6068,17 +6094,17 @@ function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
|
6068
6094
|
tableNode.markDirty();
|
|
6069
6095
|
updateTableCellNode(tableCellNode.getLatest());
|
|
6070
6096
|
}
|
|
6071
|
-
const rootNode = (0,
|
|
6097
|
+
const rootNode = (0, import_lexical13.$getRoot)();
|
|
6072
6098
|
rootNode.selectStart();
|
|
6073
6099
|
});
|
|
6074
6100
|
}, [editor, tableCellNode]);
|
|
6075
|
-
const insertTableRowAtSelection = (0,
|
|
6101
|
+
const insertTableRowAtSelection = (0, import_react80.useCallback)(
|
|
6076
6102
|
(shouldInsertAfter) => {
|
|
6077
6103
|
editor.update(() => {
|
|
6078
|
-
const selection = (0,
|
|
6104
|
+
const selection = (0, import_lexical13.$getSelection)();
|
|
6079
6105
|
const tableNode = (0, import_table4.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
|
|
6080
6106
|
let tableRowIndex;
|
|
6081
|
-
if ((0,
|
|
6107
|
+
if ((0, import_lexical13.DEPRECATED_$isGridSelection)(selection)) {
|
|
6082
6108
|
const selectionShape = selection.getShape();
|
|
6083
6109
|
tableRowIndex = shouldInsertAfter ? selectionShape.toY : selectionShape.fromY;
|
|
6084
6110
|
} else {
|
|
@@ -6091,13 +6117,13 @@ function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
|
6091
6117
|
},
|
|
6092
6118
|
[editor, tableCellNode, selectionCounts.rows, clearTableSelection]
|
|
6093
6119
|
);
|
|
6094
|
-
const insertTableColumnAtSelection = (0,
|
|
6120
|
+
const insertTableColumnAtSelection = (0, import_react80.useCallback)(
|
|
6095
6121
|
(shouldInsertAfter) => {
|
|
6096
6122
|
editor.update(() => {
|
|
6097
|
-
const selection = (0,
|
|
6123
|
+
const selection = (0, import_lexical13.$getSelection)();
|
|
6098
6124
|
const tableNode = (0, import_table4.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
|
|
6099
6125
|
let tableColumnIndex;
|
|
6100
|
-
if ((0,
|
|
6126
|
+
if ((0, import_lexical13.DEPRECATED_$isGridSelection)(selection)) {
|
|
6101
6127
|
const selectionShape = selection.getShape();
|
|
6102
6128
|
tableColumnIndex = shouldInsertAfter ? selectionShape.toX : selectionShape.fromX;
|
|
6103
6129
|
} else {
|
|
@@ -6110,7 +6136,7 @@ function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
|
6110
6136
|
},
|
|
6111
6137
|
[editor, tableCellNode, selectionCounts.columns, clearTableSelection]
|
|
6112
6138
|
);
|
|
6113
|
-
const deleteTableRowAtSelection = (0,
|
|
6139
|
+
const deleteTableRowAtSelection = (0, import_react80.useCallback)(() => {
|
|
6114
6140
|
editor.update(() => {
|
|
6115
6141
|
const tableNode = (0, import_table4.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
|
|
6116
6142
|
const tableRowIndex = (0, import_table4.$getTableRowIndexFromTableCellNode)(tableCellNode);
|
|
@@ -6118,14 +6144,14 @@ function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
|
6118
6144
|
clearTableSelection();
|
|
6119
6145
|
});
|
|
6120
6146
|
}, [editor, tableCellNode, clearTableSelection]);
|
|
6121
|
-
const deleteTableAtSelection = (0,
|
|
6147
|
+
const deleteTableAtSelection = (0, import_react80.useCallback)(() => {
|
|
6122
6148
|
editor.update(() => {
|
|
6123
6149
|
const tableNode = (0, import_table4.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
|
|
6124
6150
|
tableNode.remove();
|
|
6125
6151
|
clearTableSelection();
|
|
6126
6152
|
});
|
|
6127
6153
|
}, [editor, tableCellNode, clearTableSelection]);
|
|
6128
|
-
const deleteTableColumnAtSelection = (0,
|
|
6154
|
+
const deleteTableColumnAtSelection = (0, import_react80.useCallback)(() => {
|
|
6129
6155
|
editor.update(() => {
|
|
6130
6156
|
const tableNode = (0, import_table4.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
|
|
6131
6157
|
const tableColumnIndex = (0, import_table4.$getTableColumnIndexFromTableCellNode)(tableCellNode);
|
|
@@ -6133,7 +6159,7 @@ function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
|
6133
6159
|
clearTableSelection();
|
|
6134
6160
|
});
|
|
6135
6161
|
}, [editor, tableCellNode, clearTableSelection]);
|
|
6136
|
-
const toggleTableRowIsHeader = (0,
|
|
6162
|
+
const toggleTableRowIsHeader = (0, import_react80.useCallback)(() => {
|
|
6137
6163
|
editor.update(() => {
|
|
6138
6164
|
const tableNode = (0, import_table4.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
|
|
6139
6165
|
const tableRowIndex = (0, import_table4.$getTableRowIndexFromTableCellNode)(tableCellNode);
|
|
@@ -6154,7 +6180,7 @@ function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
|
6154
6180
|
clearTableSelection();
|
|
6155
6181
|
});
|
|
6156
6182
|
}, [editor, tableCellNode, clearTableSelection]);
|
|
6157
|
-
const toggleTableColumnIsHeader = (0,
|
|
6183
|
+
const toggleTableColumnIsHeader = (0, import_react80.useCallback)(() => {
|
|
6158
6184
|
editor.update(() => {
|
|
6159
6185
|
const tableNode = (0, import_table4.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
|
|
6160
6186
|
const tableColumnIndex = (0, import_table4.$getTableColumnIndexFromTableCellNode)(tableCellNode);
|
|
@@ -6177,36 +6203,36 @@ function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
|
6177
6203
|
clearTableSelection();
|
|
6178
6204
|
});
|
|
6179
6205
|
}, [editor, tableCellNode, clearTableSelection]);
|
|
6180
|
-
return /* @__PURE__ */ (0,
|
|
6181
|
-
/* @__PURE__ */ (0,
|
|
6182
|
-
/* @__PURE__ */ (0,
|
|
6183
|
-
/* @__PURE__ */ (0,
|
|
6184
|
-
/* @__PURE__ */ (0,
|
|
6185
|
-
/* @__PURE__ */ (0,
|
|
6206
|
+
return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [
|
|
6207
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DropdownMenu.Item, { onSelect: () => insertTableRowAtSelection(false), children: tr("actionTableInsertRowsAbove", selectionCounts.rows) }),
|
|
6208
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DropdownMenu.Item, { onSelect: () => insertTableRowAtSelection(true), children: tr("actionTableInsertRowsBelow", selectionCounts.rows) }),
|
|
6209
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DropdownMenu.Item, { onSelect: () => insertTableColumnAtSelection(false), children: tr("actionTableInsertColumnsBefore", selectionCounts.columns) }),
|
|
6210
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DropdownMenu.Item, { onSelect: () => insertTableColumnAtSelection(true), children: tr("actionTableInsertColumnsAfter", selectionCounts.columns) }),
|
|
6211
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DropdownMenu.Item, { onSelect: () => toggleTableRowIsHeader(), children: tr(
|
|
6186
6212
|
(tableCellNode.__headerState & import_table4.TableCellHeaderStates.ROW) === import_table4.TableCellHeaderStates.ROW ? "actionTableRemoveRowHeader" : "actionTableAddRowHeader"
|
|
6187
6213
|
) }),
|
|
6188
|
-
/* @__PURE__ */ (0,
|
|
6214
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DropdownMenu.Item, { onSelect: () => toggleTableColumnIsHeader(), children: tr(
|
|
6189
6215
|
(tableCellNode.__headerState & import_table4.TableCellHeaderStates.COLUMN) === import_table4.TableCellHeaderStates.COLUMN ? "actionTableRemoveColumnHeader" : "actionTableAddColumnHeader"
|
|
6190
6216
|
) }),
|
|
6191
|
-
/* @__PURE__ */ (0,
|
|
6192
|
-
tableStats.columns > 1 && /* @__PURE__ */ (0,
|
|
6193
|
-
tableStats.rows > 1 && /* @__PURE__ */ (0,
|
|
6194
|
-
/* @__PURE__ */ (0,
|
|
6217
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DropdownMenu.Separator, {}),
|
|
6218
|
+
tableStats.columns > 1 && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DropdownMenu.Item, { onSelect: () => deleteTableColumnAtSelection(), children: tr("actionTableDeleteColumn") }),
|
|
6219
|
+
tableStats.rows > 1 && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DropdownMenu.Item, { onSelect: () => deleteTableRowAtSelection(), children: tr("actionTableDeleteRow") }),
|
|
6220
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DropdownMenu.Item, { onSelect: () => deleteTableAtSelection(), children: tr("actionTableDeleteTable") })
|
|
6195
6221
|
] });
|
|
6196
6222
|
}
|
|
6197
6223
|
function TableCellActionMenuContainer({ anchorElem }) {
|
|
6198
6224
|
const [editor] = (0, import_LexicalComposerContext9.useLexicalComposerContext)();
|
|
6199
6225
|
const tr = useTr();
|
|
6200
|
-
const menuButtonRef = (0,
|
|
6201
|
-
const [isMenuOpen, setIsMenuOpen] = (0,
|
|
6202
|
-
const [tableCellNode, setTableMenuCellNode] = (0,
|
|
6203
|
-
const [tableStats, setTablestats] = (0,
|
|
6204
|
-
const moveMenu = (0,
|
|
6226
|
+
const menuButtonRef = (0, import_react80.useRef)(null);
|
|
6227
|
+
const [isMenuOpen, setIsMenuOpen] = (0, import_react80.useState)(false);
|
|
6228
|
+
const [tableCellNode, setTableMenuCellNode] = (0, import_react80.useState)(null);
|
|
6229
|
+
const [tableStats, setTablestats] = (0, import_react80.useState)({ rows: 1, columns: 1 });
|
|
6230
|
+
const moveMenu = (0, import_react80.useCallback)(() => {
|
|
6205
6231
|
if (isMenuOpen) {
|
|
6206
6232
|
return;
|
|
6207
6233
|
}
|
|
6208
6234
|
const menu = menuButtonRef.current;
|
|
6209
|
-
const selection = (0,
|
|
6235
|
+
const selection = (0, import_lexical13.$getSelection)();
|
|
6210
6236
|
const nativeSelection = window.getSelection();
|
|
6211
6237
|
const activeElement = document.activeElement;
|
|
6212
6238
|
if (selection == null || menu == null) {
|
|
@@ -6214,7 +6240,7 @@ function TableCellActionMenuContainer({ anchorElem }) {
|
|
|
6214
6240
|
return;
|
|
6215
6241
|
}
|
|
6216
6242
|
const rootElement = editor.getRootElement();
|
|
6217
|
-
if ((0,
|
|
6243
|
+
if ((0, import_lexical13.$isRangeSelection)(selection) && rootElement !== null && nativeSelection !== null && rootElement.contains(nativeSelection.anchorNode)) {
|
|
6218
6244
|
const tableCellNodeFromSelection = (0, import_table4.$getTableCellNodeFromLexicalNode)(selection.anchor.getNode());
|
|
6219
6245
|
if (tableCellNodeFromSelection == null) {
|
|
6220
6246
|
setTableMenuCellNode(null);
|
|
@@ -6244,14 +6270,14 @@ function TableCellActionMenuContainer({ anchorElem }) {
|
|
|
6244
6270
|
setTableMenuCellNode(null);
|
|
6245
6271
|
}
|
|
6246
6272
|
}, [editor, isMenuOpen]);
|
|
6247
|
-
(0,
|
|
6273
|
+
(0, import_react80.useEffect)(() => {
|
|
6248
6274
|
return editor.registerUpdateListener(() => {
|
|
6249
6275
|
editor.getEditorState().read(() => {
|
|
6250
6276
|
moveMenu();
|
|
6251
6277
|
});
|
|
6252
6278
|
});
|
|
6253
6279
|
});
|
|
6254
|
-
(0,
|
|
6280
|
+
(0, import_react80.useEffect)(() => {
|
|
6255
6281
|
const menuButtonDOM = menuButtonRef.current;
|
|
6256
6282
|
if (menuButtonDOM != null && tableCellNode != null) {
|
|
6257
6283
|
const tableCellNodeDOM = editor.getElementByKey(tableCellNode.getKey());
|
|
@@ -6269,12 +6295,12 @@ function TableCellActionMenuContainer({ anchorElem }) {
|
|
|
6269
6295
|
}
|
|
6270
6296
|
}
|
|
6271
6297
|
}, [menuButtonRef, tableCellNode, editor, anchorElem]);
|
|
6272
|
-
return /* @__PURE__ */ (0,
|
|
6298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("div", { className: "c-rte-table-cell-action-button-container", ref: menuButtonRef, children: tableCellNode != null && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
|
|
6273
6299
|
DropdownMenu.Root,
|
|
6274
6300
|
{
|
|
6275
6301
|
onOpenChange: (isOpen) => setIsMenuOpen(isOpen),
|
|
6276
|
-
content: /* @__PURE__ */ (0,
|
|
6277
|
-
children: /* @__PURE__ */ (0,
|
|
6302
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(TableActionMenu, { tableCellNode, tableStats }),
|
|
6303
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(IconButton, { size: "xs", "aria-label": tr("actionTableOpenOptions"), children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Icon.Arrow, {}) })
|
|
6278
6304
|
}
|
|
6279
6305
|
) });
|
|
6280
6306
|
}
|
|
@@ -6282,12 +6308,12 @@ function TableActionMenuPlugin({
|
|
|
6282
6308
|
anchorElem = document.body
|
|
6283
6309
|
}) {
|
|
6284
6310
|
const isEditable = (0, import_useLexicalEditable.default)();
|
|
6285
|
-
return (0, import_react_dom5.createPortal)(isEditable ? /* @__PURE__ */ (0,
|
|
6311
|
+
return (0, import_react_dom5.createPortal)(isEditable ? /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(TableCellActionMenuContainer, { anchorElem }) : null, anchorElem);
|
|
6286
6312
|
}
|
|
6287
6313
|
|
|
6288
6314
|
// src/rich-text-editor/plugins/ToolbarPlugin/index.tsx
|
|
6289
|
-
var
|
|
6290
|
-
var
|
|
6315
|
+
var import_react83 = require("react");
|
|
6316
|
+
var import_lexical15 = require("lexical");
|
|
6291
6317
|
var import_code9 = require("@lexical/code");
|
|
6292
6318
|
var import_link6 = require("@lexical/link");
|
|
6293
6319
|
var import_list5 = require("@lexical/list");
|
|
@@ -6299,10 +6325,10 @@ var import_selection3 = require("@lexical/selection");
|
|
|
6299
6325
|
var import_utils4 = require("@lexical/utils");
|
|
6300
6326
|
|
|
6301
6327
|
// src/rich-text-editor/plugins/ActionsPlugin/index.tsx
|
|
6302
|
-
var
|
|
6303
|
-
var
|
|
6328
|
+
var import_react81 = require("react");
|
|
6329
|
+
var import_lexical14 = require("lexical");
|
|
6304
6330
|
var import_LexicalComposerContext10 = require("@lexical/react/LexicalComposerContext");
|
|
6305
|
-
var
|
|
6331
|
+
var import_jsx_runtime93 = require("react/jsx-runtime");
|
|
6306
6332
|
async function copyJson(editor) {
|
|
6307
6333
|
const json = lexicalToCrystallizeRichText({ editor, editorState: editor.getEditorState() });
|
|
6308
6334
|
try {
|
|
@@ -6317,51 +6343,48 @@ function ActionsPlugin({
|
|
|
6317
6343
|
}) {
|
|
6318
6344
|
const [editor] = (0, import_LexicalComposerContext10.useLexicalComposerContext)();
|
|
6319
6345
|
const tr = useTr();
|
|
6320
|
-
const actionMenuAnchorRef = (0,
|
|
6321
|
-
return /* @__PURE__ */ (0,
|
|
6322
|
-
/* @__PURE__ */ (0,
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
{
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
editor.dispatchCommand(import_lexical15.CLEAR_EDITOR_COMMAND, void 0);
|
|
6340
|
-
editor.focus();
|
|
6341
|
-
},
|
|
6342
|
-
children: tr("actionClear")
|
|
6343
|
-
}
|
|
6344
|
-
),
|
|
6345
|
-
!append ? null : append.map((actionItem) => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
|
|
6346
|
-
ActionMenu.Item,
|
|
6347
|
-
{
|
|
6348
|
-
onSelect: actionItem.action,
|
|
6349
|
-
className: actionItem.type === "danger" ? "danger" : "",
|
|
6350
|
-
children: actionItem.title
|
|
6346
|
+
const actionMenuAnchorRef = (0, import_react81.useRef)(null);
|
|
6347
|
+
return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { ref: actionMenuAnchorRef, className: "c-rte-actions-plugin", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(ActionMenu, { container: actionMenuAnchorRef.current, children: [
|
|
6348
|
+
!prepend ? null : prepend.map((actionItem) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
6349
|
+
ActionMenu.Item,
|
|
6350
|
+
{
|
|
6351
|
+
onSelect: actionItem.action,
|
|
6352
|
+
className: actionItem.type === "danger" ? "danger" : "",
|
|
6353
|
+
children: actionItem.title
|
|
6354
|
+
},
|
|
6355
|
+
actionItem.title
|
|
6356
|
+
)),
|
|
6357
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ActionMenu.Item, { onSelect: () => copyJson(editor), children: tr("actionCopyJSON") }),
|
|
6358
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
6359
|
+
ActionMenu.Item,
|
|
6360
|
+
{
|
|
6361
|
+
className: "danger",
|
|
6362
|
+
onSelect: () => {
|
|
6363
|
+
editor.dispatchCommand(import_lexical14.CLEAR_EDITOR_COMMAND, void 0);
|
|
6364
|
+
editor.focus();
|
|
6351
6365
|
},
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6366
|
+
children: tr("actionClear")
|
|
6367
|
+
}
|
|
6368
|
+
),
|
|
6369
|
+
!append ? null : append.map((actionItem) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
6370
|
+
ActionMenu.Item,
|
|
6371
|
+
{
|
|
6372
|
+
onSelect: actionItem.action,
|
|
6373
|
+
className: actionItem.type === "danger" ? "danger" : "",
|
|
6374
|
+
children: actionItem.title
|
|
6375
|
+
},
|
|
6376
|
+
actionItem.title
|
|
6377
|
+
))
|
|
6378
|
+
] }) });
|
|
6356
6379
|
}
|
|
6357
6380
|
|
|
6358
6381
|
// src/rich-text-editor/plugins/ToolbarPlugin/insert-table.tsx
|
|
6359
|
-
var
|
|
6382
|
+
var import_react82 = require("react");
|
|
6360
6383
|
var import_table5 = require("@lexical/table");
|
|
6361
|
-
var
|
|
6384
|
+
var import_jsx_runtime94 = require("react/jsx-runtime");
|
|
6362
6385
|
function InsertTableDialog({ activeEditor }) {
|
|
6363
|
-
const [rows, setRows] = (0,
|
|
6364
|
-
const [columns, setColumns] = (0,
|
|
6386
|
+
const [rows, setRows] = (0, import_react82.useState)("5");
|
|
6387
|
+
const [columns, setColumns] = (0, import_react82.useState)("5");
|
|
6365
6388
|
const tr = useTr();
|
|
6366
6389
|
const onClick = () => {
|
|
6367
6390
|
if (parseInt(rows) < 1 || parseInt(columns) < 1) {
|
|
@@ -6376,9 +6399,9 @@ function InsertTableDialog({ activeEditor }) {
|
|
|
6376
6399
|
}
|
|
6377
6400
|
});
|
|
6378
6401
|
};
|
|
6379
|
-
return /* @__PURE__ */ (0,
|
|
6380
|
-
/* @__PURE__ */ (0,
|
|
6381
|
-
/* @__PURE__ */ (0,
|
|
6402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "c-rte-insert-table", children: [
|
|
6403
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "c-rte-insert-table__dimensions", children: [
|
|
6404
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
6382
6405
|
InputWithLabel,
|
|
6383
6406
|
{
|
|
6384
6407
|
label: tr("insertTableRows"),
|
|
@@ -6389,8 +6412,8 @@ function InsertTableDialog({ activeEditor }) {
|
|
|
6389
6412
|
onChange: (e) => setRows(e.target.value)
|
|
6390
6413
|
}
|
|
6391
6414
|
),
|
|
6392
|
-
/* @__PURE__ */ (0,
|
|
6393
|
-
/* @__PURE__ */ (0,
|
|
6415
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)("span", { className: "c-rte-insert-table__dimensions__separator" }),
|
|
6416
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
6394
6417
|
InputWithLabel,
|
|
6395
6418
|
{
|
|
6396
6419
|
type: "text",
|
|
@@ -6402,12 +6425,12 @@ function InsertTableDialog({ activeEditor }) {
|
|
|
6402
6425
|
}
|
|
6403
6426
|
)
|
|
6404
6427
|
] }),
|
|
6405
|
-
/* @__PURE__ */ (0,
|
|
6428
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: "c-rte-insert-table__actions", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Button, { as: Dialog.Close, size: "sm", intent: "action", "aria-label": tr("insertTableCommit"), onClick, children: tr("insertTableCommit") }) })
|
|
6406
6429
|
] });
|
|
6407
6430
|
}
|
|
6408
6431
|
|
|
6409
6432
|
// src/rich-text-editor/plugins/ToolbarPlugin/index.tsx
|
|
6410
|
-
var
|
|
6433
|
+
var import_jsx_runtime95 = require("react/jsx-runtime");
|
|
6411
6434
|
var headingTypeToBlockName = {
|
|
6412
6435
|
h1: "Heading 1",
|
|
6413
6436
|
h2: "Heading 2",
|
|
@@ -6448,17 +6471,17 @@ function BlockFormatDropDown({
|
|
|
6448
6471
|
const formatParagraph = () => {
|
|
6449
6472
|
if (blockType !== "paragraph") {
|
|
6450
6473
|
editor.update(() => {
|
|
6451
|
-
const selection = (0,
|
|
6452
|
-
if ((0,
|
|
6453
|
-
(0, import_selection3.$setBlocksType)(selection, () => (0,
|
|
6474
|
+
const selection = (0, import_lexical15.$getSelection)();
|
|
6475
|
+
if ((0, import_lexical15.$isRangeSelection)(selection) || (0, import_lexical15.DEPRECATED_$isGridSelection)(selection))
|
|
6476
|
+
(0, import_selection3.$setBlocksType)(selection, () => (0, import_lexical15.$createParagraphNode)());
|
|
6454
6477
|
});
|
|
6455
6478
|
}
|
|
6456
6479
|
};
|
|
6457
6480
|
const formatHeading = (headingSize) => {
|
|
6458
6481
|
if (blockType !== headingSize) {
|
|
6459
6482
|
editor.update(() => {
|
|
6460
|
-
const selection = (0,
|
|
6461
|
-
if ((0,
|
|
6483
|
+
const selection = (0, import_lexical15.$getSelection)();
|
|
6484
|
+
if ((0, import_lexical15.$isRangeSelection)(selection) || (0, import_lexical15.DEPRECATED_$isGridSelection)(selection)) {
|
|
6462
6485
|
(0, import_selection3.$setBlocksType)(selection, () => (0, import_rich_text4.$createHeadingNode)(headingSize));
|
|
6463
6486
|
}
|
|
6464
6487
|
});
|
|
@@ -6481,11 +6504,11 @@ function BlockFormatDropDown({
|
|
|
6481
6504
|
const formatQuote = () => {
|
|
6482
6505
|
if (blockType !== "quote") {
|
|
6483
6506
|
editor.update(() => {
|
|
6484
|
-
const selection = (0,
|
|
6485
|
-
if ((0,
|
|
6507
|
+
const selection = (0, import_lexical15.$getSelection)();
|
|
6508
|
+
if ((0, import_lexical15.$isRangeSelection)(selection) || (0, import_lexical15.DEPRECATED_$isGridSelection)(selection)) {
|
|
6486
6509
|
(0, import_selection3.$setBlocksType)(selection, () => (0, import_rich_text4.$createQuoteNode)());
|
|
6487
6510
|
} else {
|
|
6488
|
-
(0, import_selection3.$setBlocksType)((0,
|
|
6511
|
+
(0, import_selection3.$setBlocksType)((0, import_lexical15.$getRoot)().select(), () => (0, import_rich_text4.$createQuoteNode)());
|
|
6489
6512
|
}
|
|
6490
6513
|
});
|
|
6491
6514
|
}
|
|
@@ -6493,95 +6516,94 @@ function BlockFormatDropDown({
|
|
|
6493
6516
|
const formatCode = () => {
|
|
6494
6517
|
if (blockType !== "code") {
|
|
6495
6518
|
editor.update(() => {
|
|
6496
|
-
let selection = (0,
|
|
6497
|
-
if ((0,
|
|
6519
|
+
let selection = (0, import_lexical15.$getSelection)();
|
|
6520
|
+
if ((0, import_lexical15.$isRangeSelection)(selection) || (0, import_lexical15.DEPRECATED_$isGridSelection)(selection)) {
|
|
6498
6521
|
if (selection.isCollapsed()) {
|
|
6499
6522
|
(0, import_selection3.$setBlocksType)(selection, () => (0, import_code9.$createCodeNode)());
|
|
6500
6523
|
} else {
|
|
6501
6524
|
const textContent = selection.getTextContent();
|
|
6502
6525
|
const codeNode = (0, import_code9.$createCodeNode)();
|
|
6503
6526
|
selection.insertNodes([codeNode]);
|
|
6504
|
-
selection = (0,
|
|
6505
|
-
if ((0,
|
|
6527
|
+
selection = (0, import_lexical15.$getSelection)();
|
|
6528
|
+
if ((0, import_lexical15.$isRangeSelection)(selection))
|
|
6506
6529
|
selection.insertRawText(textContent);
|
|
6507
6530
|
}
|
|
6508
6531
|
} else {
|
|
6509
|
-
(0, import_selection3.$setBlocksType)((0,
|
|
6532
|
+
(0, import_selection3.$setBlocksType)((0, import_lexical15.$getRoot)().select(), () => (0, import_code9.$createCodeNode)());
|
|
6510
6533
|
}
|
|
6511
6534
|
});
|
|
6512
6535
|
}
|
|
6513
6536
|
};
|
|
6514
|
-
return /* @__PURE__ */ (0,
|
|
6537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6515
6538
|
DropdownMenu.Root,
|
|
6516
6539
|
{
|
|
6517
6540
|
disabled,
|
|
6518
6541
|
style: { zIndex: 1 },
|
|
6519
|
-
content: /* @__PURE__ */ (0,
|
|
6520
|
-
/* @__PURE__ */ (0,
|
|
6521
|
-
/* @__PURE__ */ (0,
|
|
6542
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_jsx_runtime95.Fragment, { children: [
|
|
6543
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(DropdownMenu.Item, { onClick: formatParagraph, children: [
|
|
6544
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6522
6545
|
"i",
|
|
6523
6546
|
{
|
|
6524
|
-
className: `
|
|
6547
|
+
className: `c-rte-icon-paragraph c-rte-toolbar__block-format__icon ${blockType === "paragraph" ? "selected" : ""}`
|
|
6525
6548
|
}
|
|
6526
6549
|
),
|
|
6527
|
-
/* @__PURE__ */ (0,
|
|
6528
|
-
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)("span", { className: `${blockType === "paragraph" ? "font-bold" : "font-normal"} text-sm px-3 min-w-[150px]`, children: "Normal" })
|
|
6550
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: `c-rte-toolbar__block-format__text ${blockType === "paragraph" ? "selected" : ""}`, children: "Normal" })
|
|
6529
6551
|
] }),
|
|
6530
|
-
headings.map((headingSize) => /* @__PURE__ */ (0,
|
|
6531
|
-
/* @__PURE__ */ (0,
|
|
6552
|
+
headings.map((headingSize) => /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(DropdownMenu.Item, { onClick: () => formatHeading(headingSize), children: [
|
|
6553
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6532
6554
|
"i",
|
|
6533
6555
|
{
|
|
6534
|
-
className: `icon
|
|
6556
|
+
className: `c-rte-icon-${headingSize} c-rte-toolbar__block-format__icon ${blockType === headingSize ? "selected" : ""}`
|
|
6535
6557
|
}
|
|
6536
6558
|
),
|
|
6537
|
-
/* @__PURE__ */ (0,
|
|
6559
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: `c-rte-toolbar__block-format__text ${blockType === headingSize ? "selected" : ""}`, children: headingTypeToBlockName[headingSize] })
|
|
6538
6560
|
] }, headingSize)),
|
|
6539
|
-
/* @__PURE__ */ (0,
|
|
6540
|
-
/* @__PURE__ */ (0,
|
|
6561
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(DropdownMenu.Item, { onClick: formatBulletList, children: [
|
|
6562
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6541
6563
|
"i",
|
|
6542
6564
|
{
|
|
6543
|
-
className: `icon
|
|
6565
|
+
className: `c-rte-icon-bullet-list c-rte-toolbar__block-format__icon ${blockType === "bullet" ? "selected" : ""}`
|
|
6544
6566
|
}
|
|
6545
6567
|
),
|
|
6546
|
-
/* @__PURE__ */ (0,
|
|
6568
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: `c-rte-toolbar__block-format__text ${blockType === "bullet" ? "selected" : ""}`, children: "Bullet List" })
|
|
6547
6569
|
] }),
|
|
6548
|
-
/* @__PURE__ */ (0,
|
|
6549
|
-
/* @__PURE__ */ (0,
|
|
6570
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(DropdownMenu.Item, { onClick: formatNumberedList, children: [
|
|
6571
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6550
6572
|
"i",
|
|
6551
6573
|
{
|
|
6552
|
-
className: `icon
|
|
6574
|
+
className: `c-rte-icon-numbered-list c-rte-toolbar__block-format__icon ${blockType === "number" ? "selected" : ""}`
|
|
6553
6575
|
}
|
|
6554
6576
|
),
|
|
6555
|
-
/* @__PURE__ */ (0,
|
|
6577
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: `c-rte-toolbar__block-format__text ${blockType === "number" ? "selected" : ""}`, children: "Numbered List" })
|
|
6556
6578
|
] }),
|
|
6557
|
-
/* @__PURE__ */ (0,
|
|
6558
|
-
/* @__PURE__ */ (0,
|
|
6579
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(DropdownMenu.Item, { onClick: formatQuote, "data-testid": "toggle-block-format-quote", children: [
|
|
6580
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6559
6581
|
"i",
|
|
6560
6582
|
{
|
|
6561
|
-
className: `
|
|
6583
|
+
className: `c-rte-icon-quote c-rte-toolbar__block-format__icon ${blockType === "quote" ? "selected" : ""}`
|
|
6562
6584
|
}
|
|
6563
6585
|
),
|
|
6564
|
-
/* @__PURE__ */ (0,
|
|
6586
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: `c-rte-toolbar__block-format__text ${blockType === "quote" ? "selected" : ""}`, children: "Quote" })
|
|
6565
6587
|
] }),
|
|
6566
|
-
/* @__PURE__ */ (0,
|
|
6567
|
-
/* @__PURE__ */ (0,
|
|
6588
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(DropdownMenu.Item, { onClick: formatCode, "data-testid": "toggle-block-format-code", children: [
|
|
6589
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6568
6590
|
"i",
|
|
6569
6591
|
{
|
|
6570
|
-
className: `icon code border w-6 h-6 rounded-md bg-no-repeat bg-center bg-[length:18px_18px] ${blockType === "code" ? "
|
|
6592
|
+
className: `icon c-rte-icon-code border w-6 h-6 rounded-md bg-no-repeat bg-center bg-[length:18px_18px] ${blockType === "code" ? "selected" : ""}`
|
|
6571
6593
|
}
|
|
6572
6594
|
),
|
|
6573
|
-
/* @__PURE__ */ (0,
|
|
6595
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: `c-rte-toolbar__block-format__text ${blockType === "code" ? "selected" : ""}`, children: "Code block" })
|
|
6574
6596
|
] })
|
|
6575
6597
|
] }),
|
|
6576
|
-
children: /* @__PURE__ */ (0,
|
|
6598
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
|
|
6577
6599
|
Button,
|
|
6578
6600
|
{
|
|
6579
6601
|
style: { backgroundColor: "transparent", padding: "0 8px" },
|
|
6580
6602
|
"aria-label": "Formatting options for text style",
|
|
6581
6603
|
"data-testid": "toggle-block-format",
|
|
6582
6604
|
children: [
|
|
6583
|
-
/* @__PURE__ */ (0,
|
|
6584
|
-
/* @__PURE__ */ (0,
|
|
6605
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("i", { className: `c-rte-toolbar__toggle-icon c-rte-icon-${blockType}` }),
|
|
6606
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Icon.Arrow, {})
|
|
6585
6607
|
]
|
|
6586
6608
|
}
|
|
6587
6609
|
)
|
|
@@ -6589,36 +6611,36 @@ function BlockFormatDropDown({
|
|
|
6589
6611
|
);
|
|
6590
6612
|
}
|
|
6591
6613
|
function Divider() {
|
|
6592
|
-
return /* @__PURE__ */ (0,
|
|
6614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: "c-rte-toolbar__divider" });
|
|
6593
6615
|
}
|
|
6594
6616
|
function ToolbarPlugin({
|
|
6595
6617
|
actionsMenuPrepend,
|
|
6596
6618
|
actionsMenuAppend
|
|
6597
6619
|
}) {
|
|
6598
6620
|
const [editor] = (0, import_LexicalComposerContext11.useLexicalComposerContext)();
|
|
6599
|
-
const [activeEditor, setActiveEditor] = (0,
|
|
6600
|
-
const [blockType, setBlockType] = (0,
|
|
6601
|
-
const [selectedElementKey, setSelectedElementKey] = (0,
|
|
6602
|
-
const [isLink, setIsLink] = (0,
|
|
6603
|
-
const [isBold, setIsBold] = (0,
|
|
6604
|
-
const [isItalic, setIsItalic] = (0,
|
|
6605
|
-
const [isUnderline, setIsUnderline] = (0,
|
|
6606
|
-
const [isStrikethrough, setIsStrikethrough] = (0,
|
|
6607
|
-
const [isSubscript, setIsSubscript] = (0,
|
|
6608
|
-
const [isSuperscript, setIsSuperscript] = (0,
|
|
6609
|
-
const [isCode, setIsCode] = (0,
|
|
6610
|
-
const [canUndo, setCanUndo] = (0,
|
|
6611
|
-
const [canRedo, setCanRedo] = (0,
|
|
6621
|
+
const [activeEditor, setActiveEditor] = (0, import_react83.useState)(editor);
|
|
6622
|
+
const [blockType, setBlockType] = (0, import_react83.useState)("paragraph");
|
|
6623
|
+
const [selectedElementKey, setSelectedElementKey] = (0, import_react83.useState)(null);
|
|
6624
|
+
const [isLink, setIsLink] = (0, import_react83.useState)(false);
|
|
6625
|
+
const [isBold, setIsBold] = (0, import_react83.useState)(false);
|
|
6626
|
+
const [isItalic, setIsItalic] = (0, import_react83.useState)(false);
|
|
6627
|
+
const [isUnderline, setIsUnderline] = (0, import_react83.useState)(false);
|
|
6628
|
+
const [isStrikethrough, setIsStrikethrough] = (0, import_react83.useState)(false);
|
|
6629
|
+
const [isSubscript, setIsSubscript] = (0, import_react83.useState)(false);
|
|
6630
|
+
const [isSuperscript, setIsSuperscript] = (0, import_react83.useState)(false);
|
|
6631
|
+
const [isCode, setIsCode] = (0, import_react83.useState)(false);
|
|
6632
|
+
const [canUndo, setCanUndo] = (0, import_react83.useState)(false);
|
|
6633
|
+
const [canRedo, setCanRedo] = (0, import_react83.useState)(false);
|
|
6612
6634
|
const tr = useTr();
|
|
6613
|
-
const [codeLanguage, setCodeLanguage] = (0,
|
|
6614
|
-
const [isEditable, setIsEditable] = (0,
|
|
6615
|
-
const updateToolbar = (0,
|
|
6616
|
-
const selection = (0,
|
|
6617
|
-
if ((0,
|
|
6635
|
+
const [codeLanguage, setCodeLanguage] = (0, import_react83.useState)("");
|
|
6636
|
+
const [isEditable, setIsEditable] = (0, import_react83.useState)(() => editor.isEditable());
|
|
6637
|
+
const updateToolbar = (0, import_react83.useCallback)(() => {
|
|
6638
|
+
const selection = (0, import_lexical15.$getSelection)();
|
|
6639
|
+
if ((0, import_lexical15.$isRangeSelection)(selection)) {
|
|
6618
6640
|
const anchorNode = selection.anchor.getNode();
|
|
6619
6641
|
let element = anchorNode.getKey() === "root" ? anchorNode : (0, import_utils4.$findMatchingParent)(anchorNode, (e) => {
|
|
6620
6642
|
const parent3 = e.getParent();
|
|
6621
|
-
return parent3 !== null && (0,
|
|
6643
|
+
return parent3 !== null && (0, import_lexical15.$isRootOrShadowRoot)(parent3);
|
|
6622
6644
|
});
|
|
6623
6645
|
if (element === null) {
|
|
6624
6646
|
element = anchorNode.getTopLevelElementOrThrow();
|
|
@@ -6659,18 +6681,18 @@ function ToolbarPlugin({
|
|
|
6659
6681
|
}
|
|
6660
6682
|
}
|
|
6661
6683
|
}, [activeEditor]);
|
|
6662
|
-
(0,
|
|
6684
|
+
(0, import_react83.useEffect)(() => {
|
|
6663
6685
|
return editor.registerCommand(
|
|
6664
|
-
|
|
6686
|
+
import_lexical15.SELECTION_CHANGE_COMMAND,
|
|
6665
6687
|
(_payload, newEditor) => {
|
|
6666
6688
|
updateToolbar();
|
|
6667
6689
|
setActiveEditor(newEditor);
|
|
6668
6690
|
return false;
|
|
6669
6691
|
},
|
|
6670
|
-
|
|
6692
|
+
import_lexical15.COMMAND_PRIORITY_CRITICAL
|
|
6671
6693
|
);
|
|
6672
6694
|
}, [editor, updateToolbar]);
|
|
6673
|
-
(0,
|
|
6695
|
+
(0, import_react83.useEffect)(() => {
|
|
6674
6696
|
return (0, import_utils4.mergeRegister)(
|
|
6675
6697
|
editor.registerEditableListener((editable) => {
|
|
6676
6698
|
setIsEditable(editable);
|
|
@@ -6681,30 +6703,30 @@ function ToolbarPlugin({
|
|
|
6681
6703
|
});
|
|
6682
6704
|
}),
|
|
6683
6705
|
activeEditor.registerCommand(
|
|
6684
|
-
|
|
6706
|
+
import_lexical15.CAN_UNDO_COMMAND,
|
|
6685
6707
|
(payload) => {
|
|
6686
6708
|
setCanUndo(payload);
|
|
6687
6709
|
return false;
|
|
6688
6710
|
},
|
|
6689
|
-
|
|
6711
|
+
import_lexical15.COMMAND_PRIORITY_CRITICAL
|
|
6690
6712
|
),
|
|
6691
6713
|
activeEditor.registerCommand(
|
|
6692
|
-
|
|
6714
|
+
import_lexical15.CAN_REDO_COMMAND,
|
|
6693
6715
|
(payload) => {
|
|
6694
6716
|
setCanRedo(payload);
|
|
6695
6717
|
return false;
|
|
6696
6718
|
},
|
|
6697
|
-
|
|
6719
|
+
import_lexical15.COMMAND_PRIORITY_CRITICAL
|
|
6698
6720
|
)
|
|
6699
6721
|
);
|
|
6700
6722
|
}, [activeEditor, editor, updateToolbar]);
|
|
6701
|
-
const clearFormatting = (0,
|
|
6723
|
+
const clearFormatting = (0, import_react83.useCallback)(() => {
|
|
6702
6724
|
activeEditor.update(() => {
|
|
6703
|
-
const selection = (0,
|
|
6704
|
-
if ((0,
|
|
6725
|
+
const selection = (0, import_lexical15.$getSelection)();
|
|
6726
|
+
if ((0, import_lexical15.$isRangeSelection)(selection)) {
|
|
6705
6727
|
(0, import_selection3.$selectAll)(selection);
|
|
6706
6728
|
selection.getNodes().forEach((node) => {
|
|
6707
|
-
if ((0,
|
|
6729
|
+
if ((0, import_lexical15.$isTextNode)(node)) {
|
|
6708
6730
|
node.setFormat(0);
|
|
6709
6731
|
node.setStyle("");
|
|
6710
6732
|
(0, import_utils4.$getNearestBlockElementAncestorOrThrow)(node).setFormat("");
|
|
@@ -6716,18 +6738,18 @@ function ToolbarPlugin({
|
|
|
6716
6738
|
}
|
|
6717
6739
|
});
|
|
6718
6740
|
}, [activeEditor]);
|
|
6719
|
-
const insertLink = (0,
|
|
6741
|
+
const insertLink = (0, import_react83.useCallback)(() => {
|
|
6720
6742
|
if (!isLink) {
|
|
6721
6743
|
editor.dispatchCommand(import_link6.TOGGLE_LINK_COMMAND, sanitizeUrl("https://"));
|
|
6722
6744
|
} else {
|
|
6723
6745
|
editor.dispatchCommand(import_link6.TOGGLE_LINK_COMMAND, null);
|
|
6724
6746
|
}
|
|
6725
6747
|
}, [editor, isLink]);
|
|
6726
|
-
const onCodeLanguageSelect = (0,
|
|
6748
|
+
const onCodeLanguageSelect = (0, import_react83.useCallback)(
|
|
6727
6749
|
(value) => {
|
|
6728
6750
|
activeEditor.update(() => {
|
|
6729
6751
|
if (selectedElementKey !== null) {
|
|
6730
|
-
const node = (0,
|
|
6752
|
+
const node = (0, import_lexical15.$getNodeByKey)(selectedElementKey);
|
|
6731
6753
|
if ((0, import_code9.$isCodeNode)(node)) {
|
|
6732
6754
|
node.setLanguage(value);
|
|
6733
6755
|
}
|
|
@@ -6736,65 +6758,60 @@ function ToolbarPlugin({
|
|
|
6736
6758
|
},
|
|
6737
6759
|
[activeEditor, selectedElementKey]
|
|
6738
6760
|
);
|
|
6739
|
-
return /* @__PURE__ */ (0,
|
|
6740
|
-
/* @__PURE__ */ (0,
|
|
6741
|
-
/* @__PURE__ */ (0,
|
|
6761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: "c-rte-toolbar", children: [
|
|
6762
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: "c-rte-toolbar__inner", children: [
|
|
6763
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6742
6764
|
IconButton,
|
|
6743
6765
|
{
|
|
6744
6766
|
disabled: !canUndo || !isEditable,
|
|
6745
6767
|
onClick: () => {
|
|
6746
|
-
activeEditor.dispatchCommand(
|
|
6768
|
+
activeEditor.dispatchCommand(import_lexical15.UNDO_COMMAND, void 0);
|
|
6747
6769
|
},
|
|
6748
6770
|
type: "button",
|
|
6749
6771
|
title: tr(IS_APPLE ? "actionUndoTitleApple" : "actionUndoTitle"),
|
|
6750
6772
|
"aria-label": tr("actionUndoLabel"),
|
|
6751
|
-
children: /* @__PURE__ */ (0,
|
|
6773
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6752
6774
|
"i",
|
|
6753
6775
|
{
|
|
6754
|
-
className: `
|
|
6776
|
+
className: `c-rte-icon-undo c-rte-toolbar__icon ${!canUndo ? "disabled" : ""}
|
|
6755
6777
|
`
|
|
6756
6778
|
}
|
|
6757
6779
|
)
|
|
6758
6780
|
}
|
|
6759
6781
|
),
|
|
6760
|
-
/* @__PURE__ */ (0,
|
|
6782
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6761
6783
|
IconButton,
|
|
6762
6784
|
{
|
|
6763
6785
|
disabled: !canRedo || !isEditable,
|
|
6764
6786
|
onClick: () => {
|
|
6765
|
-
activeEditor.dispatchCommand(
|
|
6787
|
+
activeEditor.dispatchCommand(import_lexical15.REDO_COMMAND, void 0);
|
|
6766
6788
|
},
|
|
6767
6789
|
type: "button",
|
|
6768
6790
|
title: tr(IS_APPLE ? "actionRedoTitleApple" : "actionRedoTitle"),
|
|
6769
6791
|
"aria-label": tr("actionRedoLabel"),
|
|
6770
|
-
children: /* @__PURE__ */ (0,
|
|
6771
|
-
"i",
|
|
6772
|
-
{
|
|
6773
|
-
className: `format icon redo border w-4 h-6 bg-no-repeat bg-center bg-[length:17px_17px] ${canRedo ? "opacity-100" : "opacity-30"}`
|
|
6774
|
-
}
|
|
6775
|
-
)
|
|
6792
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("i", { className: `c-rte-icon-redo c-rte-toolbar__icon ${!canRedo ? "disabled" : ""}` })
|
|
6776
6793
|
}
|
|
6777
6794
|
),
|
|
6778
|
-
/* @__PURE__ */ (0,
|
|
6779
|
-
blockType in blockTypeToBlockName && activeEditor === editor && /* @__PURE__ */ (0,
|
|
6780
|
-
/* @__PURE__ */ (0,
|
|
6781
|
-
/* @__PURE__ */ (0,
|
|
6795
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Divider, {}),
|
|
6796
|
+
blockType in blockTypeToBlockName && activeEditor === editor && /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_jsx_runtime95.Fragment, { children: [
|
|
6797
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(BlockFormatDropDown, { disabled: !isEditable, blockType, editor }),
|
|
6798
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Divider, {})
|
|
6782
6799
|
] }),
|
|
6783
|
-
blockType === "code" ? /* @__PURE__ */ (0,
|
|
6800
|
+
blockType === "code" ? /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_jsx_runtime95.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6784
6801
|
DropdownMenu.Root,
|
|
6785
6802
|
{
|
|
6786
6803
|
disabled: !isEditable,
|
|
6787
6804
|
style: { zIndex: 1 },
|
|
6788
|
-
content: /* @__PURE__ */ (0,
|
|
6789
|
-
return /* @__PURE__ */ (0,
|
|
6805
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_jsx_runtime95.Fragment, { children: CODE_LANGUAGE_OPTIONS.map(([value, name]) => {
|
|
6806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6790
6807
|
DropdownMenu.Item,
|
|
6791
6808
|
{
|
|
6792
6809
|
className: `item ${dropDownActiveClass(value === codeLanguage)}`,
|
|
6793
6810
|
onClick: () => onCodeLanguageSelect(value),
|
|
6794
|
-
children: /* @__PURE__ */ (0,
|
|
6811
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6795
6812
|
"span",
|
|
6796
6813
|
{
|
|
6797
|
-
className: `
|
|
6814
|
+
className: `c-rte-toolbar__code-lang__sel-item ${dropDownActiveClass(value === codeLanguage) ? "selected" : ""}`,
|
|
6798
6815
|
children: name
|
|
6799
6816
|
}
|
|
6800
6817
|
)
|
|
@@ -6802,149 +6819,144 @@ function ToolbarPlugin({
|
|
|
6802
6819
|
value
|
|
6803
6820
|
);
|
|
6804
6821
|
}) }),
|
|
6805
|
-
children: /* @__PURE__ */ (0,
|
|
6822
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Button, { "aria-label": tr("codeSelectLanguage"), append: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Icon.Arrow, {}), children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: "c-rte-toolbar__code-lang__button-text", children: (0, import_code9.getLanguageFriendlyName)(codeLanguage) }) })
|
|
6806
6823
|
}
|
|
6807
|
-
) }) : /* @__PURE__ */ (0,
|
|
6808
|
-
/* @__PURE__ */ (0,
|
|
6824
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Dialog, { children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: "c-rte-toolbar__actions-rest", children: [
|
|
6825
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6809
6826
|
IconButton,
|
|
6810
6827
|
{
|
|
6811
6828
|
disabled: !isEditable,
|
|
6812
|
-
className:
|
|
6829
|
+
className: `c-rte-toolbar__icon-btn ${isBold ? "selected" : ""}`,
|
|
6813
6830
|
type: "button",
|
|
6814
6831
|
title: tr(IS_APPLE ? "actionFormatAsStrongTitleApple" : "actionFormatAsStrongTitle"),
|
|
6815
6832
|
"aria-label": tr("actionFormatAsStrongLabel"),
|
|
6816
6833
|
"data-testid": "toggle-format-bold",
|
|
6817
6834
|
onClick: () => {
|
|
6818
|
-
activeEditor.dispatchCommand(
|
|
6835
|
+
activeEditor.dispatchCommand(import_lexical15.FORMAT_TEXT_COMMAND, "bold");
|
|
6819
6836
|
},
|
|
6820
|
-
children: /* @__PURE__ */ (0,
|
|
6837
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("i", { className: `c-rte-toolbar__icon-btn__icon c-rte-icon-bold` })
|
|
6821
6838
|
}
|
|
6822
6839
|
),
|
|
6823
|
-
/* @__PURE__ */ (0,
|
|
6840
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6824
6841
|
IconButton,
|
|
6825
6842
|
{
|
|
6826
|
-
className:
|
|
6843
|
+
className: `c-rte-toolbar__icon-btn ${isItalic ? "selected" : ""}`,
|
|
6827
6844
|
disabled: !isEditable,
|
|
6828
6845
|
onClick: () => {
|
|
6829
|
-
activeEditor.dispatchCommand(
|
|
6846
|
+
activeEditor.dispatchCommand(import_lexical15.FORMAT_TEXT_COMMAND, "italic");
|
|
6830
6847
|
},
|
|
6831
6848
|
type: "button",
|
|
6832
6849
|
title: tr(IS_APPLE ? "actionFormatAsEmphasizedTitleApple" : "actionFormatAsEmphasizedTitle"),
|
|
6833
6850
|
"aria-label": tr("actionFormatAsEmphasizedLabel"),
|
|
6834
6851
|
"data-testid": "toggle-format-emphasized",
|
|
6835
|
-
children: /* @__PURE__ */ (0,
|
|
6852
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("i", { className: `c-rte-toolbar__icon-btn__icon c-rte-icon-italic` })
|
|
6836
6853
|
}
|
|
6837
6854
|
),
|
|
6838
|
-
/* @__PURE__ */ (0,
|
|
6855
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6839
6856
|
IconButton,
|
|
6840
6857
|
{
|
|
6841
|
-
className:
|
|
6858
|
+
className: `c-rte-toolbar__icon-btn ${isUnderline ? "selected" : ""}`,
|
|
6842
6859
|
disabled: !isEditable,
|
|
6843
6860
|
onClick: () => {
|
|
6844
|
-
activeEditor.dispatchCommand(
|
|
6861
|
+
activeEditor.dispatchCommand(import_lexical15.FORMAT_TEXT_COMMAND, "underline");
|
|
6845
6862
|
},
|
|
6846
6863
|
type: "button",
|
|
6847
6864
|
title: tr(IS_APPLE ? "actionFormatAsUnderlinedTitleApple" : "actionFormatAsUnderlinedTitle"),
|
|
6848
6865
|
"aria-label": tr("actionFormatAsUnderlinedLabel"),
|
|
6849
6866
|
"data-testid": "toggle-format-underlined",
|
|
6850
|
-
children: /* @__PURE__ */ (0,
|
|
6851
|
-
"i",
|
|
6852
|
-
{
|
|
6853
|
-
className: `format icon underline border w-full h-full bg-no-repeat bg-center bg-[length:18px_18px]`
|
|
6854
|
-
}
|
|
6855
|
-
)
|
|
6867
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("i", { className: `c-rte-toolbar__icon-btn__icon c-rte-icon-underline` })
|
|
6856
6868
|
}
|
|
6857
6869
|
),
|
|
6858
|
-
/* @__PURE__ */ (0,
|
|
6870
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6859
6871
|
IconButton,
|
|
6860
6872
|
{
|
|
6861
|
-
className:
|
|
6873
|
+
className: `c-rte-toolbar__icon-btn ${isCode ? "selected" : ""}`,
|
|
6862
6874
|
disabled: !isEditable,
|
|
6863
6875
|
onClick: () => {
|
|
6864
|
-
activeEditor.dispatchCommand(
|
|
6876
|
+
activeEditor.dispatchCommand(import_lexical15.FORMAT_TEXT_COMMAND, "code");
|
|
6865
6877
|
},
|
|
6866
6878
|
type: "button",
|
|
6867
6879
|
title: tr("actionInsertCodeBlock"),
|
|
6868
6880
|
"aria-label": tr("actionInsertCodeBlock"),
|
|
6869
|
-
children: /* @__PURE__ */ (0,
|
|
6881
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("i", { className: `c-rte-toolbar__icon-btn__icon c-rte-icon-code` })
|
|
6870
6882
|
}
|
|
6871
6883
|
),
|
|
6872
|
-
/* @__PURE__ */ (0,
|
|
6884
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6873
6885
|
IconButton,
|
|
6874
6886
|
{
|
|
6875
|
-
className:
|
|
6887
|
+
className: `c-rte-toolbar__icon-btn ${isLink ? "selected" : ""}`,
|
|
6876
6888
|
disabled: !isEditable,
|
|
6877
6889
|
onClick: insertLink,
|
|
6878
6890
|
type: "button",
|
|
6879
6891
|
"aria-label": tr("actionInsertlink"),
|
|
6880
6892
|
title: tr("actionInsertlink"),
|
|
6881
|
-
children: /* @__PURE__ */ (0,
|
|
6893
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("i", { className: `c-rte-toolbar__icon-btn__icon c-rte-icon-link` })
|
|
6882
6894
|
}
|
|
6883
6895
|
),
|
|
6884
|
-
/* @__PURE__ */ (0,
|
|
6896
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6885
6897
|
DropdownMenu.Root,
|
|
6886
6898
|
{
|
|
6887
6899
|
disabled: !isEditable,
|
|
6888
6900
|
style: { zIndex: 1 },
|
|
6889
|
-
content: /* @__PURE__ */ (0,
|
|
6890
|
-
/* @__PURE__ */ (0,
|
|
6901
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_jsx_runtime95.Fragment, { children: [
|
|
6902
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
|
|
6891
6903
|
DropdownMenu.Item,
|
|
6892
6904
|
{
|
|
6893
6905
|
onClick: () => {
|
|
6894
|
-
activeEditor.dispatchCommand(
|
|
6906
|
+
activeEditor.dispatchCommand(import_lexical15.FORMAT_TEXT_COMMAND, "strikethrough");
|
|
6895
6907
|
},
|
|
6896
6908
|
title: tr("actionFormatWithStrikethroughTitle"),
|
|
6897
6909
|
"aria-label": tr("actionFormatWithStrikethroughLabel"),
|
|
6898
6910
|
children: [
|
|
6899
|
-
/* @__PURE__ */ (0,
|
|
6911
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6900
6912
|
"i",
|
|
6901
6913
|
{
|
|
6902
|
-
className: `icon
|
|
6914
|
+
className: `c-rte-icon-strikethrough c-rte-toolbar__dd-item__icon ${isStrikethrough ? "selected" : ""}`
|
|
6903
6915
|
}
|
|
6904
6916
|
),
|
|
6905
|
-
/* @__PURE__ */ (0,
|
|
6917
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: `c-rte-toolbar__dd-item__text ${isStrikethrough ? "selected" : ""}`, children: tr("actionFormatAsStrongTitle") })
|
|
6906
6918
|
]
|
|
6907
6919
|
}
|
|
6908
6920
|
),
|
|
6909
|
-
/* @__PURE__ */ (0,
|
|
6921
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
|
|
6910
6922
|
DropdownMenu.Item,
|
|
6911
6923
|
{
|
|
6912
6924
|
onClick: () => {
|
|
6913
|
-
activeEditor.dispatchCommand(
|
|
6925
|
+
activeEditor.dispatchCommand(import_lexical15.FORMAT_TEXT_COMMAND, "subscript");
|
|
6914
6926
|
},
|
|
6915
6927
|
title: tr("actionFormatWithSubscriptTitle"),
|
|
6916
6928
|
"aria-label": tr("actionFormatWithSubscriptLabel"),
|
|
6917
6929
|
children: [
|
|
6918
|
-
/* @__PURE__ */ (0,
|
|
6930
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6919
6931
|
"i",
|
|
6920
6932
|
{
|
|
6921
|
-
className: `icon
|
|
6933
|
+
className: `c-rte-icon-subscript c-rte-toolbar__dd-item__icon ${isSubscript ? "selected" : ""}`
|
|
6922
6934
|
}
|
|
6923
6935
|
),
|
|
6924
|
-
/* @__PURE__ */ (0,
|
|
6936
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: `c-rte-toolbar__dd-item__text ${isSubscript ? "selected" : ""}`, children: tr("actionFormatWithSubscriptTitle") })
|
|
6925
6937
|
]
|
|
6926
6938
|
}
|
|
6927
6939
|
),
|
|
6928
|
-
/* @__PURE__ */ (0,
|
|
6940
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
|
|
6929
6941
|
DropdownMenu.Item,
|
|
6930
6942
|
{
|
|
6931
6943
|
onClick: () => {
|
|
6932
|
-
activeEditor.dispatchCommand(
|
|
6944
|
+
activeEditor.dispatchCommand(import_lexical15.FORMAT_TEXT_COMMAND, "superscript");
|
|
6933
6945
|
},
|
|
6934
6946
|
title: tr("actionFormatWithSuperscriptTitle"),
|
|
6935
6947
|
"aria-label": tr("actionFormatWithSuperscriptLabel"),
|
|
6936
6948
|
children: [
|
|
6937
|
-
/* @__PURE__ */ (0,
|
|
6949
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6938
6950
|
"i",
|
|
6939
6951
|
{
|
|
6940
|
-
className: `icon
|
|
6952
|
+
className: `c-rte-icon-superscript c-rte-toolbar__dd-item__icon ${isSuperscript ? "selected" : ""}`
|
|
6941
6953
|
}
|
|
6942
6954
|
),
|
|
6943
|
-
/* @__PURE__ */ (0,
|
|
6955
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: `c-rte-toolbar__dd-item__text ${isSuperscript ? "selected" : ""}`, children: tr("actionFormatWithSuperscriptTitle") })
|
|
6944
6956
|
]
|
|
6945
6957
|
}
|
|
6946
6958
|
),
|
|
6947
|
-
/* @__PURE__ */ (0,
|
|
6959
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
|
|
6948
6960
|
DropdownMenu.Item,
|
|
6949
6961
|
{
|
|
6950
6962
|
onClick: clearFormatting,
|
|
@@ -6952,60 +6964,60 @@ function ToolbarPlugin({
|
|
|
6952
6964
|
title: tr("actionClearTextFormatting"),
|
|
6953
6965
|
"aria-label": tr("actionClearTextFormatting"),
|
|
6954
6966
|
children: [
|
|
6955
|
-
/* @__PURE__ */ (0,
|
|
6956
|
-
/* @__PURE__ */ (0,
|
|
6967
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("i", { className: "c-rte-icon-clear c-rte-toolbar__dd-item__icon" }),
|
|
6968
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: "c-rte-toolbar__dd-item__text--clear", children: "Clear Formatting" })
|
|
6957
6969
|
]
|
|
6958
6970
|
}
|
|
6959
6971
|
)
|
|
6960
6972
|
] }),
|
|
6961
|
-
children: /* @__PURE__ */ (0,
|
|
6973
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
|
|
6962
6974
|
Button,
|
|
6963
6975
|
{
|
|
6964
6976
|
style: { backgroundColor: "transparent", padding: "0 8px" },
|
|
6965
6977
|
"aria-label": tr("actionTextFormattingOptions"),
|
|
6966
6978
|
children: [
|
|
6967
|
-
/* @__PURE__ */ (0,
|
|
6968
|
-
/* @__PURE__ */ (0,
|
|
6979
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("i", { className: `c-rte-icon-dropdown-more c-rte-toolbar__toggle-icon` }),
|
|
6980
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Icon.Arrow, {})
|
|
6969
6981
|
]
|
|
6970
6982
|
}
|
|
6971
6983
|
)
|
|
6972
6984
|
}
|
|
6973
6985
|
),
|
|
6974
|
-
/* @__PURE__ */ (0,
|
|
6975
|
-
/* @__PURE__ */ (0,
|
|
6986
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Divider, {}),
|
|
6987
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
6976
6988
|
DropdownMenu.Root,
|
|
6977
6989
|
{
|
|
6978
6990
|
style: { zIndex: 1 },
|
|
6979
6991
|
disabled: !isEditable,
|
|
6980
|
-
content: /* @__PURE__ */ (0,
|
|
6981
|
-
/* @__PURE__ */ (0,
|
|
6992
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_jsx_runtime95.Fragment, { children: [
|
|
6993
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
|
|
6982
6994
|
DropdownMenu.Item,
|
|
6983
6995
|
{
|
|
6984
6996
|
onClick: () => {
|
|
6985
6997
|
activeEditor.dispatchCommand(import_LexicalHorizontalRuleNode4.INSERT_HORIZONTAL_RULE_COMMAND, void 0);
|
|
6986
6998
|
},
|
|
6987
|
-
children:
|
|
6988
|
-
/* @__PURE__ */ (0,
|
|
6989
|
-
/* @__PURE__ */ (0,
|
|
6990
|
-
]
|
|
6999
|
+
children: [
|
|
7000
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("i", { className: "c-rte-toolbar__dd-item__icon c-rte-icon-horizontal-rule" }),
|
|
7001
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: "c-rte-toolbar__dd-item__text", children: tr("horizontalRule") })
|
|
7002
|
+
]
|
|
6991
7003
|
}
|
|
6992
7004
|
),
|
|
6993
|
-
/* @__PURE__ */ (0,
|
|
6994
|
-
/* @__PURE__ */ (0,
|
|
6995
|
-
/* @__PURE__ */ (0,
|
|
7005
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(DropdownMenu.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Dialog.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: "c-rte-toolbar__dd-item--table", children: [
|
|
7006
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("i", { className: "c-rte-toolbar__dd-item__icon c-rte-icon-table" }),
|
|
7007
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("span", { className: "c-rte-toolbar__dd-item__text", children: tr("table") })
|
|
6996
7008
|
] }) }) })
|
|
6997
7009
|
] }),
|
|
6998
|
-
children: /* @__PURE__ */ (0,
|
|
7010
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(IconButton, { children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("i", { className: "c-rte-icon-plus c-rte-toolbar__plus" }) })
|
|
6999
7011
|
}
|
|
7000
7012
|
),
|
|
7001
|
-
/* @__PURE__ */ (0,
|
|
7002
|
-
/* @__PURE__ */ (0,
|
|
7003
|
-
/* @__PURE__ */ (0,
|
|
7004
|
-
/* @__PURE__ */ (0,
|
|
7013
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Dialog.Content, { children: [
|
|
7014
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Dialog.Title, { children: tr("insertTableTitle") }),
|
|
7015
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Dialog.Description, { children: tr("insertTableDescription") }),
|
|
7016
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(InsertTableDialog, { activeEditor })
|
|
7005
7017
|
] })
|
|
7006
7018
|
] }) })
|
|
7007
7019
|
] }),
|
|
7008
|
-
/* @__PURE__ */ (0,
|
|
7020
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(ActionsPlugin, { prepend: actionsMenuPrepend, append: actionsMenuAppend })
|
|
7009
7021
|
] });
|
|
7010
7022
|
}
|
|
7011
7023
|
|
|
@@ -7059,7 +7071,7 @@ var theme = {
|
|
|
7059
7071
|
h5: "CrystallizeRTEditorTheme__h5",
|
|
7060
7072
|
h6: "CrystallizeRTEditorTheme__h6"
|
|
7061
7073
|
},
|
|
7062
|
-
image: "
|
|
7074
|
+
image: "",
|
|
7063
7075
|
indent: "CrystallizeRTEditorTheme__indent",
|
|
7064
7076
|
link: "CrystallizeRTEditorTheme__link",
|
|
7065
7077
|
list: {
|
|
@@ -7112,7 +7124,7 @@ var theme = {
|
|
|
7112
7124
|
var CrystallizeRTEditorTheme_default = theme;
|
|
7113
7125
|
|
|
7114
7126
|
// src/rich-text-editor/rich-text-editor.tsx
|
|
7115
|
-
var
|
|
7127
|
+
var import_jsx_runtime96 = require("react/jsx-runtime");
|
|
7116
7128
|
function RichTextEditor({
|
|
7117
7129
|
initialData,
|
|
7118
7130
|
editable = true,
|
|
@@ -7120,7 +7132,7 @@ function RichTextEditor({
|
|
|
7120
7132
|
labelTranslations,
|
|
7121
7133
|
...rest
|
|
7122
7134
|
}) {
|
|
7123
|
-
return /* @__PURE__ */ (0,
|
|
7135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
7124
7136
|
import_LexicalComposer.LexicalComposer,
|
|
7125
7137
|
{
|
|
7126
7138
|
initialConfig: {
|
|
@@ -7135,7 +7147,7 @@ function RichTextEditor({
|
|
|
7135
7147
|
richText: initialData
|
|
7136
7148
|
}) : void 0
|
|
7137
7149
|
},
|
|
7138
|
-
children: /* @__PURE__ */ (0,
|
|
7150
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(I18nProvider, { language, labelTranslations, children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(SharedHistoryContext, { children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: "c-rich-text-editor", children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(RichTextEditorWithoutContext, { ...rest, editable }) }) }) })
|
|
7139
7151
|
}
|
|
7140
7152
|
);
|
|
7141
7153
|
}
|
|
@@ -7148,34 +7160,23 @@ function RichTextEditorWithoutContext({
|
|
|
7148
7160
|
actionsMenuAppend,
|
|
7149
7161
|
slotPreContent,
|
|
7150
7162
|
maxLength,
|
|
7151
|
-
editable
|
|
7163
|
+
editable,
|
|
7164
|
+
id
|
|
7152
7165
|
}) {
|
|
7153
7166
|
const { historyState } = useSharedHistoryContext();
|
|
7154
|
-
const placeholder = /* @__PURE__ */ (0,
|
|
7167
|
+
const placeholder = /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: "c-rte-placeholder", children: placeholderText ?? "" });
|
|
7155
7168
|
const [editor] = (0, import_LexicalComposerContext12.useLexicalComposerContext)();
|
|
7156
|
-
const [floatingAnchorElem, setFloatingAnchorElem] = (0,
|
|
7157
|
-
const [isSmallWidthViewport, setIsSmallWidthViewport] = (0,
|
|
7158
|
-
const firstOnChangeTriggeredRef = (0,
|
|
7169
|
+
const [floatingAnchorElem, setFloatingAnchorElem] = (0, import_react84.useState)(null);
|
|
7170
|
+
const [isSmallWidthViewport, setIsSmallWidthViewport] = (0, import_react84.useState)(false);
|
|
7171
|
+
const firstOnChangeTriggeredRef = (0, import_react84.useRef)(!autoFocus);
|
|
7159
7172
|
const onRef = (_floatingAnchorElem) => {
|
|
7160
7173
|
if (_floatingAnchorElem !== null) {
|
|
7161
7174
|
setFloatingAnchorElem(_floatingAnchorElem);
|
|
7162
7175
|
}
|
|
7163
7176
|
};
|
|
7164
|
-
(0,
|
|
7177
|
+
(0, import_react84.useEffect)(() => {
|
|
7165
7178
|
editor.setEditable(editable || false);
|
|
7166
7179
|
}, [editable, editor]);
|
|
7167
|
-
(0, import_react83.useEffect)(() => {
|
|
7168
|
-
const updateViewPortWidth = () => {
|
|
7169
|
-
const isNextSmallWidthViewport = window.matchMedia("(max-width: 1025px)").matches;
|
|
7170
|
-
if (isNextSmallWidthViewport !== isSmallWidthViewport) {
|
|
7171
|
-
setIsSmallWidthViewport(isNextSmallWidthViewport);
|
|
7172
|
-
}
|
|
7173
|
-
};
|
|
7174
|
-
window.addEventListener("resize", updateViewPortWidth);
|
|
7175
|
-
return () => {
|
|
7176
|
-
window.removeEventListener("resize", updateViewPortWidth);
|
|
7177
|
-
};
|
|
7178
|
-
}, [isSmallWidthViewport]);
|
|
7179
7180
|
function onLocalChange(editorState) {
|
|
7180
7181
|
if (onChange) {
|
|
7181
7182
|
if (triggerOnChangeOnAutoFocus || firstOnChangeTriggeredRef.current) {
|
|
@@ -7184,37 +7185,38 @@ function RichTextEditorWithoutContext({
|
|
|
7184
7185
|
}
|
|
7185
7186
|
firstOnChangeTriggeredRef.current = true;
|
|
7186
7187
|
}
|
|
7187
|
-
return /* @__PURE__ */ (0,
|
|
7188
|
-
/* @__PURE__ */ (0,
|
|
7189
|
-
/* @__PURE__ */ (0,
|
|
7188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(import_jsx_runtime96.Fragment, { children: [
|
|
7189
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_LexicalOnChangePlugin.OnChangePlugin, { onChange: onLocalChange, ignoreSelectionChange: true }),
|
|
7190
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(DimensionDetectorPlugin, { onChange: (d) => setIsSmallWidthViewport(d.isSmallWidth) }),
|
|
7191
|
+
isSmallWidthViewport ? null : /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(ToolbarPlugin, { actionsMenuPrepend, actionsMenuAppend }),
|
|
7190
7192
|
slotPreContent,
|
|
7191
|
-
/* @__PURE__ */ (0,
|
|
7192
|
-
maxLength != null ? /* @__PURE__ */ (0,
|
|
7193
|
-
!autoFocus ? null : /* @__PURE__ */ (0,
|
|
7194
|
-
/* @__PURE__ */ (0,
|
|
7195
|
-
/* @__PURE__ */ (0,
|
|
7196
|
-
/* @__PURE__ */ (0,
|
|
7197
|
-
/* @__PURE__ */ (0,
|
|
7193
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { className: "c-rte-editor-container", children: [
|
|
7194
|
+
maxLength != null ? /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(MaxLengthPlugin, { maxLength }) : null,
|
|
7195
|
+
!autoFocus ? null : /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_LexicalAutoFocusPlugin.AutoFocusPlugin, {}),
|
|
7196
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_LexicalClearEditorPlugin.ClearEditorPlugin, {}),
|
|
7197
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(LexicalAutoLinkPlugin, {}),
|
|
7198
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_LexicalHistoryPlugin2.HistoryPlugin, { externalHistoryState: historyState }),
|
|
7199
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
7198
7200
|
import_LexicalRichTextPlugin.RichTextPlugin,
|
|
7199
7201
|
{
|
|
7200
|
-
contentEditable: /* @__PURE__ */ (0,
|
|
7202
|
+
contentEditable: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: "c-rte-editor-scroller", children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: "c-rte-editor", ref: onRef, children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_LexicalContentEditable.ContentEditable, { className: "c-rte-contenteditable-root", id }) }) }),
|
|
7201
7203
|
placeholder,
|
|
7202
7204
|
ErrorBoundary: import_LexicalErrorBoundary.default
|
|
7203
7205
|
}
|
|
7204
7206
|
),
|
|
7205
|
-
/* @__PURE__ */ (0,
|
|
7206
|
-
/* @__PURE__ */ (0,
|
|
7207
|
-
/* @__PURE__ */ (0,
|
|
7208
|
-
/* @__PURE__ */ (0,
|
|
7209
|
-
/* @__PURE__ */ (0,
|
|
7210
|
-
/* @__PURE__ */ (0,
|
|
7211
|
-
/* @__PURE__ */ (0,
|
|
7212
|
-
/* @__PURE__ */ (0,
|
|
7213
|
-
floatingAnchorElem && !isSmallWidthViewport && /* @__PURE__ */ (0,
|
|
7214
|
-
/* @__PURE__ */ (0,
|
|
7215
|
-
/* @__PURE__ */ (0,
|
|
7216
|
-
/* @__PURE__ */ (0,
|
|
7217
|
-
/* @__PURE__ */ (0,
|
|
7207
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(CodeHighlightPlugin, {}),
|
|
7208
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_LexicalListPlugin.ListPlugin, {}),
|
|
7209
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(ListMaxIndentLevelPlugin, { maxDepth: 7 }),
|
|
7210
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_LexicalTablePlugin.TablePlugin, {}),
|
|
7211
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(LinkPlugin, {}),
|
|
7212
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_LexicalHorizontalRulePlugin.HorizontalRulePlugin, {}),
|
|
7213
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(TabFocusPlugin, {}),
|
|
7214
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_LexicalTabIndentationPlugin.TabIndentationPlugin, {}),
|
|
7215
|
+
floatingAnchorElem && !isSmallWidthViewport && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(import_jsx_runtime96.Fragment, { children: [
|
|
7216
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }),
|
|
7217
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem }),
|
|
7218
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(TableActionMenuPlugin, { anchorElem: floatingAnchorElem }),
|
|
7219
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem })
|
|
7218
7220
|
] })
|
|
7219
7221
|
] })
|
|
7220
7222
|
] });
|