@crystallize/design-system 1.11.7 → 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 +17 -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 +538 -517
- package/dist/index.mjs +419 -398
- package/package.json +22 -23
- 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/model/crystallize-to-lexical.ts +4 -3
- package/src/rich-text-editor/model/parse-initial-state.test.ts +48 -0
- package/src/rich-text-editor/model/parse-initial-state.ts +20 -0
- 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 +24 -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.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import { forwardRef as forwardRef2 } from "react";
|
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
4
|
|
|
5
5
|
// src/spinner/index.tsx
|
|
6
|
-
import { cx } from "class-variance-authority";
|
|
7
6
|
import { forwardRef } from "react";
|
|
7
|
+
import { cx } from "class-variance-authority";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
var realSize = 40;
|
|
10
10
|
var Spinner = forwardRef(
|
|
@@ -173,8 +173,8 @@ import { cva as cva3 } from "class-variance-authority";
|
|
|
173
173
|
import { Portal as Portal2, Separator } from "@radix-ui/react-dropdown-menu";
|
|
174
174
|
|
|
175
175
|
// src/dropdown-menu/dropdown-menu-item.tsx
|
|
176
|
-
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
177
176
|
import { cx as cx2 } from "class-variance-authority";
|
|
177
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
178
178
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
179
179
|
function DropdownMenuItem({ children, className, ...delegated }) {
|
|
180
180
|
return /* @__PURE__ */ jsx4(DropdownMenuPrimitive.Item, { ...delegated, className: cx2("c-dropdown-menu-item", className), children });
|
|
@@ -303,8 +303,8 @@ var Avatar = forwardRef3(({ name, size, className, ...delegated }, ref) => {
|
|
|
303
303
|
Avatar.displayName = "Avatar";
|
|
304
304
|
|
|
305
305
|
// src/checkbox/checkbox.tsx
|
|
306
|
-
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
307
306
|
import { forwardRef as forwardRef4 } from "react";
|
|
307
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
308
308
|
import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
309
309
|
var Checkbox = forwardRef4((props, ref) => {
|
|
310
310
|
return /* @__PURE__ */ jsx11(CheckboxPrimitive.Root, { ...props, ref, className: "c-checkbox", children: /* @__PURE__ */ jsx11(CheckboxPrimitive.Indicator, { children: /* @__PURE__ */ jsxs5("svg", { viewBox: "0 0 9 9", fill: "none", className: "c-checkbox__svg", children: [
|
|
@@ -326,8 +326,8 @@ var Checkbox = forwardRef4((props, ref) => {
|
|
|
326
326
|
});
|
|
327
327
|
Checkbox.displayName = "Checkbox";
|
|
328
328
|
|
|
329
|
-
// src/dialog/
|
|
330
|
-
|
|
329
|
+
// src/dialog/config.tsx
|
|
330
|
+
import { unmountComponentAtNode, render as DOMRender } from "react-dom";
|
|
331
331
|
|
|
332
332
|
// src/dialog/dialog.tsx
|
|
333
333
|
import { cva as cva5, cx as cx5 } from "class-variance-authority";
|
|
@@ -3715,9 +3715,6 @@ DialogBase.Content = DialogContent;
|
|
|
3715
3715
|
DialogBase.Overlay = DialogPrimitive.Overlay;
|
|
3716
3716
|
DialogBase.Close = DialogPrimitive.Close;
|
|
3717
3717
|
|
|
3718
|
-
// src/dialog/config.tsx
|
|
3719
|
-
import { unmountComponentAtNode, render as DOMRender } from "react-dom";
|
|
3720
|
-
|
|
3721
3718
|
// src/dialog/confirm-dialog.tsx
|
|
3722
3719
|
import { jsx as jsx67, jsxs as jsxs58 } from "react/jsx-runtime";
|
|
3723
3720
|
function ConfirmDialog({
|
|
@@ -3782,6 +3779,9 @@ function ConfirmDialog({
|
|
|
3782
3779
|
) });
|
|
3783
3780
|
}
|
|
3784
3781
|
|
|
3782
|
+
// src/dialog/destroyFns.ts
|
|
3783
|
+
var destroyFns = [];
|
|
3784
|
+
|
|
3785
3785
|
// src/dialog/config.tsx
|
|
3786
3786
|
import { jsx as jsx68 } from "react/jsx-runtime";
|
|
3787
3787
|
function confirm(config) {
|
|
@@ -3953,8 +3953,8 @@ var IconButton = forwardRef59(
|
|
|
3953
3953
|
IconButton.displayName = "Button";
|
|
3954
3954
|
|
|
3955
3955
|
// src/inline-radio/inline-radio.tsx
|
|
3956
|
-
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
3957
3956
|
import { cx as cx6, cva as cva7 } from "class-variance-authority";
|
|
3957
|
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
3958
3958
|
import { jsx as jsx70 } from "react/jsx-runtime";
|
|
3959
3959
|
var inlineRadioGroupStyles = cva7("c-inline-radio-group", {
|
|
3960
3960
|
variants: {
|
|
@@ -3984,34 +3984,12 @@ var InlineRadio = {
|
|
|
3984
3984
|
import { forwardRef as forwardRef63 } from "react";
|
|
3985
3985
|
import { cva as cva9, cx as cx8 } from "class-variance-authority";
|
|
3986
3986
|
|
|
3987
|
-
// src/
|
|
3988
|
-
import { cva as cva8 } from "class-variance-authority";
|
|
3987
|
+
// src/iconography/triangle.tsx
|
|
3989
3988
|
import { forwardRef as forwardRef60 } from "react";
|
|
3990
3989
|
import { jsx as jsx71 } from "react/jsx-runtime";
|
|
3991
|
-
var
|
|
3992
|
-
variants: {},
|
|
3993
|
-
defaultVariants: {}
|
|
3994
|
-
});
|
|
3995
|
-
var Input = forwardRef60(({ className, ...delegated }, ref) => {
|
|
3996
|
-
return /* @__PURE__ */ jsx71("input", { ref, className: inputStyles({ className }), type: "text", ...delegated });
|
|
3997
|
-
});
|
|
3998
|
-
Input.displayName = "Input";
|
|
3999
|
-
|
|
4000
|
-
// src/label/label.tsx
|
|
4001
|
-
import { forwardRef as forwardRef61 } from "react";
|
|
4002
|
-
import { cx as cx7 } from "class-variance-authority";
|
|
4003
|
-
import { jsx as jsx72 } from "react/jsx-runtime";
|
|
4004
|
-
var Label2 = forwardRef61(({ className, ...delegated }, ref) => {
|
|
4005
|
-
return /* @__PURE__ */ jsx72("label", { ref, className: cx7("c-label", className), ...delegated });
|
|
4006
|
-
});
|
|
4007
|
-
Label2.displayName = "Label";
|
|
4008
|
-
|
|
4009
|
-
// src/iconography/triangle.tsx
|
|
4010
|
-
import { forwardRef as forwardRef62 } from "react";
|
|
4011
|
-
import { jsx as jsx73 } from "react/jsx-runtime";
|
|
4012
|
-
var Triangle = forwardRef62((delegated, ref) => {
|
|
3990
|
+
var Triangle = forwardRef60((delegated, ref) => {
|
|
4013
3991
|
const { width = 20, height = 20, ...rest } = delegated;
|
|
4014
|
-
return /* @__PURE__ */
|
|
3992
|
+
return /* @__PURE__ */ jsx71(
|
|
4015
3993
|
"svg",
|
|
4016
3994
|
{
|
|
4017
3995
|
viewBox: "0 0 17 15",
|
|
@@ -4021,11 +3999,33 @@ var Triangle = forwardRef62((delegated, ref) => {
|
|
|
4021
3999
|
fill: "none",
|
|
4022
4000
|
xmlns: "http://www.w3.org/2000/svg",
|
|
4023
4001
|
...rest,
|
|
4024
|
-
children: /* @__PURE__ */
|
|
4002
|
+
children: /* @__PURE__ */ jsx71("path", { d: "M15.463 1.2L8.5 12.685 1.537 1.2h13.925zM1.353.896s0 0 0 0h0z", stroke: "currentColor", strokeWidth: 2.4 })
|
|
4025
4003
|
}
|
|
4026
4004
|
);
|
|
4027
4005
|
});
|
|
4028
4006
|
|
|
4007
|
+
// src/input/input.tsx
|
|
4008
|
+
import { forwardRef as forwardRef61 } from "react";
|
|
4009
|
+
import { cva as cva8 } from "class-variance-authority";
|
|
4010
|
+
import { jsx as jsx72 } from "react/jsx-runtime";
|
|
4011
|
+
var inputStyles = cva8(["c-input"], {
|
|
4012
|
+
variants: {},
|
|
4013
|
+
defaultVariants: {}
|
|
4014
|
+
});
|
|
4015
|
+
var Input = forwardRef61(({ className, ...delegated }, ref) => {
|
|
4016
|
+
return /* @__PURE__ */ jsx72("input", { ref, className: inputStyles({ className }), type: "text", ...delegated });
|
|
4017
|
+
});
|
|
4018
|
+
Input.displayName = "Input";
|
|
4019
|
+
|
|
4020
|
+
// src/label/label.tsx
|
|
4021
|
+
import { forwardRef as forwardRef62 } from "react";
|
|
4022
|
+
import { cx as cx7 } from "class-variance-authority";
|
|
4023
|
+
import { jsx as jsx73 } from "react/jsx-runtime";
|
|
4024
|
+
var Label2 = forwardRef62(({ className, ...delegated }, ref) => {
|
|
4025
|
+
return /* @__PURE__ */ jsx73("label", { ref, className: cx7("c-label", className), ...delegated });
|
|
4026
|
+
});
|
|
4027
|
+
Label2.displayName = "Label";
|
|
4028
|
+
|
|
4029
4029
|
// src/input-with-label/input-with-label.tsx
|
|
4030
4030
|
import { Fragment, jsx as jsx74, jsxs as jsxs59 } from "react/jsx-runtime";
|
|
4031
4031
|
var inputWithLabelStyles = cva9(["c-input-with-label"], {
|
|
@@ -4064,8 +4064,8 @@ var InputWithLabel = forwardRef63(
|
|
|
4064
4064
|
InputWithLabel.displayName = "InputWithLabel";
|
|
4065
4065
|
|
|
4066
4066
|
// src/progress/progress.tsx
|
|
4067
|
-
import * as ProgressPrimitives from "@radix-ui/react-progress";
|
|
4068
4067
|
import { cx as cx9 } from "class-variance-authority";
|
|
4068
|
+
import * as ProgressPrimitives from "@radix-ui/react-progress";
|
|
4069
4069
|
import { jsx as jsx75 } from "react/jsx-runtime";
|
|
4070
4070
|
function Progress({ className, value }) {
|
|
4071
4071
|
return /* @__PURE__ */ jsx75(ProgressPrimitives.Root, { className: cx9(className, "c-progress-root"), value, children: /* @__PURE__ */ jsx75(
|
|
@@ -4103,8 +4103,8 @@ SelectItem.displayName = "SelectItem";
|
|
|
4103
4103
|
|
|
4104
4104
|
// src/select/select-root.tsx
|
|
4105
4105
|
import { forwardRef as forwardRef65 } from "react";
|
|
4106
|
-
import * as SelectPrimitives2 from "@radix-ui/react-select";
|
|
4107
4106
|
import { cva as cva10 } from "class-variance-authority";
|
|
4107
|
+
import * as SelectPrimitives2 from "@radix-ui/react-select";
|
|
4108
4108
|
import { jsx as jsx78, jsxs as jsxs61 } from "react/jsx-runtime";
|
|
4109
4109
|
var selectTriggerStyles = cva10("c-select-trigger", {
|
|
4110
4110
|
variants: {
|
|
@@ -4143,9 +4143,9 @@ var Select = {
|
|
|
4143
4143
|
};
|
|
4144
4144
|
|
|
4145
4145
|
// src/slider/slider.tsx
|
|
4146
|
-
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
4147
|
-
import { cx as cx10 } from "class-variance-authority";
|
|
4148
4146
|
import { forwardRef as forwardRef66 } from "react";
|
|
4147
|
+
import { cx as cx10 } from "class-variance-authority";
|
|
4148
|
+
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
4149
4149
|
import { jsx as jsx79, jsxs as jsxs62 } from "react/jsx-runtime";
|
|
4150
4150
|
var Slider = forwardRef66(({ className, transparentRange, ...delegated }, ref) => {
|
|
4151
4151
|
return /* @__PURE__ */ jsxs62(SliderPrimitive.Root, { className: cx10("c-slider-root", className), ref, ...delegated, children: [
|
|
@@ -4198,7 +4198,7 @@ function Tag({ children, className, variant, size, prepend, onRemove, ...delegat
|
|
|
4198
4198
|
}
|
|
4199
4199
|
|
|
4200
4200
|
// src/rich-text-editor/rich-text-editor.tsx
|
|
4201
|
-
import { useEffect as
|
|
4201
|
+
import { useEffect as useEffect12, useRef as useRef7, useState as useState11 } from "react";
|
|
4202
4202
|
import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
4203
4203
|
import { ClearEditorPlugin } from "@lexical/react/LexicalClearEditorPlugin";
|
|
4204
4204
|
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
@@ -4336,10 +4336,27 @@ import { $createListItemNode, $createListNode } from "@lexical/list";
|
|
|
4336
4336
|
import { $createHorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode";
|
|
4337
4337
|
import { $createHeadingNode, $createQuoteNode } from "@lexical/rich-text";
|
|
4338
4338
|
import { $createTableCellNode, $createTableNode, $createTableRowNode } from "@lexical/table";
|
|
4339
|
+
|
|
4340
|
+
// src/rich-text-editor/model/parse-initial-state.ts
|
|
4341
|
+
function parseInitialState({ richText }) {
|
|
4342
|
+
let richTextArray = Array.isArray(richText) ? richText : [richText];
|
|
4343
|
+
richTextArray = richTextArray.map((rootNode) => {
|
|
4344
|
+
if (!rootNode.kind || rootNode.kind === "inline") {
|
|
4345
|
+
return {
|
|
4346
|
+
type: "paragraph",
|
|
4347
|
+
kind: "block",
|
|
4348
|
+
children: [rootNode]
|
|
4349
|
+
};
|
|
4350
|
+
}
|
|
4351
|
+
return rootNode;
|
|
4352
|
+
});
|
|
4353
|
+
return richTextArray;
|
|
4354
|
+
}
|
|
4355
|
+
|
|
4356
|
+
// src/rich-text-editor/model/crystallize-to-lexical.ts
|
|
4339
4357
|
function composeInitialState({ richText }) {
|
|
4340
4358
|
return function setLexicalState() {
|
|
4341
4359
|
const root = $getRoot();
|
|
4342
|
-
const richTextArray = Array.isArray(richText) ? richText : [richText];
|
|
4343
4360
|
function handleNode({
|
|
4344
4361
|
crystallizeContentNode,
|
|
4345
4362
|
lexicalParent
|
|
@@ -4481,7 +4498,9 @@ function composeInitialState({ richText }) {
|
|
|
4481
4498
|
lexicalParent.append(lexicalNode);
|
|
4482
4499
|
}
|
|
4483
4500
|
}
|
|
4484
|
-
|
|
4501
|
+
parseInitialState({ richText }).forEach(
|
|
4502
|
+
(crystallizeContentNode) => handleNode({ crystallizeContentNode, lexicalParent: root })
|
|
4503
|
+
);
|
|
4485
4504
|
};
|
|
4486
4505
|
}
|
|
4487
4506
|
function getLexicalTextFormat(node) {
|
|
@@ -4733,8 +4752,8 @@ var BaseNodes = [
|
|
|
4733
4752
|
];
|
|
4734
4753
|
|
|
4735
4754
|
// src/rich-text-editor/plugins/AutoLinkPlugin/index.tsx
|
|
4736
|
-
import { AutoLinkPlugin } from "@lexical/react/LexicalAutoLinkPlugin";
|
|
4737
4755
|
import "react";
|
|
4756
|
+
import { AutoLinkPlugin } from "@lexical/react/LexicalAutoLinkPlugin";
|
|
4738
4757
|
import { jsx as jsx83 } from "react/jsx-runtime";
|
|
4739
4758
|
var URL_MATCHER = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
|
4740
4759
|
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,}))/;
|
|
@@ -4809,7 +4828,7 @@ function CopyButton({ editor, getCodeDOMNode }) {
|
|
|
4809
4828
|
console.error("Failed to copy: ", err);
|
|
4810
4829
|
}
|
|
4811
4830
|
}
|
|
4812
|
-
return /* @__PURE__ */ jsx84("button", { className: "
|
|
4831
|
+
return /* @__PURE__ */ jsx84("button", { className: "c-rte-code-button", onClick: handleClick, "aria-label": tr("actionCopyCode"), children: isCopyCompleted ? /* @__PURE__ */ jsx84("i", { className: "c-rte-code-button__icon c-rte-icon-success" }) : /* @__PURE__ */ jsx84("i", { className: "c-rte-code-button__icon c-rte-icon-copy" }) });
|
|
4813
4832
|
}
|
|
4814
4833
|
|
|
4815
4834
|
// src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx
|
|
@@ -4903,19 +4922,19 @@ function PrettierButton({ lang, editor, getCodeDOMNode }) {
|
|
|
4903
4922
|
setTipsVisible(false);
|
|
4904
4923
|
}
|
|
4905
4924
|
}
|
|
4906
|
-
return /* @__PURE__ */ jsxs64("div", { className: "prettier-wrapper", children: [
|
|
4925
|
+
return /* @__PURE__ */ jsxs64("div", { className: "c-rte-prettier-wrapper", children: [
|
|
4907
4926
|
/* @__PURE__ */ jsx85(
|
|
4908
4927
|
"button",
|
|
4909
4928
|
{
|
|
4910
|
-
className: "
|
|
4929
|
+
className: "c-rte-code-button",
|
|
4911
4930
|
onClick: handleClick,
|
|
4912
4931
|
onMouseEnter: handleMouseEnter,
|
|
4913
4932
|
onMouseLeave: handleMouseLeave,
|
|
4914
4933
|
"aria-label": tr("actionFormatCode"),
|
|
4915
|
-
children: syntaxError ? /* @__PURE__ */ jsx85("i", { className: "
|
|
4934
|
+
children: syntaxError ? /* @__PURE__ */ jsx85("i", { className: "c-rte-code-button__icon c-rte-icon-prettier-error" }) : /* @__PURE__ */ jsx85("i", { className: "c-rte-code-button__icon c-rte-icon-prettier" })
|
|
4916
4935
|
}
|
|
4917
4936
|
),
|
|
4918
|
-
tipsVisible ? /* @__PURE__ */ jsx85("pre", { className: "code-error-tips", children: syntaxError }) : null
|
|
4937
|
+
tipsVisible ? /* @__PURE__ */ jsx85("pre", { className: "c-rte-code-error-tips", children: syntaxError }) : null
|
|
4919
4938
|
] });
|
|
4920
4939
|
}
|
|
4921
4940
|
|
|
@@ -4997,8 +5016,8 @@ function CodeActionMenuContainer({ anchorElem }) {
|
|
|
4997
5016
|
});
|
|
4998
5017
|
const normalizedLang = normalizeCodeLang(lang);
|
|
4999
5018
|
const codeFriendlyName = getLanguageFriendlyName(lang);
|
|
5000
|
-
return /* @__PURE__ */ jsx86(Fragment2, { children: isShown ? /* @__PURE__ */ jsxs65("div", { className: "code-action-menu-container", style: { ...position }, children: [
|
|
5001
|
-
/* @__PURE__ */ jsx86("div", { className: "code-highlight-language", children: codeFriendlyName }),
|
|
5019
|
+
return /* @__PURE__ */ jsx86(Fragment2, { children: isShown ? /* @__PURE__ */ jsxs65("div", { className: "c-rte-code-action-menu-container", style: { ...position }, children: [
|
|
5020
|
+
/* @__PURE__ */ jsx86("div", { className: "c-rte-code-highlight-language", children: codeFriendlyName }),
|
|
5002
5021
|
/* @__PURE__ */ jsx86(CopyButton, { editor, getCodeDOMNode }),
|
|
5003
5022
|
canBePrettier(normalizedLang) ? /* @__PURE__ */ jsx86(PrettierButton, { editor, getCodeDOMNode, lang: normalizedLang }) : null
|
|
5004
5023
|
] }) : null });
|
|
@@ -5007,7 +5026,7 @@ function getMouseInfo(event) {
|
|
|
5007
5026
|
const target = event.target;
|
|
5008
5027
|
if (target && target instanceof HTMLElement) {
|
|
5009
5028
|
const codeDOMNode = target.closest("code.CrystallizeRTEditorTheme__code");
|
|
5010
|
-
const isOutside = !(codeDOMNode || target.closest("div.code-action-menu-container"));
|
|
5029
|
+
const isOutside = !(codeDOMNode || target.closest("div.c-rte-code-action-menu-container"));
|
|
5011
5030
|
return { codeDOMNode, isOutside };
|
|
5012
5031
|
} else {
|
|
5013
5032
|
return { codeDOMNode: null, isOutside: true };
|
|
@@ -5031,8 +5050,42 @@ function CodeHighlightPlugin() {
|
|
|
5031
5050
|
return null;
|
|
5032
5051
|
}
|
|
5033
5052
|
|
|
5053
|
+
// src/rich-text-editor/plugins/DimensionsDetectorPlugin/index.tsx
|
|
5054
|
+
import { useEffect as useEffect3, useRef as useRef2, useState as useState4 } from "react";
|
|
5055
|
+
import { jsx as jsx87 } from "react/jsx-runtime";
|
|
5056
|
+
function DimensionDetectorPlugin({ onChange }) {
|
|
5057
|
+
const [dimensions, setDimensions] = useState4();
|
|
5058
|
+
const ref = useRef2(null);
|
|
5059
|
+
useEffect3(() => {
|
|
5060
|
+
if (ref.current) {
|
|
5061
|
+
const el = ref.current;
|
|
5062
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
5063
|
+
const [first] = entries;
|
|
5064
|
+
if (first) {
|
|
5065
|
+
const [contentBox] = first.contentBoxSize;
|
|
5066
|
+
if (contentBox) {
|
|
5067
|
+
const width = contentBox.inlineSize;
|
|
5068
|
+
setDimensions({
|
|
5069
|
+
width,
|
|
5070
|
+
isSmallWidth: width < 600
|
|
5071
|
+
});
|
|
5072
|
+
}
|
|
5073
|
+
}
|
|
5074
|
+
});
|
|
5075
|
+
resizeObserver.observe(el);
|
|
5076
|
+
return () => resizeObserver.disconnect();
|
|
5077
|
+
}
|
|
5078
|
+
}, []);
|
|
5079
|
+
useEffect3(() => {
|
|
5080
|
+
if (dimensions) {
|
|
5081
|
+
onChange(dimensions);
|
|
5082
|
+
}
|
|
5083
|
+
}, [dimensions, onChange]);
|
|
5084
|
+
return /* @__PURE__ */ jsx87("div", { ref, style: { height: 1, marginTop: -1 } });
|
|
5085
|
+
}
|
|
5086
|
+
|
|
5034
5087
|
// src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.tsx
|
|
5035
|
-
import { useCallback, useEffect as
|
|
5088
|
+
import { useCallback, useEffect as useEffect5, useRef as useRef3, useState as useState6 } from "react";
|
|
5036
5089
|
import "react";
|
|
5037
5090
|
import {
|
|
5038
5091
|
$getSelection as $getSelection3,
|
|
@@ -5049,10 +5102,10 @@ import { useLexicalComposerContext as useLexicalComposerContext4 } from "@lexica
|
|
|
5049
5102
|
import { $findMatchingParent, mergeRegister } from "@lexical/utils";
|
|
5050
5103
|
|
|
5051
5104
|
// src/rich-text-editor/ui/LinkPreview.tsx
|
|
5052
|
-
import { Suspense, useEffect as
|
|
5105
|
+
import { Suspense, useEffect as useEffect4, useState as useState5 } from "react";
|
|
5053
5106
|
import { $getSelection as $getSelection2, $isTextNode as $isTextNode3 } from "lexical";
|
|
5054
5107
|
import { useLexicalComposerContext as useLexicalComposerContext3 } from "@lexical/react/LexicalComposerContext";
|
|
5055
|
-
import { Fragment as Fragment3, jsx as
|
|
5108
|
+
import { Fragment as Fragment3, jsx as jsx88, jsxs as jsxs66 } from "react/jsx-runtime";
|
|
5056
5109
|
var PREVIEW_CACHE = {};
|
|
5057
5110
|
var URL_MATCHER2 = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
|
5058
5111
|
function useSuspenseRequest(url) {
|
|
@@ -5076,12 +5129,12 @@ function useSuspenseRequest(url) {
|
|
|
5076
5129
|
function LinkPreviewContent({
|
|
5077
5130
|
url
|
|
5078
5131
|
}) {
|
|
5079
|
-
const [textContent, setTextContent] =
|
|
5132
|
+
const [textContent, setTextContent] = useState5("");
|
|
5080
5133
|
const { preview } = useSuspenseRequest(url);
|
|
5081
5134
|
const [editor] = useLexicalComposerContext3();
|
|
5082
5135
|
const tr = useTr();
|
|
5083
5136
|
const hasPreview = preview !== null && preview.google?.title;
|
|
5084
|
-
|
|
5137
|
+
useEffect4(() => {
|
|
5085
5138
|
editor.update(() => {
|
|
5086
5139
|
const sel = $getSelection2();
|
|
5087
5140
|
const nodes = sel?.getNodes();
|
|
@@ -5109,18 +5162,18 @@ function LinkPreviewContent({
|
|
|
5109
5162
|
if (!hasPreview) {
|
|
5110
5163
|
return null;
|
|
5111
5164
|
}
|
|
5112
|
-
return /* @__PURE__ */ jsxs66("div", { className: "
|
|
5113
|
-
preview.google.image && /* @__PURE__ */
|
|
5114
|
-
preview.google.title && /* @__PURE__ */
|
|
5115
|
-
preview.google.description && /* @__PURE__ */
|
|
5116
|
-
textContent && textContent !== preview.google.title ? /* @__PURE__ */
|
|
5165
|
+
return /* @__PURE__ */ jsxs66("div", { className: "c-rte-link-preview", children: [
|
|
5166
|
+
preview.google.image && /* @__PURE__ */ jsx88("div", { className: "c-rte-link-preview-image-wrapper", children: /* @__PURE__ */ jsx88("img", { src: preview.google.image, alt: preview.google.title, className: "c-rte-link-preview-image" }) }),
|
|
5167
|
+
preview.google.title && /* @__PURE__ */ jsx88("div", { className: "c-rte-link-preview-title", children: preview.google.title }),
|
|
5168
|
+
preview.google.description && /* @__PURE__ */ jsx88("div", { className: "c-rte-link-preview-description", children: preview.google.description }),
|
|
5169
|
+
textContent && textContent !== preview.google.title ? /* @__PURE__ */ jsx88(Button, { className: "c-rte-link-preview__replace-text-btn", onClick: useTitleForText, children: tr("linkPreviewReplaceTextWithTitle") }) : null
|
|
5117
5170
|
] });
|
|
5118
5171
|
}
|
|
5119
5172
|
function Glimmer(props) {
|
|
5120
|
-
return /* @__PURE__ */
|
|
5173
|
+
return /* @__PURE__ */ jsx88(
|
|
5121
5174
|
"div",
|
|
5122
5175
|
{
|
|
5123
|
-
className: "
|
|
5176
|
+
className: "c-rte-link-preview-glimmer",
|
|
5124
5177
|
...props,
|
|
5125
5178
|
style: {
|
|
5126
5179
|
animationDelay: String((props.index || 0) * 300),
|
|
@@ -5132,22 +5185,21 @@ function Glimmer(props) {
|
|
|
5132
5185
|
function LinkPreview({
|
|
5133
5186
|
url
|
|
5134
5187
|
}) {
|
|
5135
|
-
return /* @__PURE__ */
|
|
5188
|
+
return /* @__PURE__ */ jsx88(
|
|
5136
5189
|
Suspense,
|
|
5137
5190
|
{
|
|
5138
5191
|
fallback: /* @__PURE__ */ jsxs66(Fragment3, { children: [
|
|
5139
|
-
/* @__PURE__ */
|
|
5140
|
-
/* @__PURE__ */
|
|
5141
|
-
/* @__PURE__ */
|
|
5192
|
+
/* @__PURE__ */ jsx88(Glimmer, { style: { height: "80px" }, index: 0 }),
|
|
5193
|
+
/* @__PURE__ */ jsx88(Glimmer, { style: { width: "60%" }, index: 1 }),
|
|
5194
|
+
/* @__PURE__ */ jsx88(Glimmer, { style: { width: "80%" }, index: 2 })
|
|
5142
5195
|
] }),
|
|
5143
|
-
children: /* @__PURE__ */
|
|
5196
|
+
children: /* @__PURE__ */ jsx88(LinkPreviewContent, { url })
|
|
5144
5197
|
}
|
|
5145
5198
|
);
|
|
5146
5199
|
}
|
|
5147
5200
|
|
|
5148
5201
|
// src/rich-text-editor/utils/getSelectedNode.ts
|
|
5149
5202
|
import { $isAtNodeEnd } from "@lexical/selection";
|
|
5150
|
-
import "lexical";
|
|
5151
5203
|
function getSelectedNode(selection) {
|
|
5152
5204
|
const anchor = selection.anchor;
|
|
5153
5205
|
const focus = selection.focus;
|
|
@@ -5208,20 +5260,20 @@ function validateUrl(url) {
|
|
|
5208
5260
|
}
|
|
5209
5261
|
|
|
5210
5262
|
// src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.tsx
|
|
5211
|
-
import { Fragment as Fragment4, jsx as
|
|
5263
|
+
import { Fragment as Fragment4, jsx as jsx89, jsxs as jsxs67 } from "react/jsx-runtime";
|
|
5212
5264
|
function FloatingLinkEditor({
|
|
5213
5265
|
editor,
|
|
5214
5266
|
isLink,
|
|
5215
5267
|
setIsLink,
|
|
5216
5268
|
anchorElem
|
|
5217
5269
|
}) {
|
|
5218
|
-
const editorRef =
|
|
5219
|
-
const inputRef =
|
|
5220
|
-
const [linkUrl, setLinkUrl] =
|
|
5221
|
-
const [rel, setRel] =
|
|
5222
|
-
const [target, setTarget] =
|
|
5223
|
-
const [isEditMode, setEditMode] =
|
|
5224
|
-
const [lastSelection, setLastSelection] =
|
|
5270
|
+
const editorRef = useRef3(null);
|
|
5271
|
+
const inputRef = useRef3(null);
|
|
5272
|
+
const [linkUrl, setLinkUrl] = useState6("");
|
|
5273
|
+
const [rel, setRel] = useState6(null);
|
|
5274
|
+
const [target, setTarget] = useState6(null);
|
|
5275
|
+
const [isEditMode, setEditMode] = useState6(false);
|
|
5276
|
+
const [lastSelection, setLastSelection] = useState6(null);
|
|
5225
5277
|
const tr = useTr();
|
|
5226
5278
|
const updateLinkEditor = useCallback(() => {
|
|
5227
5279
|
const selection = $getSelection3();
|
|
@@ -5273,7 +5325,7 @@ function FloatingLinkEditor({
|
|
|
5273
5325
|
}
|
|
5274
5326
|
return true;
|
|
5275
5327
|
}, [anchorElem, editor]);
|
|
5276
|
-
|
|
5328
|
+
useEffect5(() => {
|
|
5277
5329
|
const scrollerElem = anchorElem.parentElement;
|
|
5278
5330
|
const update = () => {
|
|
5279
5331
|
editor.getEditorState().read(() => {
|
|
@@ -5291,7 +5343,7 @@ function FloatingLinkEditor({
|
|
|
5291
5343
|
}
|
|
5292
5344
|
};
|
|
5293
5345
|
}, [anchorElem.parentElement, editor, updateLinkEditor]);
|
|
5294
|
-
|
|
5346
|
+
useEffect5(() => {
|
|
5295
5347
|
return mergeRegister(
|
|
5296
5348
|
editor.registerUpdateListener(({ editorState }) => {
|
|
5297
5349
|
editorState.read(() => {
|
|
@@ -5319,18 +5371,18 @@ function FloatingLinkEditor({
|
|
|
5319
5371
|
)
|
|
5320
5372
|
);
|
|
5321
5373
|
}, [editor, updateLinkEditor, setIsLink, isLink]);
|
|
5322
|
-
|
|
5374
|
+
useEffect5(() => {
|
|
5323
5375
|
editor.getEditorState().read(() => {
|
|
5324
5376
|
updateLinkEditor();
|
|
5325
5377
|
});
|
|
5326
5378
|
}, [editor, updateLinkEditor]);
|
|
5327
|
-
|
|
5379
|
+
useEffect5(() => {
|
|
5328
5380
|
if (isEditMode && inputRef.current) {
|
|
5329
5381
|
inputRef.current.focus();
|
|
5330
5382
|
}
|
|
5331
5383
|
}, [isEditMode]);
|
|
5332
|
-
return /* @__PURE__ */
|
|
5333
|
-
/* @__PURE__ */
|
|
5384
|
+
return /* @__PURE__ */ jsx89("div", { ref: editorRef, className: "c-rte-link-editor", children: isEditMode ? /* @__PURE__ */ jsxs67("div", { children: [
|
|
5385
|
+
/* @__PURE__ */ jsx89("div", { className: "c-rte-link-editor-input-group", children: /* @__PURE__ */ jsx89(
|
|
5334
5386
|
InputWithLabel,
|
|
5335
5387
|
{
|
|
5336
5388
|
label: tr("linkEditorLink"),
|
|
@@ -5339,7 +5391,7 @@ function FloatingLinkEditor({
|
|
|
5339
5391
|
onChange: (e) => setLinkUrl(e.target.value)
|
|
5340
5392
|
}
|
|
5341
5393
|
) }),
|
|
5342
|
-
/* @__PURE__ */
|
|
5394
|
+
/* @__PURE__ */ jsx89("div", { className: "c-rte-link-editor-input-group", children: /* @__PURE__ */ jsx89(
|
|
5343
5395
|
InputWithLabel,
|
|
5344
5396
|
{
|
|
5345
5397
|
label: tr("linkEditorRel"),
|
|
@@ -5348,7 +5400,7 @@ function FloatingLinkEditor({
|
|
|
5348
5400
|
onChange: (e) => setRel(e.target.value)
|
|
5349
5401
|
}
|
|
5350
5402
|
) }),
|
|
5351
|
-
/* @__PURE__ */
|
|
5403
|
+
/* @__PURE__ */ jsx89("div", { className: "c-rte-link-editor-input-group", children: /* @__PURE__ */ jsx89(
|
|
5352
5404
|
InputWithLabel,
|
|
5353
5405
|
{
|
|
5354
5406
|
label: tr("linkEditorTarget"),
|
|
@@ -5357,7 +5409,7 @@ function FloatingLinkEditor({
|
|
|
5357
5409
|
onChange: (e) => setTarget(e.target.value)
|
|
5358
5410
|
}
|
|
5359
5411
|
) }),
|
|
5360
|
-
/* @__PURE__ */
|
|
5412
|
+
/* @__PURE__ */ jsx89("div", { className: "c-rte-link-editor-button-wrap", children: /* @__PURE__ */ jsx89(
|
|
5361
5413
|
Button,
|
|
5362
5414
|
{
|
|
5363
5415
|
onClick: () => {
|
|
@@ -5376,15 +5428,15 @@ function FloatingLinkEditor({
|
|
|
5376
5428
|
}
|
|
5377
5429
|
) })
|
|
5378
5430
|
] }) : /* @__PURE__ */ jsxs67(Fragment4, { children: [
|
|
5379
|
-
/* @__PURE__ */ jsxs67("div", { className: "
|
|
5380
|
-
/* @__PURE__ */ jsxs67("div", { className: "
|
|
5381
|
-
/* @__PURE__ */
|
|
5382
|
-
rel || target ? /* @__PURE__ */ jsxs67("div", { className: "
|
|
5383
|
-
rel && /* @__PURE__ */
|
|
5384
|
-
target && /* @__PURE__ */
|
|
5431
|
+
/* @__PURE__ */ jsxs67("div", { className: "c-rte-link-editor-link-input", children: [
|
|
5432
|
+
/* @__PURE__ */ jsxs67("div", { className: "c-rte-link-editor-link-preview", children: [
|
|
5433
|
+
/* @__PURE__ */ jsx89("a", { href: linkUrl, target: "_blank", rel: "noopener noreferrer", children: linkUrl }),
|
|
5434
|
+
rel || target ? /* @__PURE__ */ jsxs67("div", { className: "c-rte-link-editor-preview-attrs", children: [
|
|
5435
|
+
rel && /* @__PURE__ */ jsx89("div", { className: "c-rte-link-editor-preview-attr", children: rel }),
|
|
5436
|
+
target && /* @__PURE__ */ jsx89("div", { className: "c-rte-link-editor-preview-attr", children: target })
|
|
5385
5437
|
] }) : null
|
|
5386
5438
|
] }),
|
|
5387
|
-
/* @__PURE__ */
|
|
5439
|
+
/* @__PURE__ */ jsx89("div", { children: /* @__PURE__ */ jsx89(
|
|
5388
5440
|
IconButton,
|
|
5389
5441
|
{
|
|
5390
5442
|
size: "sm",
|
|
@@ -5392,16 +5444,16 @@ function FloatingLinkEditor({
|
|
|
5392
5444
|
onMouseDown: (event) => event.preventDefault(),
|
|
5393
5445
|
onClick: () => setEditMode(true),
|
|
5394
5446
|
"aria-label": tr("linkEditorEdit"),
|
|
5395
|
-
children: /* @__PURE__ */
|
|
5447
|
+
children: /* @__PURE__ */ jsx89(Icon.Edit, {})
|
|
5396
5448
|
}
|
|
5397
5449
|
) })
|
|
5398
5450
|
] }),
|
|
5399
|
-
/* @__PURE__ */
|
|
5451
|
+
/* @__PURE__ */ jsx89("div", { children: /* @__PURE__ */ jsx89(LinkPreview, { url: linkUrl }) })
|
|
5400
5452
|
] }) });
|
|
5401
5453
|
}
|
|
5402
5454
|
function useFloatingLinkEditorToolbar(editor, anchorElem) {
|
|
5403
|
-
const [activeEditor, setActiveEditor] =
|
|
5404
|
-
const [isLink, setIsLink] =
|
|
5455
|
+
const [activeEditor, setActiveEditor] = useState6(editor);
|
|
5456
|
+
const [isLink, setIsLink] = useState6(false);
|
|
5405
5457
|
const updateToolbar = useCallback(() => {
|
|
5406
5458
|
const selection = $getSelection3();
|
|
5407
5459
|
if ($isRangeSelection(selection)) {
|
|
@@ -5415,7 +5467,7 @@ function useFloatingLinkEditorToolbar(editor, anchorElem) {
|
|
|
5415
5467
|
}
|
|
5416
5468
|
}
|
|
5417
5469
|
}, []);
|
|
5418
|
-
|
|
5470
|
+
useEffect5(() => {
|
|
5419
5471
|
return editor.registerCommand(
|
|
5420
5472
|
SELECTION_CHANGE_COMMAND,
|
|
5421
5473
|
(_payload, newEditor) => {
|
|
@@ -5427,7 +5479,7 @@ function useFloatingLinkEditorToolbar(editor, anchorElem) {
|
|
|
5427
5479
|
);
|
|
5428
5480
|
}, [editor, updateToolbar]);
|
|
5429
5481
|
return isLink ? createPortal2(
|
|
5430
|
-
/* @__PURE__ */
|
|
5482
|
+
/* @__PURE__ */ jsx89(FloatingLinkEditor, { editor: activeEditor, isLink, anchorElem, setIsLink }),
|
|
5431
5483
|
anchorElem
|
|
5432
5484
|
) : null;
|
|
5433
5485
|
}
|
|
@@ -5439,7 +5491,7 @@ function FloatingLinkEditorPlugin({
|
|
|
5439
5491
|
}
|
|
5440
5492
|
|
|
5441
5493
|
// src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx
|
|
5442
|
-
import { useCallback as useCallback2, useEffect as
|
|
5494
|
+
import { useCallback as useCallback2, useEffect as useEffect6, useRef as useRef4, useState as useState7 } from "react";
|
|
5443
5495
|
import "react";
|
|
5444
5496
|
import {
|
|
5445
5497
|
$getSelection as $getSelection4,
|
|
@@ -5488,7 +5540,7 @@ function getDOMRangeRect(nativeSelection, rootElement) {
|
|
|
5488
5540
|
}
|
|
5489
5541
|
|
|
5490
5542
|
// src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx
|
|
5491
|
-
import { Fragment as Fragment5, jsx as
|
|
5543
|
+
import { Fragment as Fragment5, jsx as jsx90, jsxs as jsxs68 } from "react/jsx-runtime";
|
|
5492
5544
|
function TextFormatFloatingToolbar({
|
|
5493
5545
|
editor,
|
|
5494
5546
|
anchorElem,
|
|
@@ -5501,7 +5553,7 @@ function TextFormatFloatingToolbar({
|
|
|
5501
5553
|
isSubscript,
|
|
5502
5554
|
isSuperscript
|
|
5503
5555
|
}) {
|
|
5504
|
-
const popupCharStylesEditorRef =
|
|
5556
|
+
const popupCharStylesEditorRef = useRef4(null);
|
|
5505
5557
|
const tr = useTr();
|
|
5506
5558
|
const insertLink = useCallback2(() => {
|
|
5507
5559
|
if (!isLink) {
|
|
@@ -5523,7 +5575,7 @@ function TextFormatFloatingToolbar({
|
|
|
5523
5575
|
setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElem);
|
|
5524
5576
|
}
|
|
5525
5577
|
}, [editor, anchorElem]);
|
|
5526
|
-
|
|
5578
|
+
useEffect6(() => {
|
|
5527
5579
|
const scrollerElem = anchorElem.parentElement;
|
|
5528
5580
|
const update = () => {
|
|
5529
5581
|
editor.getEditorState().read(() => {
|
|
@@ -5541,7 +5593,7 @@ function TextFormatFloatingToolbar({
|
|
|
5541
5593
|
}
|
|
5542
5594
|
};
|
|
5543
5595
|
}, [editor, updateTextFormatFloatingToolbar, anchorElem]);
|
|
5544
|
-
|
|
5596
|
+
useEffect6(() => {
|
|
5545
5597
|
editor.getEditorState().read(() => {
|
|
5546
5598
|
updateTextFormatFloatingToolbar();
|
|
5547
5599
|
});
|
|
@@ -5561,8 +5613,8 @@ function TextFormatFloatingToolbar({
|
|
|
5561
5613
|
)
|
|
5562
5614
|
);
|
|
5563
5615
|
}, [editor, updateTextFormatFloatingToolbar]);
|
|
5564
|
-
return /* @__PURE__ */
|
|
5565
|
-
/* @__PURE__ */
|
|
5616
|
+
return /* @__PURE__ */ jsx90("div", { ref: popupCharStylesEditorRef, className: "c-rte-floating-text-format-tb-plugin", children: editor.isEditable() && /* @__PURE__ */ jsxs68(Fragment5, { children: [
|
|
5617
|
+
/* @__PURE__ */ jsx90(
|
|
5566
5618
|
IconButton,
|
|
5567
5619
|
{
|
|
5568
5620
|
onClick: () => {
|
|
@@ -5571,15 +5623,15 @@ function TextFormatFloatingToolbar({
|
|
|
5571
5623
|
style: { padding: 0, overflow: "hidden" },
|
|
5572
5624
|
title: tr(IS_APPLE ? "actionFormatAsStrongTitleApple" : "actionFormatAsStrongTitle"),
|
|
5573
5625
|
"aria-label": tr("actionFormatAsStrongLabel"),
|
|
5574
|
-
children: /* @__PURE__ */
|
|
5626
|
+
children: /* @__PURE__ */ jsx90(
|
|
5575
5627
|
"i",
|
|
5576
5628
|
{
|
|
5577
|
-
className: `
|
|
5629
|
+
className: `c-rte-icon-bold c-rte-floating-text-format-tb-plugin__format-icon ${isBold ? "selected" : ""}`
|
|
5578
5630
|
}
|
|
5579
5631
|
)
|
|
5580
5632
|
}
|
|
5581
5633
|
),
|
|
5582
|
-
/* @__PURE__ */
|
|
5634
|
+
/* @__PURE__ */ jsx90(
|
|
5583
5635
|
IconButton,
|
|
5584
5636
|
{
|
|
5585
5637
|
style: { padding: 0, overflow: "hidden" },
|
|
@@ -5588,15 +5640,15 @@ function TextFormatFloatingToolbar({
|
|
|
5588
5640
|
},
|
|
5589
5641
|
title: tr("actionFormatAsEmphasizedTitle"),
|
|
5590
5642
|
"aria-label": tr("actionFormatAsEmphasizedLabel"),
|
|
5591
|
-
children: /* @__PURE__ */
|
|
5643
|
+
children: /* @__PURE__ */ jsx90(
|
|
5592
5644
|
"i",
|
|
5593
5645
|
{
|
|
5594
|
-
className: `
|
|
5646
|
+
className: `c-rte-icon-italic c-rte-floating-text-format-tb-plugin__format-icon ${isItalic ? "selected" : ""}`
|
|
5595
5647
|
}
|
|
5596
5648
|
)
|
|
5597
5649
|
}
|
|
5598
5650
|
),
|
|
5599
|
-
/* @__PURE__ */
|
|
5651
|
+
/* @__PURE__ */ jsx90(
|
|
5600
5652
|
IconButton,
|
|
5601
5653
|
{
|
|
5602
5654
|
style: { padding: 0, overflow: "hidden" },
|
|
@@ -5605,15 +5657,15 @@ function TextFormatFloatingToolbar({
|
|
|
5605
5657
|
},
|
|
5606
5658
|
title: tr("actionFormatAsUnderlinedTitle"),
|
|
5607
5659
|
"aria-label": tr("actionFormatAsUnderlinedLabel"),
|
|
5608
|
-
children: /* @__PURE__ */
|
|
5660
|
+
children: /* @__PURE__ */ jsx90(
|
|
5609
5661
|
"i",
|
|
5610
5662
|
{
|
|
5611
|
-
className: `
|
|
5663
|
+
className: `c-rte-icon-underline c-rte-floating-text-format-tb-plugin__format-icon ${isUnderline ? "selected" : ""}`
|
|
5612
5664
|
}
|
|
5613
5665
|
)
|
|
5614
5666
|
}
|
|
5615
5667
|
),
|
|
5616
|
-
/* @__PURE__ */
|
|
5668
|
+
/* @__PURE__ */ jsx90(
|
|
5617
5669
|
IconButton,
|
|
5618
5670
|
{
|
|
5619
5671
|
style: { padding: 0, overflow: "hidden" },
|
|
@@ -5622,15 +5674,15 @@ function TextFormatFloatingToolbar({
|
|
|
5622
5674
|
},
|
|
5623
5675
|
title: tr("actionFormatWithStrikethroughTitle"),
|
|
5624
5676
|
"aria-label": tr("actionFormatWithStrikethroughLabel"),
|
|
5625
|
-
children: /* @__PURE__ */
|
|
5677
|
+
children: /* @__PURE__ */ jsx90(
|
|
5626
5678
|
"i",
|
|
5627
5679
|
{
|
|
5628
|
-
className: `
|
|
5680
|
+
className: `c-rte-icon-strikethrough c-rte-floating-text-format-tb-plugin__format-icon ${isStrikethrough ? "selected" : ""}`
|
|
5629
5681
|
}
|
|
5630
5682
|
)
|
|
5631
5683
|
}
|
|
5632
5684
|
),
|
|
5633
|
-
/* @__PURE__ */
|
|
5685
|
+
/* @__PURE__ */ jsx90(
|
|
5634
5686
|
IconButton,
|
|
5635
5687
|
{
|
|
5636
5688
|
style: { padding: 0, overflow: "hidden" },
|
|
@@ -5639,15 +5691,15 @@ function TextFormatFloatingToolbar({
|
|
|
5639
5691
|
},
|
|
5640
5692
|
title: tr("actionFormatWithSubscriptTitle"),
|
|
5641
5693
|
"aria-label": tr("actionFormatWithSubscriptLabel"),
|
|
5642
|
-
children: /* @__PURE__ */
|
|
5694
|
+
children: /* @__PURE__ */ jsx90(
|
|
5643
5695
|
"i",
|
|
5644
5696
|
{
|
|
5645
|
-
className: `
|
|
5697
|
+
className: `c-rte-icon-subscript c-rte-floating-text-format-tb-plugin__format-icon ${isSubscript ? "selected" : ""}`
|
|
5646
5698
|
}
|
|
5647
5699
|
)
|
|
5648
5700
|
}
|
|
5649
5701
|
),
|
|
5650
|
-
/* @__PURE__ */
|
|
5702
|
+
/* @__PURE__ */ jsx90(
|
|
5651
5703
|
IconButton,
|
|
5652
5704
|
{
|
|
5653
5705
|
style: { padding: 0, overflow: "hidden" },
|
|
@@ -5656,15 +5708,15 @@ function TextFormatFloatingToolbar({
|
|
|
5656
5708
|
},
|
|
5657
5709
|
title: tr("actionFormatWithSuperscriptTitle"),
|
|
5658
5710
|
"aria-label": tr("actionFormatWithSuperscriptLabel"),
|
|
5659
|
-
children: /* @__PURE__ */
|
|
5711
|
+
children: /* @__PURE__ */ jsx90(
|
|
5660
5712
|
"i",
|
|
5661
5713
|
{
|
|
5662
|
-
className: `
|
|
5714
|
+
className: `c-rte-icon-superscript c-rte-floating-text-format-tb-plugin__format-icon ${isSuperscript ? "selected" : ""}`
|
|
5663
5715
|
}
|
|
5664
5716
|
)
|
|
5665
5717
|
}
|
|
5666
5718
|
),
|
|
5667
|
-
/* @__PURE__ */
|
|
5719
|
+
/* @__PURE__ */ jsx90(
|
|
5668
5720
|
IconButton,
|
|
5669
5721
|
{
|
|
5670
5722
|
style: { padding: 0, overflow: "hidden" },
|
|
@@ -5672,24 +5724,24 @@ function TextFormatFloatingToolbar({
|
|
|
5672
5724
|
editor.dispatchCommand(FORMAT_TEXT_COMMAND, "code");
|
|
5673
5725
|
},
|
|
5674
5726
|
"aria-label": tr("actionInsertCodeBlock"),
|
|
5675
|
-
children: /* @__PURE__ */
|
|
5727
|
+
children: /* @__PURE__ */ jsx90(
|
|
5676
5728
|
"i",
|
|
5677
5729
|
{
|
|
5678
|
-
className: `
|
|
5730
|
+
className: `c-rte-icon-code c-rte-floating-text-format-tb-plugin__format-icon ${isCode ? "selected" : ""}`
|
|
5679
5731
|
}
|
|
5680
5732
|
)
|
|
5681
5733
|
}
|
|
5682
5734
|
),
|
|
5683
|
-
/* @__PURE__ */
|
|
5735
|
+
/* @__PURE__ */ jsx90(
|
|
5684
5736
|
IconButton,
|
|
5685
5737
|
{
|
|
5686
5738
|
style: { padding: 0, overflow: "hidden" },
|
|
5687
5739
|
onClick: insertLink,
|
|
5688
5740
|
"aria-label": tr("actionInsertlink"),
|
|
5689
|
-
children: /* @__PURE__ */
|
|
5741
|
+
children: /* @__PURE__ */ jsx90(
|
|
5690
5742
|
"i",
|
|
5691
5743
|
{
|
|
5692
|
-
className: `
|
|
5744
|
+
className: `c-rte-icon-link c-rte-floating-text-format-tb-plugin__format-icon ${isLink ? "selected" : ""}`
|
|
5693
5745
|
}
|
|
5694
5746
|
)
|
|
5695
5747
|
}
|
|
@@ -5697,15 +5749,15 @@ function TextFormatFloatingToolbar({
|
|
|
5697
5749
|
] }) });
|
|
5698
5750
|
}
|
|
5699
5751
|
function useFloatingTextFormatToolbar(editor, anchorElem) {
|
|
5700
|
-
const [isText, setIsText] =
|
|
5701
|
-
const [isLink, setIsLink] =
|
|
5702
|
-
const [isBold, setIsBold] =
|
|
5703
|
-
const [isItalic, setIsItalic] =
|
|
5704
|
-
const [isUnderline, setIsUnderline] =
|
|
5705
|
-
const [isStrikethrough, setIsStrikethrough] =
|
|
5706
|
-
const [isSubscript, setIsSubscript] =
|
|
5707
|
-
const [isSuperscript, setIsSuperscript] =
|
|
5708
|
-
const [isCode, setIsCode] =
|
|
5752
|
+
const [isText, setIsText] = useState7(false);
|
|
5753
|
+
const [isLink, setIsLink] = useState7(false);
|
|
5754
|
+
const [isBold, setIsBold] = useState7(false);
|
|
5755
|
+
const [isItalic, setIsItalic] = useState7(false);
|
|
5756
|
+
const [isUnderline, setIsUnderline] = useState7(false);
|
|
5757
|
+
const [isStrikethrough, setIsStrikethrough] = useState7(false);
|
|
5758
|
+
const [isSubscript, setIsSubscript] = useState7(false);
|
|
5759
|
+
const [isSuperscript, setIsSuperscript] = useState7(false);
|
|
5760
|
+
const [isCode, setIsCode] = useState7(false);
|
|
5709
5761
|
const updatePopup = useCallback2(() => {
|
|
5710
5762
|
editor.getEditorState().read(() => {
|
|
5711
5763
|
if (editor.isComposing()) {
|
|
@@ -5742,13 +5794,13 @@ function useFloatingTextFormatToolbar(editor, anchorElem) {
|
|
|
5742
5794
|
}
|
|
5743
5795
|
});
|
|
5744
5796
|
}, [editor]);
|
|
5745
|
-
|
|
5797
|
+
useEffect6(() => {
|
|
5746
5798
|
document.addEventListener("selectionchange", updatePopup);
|
|
5747
5799
|
return () => {
|
|
5748
5800
|
document.removeEventListener("selectionchange", updatePopup);
|
|
5749
5801
|
};
|
|
5750
5802
|
}, [updatePopup]);
|
|
5751
|
-
|
|
5803
|
+
useEffect6(() => {
|
|
5752
5804
|
return mergeRegister2(
|
|
5753
5805
|
editor.registerUpdateListener(() => {
|
|
5754
5806
|
updatePopup();
|
|
@@ -5764,7 +5816,7 @@ function useFloatingTextFormatToolbar(editor, anchorElem) {
|
|
|
5764
5816
|
return null;
|
|
5765
5817
|
}
|
|
5766
5818
|
return createPortal3(
|
|
5767
|
-
/* @__PURE__ */
|
|
5819
|
+
/* @__PURE__ */ jsx90(
|
|
5768
5820
|
TextFormatFloatingToolbar,
|
|
5769
5821
|
{
|
|
5770
5822
|
editor,
|
|
@@ -5790,16 +5842,15 @@ function FloatingTextFormatToolbarPlugin({
|
|
|
5790
5842
|
}
|
|
5791
5843
|
|
|
5792
5844
|
// src/rich-text-editor/plugins/LinkPlugin/index.tsx
|
|
5793
|
-
import { LinkPlugin as LexicalLinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
5794
5845
|
import "react";
|
|
5795
|
-
import {
|
|
5846
|
+
import { LinkPlugin as LexicalLinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
5847
|
+
import { jsx as jsx91 } from "react/jsx-runtime";
|
|
5796
5848
|
function LinkPlugin() {
|
|
5797
|
-
return /* @__PURE__ */
|
|
5849
|
+
return /* @__PURE__ */ jsx91(LexicalLinkPlugin, { validateUrl });
|
|
5798
5850
|
}
|
|
5799
5851
|
|
|
5800
5852
|
// src/rich-text-editor/plugins/ListMaxIndentLevelPlugin/index.ts
|
|
5801
|
-
import {
|
|
5802
|
-
import { useLexicalComposerContext as useLexicalComposerContext6 } from "@lexical/react/LexicalComposerContext";
|
|
5853
|
+
import { useEffect as useEffect7 } from "react";
|
|
5803
5854
|
import {
|
|
5804
5855
|
$getSelection as $getSelection5,
|
|
5805
5856
|
$isElementNode as $isElementNode2,
|
|
@@ -5807,18 +5858,14 @@ import {
|
|
|
5807
5858
|
COMMAND_PRIORITY_CRITICAL as COMMAND_PRIORITY_CRITICAL2,
|
|
5808
5859
|
INDENT_CONTENT_COMMAND
|
|
5809
5860
|
} from "lexical";
|
|
5810
|
-
import {
|
|
5861
|
+
import { $getListDepth, $isListItemNode as $isListItemNode2, $isListNode as $isListNode2 } from "@lexical/list";
|
|
5862
|
+
import { useLexicalComposerContext as useLexicalComposerContext6 } from "@lexical/react/LexicalComposerContext";
|
|
5811
5863
|
function getElementNodesInSelection(selection) {
|
|
5812
5864
|
const nodesInSelection = selection.getNodes();
|
|
5813
5865
|
if (nodesInSelection.length === 0) {
|
|
5814
|
-
return /* @__PURE__ */ new Set([
|
|
5815
|
-
selection.anchor.getNode().getParentOrThrow(),
|
|
5816
|
-
selection.focus.getNode().getParentOrThrow()
|
|
5817
|
-
]);
|
|
5866
|
+
return /* @__PURE__ */ new Set([selection.anchor.getNode().getParentOrThrow(), selection.focus.getNode().getParentOrThrow()]);
|
|
5818
5867
|
}
|
|
5819
|
-
return new Set(
|
|
5820
|
-
nodesInSelection.map((n) => $isElementNode2(n) ? n : n.getParentOrThrow())
|
|
5821
|
-
);
|
|
5868
|
+
return new Set(nodesInSelection.map((n) => $isElementNode2(n) ? n : n.getParentOrThrow()));
|
|
5822
5869
|
}
|
|
5823
5870
|
function isIndentPermitted(maxDepth) {
|
|
5824
5871
|
const selection = $getSelection5();
|
|
@@ -5833,9 +5880,7 @@ function isIndentPermitted(maxDepth) {
|
|
|
5833
5880
|
} else if ($isListItemNode2(elementNode)) {
|
|
5834
5881
|
const parent2 = elementNode.getParent();
|
|
5835
5882
|
if (!$isListNode2(parent2)) {
|
|
5836
|
-
throw new Error(
|
|
5837
|
-
"ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent."
|
|
5838
|
-
);
|
|
5883
|
+
throw new Error("ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent.");
|
|
5839
5884
|
}
|
|
5840
5885
|
totalDepth = Math.max($getListDepth(parent2) + 1, totalDepth);
|
|
5841
5886
|
}
|
|
@@ -5844,7 +5889,7 @@ function isIndentPermitted(maxDepth) {
|
|
|
5844
5889
|
}
|
|
5845
5890
|
function ListMaxIndentLevelPlugin({ maxDepth }) {
|
|
5846
5891
|
const [editor] = useLexicalComposerContext6();
|
|
5847
|
-
|
|
5892
|
+
useEffect7(() => {
|
|
5848
5893
|
return editor.registerCommand(
|
|
5849
5894
|
INDENT_CONTENT_COMMAND,
|
|
5850
5895
|
() => !isIndentPermitted(maxDepth ?? 7),
|
|
@@ -5855,7 +5900,7 @@ function ListMaxIndentLevelPlugin({ maxDepth }) {
|
|
|
5855
5900
|
}
|
|
5856
5901
|
|
|
5857
5902
|
// src/rich-text-editor/plugins/MaxLengthPlugin/index.tsx
|
|
5858
|
-
import { useEffect as
|
|
5903
|
+
import { useEffect as useEffect8 } from "react";
|
|
5859
5904
|
import { $getSelection as $getSelection6, $isRangeSelection as $isRangeSelection4 } from "lexical";
|
|
5860
5905
|
import { useLexicalComposerContext as useLexicalComposerContext7 } from "@lexical/react/LexicalComposerContext";
|
|
5861
5906
|
import { trimTextContentFromAnchor } from "@lexical/selection";
|
|
@@ -5897,7 +5942,7 @@ ${content}
|
|
|
5897
5942
|
// src/rich-text-editor/plugins/MaxLengthPlugin/index.tsx
|
|
5898
5943
|
function MaxLengthPlugin({ maxLength }) {
|
|
5899
5944
|
const [editor] = useLexicalComposerContext7();
|
|
5900
|
-
|
|
5945
|
+
useEffect8(() => {
|
|
5901
5946
|
let lastRestoredEditorState = null;
|
|
5902
5947
|
return editor.registerUpdateListener(({ editorState, prevEditorState }) => {
|
|
5903
5948
|
editor.update(() => {
|
|
@@ -5927,7 +5972,7 @@ function MaxLengthPlugin({ maxLength }) {
|
|
|
5927
5972
|
}
|
|
5928
5973
|
|
|
5929
5974
|
// src/rich-text-editor/plugins/TabFocusPlugin/index.tsx
|
|
5930
|
-
import { useEffect as
|
|
5975
|
+
import { useEffect as useEffect9 } from "react";
|
|
5931
5976
|
import { $getSelection as $getSelection7, $isRangeSelection as $isRangeSelection5, $setSelection as $setSelection2, FOCUS_COMMAND } from "lexical";
|
|
5932
5977
|
import { useLexicalComposerContext as useLexicalComposerContext8 } from "@lexical/react/LexicalComposerContext";
|
|
5933
5978
|
var COMMAND_PRIORITY_LOW3 = 1;
|
|
@@ -5947,7 +5992,7 @@ function registerKeyTimeStampTracker() {
|
|
|
5947
5992
|
}
|
|
5948
5993
|
function TabFocusPlugin() {
|
|
5949
5994
|
const [editor] = useLexicalComposerContext8();
|
|
5950
|
-
|
|
5995
|
+
useEffect9(() => {
|
|
5951
5996
|
if (!hasRegisteredKeyDownListener) {
|
|
5952
5997
|
registerKeyTimeStampTracker();
|
|
5953
5998
|
hasRegisteredKeyDownListener = true;
|
|
@@ -5970,7 +6015,7 @@ function TabFocusPlugin() {
|
|
|
5970
6015
|
}
|
|
5971
6016
|
|
|
5972
6017
|
// src/rich-text-editor/plugins/TableActionMenuPlugin/index.tsx
|
|
5973
|
-
import { useCallback as useCallback3, useEffect as
|
|
6018
|
+
import { useCallback as useCallback3, useEffect as useEffect10, useRef as useRef5, useState as useState8 } from "react";
|
|
5974
6019
|
import { $getRoot as $getRoot3, $getSelection as $getSelection8, $isRangeSelection as $isRangeSelection6, DEPRECATED_$isGridSelection } from "lexical";
|
|
5975
6020
|
import { createPortal as createPortal4 } from "react-dom";
|
|
5976
6021
|
import { useLexicalComposerContext as useLexicalComposerContext9 } from "@lexical/react/LexicalComposerContext";
|
|
@@ -5992,16 +6037,16 @@ import {
|
|
|
5992
6037
|
TableCellHeaderStates,
|
|
5993
6038
|
TableCellNode as TableCellNode2
|
|
5994
6039
|
} from "@lexical/table";
|
|
5995
|
-
import { Fragment as Fragment6, jsx as
|
|
6040
|
+
import { Fragment as Fragment6, jsx as jsx92, jsxs as jsxs69 } from "react/jsx-runtime";
|
|
5996
6041
|
function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
5997
6042
|
const [editor] = useLexicalComposerContext9();
|
|
5998
|
-
const [tableCellNode, updateTableCellNode] =
|
|
5999
|
-
const [selectionCounts, updateSelectionCounts] =
|
|
6043
|
+
const [tableCellNode, updateTableCellNode] = useState8(_tableCellNode);
|
|
6044
|
+
const [selectionCounts, updateSelectionCounts] = useState8({
|
|
6000
6045
|
columns: 1,
|
|
6001
6046
|
rows: 1
|
|
6002
6047
|
});
|
|
6003
6048
|
const tr = useTr();
|
|
6004
|
-
|
|
6049
|
+
useEffect10(() => {
|
|
6005
6050
|
return editor.registerMutationListener(TableCellNode2, (nodeMutations) => {
|
|
6006
6051
|
const nodeUpdated = nodeMutations.get(tableCellNode.getKey()) === "updated";
|
|
6007
6052
|
if (nodeUpdated) {
|
|
@@ -6011,7 +6056,7 @@ function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
|
6011
6056
|
}
|
|
6012
6057
|
});
|
|
6013
6058
|
}, [editor, tableCellNode]);
|
|
6014
|
-
|
|
6059
|
+
useEffect10(() => {
|
|
6015
6060
|
editor.getEditorState().read(() => {
|
|
6016
6061
|
const selection = $getSelection8();
|
|
6017
6062
|
if (DEPRECATED_$isGridSelection(selection)) {
|
|
@@ -6148,29 +6193,29 @@ function TableActionMenu({ tableCellNode: _tableCellNode, tableStats }) {
|
|
|
6148
6193
|
});
|
|
6149
6194
|
}, [editor, tableCellNode, clearTableSelection]);
|
|
6150
6195
|
return /* @__PURE__ */ jsxs69(Fragment6, { children: [
|
|
6151
|
-
/* @__PURE__ */
|
|
6152
|
-
/* @__PURE__ */
|
|
6153
|
-
/* @__PURE__ */
|
|
6154
|
-
/* @__PURE__ */
|
|
6155
|
-
/* @__PURE__ */
|
|
6196
|
+
/* @__PURE__ */ jsx92(DropdownMenu.Item, { onSelect: () => insertTableRowAtSelection(false), children: tr("actionTableInsertRowsAbove", selectionCounts.rows) }),
|
|
6197
|
+
/* @__PURE__ */ jsx92(DropdownMenu.Item, { onSelect: () => insertTableRowAtSelection(true), children: tr("actionTableInsertRowsBelow", selectionCounts.rows) }),
|
|
6198
|
+
/* @__PURE__ */ jsx92(DropdownMenu.Item, { onSelect: () => insertTableColumnAtSelection(false), children: tr("actionTableInsertColumnsBefore", selectionCounts.columns) }),
|
|
6199
|
+
/* @__PURE__ */ jsx92(DropdownMenu.Item, { onSelect: () => insertTableColumnAtSelection(true), children: tr("actionTableInsertColumnsAfter", selectionCounts.columns) }),
|
|
6200
|
+
/* @__PURE__ */ jsx92(DropdownMenu.Item, { onSelect: () => toggleTableRowIsHeader(), children: tr(
|
|
6156
6201
|
(tableCellNode.__headerState & TableCellHeaderStates.ROW) === TableCellHeaderStates.ROW ? "actionTableRemoveRowHeader" : "actionTableAddRowHeader"
|
|
6157
6202
|
) }),
|
|
6158
|
-
/* @__PURE__ */
|
|
6203
|
+
/* @__PURE__ */ jsx92(DropdownMenu.Item, { onSelect: () => toggleTableColumnIsHeader(), children: tr(
|
|
6159
6204
|
(tableCellNode.__headerState & TableCellHeaderStates.COLUMN) === TableCellHeaderStates.COLUMN ? "actionTableRemoveColumnHeader" : "actionTableAddColumnHeader"
|
|
6160
6205
|
) }),
|
|
6161
|
-
/* @__PURE__ */
|
|
6162
|
-
tableStats.columns > 1 && /* @__PURE__ */
|
|
6163
|
-
tableStats.rows > 1 && /* @__PURE__ */
|
|
6164
|
-
/* @__PURE__ */
|
|
6206
|
+
/* @__PURE__ */ jsx92(DropdownMenu.Separator, {}),
|
|
6207
|
+
tableStats.columns > 1 && /* @__PURE__ */ jsx92(DropdownMenu.Item, { onSelect: () => deleteTableColumnAtSelection(), children: tr("actionTableDeleteColumn") }),
|
|
6208
|
+
tableStats.rows > 1 && /* @__PURE__ */ jsx92(DropdownMenu.Item, { onSelect: () => deleteTableRowAtSelection(), children: tr("actionTableDeleteRow") }),
|
|
6209
|
+
/* @__PURE__ */ jsx92(DropdownMenu.Item, { onSelect: () => deleteTableAtSelection(), children: tr("actionTableDeleteTable") })
|
|
6165
6210
|
] });
|
|
6166
6211
|
}
|
|
6167
6212
|
function TableCellActionMenuContainer({ anchorElem }) {
|
|
6168
6213
|
const [editor] = useLexicalComposerContext9();
|
|
6169
6214
|
const tr = useTr();
|
|
6170
|
-
const menuButtonRef =
|
|
6171
|
-
const [isMenuOpen, setIsMenuOpen] =
|
|
6172
|
-
const [tableCellNode, setTableMenuCellNode] =
|
|
6173
|
-
const [tableStats, setTablestats] =
|
|
6215
|
+
const menuButtonRef = useRef5(null);
|
|
6216
|
+
const [isMenuOpen, setIsMenuOpen] = useState8(false);
|
|
6217
|
+
const [tableCellNode, setTableMenuCellNode] = useState8(null);
|
|
6218
|
+
const [tableStats, setTablestats] = useState8({ rows: 1, columns: 1 });
|
|
6174
6219
|
const moveMenu = useCallback3(() => {
|
|
6175
6220
|
if (isMenuOpen) {
|
|
6176
6221
|
return;
|
|
@@ -6214,14 +6259,14 @@ function TableCellActionMenuContainer({ anchorElem }) {
|
|
|
6214
6259
|
setTableMenuCellNode(null);
|
|
6215
6260
|
}
|
|
6216
6261
|
}, [editor, isMenuOpen]);
|
|
6217
|
-
|
|
6262
|
+
useEffect10(() => {
|
|
6218
6263
|
return editor.registerUpdateListener(() => {
|
|
6219
6264
|
editor.getEditorState().read(() => {
|
|
6220
6265
|
moveMenu();
|
|
6221
6266
|
});
|
|
6222
6267
|
});
|
|
6223
6268
|
});
|
|
6224
|
-
|
|
6269
|
+
useEffect10(() => {
|
|
6225
6270
|
const menuButtonDOM = menuButtonRef.current;
|
|
6226
6271
|
if (menuButtonDOM != null && tableCellNode != null) {
|
|
6227
6272
|
const tableCellNodeDOM = editor.getElementByKey(tableCellNode.getKey());
|
|
@@ -6239,12 +6284,12 @@ function TableCellActionMenuContainer({ anchorElem }) {
|
|
|
6239
6284
|
}
|
|
6240
6285
|
}
|
|
6241
6286
|
}, [menuButtonRef, tableCellNode, editor, anchorElem]);
|
|
6242
|
-
return /* @__PURE__ */
|
|
6287
|
+
return /* @__PURE__ */ jsx92("div", { className: "c-rte-table-cell-action-button-container", ref: menuButtonRef, children: tableCellNode != null && /* @__PURE__ */ jsx92(
|
|
6243
6288
|
DropdownMenu.Root,
|
|
6244
6289
|
{
|
|
6245
6290
|
onOpenChange: (isOpen) => setIsMenuOpen(isOpen),
|
|
6246
|
-
content: /* @__PURE__ */
|
|
6247
|
-
children: /* @__PURE__ */
|
|
6291
|
+
content: /* @__PURE__ */ jsx92(TableActionMenu, { tableCellNode, tableStats }),
|
|
6292
|
+
children: /* @__PURE__ */ jsx92(IconButton, { size: "xs", "aria-label": tr("actionTableOpenOptions"), children: /* @__PURE__ */ jsx92(Icon.Arrow, {}) })
|
|
6248
6293
|
}
|
|
6249
6294
|
) });
|
|
6250
6295
|
}
|
|
@@ -6252,11 +6297,11 @@ function TableActionMenuPlugin({
|
|
|
6252
6297
|
anchorElem = document.body
|
|
6253
6298
|
}) {
|
|
6254
6299
|
const isEditable = useLexicalEditable();
|
|
6255
|
-
return createPortal4(isEditable ? /* @__PURE__ */
|
|
6300
|
+
return createPortal4(isEditable ? /* @__PURE__ */ jsx92(TableCellActionMenuContainer, { anchorElem }) : null, anchorElem);
|
|
6256
6301
|
}
|
|
6257
6302
|
|
|
6258
6303
|
// src/rich-text-editor/plugins/ToolbarPlugin/index.tsx
|
|
6259
|
-
import { useCallback as useCallback4, useEffect as
|
|
6304
|
+
import { useCallback as useCallback4, useEffect as useEffect11, useState as useState10 } from "react";
|
|
6260
6305
|
import {
|
|
6261
6306
|
$createParagraphNode as $createParagraphNode2,
|
|
6262
6307
|
$getNodeByKey,
|
|
@@ -6302,10 +6347,10 @@ import {
|
|
|
6302
6347
|
} from "@lexical/utils";
|
|
6303
6348
|
|
|
6304
6349
|
// src/rich-text-editor/plugins/ActionsPlugin/index.tsx
|
|
6305
|
-
import { useRef as
|
|
6350
|
+
import { useRef as useRef6 } from "react";
|
|
6306
6351
|
import { CLEAR_EDITOR_COMMAND } from "lexical";
|
|
6307
6352
|
import { useLexicalComposerContext as useLexicalComposerContext10 } from "@lexical/react/LexicalComposerContext";
|
|
6308
|
-
import { jsx as
|
|
6353
|
+
import { jsx as jsx93, jsxs as jsxs70 } from "react/jsx-runtime";
|
|
6309
6354
|
async function copyJson(editor) {
|
|
6310
6355
|
const json = lexicalToCrystallizeRichText({ editor, editorState: editor.getEditorState() });
|
|
6311
6356
|
try {
|
|
@@ -6320,51 +6365,48 @@ function ActionsPlugin({
|
|
|
6320
6365
|
}) {
|
|
6321
6366
|
const [editor] = useLexicalComposerContext10();
|
|
6322
6367
|
const tr = useTr();
|
|
6323
|
-
const actionMenuAnchorRef =
|
|
6324
|
-
return /* @__PURE__ */
|
|
6325
|
-
/* @__PURE__ */
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
{
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
editor.dispatchCommand(CLEAR_EDITOR_COMMAND, void 0);
|
|
6343
|
-
editor.focus();
|
|
6344
|
-
},
|
|
6345
|
-
children: tr("actionClear")
|
|
6346
|
-
}
|
|
6347
|
-
),
|
|
6348
|
-
!append ? null : append.map((actionItem) => /* @__PURE__ */ jsx92(
|
|
6349
|
-
ActionMenu.Item,
|
|
6350
|
-
{
|
|
6351
|
-
onSelect: actionItem.action,
|
|
6352
|
-
className: actionItem.type === "danger" ? "danger" : "",
|
|
6353
|
-
children: actionItem.title
|
|
6368
|
+
const actionMenuAnchorRef = useRef6(null);
|
|
6369
|
+
return /* @__PURE__ */ jsx93("div", { ref: actionMenuAnchorRef, className: "c-rte-actions-plugin", children: /* @__PURE__ */ jsxs70(ActionMenu, { container: actionMenuAnchorRef.current, children: [
|
|
6370
|
+
!prepend ? null : prepend.map((actionItem) => /* @__PURE__ */ jsx93(
|
|
6371
|
+
ActionMenu.Item,
|
|
6372
|
+
{
|
|
6373
|
+
onSelect: actionItem.action,
|
|
6374
|
+
className: actionItem.type === "danger" ? "danger" : "",
|
|
6375
|
+
children: actionItem.title
|
|
6376
|
+
},
|
|
6377
|
+
actionItem.title
|
|
6378
|
+
)),
|
|
6379
|
+
/* @__PURE__ */ jsx93(ActionMenu.Item, { onSelect: () => copyJson(editor), children: tr("actionCopyJSON") }),
|
|
6380
|
+
/* @__PURE__ */ jsx93(
|
|
6381
|
+
ActionMenu.Item,
|
|
6382
|
+
{
|
|
6383
|
+
className: "danger",
|
|
6384
|
+
onSelect: () => {
|
|
6385
|
+
editor.dispatchCommand(CLEAR_EDITOR_COMMAND, void 0);
|
|
6386
|
+
editor.focus();
|
|
6354
6387
|
},
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6388
|
+
children: tr("actionClear")
|
|
6389
|
+
}
|
|
6390
|
+
),
|
|
6391
|
+
!append ? null : append.map((actionItem) => /* @__PURE__ */ jsx93(
|
|
6392
|
+
ActionMenu.Item,
|
|
6393
|
+
{
|
|
6394
|
+
onSelect: actionItem.action,
|
|
6395
|
+
className: actionItem.type === "danger" ? "danger" : "",
|
|
6396
|
+
children: actionItem.title
|
|
6397
|
+
},
|
|
6398
|
+
actionItem.title
|
|
6399
|
+
))
|
|
6400
|
+
] }) });
|
|
6359
6401
|
}
|
|
6360
6402
|
|
|
6361
6403
|
// src/rich-text-editor/plugins/ToolbarPlugin/insert-table.tsx
|
|
6362
|
-
import { useState as
|
|
6404
|
+
import { useState as useState9 } from "react";
|
|
6363
6405
|
import { INSERT_TABLE_COMMAND } from "@lexical/table";
|
|
6364
|
-
import {
|
|
6406
|
+
import { jsx as jsx94, jsxs as jsxs71 } from "react/jsx-runtime";
|
|
6365
6407
|
function InsertTableDialog({ activeEditor }) {
|
|
6366
|
-
const [rows, setRows] =
|
|
6367
|
-
const [columns, setColumns] =
|
|
6408
|
+
const [rows, setRows] = useState9("5");
|
|
6409
|
+
const [columns, setColumns] = useState9("5");
|
|
6368
6410
|
const tr = useTr();
|
|
6369
6411
|
const onClick = () => {
|
|
6370
6412
|
if (parseInt(rows) < 1 || parseInt(columns) < 1) {
|
|
@@ -6379,9 +6421,9 @@ function InsertTableDialog({ activeEditor }) {
|
|
|
6379
6421
|
}
|
|
6380
6422
|
});
|
|
6381
6423
|
};
|
|
6382
|
-
return /* @__PURE__ */ jsxs71(
|
|
6383
|
-
/* @__PURE__ */ jsxs71("div", { className: "
|
|
6384
|
-
/* @__PURE__ */
|
|
6424
|
+
return /* @__PURE__ */ jsxs71("div", { className: "c-rte-insert-table", children: [
|
|
6425
|
+
/* @__PURE__ */ jsxs71("div", { className: "c-rte-insert-table__dimensions", children: [
|
|
6426
|
+
/* @__PURE__ */ jsx94(
|
|
6385
6427
|
InputWithLabel,
|
|
6386
6428
|
{
|
|
6387
6429
|
label: tr("insertTableRows"),
|
|
@@ -6392,8 +6434,8 @@ function InsertTableDialog({ activeEditor }) {
|
|
|
6392
6434
|
onChange: (e) => setRows(e.target.value)
|
|
6393
6435
|
}
|
|
6394
6436
|
),
|
|
6395
|
-
/* @__PURE__ */
|
|
6396
|
-
/* @__PURE__ */
|
|
6437
|
+
/* @__PURE__ */ jsx94("span", { className: "c-rte-insert-table__dimensions__separator" }),
|
|
6438
|
+
/* @__PURE__ */ jsx94(
|
|
6397
6439
|
InputWithLabel,
|
|
6398
6440
|
{
|
|
6399
6441
|
type: "text",
|
|
@@ -6405,12 +6447,12 @@ function InsertTableDialog({ activeEditor }) {
|
|
|
6405
6447
|
}
|
|
6406
6448
|
)
|
|
6407
6449
|
] }),
|
|
6408
|
-
/* @__PURE__ */
|
|
6450
|
+
/* @__PURE__ */ jsx94("div", { className: "c-rte-insert-table__actions", children: /* @__PURE__ */ jsx94(Button, { as: Dialog.Close, size: "sm", intent: "action", "aria-label": tr("insertTableCommit"), onClick, children: tr("insertTableCommit") }) })
|
|
6409
6451
|
] });
|
|
6410
6452
|
}
|
|
6411
6453
|
|
|
6412
6454
|
// src/rich-text-editor/plugins/ToolbarPlugin/index.tsx
|
|
6413
|
-
import { Fragment as
|
|
6455
|
+
import { Fragment as Fragment7, jsx as jsx95, jsxs as jsxs72 } from "react/jsx-runtime";
|
|
6414
6456
|
var headingTypeToBlockName = {
|
|
6415
6457
|
h1: "Heading 1",
|
|
6416
6458
|
h2: "Heading 2",
|
|
@@ -6514,66 +6556,65 @@ function BlockFormatDropDown({
|
|
|
6514
6556
|
});
|
|
6515
6557
|
}
|
|
6516
6558
|
};
|
|
6517
|
-
return /* @__PURE__ */
|
|
6559
|
+
return /* @__PURE__ */ jsx95(
|
|
6518
6560
|
DropdownMenu.Root,
|
|
6519
6561
|
{
|
|
6520
6562
|
disabled,
|
|
6521
6563
|
style: { zIndex: 1 },
|
|
6522
|
-
content: /* @__PURE__ */ jsxs72(
|
|
6564
|
+
content: /* @__PURE__ */ jsxs72(Fragment7, { children: [
|
|
6523
6565
|
/* @__PURE__ */ jsxs72(DropdownMenu.Item, { onClick: formatParagraph, children: [
|
|
6524
|
-
/* @__PURE__ */
|
|
6566
|
+
/* @__PURE__ */ jsx95(
|
|
6525
6567
|
"i",
|
|
6526
6568
|
{
|
|
6527
|
-
className: `
|
|
6569
|
+
className: `c-rte-icon-paragraph c-rte-toolbar__block-format__icon ${blockType === "paragraph" ? "selected" : ""}`
|
|
6528
6570
|
}
|
|
6529
6571
|
),
|
|
6530
|
-
/* @__PURE__ */
|
|
6531
|
-
/* @__PURE__ */ jsx94("span", { className: `${blockType === "paragraph" ? "font-bold" : "font-normal"} text-sm px-3 min-w-[150px]`, children: "Normal" })
|
|
6572
|
+
/* @__PURE__ */ jsx95("span", { className: `c-rte-toolbar__block-format__text ${blockType === "paragraph" ? "selected" : ""}`, children: "Normal" })
|
|
6532
6573
|
] }),
|
|
6533
6574
|
headings.map((headingSize) => /* @__PURE__ */ jsxs72(DropdownMenu.Item, { onClick: () => formatHeading(headingSize), children: [
|
|
6534
|
-
/* @__PURE__ */
|
|
6575
|
+
/* @__PURE__ */ jsx95(
|
|
6535
6576
|
"i",
|
|
6536
6577
|
{
|
|
6537
|
-
className: `icon
|
|
6578
|
+
className: `c-rte-icon-${headingSize} c-rte-toolbar__block-format__icon ${blockType === headingSize ? "selected" : ""}`
|
|
6538
6579
|
}
|
|
6539
6580
|
),
|
|
6540
|
-
/* @__PURE__ */
|
|
6581
|
+
/* @__PURE__ */ jsx95("span", { className: `c-rte-toolbar__block-format__text ${blockType === headingSize ? "selected" : ""}`, children: headingTypeToBlockName[headingSize] })
|
|
6541
6582
|
] }, headingSize)),
|
|
6542
6583
|
/* @__PURE__ */ jsxs72(DropdownMenu.Item, { onClick: formatBulletList, children: [
|
|
6543
|
-
/* @__PURE__ */
|
|
6584
|
+
/* @__PURE__ */ jsx95(
|
|
6544
6585
|
"i",
|
|
6545
6586
|
{
|
|
6546
|
-
className: `icon
|
|
6587
|
+
className: `c-rte-icon-bullet-list c-rte-toolbar__block-format__icon ${blockType === "bullet" ? "selected" : ""}`
|
|
6547
6588
|
}
|
|
6548
6589
|
),
|
|
6549
|
-
/* @__PURE__ */
|
|
6590
|
+
/* @__PURE__ */ jsx95("span", { className: `c-rte-toolbar__block-format__text ${blockType === "bullet" ? "selected" : ""}`, children: "Bullet List" })
|
|
6550
6591
|
] }),
|
|
6551
6592
|
/* @__PURE__ */ jsxs72(DropdownMenu.Item, { onClick: formatNumberedList, children: [
|
|
6552
|
-
/* @__PURE__ */
|
|
6593
|
+
/* @__PURE__ */ jsx95(
|
|
6553
6594
|
"i",
|
|
6554
6595
|
{
|
|
6555
|
-
className: `icon
|
|
6596
|
+
className: `c-rte-icon-numbered-list c-rte-toolbar__block-format__icon ${blockType === "number" ? "selected" : ""}`
|
|
6556
6597
|
}
|
|
6557
6598
|
),
|
|
6558
|
-
/* @__PURE__ */
|
|
6599
|
+
/* @__PURE__ */ jsx95("span", { className: `c-rte-toolbar__block-format__text ${blockType === "number" ? "selected" : ""}`, children: "Numbered List" })
|
|
6559
6600
|
] }),
|
|
6560
6601
|
/* @__PURE__ */ jsxs72(DropdownMenu.Item, { onClick: formatQuote, "data-testid": "toggle-block-format-quote", children: [
|
|
6561
|
-
/* @__PURE__ */
|
|
6602
|
+
/* @__PURE__ */ jsx95(
|
|
6562
6603
|
"i",
|
|
6563
6604
|
{
|
|
6564
|
-
className: `
|
|
6605
|
+
className: `c-rte-icon-quote c-rte-toolbar__block-format__icon ${blockType === "quote" ? "selected" : ""}`
|
|
6565
6606
|
}
|
|
6566
6607
|
),
|
|
6567
|
-
/* @__PURE__ */
|
|
6608
|
+
/* @__PURE__ */ jsx95("span", { className: `c-rte-toolbar__block-format__text ${blockType === "quote" ? "selected" : ""}`, children: "Quote" })
|
|
6568
6609
|
] }),
|
|
6569
6610
|
/* @__PURE__ */ jsxs72(DropdownMenu.Item, { onClick: formatCode, "data-testid": "toggle-block-format-code", children: [
|
|
6570
|
-
/* @__PURE__ */
|
|
6611
|
+
/* @__PURE__ */ jsx95(
|
|
6571
6612
|
"i",
|
|
6572
6613
|
{
|
|
6573
|
-
className: `icon code border w-6 h-6 rounded-md bg-no-repeat bg-center bg-[length:18px_18px] ${blockType === "code" ? "
|
|
6614
|
+
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" : ""}`
|
|
6574
6615
|
}
|
|
6575
6616
|
),
|
|
6576
|
-
/* @__PURE__ */
|
|
6617
|
+
/* @__PURE__ */ jsx95("span", { className: `c-rte-toolbar__block-format__text ${blockType === "code" ? "selected" : ""}`, children: "Code block" })
|
|
6577
6618
|
] })
|
|
6578
6619
|
] }),
|
|
6579
6620
|
children: /* @__PURE__ */ jsxs72(
|
|
@@ -6583,8 +6624,8 @@ function BlockFormatDropDown({
|
|
|
6583
6624
|
"aria-label": "Formatting options for text style",
|
|
6584
6625
|
"data-testid": "toggle-block-format",
|
|
6585
6626
|
children: [
|
|
6586
|
-
/* @__PURE__ */
|
|
6587
|
-
/* @__PURE__ */
|
|
6627
|
+
/* @__PURE__ */ jsx95("i", { className: `c-rte-toolbar__toggle-icon c-rte-icon-${blockType}` }),
|
|
6628
|
+
/* @__PURE__ */ jsx95(Icon.Arrow, {})
|
|
6588
6629
|
]
|
|
6589
6630
|
}
|
|
6590
6631
|
)
|
|
@@ -6592,29 +6633,29 @@ function BlockFormatDropDown({
|
|
|
6592
6633
|
);
|
|
6593
6634
|
}
|
|
6594
6635
|
function Divider() {
|
|
6595
|
-
return /* @__PURE__ */
|
|
6636
|
+
return /* @__PURE__ */ jsx95("div", { className: "c-rte-toolbar__divider" });
|
|
6596
6637
|
}
|
|
6597
6638
|
function ToolbarPlugin({
|
|
6598
6639
|
actionsMenuPrepend,
|
|
6599
6640
|
actionsMenuAppend
|
|
6600
6641
|
}) {
|
|
6601
6642
|
const [editor] = useLexicalComposerContext11();
|
|
6602
|
-
const [activeEditor, setActiveEditor] =
|
|
6603
|
-
const [blockType, setBlockType] =
|
|
6604
|
-
const [selectedElementKey, setSelectedElementKey] =
|
|
6605
|
-
const [isLink, setIsLink] =
|
|
6606
|
-
const [isBold, setIsBold] =
|
|
6607
|
-
const [isItalic, setIsItalic] =
|
|
6608
|
-
const [isUnderline, setIsUnderline] =
|
|
6609
|
-
const [isStrikethrough, setIsStrikethrough] =
|
|
6610
|
-
const [isSubscript, setIsSubscript] =
|
|
6611
|
-
const [isSuperscript, setIsSuperscript] =
|
|
6612
|
-
const [isCode, setIsCode] =
|
|
6613
|
-
const [canUndo, setCanUndo] =
|
|
6614
|
-
const [canRedo, setCanRedo] =
|
|
6643
|
+
const [activeEditor, setActiveEditor] = useState10(editor);
|
|
6644
|
+
const [blockType, setBlockType] = useState10("paragraph");
|
|
6645
|
+
const [selectedElementKey, setSelectedElementKey] = useState10(null);
|
|
6646
|
+
const [isLink, setIsLink] = useState10(false);
|
|
6647
|
+
const [isBold, setIsBold] = useState10(false);
|
|
6648
|
+
const [isItalic, setIsItalic] = useState10(false);
|
|
6649
|
+
const [isUnderline, setIsUnderline] = useState10(false);
|
|
6650
|
+
const [isStrikethrough, setIsStrikethrough] = useState10(false);
|
|
6651
|
+
const [isSubscript, setIsSubscript] = useState10(false);
|
|
6652
|
+
const [isSuperscript, setIsSuperscript] = useState10(false);
|
|
6653
|
+
const [isCode, setIsCode] = useState10(false);
|
|
6654
|
+
const [canUndo, setCanUndo] = useState10(false);
|
|
6655
|
+
const [canRedo, setCanRedo] = useState10(false);
|
|
6615
6656
|
const tr = useTr();
|
|
6616
|
-
const [codeLanguage, setCodeLanguage] =
|
|
6617
|
-
const [isEditable, setIsEditable] =
|
|
6657
|
+
const [codeLanguage, setCodeLanguage] = useState10("");
|
|
6658
|
+
const [isEditable, setIsEditable] = useState10(() => editor.isEditable());
|
|
6618
6659
|
const updateToolbar = useCallback4(() => {
|
|
6619
6660
|
const selection = $getSelection9();
|
|
6620
6661
|
if ($isRangeSelection7(selection)) {
|
|
@@ -6662,7 +6703,7 @@ function ToolbarPlugin({
|
|
|
6662
6703
|
}
|
|
6663
6704
|
}
|
|
6664
6705
|
}, [activeEditor]);
|
|
6665
|
-
|
|
6706
|
+
useEffect11(() => {
|
|
6666
6707
|
return editor.registerCommand(
|
|
6667
6708
|
SELECTION_CHANGE_COMMAND3,
|
|
6668
6709
|
(_payload, newEditor) => {
|
|
@@ -6673,7 +6714,7 @@ function ToolbarPlugin({
|
|
|
6673
6714
|
COMMAND_PRIORITY_CRITICAL3
|
|
6674
6715
|
);
|
|
6675
6716
|
}, [editor, updateToolbar]);
|
|
6676
|
-
|
|
6717
|
+
useEffect11(() => {
|
|
6677
6718
|
return mergeRegister3(
|
|
6678
6719
|
editor.registerEditableListener((editable) => {
|
|
6679
6720
|
setIsEditable(editable);
|
|
@@ -6739,9 +6780,9 @@ function ToolbarPlugin({
|
|
|
6739
6780
|
},
|
|
6740
6781
|
[activeEditor, selectedElementKey]
|
|
6741
6782
|
);
|
|
6742
|
-
return /* @__PURE__ */ jsxs72("div", { className: "toolbar", children: [
|
|
6743
|
-
/* @__PURE__ */ jsxs72("div", { className: "
|
|
6744
|
-
/* @__PURE__ */
|
|
6783
|
+
return /* @__PURE__ */ jsxs72("div", { className: "c-rte-toolbar", children: [
|
|
6784
|
+
/* @__PURE__ */ jsxs72("div", { className: "c-rte-toolbar__inner", children: [
|
|
6785
|
+
/* @__PURE__ */ jsx95(
|
|
6745
6786
|
IconButton,
|
|
6746
6787
|
{
|
|
6747
6788
|
disabled: !canUndo || !isEditable,
|
|
@@ -6751,16 +6792,16 @@ function ToolbarPlugin({
|
|
|
6751
6792
|
type: "button",
|
|
6752
6793
|
title: tr(IS_APPLE ? "actionUndoTitleApple" : "actionUndoTitle"),
|
|
6753
6794
|
"aria-label": tr("actionUndoLabel"),
|
|
6754
|
-
children: /* @__PURE__ */
|
|
6795
|
+
children: /* @__PURE__ */ jsx95(
|
|
6755
6796
|
"i",
|
|
6756
6797
|
{
|
|
6757
|
-
className: `
|
|
6798
|
+
className: `c-rte-icon-undo c-rte-toolbar__icon ${!canUndo ? "disabled" : ""}
|
|
6758
6799
|
`
|
|
6759
6800
|
}
|
|
6760
6801
|
)
|
|
6761
6802
|
}
|
|
6762
6803
|
),
|
|
6763
|
-
/* @__PURE__ */
|
|
6804
|
+
/* @__PURE__ */ jsx95(
|
|
6764
6805
|
IconButton,
|
|
6765
6806
|
{
|
|
6766
6807
|
disabled: !canRedo || !isEditable,
|
|
@@ -6770,34 +6811,29 @@ function ToolbarPlugin({
|
|
|
6770
6811
|
type: "button",
|
|
6771
6812
|
title: tr(IS_APPLE ? "actionRedoTitleApple" : "actionRedoTitle"),
|
|
6772
6813
|
"aria-label": tr("actionRedoLabel"),
|
|
6773
|
-
children: /* @__PURE__ */
|
|
6774
|
-
"i",
|
|
6775
|
-
{
|
|
6776
|
-
className: `format icon redo border w-4 h-6 bg-no-repeat bg-center bg-[length:17px_17px] ${canRedo ? "opacity-100" : "opacity-30"}`
|
|
6777
|
-
}
|
|
6778
|
-
)
|
|
6814
|
+
children: /* @__PURE__ */ jsx95("i", { className: `c-rte-icon-redo c-rte-toolbar__icon ${!canRedo ? "disabled" : ""}` })
|
|
6779
6815
|
}
|
|
6780
6816
|
),
|
|
6781
|
-
/* @__PURE__ */
|
|
6782
|
-
blockType in blockTypeToBlockName && activeEditor === editor && /* @__PURE__ */ jsxs72(
|
|
6783
|
-
/* @__PURE__ */
|
|
6784
|
-
/* @__PURE__ */
|
|
6817
|
+
/* @__PURE__ */ jsx95(Divider, {}),
|
|
6818
|
+
blockType in blockTypeToBlockName && activeEditor === editor && /* @__PURE__ */ jsxs72(Fragment7, { children: [
|
|
6819
|
+
/* @__PURE__ */ jsx95(BlockFormatDropDown, { disabled: !isEditable, blockType, editor }),
|
|
6820
|
+
/* @__PURE__ */ jsx95(Divider, {})
|
|
6785
6821
|
] }),
|
|
6786
|
-
blockType === "code" ? /* @__PURE__ */
|
|
6822
|
+
blockType === "code" ? /* @__PURE__ */ jsx95(Fragment7, { children: /* @__PURE__ */ jsx95(
|
|
6787
6823
|
DropdownMenu.Root,
|
|
6788
6824
|
{
|
|
6789
6825
|
disabled: !isEditable,
|
|
6790
6826
|
style: { zIndex: 1 },
|
|
6791
|
-
content: /* @__PURE__ */
|
|
6792
|
-
return /* @__PURE__ */
|
|
6827
|
+
content: /* @__PURE__ */ jsx95(Fragment7, { children: CODE_LANGUAGE_OPTIONS.map(([value, name]) => {
|
|
6828
|
+
return /* @__PURE__ */ jsx95(
|
|
6793
6829
|
DropdownMenu.Item,
|
|
6794
6830
|
{
|
|
6795
6831
|
className: `item ${dropDownActiveClass(value === codeLanguage)}`,
|
|
6796
6832
|
onClick: () => onCodeLanguageSelect(value),
|
|
6797
|
-
children: /* @__PURE__ */
|
|
6833
|
+
children: /* @__PURE__ */ jsx95(
|
|
6798
6834
|
"span",
|
|
6799
6835
|
{
|
|
6800
|
-
className: `
|
|
6836
|
+
className: `c-rte-toolbar__code-lang__sel-item ${dropDownActiveClass(value === codeLanguage) ? "selected" : ""}`,
|
|
6801
6837
|
children: name
|
|
6802
6838
|
}
|
|
6803
6839
|
)
|
|
@@ -6805,14 +6841,14 @@ function ToolbarPlugin({
|
|
|
6805
6841
|
value
|
|
6806
6842
|
);
|
|
6807
6843
|
}) }),
|
|
6808
|
-
children: /* @__PURE__ */
|
|
6844
|
+
children: /* @__PURE__ */ jsx95(Button, { "aria-label": tr("codeSelectLanguage"), append: /* @__PURE__ */ jsx95(Icon.Arrow, {}), children: /* @__PURE__ */ jsx95("span", { className: "c-rte-toolbar__code-lang__button-text", children: getLanguageFriendlyName2(codeLanguage) }) })
|
|
6809
6845
|
}
|
|
6810
|
-
) }) : /* @__PURE__ */
|
|
6811
|
-
/* @__PURE__ */
|
|
6846
|
+
) }) : /* @__PURE__ */ jsx95(Dialog, { children: /* @__PURE__ */ jsxs72("div", { className: "c-rte-toolbar__actions-rest", children: [
|
|
6847
|
+
/* @__PURE__ */ jsx95(
|
|
6812
6848
|
IconButton,
|
|
6813
6849
|
{
|
|
6814
6850
|
disabled: !isEditable,
|
|
6815
|
-
className:
|
|
6851
|
+
className: `c-rte-toolbar__icon-btn ${isBold ? "selected" : ""}`,
|
|
6816
6852
|
type: "button",
|
|
6817
6853
|
title: tr(IS_APPLE ? "actionFormatAsStrongTitleApple" : "actionFormatAsStrongTitle"),
|
|
6818
6854
|
"aria-label": tr("actionFormatAsStrongLabel"),
|
|
@@ -6820,13 +6856,13 @@ function ToolbarPlugin({
|
|
|
6820
6856
|
onClick: () => {
|
|
6821
6857
|
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND2, "bold");
|
|
6822
6858
|
},
|
|
6823
|
-
children: /* @__PURE__ */
|
|
6859
|
+
children: /* @__PURE__ */ jsx95("i", { className: `c-rte-toolbar__icon-btn__icon c-rte-icon-bold` })
|
|
6824
6860
|
}
|
|
6825
6861
|
),
|
|
6826
|
-
/* @__PURE__ */
|
|
6862
|
+
/* @__PURE__ */ jsx95(
|
|
6827
6863
|
IconButton,
|
|
6828
6864
|
{
|
|
6829
|
-
className:
|
|
6865
|
+
className: `c-rte-toolbar__icon-btn ${isItalic ? "selected" : ""}`,
|
|
6830
6866
|
disabled: !isEditable,
|
|
6831
6867
|
onClick: () => {
|
|
6832
6868
|
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND2, "italic");
|
|
@@ -6835,13 +6871,13 @@ function ToolbarPlugin({
|
|
|
6835
6871
|
title: tr(IS_APPLE ? "actionFormatAsEmphasizedTitleApple" : "actionFormatAsEmphasizedTitle"),
|
|
6836
6872
|
"aria-label": tr("actionFormatAsEmphasizedLabel"),
|
|
6837
6873
|
"data-testid": "toggle-format-emphasized",
|
|
6838
|
-
children: /* @__PURE__ */
|
|
6874
|
+
children: /* @__PURE__ */ jsx95("i", { className: `c-rte-toolbar__icon-btn__icon c-rte-icon-italic` })
|
|
6839
6875
|
}
|
|
6840
6876
|
),
|
|
6841
|
-
/* @__PURE__ */
|
|
6877
|
+
/* @__PURE__ */ jsx95(
|
|
6842
6878
|
IconButton,
|
|
6843
6879
|
{
|
|
6844
|
-
className:
|
|
6880
|
+
className: `c-rte-toolbar__icon-btn ${isUnderline ? "selected" : ""}`,
|
|
6845
6881
|
disabled: !isEditable,
|
|
6846
6882
|
onClick: () => {
|
|
6847
6883
|
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND2, "underline");
|
|
@@ -6850,18 +6886,13 @@ function ToolbarPlugin({
|
|
|
6850
6886
|
title: tr(IS_APPLE ? "actionFormatAsUnderlinedTitleApple" : "actionFormatAsUnderlinedTitle"),
|
|
6851
6887
|
"aria-label": tr("actionFormatAsUnderlinedLabel"),
|
|
6852
6888
|
"data-testid": "toggle-format-underlined",
|
|
6853
|
-
children: /* @__PURE__ */
|
|
6854
|
-
"i",
|
|
6855
|
-
{
|
|
6856
|
-
className: `format icon underline border w-full h-full bg-no-repeat bg-center bg-[length:18px_18px]`
|
|
6857
|
-
}
|
|
6858
|
-
)
|
|
6889
|
+
children: /* @__PURE__ */ jsx95("i", { className: `c-rte-toolbar__icon-btn__icon c-rte-icon-underline` })
|
|
6859
6890
|
}
|
|
6860
6891
|
),
|
|
6861
|
-
/* @__PURE__ */
|
|
6892
|
+
/* @__PURE__ */ jsx95(
|
|
6862
6893
|
IconButton,
|
|
6863
6894
|
{
|
|
6864
|
-
className:
|
|
6895
|
+
className: `c-rte-toolbar__icon-btn ${isCode ? "selected" : ""}`,
|
|
6865
6896
|
disabled: !isEditable,
|
|
6866
6897
|
onClick: () => {
|
|
6867
6898
|
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND2, "code");
|
|
@@ -6869,27 +6900,27 @@ function ToolbarPlugin({
|
|
|
6869
6900
|
type: "button",
|
|
6870
6901
|
title: tr("actionInsertCodeBlock"),
|
|
6871
6902
|
"aria-label": tr("actionInsertCodeBlock"),
|
|
6872
|
-
children: /* @__PURE__ */
|
|
6903
|
+
children: /* @__PURE__ */ jsx95("i", { className: `c-rte-toolbar__icon-btn__icon c-rte-icon-code` })
|
|
6873
6904
|
}
|
|
6874
6905
|
),
|
|
6875
|
-
/* @__PURE__ */
|
|
6906
|
+
/* @__PURE__ */ jsx95(
|
|
6876
6907
|
IconButton,
|
|
6877
6908
|
{
|
|
6878
|
-
className:
|
|
6909
|
+
className: `c-rte-toolbar__icon-btn ${isLink ? "selected" : ""}`,
|
|
6879
6910
|
disabled: !isEditable,
|
|
6880
6911
|
onClick: insertLink,
|
|
6881
6912
|
type: "button",
|
|
6882
6913
|
"aria-label": tr("actionInsertlink"),
|
|
6883
6914
|
title: tr("actionInsertlink"),
|
|
6884
|
-
children: /* @__PURE__ */
|
|
6915
|
+
children: /* @__PURE__ */ jsx95("i", { className: `c-rte-toolbar__icon-btn__icon c-rte-icon-link` })
|
|
6885
6916
|
}
|
|
6886
6917
|
),
|
|
6887
|
-
/* @__PURE__ */
|
|
6918
|
+
/* @__PURE__ */ jsx95(
|
|
6888
6919
|
DropdownMenu.Root,
|
|
6889
6920
|
{
|
|
6890
6921
|
disabled: !isEditable,
|
|
6891
6922
|
style: { zIndex: 1 },
|
|
6892
|
-
content: /* @__PURE__ */ jsxs72(
|
|
6923
|
+
content: /* @__PURE__ */ jsxs72(Fragment7, { children: [
|
|
6893
6924
|
/* @__PURE__ */ jsxs72(
|
|
6894
6925
|
DropdownMenu.Item,
|
|
6895
6926
|
{
|
|
@@ -6899,13 +6930,13 @@ function ToolbarPlugin({
|
|
|
6899
6930
|
title: tr("actionFormatWithStrikethroughTitle"),
|
|
6900
6931
|
"aria-label": tr("actionFormatWithStrikethroughLabel"),
|
|
6901
6932
|
children: [
|
|
6902
|
-
/* @__PURE__ */
|
|
6933
|
+
/* @__PURE__ */ jsx95(
|
|
6903
6934
|
"i",
|
|
6904
6935
|
{
|
|
6905
|
-
className: `icon
|
|
6936
|
+
className: `c-rte-icon-strikethrough c-rte-toolbar__dd-item__icon ${isStrikethrough ? "selected" : ""}`
|
|
6906
6937
|
}
|
|
6907
6938
|
),
|
|
6908
|
-
/* @__PURE__ */
|
|
6939
|
+
/* @__PURE__ */ jsx95("span", { className: `c-rte-toolbar__dd-item__text ${isStrikethrough ? "selected" : ""}`, children: tr("actionFormatAsStrongTitle") })
|
|
6909
6940
|
]
|
|
6910
6941
|
}
|
|
6911
6942
|
),
|
|
@@ -6918,13 +6949,13 @@ function ToolbarPlugin({
|
|
|
6918
6949
|
title: tr("actionFormatWithSubscriptTitle"),
|
|
6919
6950
|
"aria-label": tr("actionFormatWithSubscriptLabel"),
|
|
6920
6951
|
children: [
|
|
6921
|
-
/* @__PURE__ */
|
|
6952
|
+
/* @__PURE__ */ jsx95(
|
|
6922
6953
|
"i",
|
|
6923
6954
|
{
|
|
6924
|
-
className: `icon
|
|
6955
|
+
className: `c-rte-icon-subscript c-rte-toolbar__dd-item__icon ${isSubscript ? "selected" : ""}`
|
|
6925
6956
|
}
|
|
6926
6957
|
),
|
|
6927
|
-
/* @__PURE__ */
|
|
6958
|
+
/* @__PURE__ */ jsx95("span", { className: `c-rte-toolbar__dd-item__text ${isSubscript ? "selected" : ""}`, children: tr("actionFormatWithSubscriptTitle") })
|
|
6928
6959
|
]
|
|
6929
6960
|
}
|
|
6930
6961
|
),
|
|
@@ -6937,13 +6968,13 @@ function ToolbarPlugin({
|
|
|
6937
6968
|
title: tr("actionFormatWithSuperscriptTitle"),
|
|
6938
6969
|
"aria-label": tr("actionFormatWithSuperscriptLabel"),
|
|
6939
6970
|
children: [
|
|
6940
|
-
/* @__PURE__ */
|
|
6971
|
+
/* @__PURE__ */ jsx95(
|
|
6941
6972
|
"i",
|
|
6942
6973
|
{
|
|
6943
|
-
className: `icon
|
|
6974
|
+
className: `c-rte-icon-superscript c-rte-toolbar__dd-item__icon ${isSuperscript ? "selected" : ""}`
|
|
6944
6975
|
}
|
|
6945
6976
|
),
|
|
6946
|
-
/* @__PURE__ */
|
|
6977
|
+
/* @__PURE__ */ jsx95("span", { className: `c-rte-toolbar__dd-item__text ${isSuperscript ? "selected" : ""}`, children: tr("actionFormatWithSuperscriptTitle") })
|
|
6947
6978
|
]
|
|
6948
6979
|
}
|
|
6949
6980
|
),
|
|
@@ -6955,8 +6986,8 @@ function ToolbarPlugin({
|
|
|
6955
6986
|
title: tr("actionClearTextFormatting"),
|
|
6956
6987
|
"aria-label": tr("actionClearTextFormatting"),
|
|
6957
6988
|
children: [
|
|
6958
|
-
/* @__PURE__ */
|
|
6959
|
-
/* @__PURE__ */
|
|
6989
|
+
/* @__PURE__ */ jsx95("i", { className: "c-rte-icon-clear c-rte-toolbar__dd-item__icon" }),
|
|
6990
|
+
/* @__PURE__ */ jsx95("span", { className: "c-rte-toolbar__dd-item__text--clear", children: "Clear Formatting" })
|
|
6960
6991
|
]
|
|
6961
6992
|
}
|
|
6962
6993
|
)
|
|
@@ -6967,48 +6998,48 @@ function ToolbarPlugin({
|
|
|
6967
6998
|
style: { backgroundColor: "transparent", padding: "0 8px" },
|
|
6968
6999
|
"aria-label": tr("actionTextFormattingOptions"),
|
|
6969
7000
|
children: [
|
|
6970
|
-
/* @__PURE__ */
|
|
6971
|
-
/* @__PURE__ */
|
|
7001
|
+
/* @__PURE__ */ jsx95("i", { className: `c-rte-icon-dropdown-more c-rte-toolbar__toggle-icon` }),
|
|
7002
|
+
/* @__PURE__ */ jsx95(Icon.Arrow, {})
|
|
6972
7003
|
]
|
|
6973
7004
|
}
|
|
6974
7005
|
)
|
|
6975
7006
|
}
|
|
6976
7007
|
),
|
|
6977
|
-
/* @__PURE__ */
|
|
6978
|
-
/* @__PURE__ */
|
|
7008
|
+
/* @__PURE__ */ jsx95(Divider, {}),
|
|
7009
|
+
/* @__PURE__ */ jsx95(
|
|
6979
7010
|
DropdownMenu.Root,
|
|
6980
7011
|
{
|
|
6981
7012
|
style: { zIndex: 1 },
|
|
6982
7013
|
disabled: !isEditable,
|
|
6983
|
-
content: /* @__PURE__ */ jsxs72(
|
|
6984
|
-
/* @__PURE__ */
|
|
7014
|
+
content: /* @__PURE__ */ jsxs72(Fragment7, { children: [
|
|
7015
|
+
/* @__PURE__ */ jsxs72(
|
|
6985
7016
|
DropdownMenu.Item,
|
|
6986
7017
|
{
|
|
6987
7018
|
onClick: () => {
|
|
6988
7019
|
activeEditor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, void 0);
|
|
6989
7020
|
},
|
|
6990
|
-
children:
|
|
6991
|
-
/* @__PURE__ */
|
|
6992
|
-
/* @__PURE__ */
|
|
6993
|
-
]
|
|
7021
|
+
children: [
|
|
7022
|
+
/* @__PURE__ */ jsx95("i", { className: "c-rte-toolbar__dd-item__icon c-rte-icon-horizontal-rule" }),
|
|
7023
|
+
/* @__PURE__ */ jsx95("span", { className: "c-rte-toolbar__dd-item__text", children: tr("horizontalRule") })
|
|
7024
|
+
]
|
|
6994
7025
|
}
|
|
6995
7026
|
),
|
|
6996
|
-
/* @__PURE__ */
|
|
6997
|
-
/* @__PURE__ */
|
|
6998
|
-
/* @__PURE__ */
|
|
7027
|
+
/* @__PURE__ */ jsx95(DropdownMenu.Item, { children: /* @__PURE__ */ jsx95(Dialog.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs72("div", { className: "c-rte-toolbar__dd-item--table", children: [
|
|
7028
|
+
/* @__PURE__ */ jsx95("i", { className: "c-rte-toolbar__dd-item__icon c-rte-icon-table" }),
|
|
7029
|
+
/* @__PURE__ */ jsx95("span", { className: "c-rte-toolbar__dd-item__text", children: tr("table") })
|
|
6999
7030
|
] }) }) })
|
|
7000
7031
|
] }),
|
|
7001
|
-
children: /* @__PURE__ */
|
|
7032
|
+
children: /* @__PURE__ */ jsx95(IconButton, { children: /* @__PURE__ */ jsx95("i", { className: "c-rte-icon-plus c-rte-toolbar__plus" }) })
|
|
7002
7033
|
}
|
|
7003
7034
|
),
|
|
7004
7035
|
/* @__PURE__ */ jsxs72(Dialog.Content, { children: [
|
|
7005
|
-
/* @__PURE__ */
|
|
7006
|
-
/* @__PURE__ */
|
|
7007
|
-
/* @__PURE__ */
|
|
7036
|
+
/* @__PURE__ */ jsx95(Dialog.Title, { children: tr("insertTableTitle") }),
|
|
7037
|
+
/* @__PURE__ */ jsx95(Dialog.Description, { children: tr("insertTableDescription") }),
|
|
7038
|
+
/* @__PURE__ */ jsx95(InsertTableDialog, { activeEditor })
|
|
7008
7039
|
] })
|
|
7009
7040
|
] }) })
|
|
7010
7041
|
] }),
|
|
7011
|
-
/* @__PURE__ */
|
|
7042
|
+
/* @__PURE__ */ jsx95(ActionsPlugin, { prepend: actionsMenuPrepend, append: actionsMenuAppend })
|
|
7012
7043
|
] });
|
|
7013
7044
|
}
|
|
7014
7045
|
|
|
@@ -7062,7 +7093,7 @@ var theme = {
|
|
|
7062
7093
|
h5: "CrystallizeRTEditorTheme__h5",
|
|
7063
7094
|
h6: "CrystallizeRTEditorTheme__h6"
|
|
7064
7095
|
},
|
|
7065
|
-
image: "
|
|
7096
|
+
image: "",
|
|
7066
7097
|
indent: "CrystallizeRTEditorTheme__indent",
|
|
7067
7098
|
link: "CrystallizeRTEditorTheme__link",
|
|
7068
7099
|
list: {
|
|
@@ -7115,7 +7146,7 @@ var theme = {
|
|
|
7115
7146
|
var CrystallizeRTEditorTheme_default = theme;
|
|
7116
7147
|
|
|
7117
7148
|
// src/rich-text-editor/rich-text-editor.tsx
|
|
7118
|
-
import { Fragment as
|
|
7149
|
+
import { Fragment as Fragment8, jsx as jsx96, jsxs as jsxs73 } from "react/jsx-runtime";
|
|
7119
7150
|
function RichTextEditor({
|
|
7120
7151
|
initialData,
|
|
7121
7152
|
editable = true,
|
|
@@ -7123,7 +7154,7 @@ function RichTextEditor({
|
|
|
7123
7154
|
labelTranslations,
|
|
7124
7155
|
...rest
|
|
7125
7156
|
}) {
|
|
7126
|
-
return /* @__PURE__ */
|
|
7157
|
+
return /* @__PURE__ */ jsx96(
|
|
7127
7158
|
LexicalComposer,
|
|
7128
7159
|
{
|
|
7129
7160
|
initialConfig: {
|
|
@@ -7138,7 +7169,7 @@ function RichTextEditor({
|
|
|
7138
7169
|
richText: initialData
|
|
7139
7170
|
}) : void 0
|
|
7140
7171
|
},
|
|
7141
|
-
children: /* @__PURE__ */
|
|
7172
|
+
children: /* @__PURE__ */ jsx96(I18nProvider, { language, labelTranslations, children: /* @__PURE__ */ jsx96(SharedHistoryContext, { children: /* @__PURE__ */ jsx96("div", { className: "c-rich-text-editor", children: /* @__PURE__ */ jsx96(RichTextEditorWithoutContext, { ...rest, editable }) }) }) })
|
|
7142
7173
|
}
|
|
7143
7174
|
);
|
|
7144
7175
|
}
|
|
@@ -7151,34 +7182,23 @@ function RichTextEditorWithoutContext({
|
|
|
7151
7182
|
actionsMenuAppend,
|
|
7152
7183
|
slotPreContent,
|
|
7153
7184
|
maxLength,
|
|
7154
|
-
editable
|
|
7185
|
+
editable,
|
|
7186
|
+
id
|
|
7155
7187
|
}) {
|
|
7156
7188
|
const { historyState } = useSharedHistoryContext();
|
|
7157
|
-
const placeholder = /* @__PURE__ */
|
|
7189
|
+
const placeholder = /* @__PURE__ */ jsx96("div", { className: "c-rte-placeholder", children: placeholderText ?? "" });
|
|
7158
7190
|
const [editor] = useLexicalComposerContext12();
|
|
7159
|
-
const [floatingAnchorElem, setFloatingAnchorElem] =
|
|
7160
|
-
const [isSmallWidthViewport, setIsSmallWidthViewport] =
|
|
7161
|
-
const firstOnChangeTriggeredRef =
|
|
7191
|
+
const [floatingAnchorElem, setFloatingAnchorElem] = useState11(null);
|
|
7192
|
+
const [isSmallWidthViewport, setIsSmallWidthViewport] = useState11(false);
|
|
7193
|
+
const firstOnChangeTriggeredRef = useRef7(!autoFocus);
|
|
7162
7194
|
const onRef = (_floatingAnchorElem) => {
|
|
7163
7195
|
if (_floatingAnchorElem !== null) {
|
|
7164
7196
|
setFloatingAnchorElem(_floatingAnchorElem);
|
|
7165
7197
|
}
|
|
7166
7198
|
};
|
|
7167
|
-
|
|
7199
|
+
useEffect12(() => {
|
|
7168
7200
|
editor.setEditable(editable || false);
|
|
7169
7201
|
}, [editable, editor]);
|
|
7170
|
-
useEffect11(() => {
|
|
7171
|
-
const updateViewPortWidth = () => {
|
|
7172
|
-
const isNextSmallWidthViewport = window.matchMedia("(max-width: 1025px)").matches;
|
|
7173
|
-
if (isNextSmallWidthViewport !== isSmallWidthViewport) {
|
|
7174
|
-
setIsSmallWidthViewport(isNextSmallWidthViewport);
|
|
7175
|
-
}
|
|
7176
|
-
};
|
|
7177
|
-
window.addEventListener("resize", updateViewPortWidth);
|
|
7178
|
-
return () => {
|
|
7179
|
-
window.removeEventListener("resize", updateViewPortWidth);
|
|
7180
|
-
};
|
|
7181
|
-
}, [isSmallWidthViewport]);
|
|
7182
7202
|
function onLocalChange(editorState) {
|
|
7183
7203
|
if (onChange) {
|
|
7184
7204
|
if (triggerOnChangeOnAutoFocus || firstOnChangeTriggeredRef.current) {
|
|
@@ -7187,37 +7207,38 @@ function RichTextEditorWithoutContext({
|
|
|
7187
7207
|
}
|
|
7188
7208
|
firstOnChangeTriggeredRef.current = true;
|
|
7189
7209
|
}
|
|
7190
|
-
return /* @__PURE__ */ jsxs73(
|
|
7191
|
-
/* @__PURE__ */
|
|
7192
|
-
/* @__PURE__ */
|
|
7210
|
+
return /* @__PURE__ */ jsxs73(Fragment8, { children: [
|
|
7211
|
+
/* @__PURE__ */ jsx96(OnChangePlugin, { onChange: onLocalChange, ignoreSelectionChange: true }),
|
|
7212
|
+
/* @__PURE__ */ jsx96(DimensionDetectorPlugin, { onChange: (d) => setIsSmallWidthViewport(d.isSmallWidth) }),
|
|
7213
|
+
isSmallWidthViewport ? null : /* @__PURE__ */ jsx96(ToolbarPlugin, { actionsMenuPrepend, actionsMenuAppend }),
|
|
7193
7214
|
slotPreContent,
|
|
7194
|
-
/* @__PURE__ */ jsxs73("div", { className: "editor-container", children: [
|
|
7195
|
-
maxLength != null ? /* @__PURE__ */
|
|
7196
|
-
!autoFocus ? null : /* @__PURE__ */
|
|
7197
|
-
/* @__PURE__ */
|
|
7198
|
-
/* @__PURE__ */
|
|
7199
|
-
/* @__PURE__ */
|
|
7200
|
-
/* @__PURE__ */
|
|
7215
|
+
/* @__PURE__ */ jsxs73("div", { className: "c-rte-editor-container", children: [
|
|
7216
|
+
maxLength != null ? /* @__PURE__ */ jsx96(MaxLengthPlugin, { maxLength }) : null,
|
|
7217
|
+
!autoFocus ? null : /* @__PURE__ */ jsx96(AutoFocusPlugin, {}),
|
|
7218
|
+
/* @__PURE__ */ jsx96(ClearEditorPlugin, {}),
|
|
7219
|
+
/* @__PURE__ */ jsx96(LexicalAutoLinkPlugin, {}),
|
|
7220
|
+
/* @__PURE__ */ jsx96(HistoryPlugin, { externalHistoryState: historyState }),
|
|
7221
|
+
/* @__PURE__ */ jsx96(
|
|
7201
7222
|
RichTextPlugin,
|
|
7202
7223
|
{
|
|
7203
|
-
contentEditable: /* @__PURE__ */
|
|
7224
|
+
contentEditable: /* @__PURE__ */ jsx96("div", { className: "c-rte-editor-scroller", children: /* @__PURE__ */ jsx96("div", { className: "c-rte-editor", ref: onRef, children: /* @__PURE__ */ jsx96(ContentEditable, { className: "c-rte-contenteditable-root", id }) }) }),
|
|
7204
7225
|
placeholder,
|
|
7205
7226
|
ErrorBoundary: LexicalErrorBoundary
|
|
7206
7227
|
}
|
|
7207
7228
|
),
|
|
7208
|
-
/* @__PURE__ */
|
|
7209
|
-
/* @__PURE__ */
|
|
7210
|
-
/* @__PURE__ */
|
|
7211
|
-
/* @__PURE__ */
|
|
7212
|
-
/* @__PURE__ */
|
|
7213
|
-
/* @__PURE__ */
|
|
7214
|
-
/* @__PURE__ */
|
|
7215
|
-
/* @__PURE__ */
|
|
7216
|
-
floatingAnchorElem && !isSmallWidthViewport && /* @__PURE__ */ jsxs73(
|
|
7217
|
-
/* @__PURE__ */
|
|
7218
|
-
/* @__PURE__ */
|
|
7219
|
-
/* @__PURE__ */
|
|
7220
|
-
/* @__PURE__ */
|
|
7229
|
+
/* @__PURE__ */ jsx96(CodeHighlightPlugin, {}),
|
|
7230
|
+
/* @__PURE__ */ jsx96(ListPlugin, {}),
|
|
7231
|
+
/* @__PURE__ */ jsx96(ListMaxIndentLevelPlugin, { maxDepth: 7 }),
|
|
7232
|
+
/* @__PURE__ */ jsx96(TablePlugin, {}),
|
|
7233
|
+
/* @__PURE__ */ jsx96(LinkPlugin, {}),
|
|
7234
|
+
/* @__PURE__ */ jsx96(HorizontalRulePlugin, {}),
|
|
7235
|
+
/* @__PURE__ */ jsx96(TabFocusPlugin, {}),
|
|
7236
|
+
/* @__PURE__ */ jsx96(TabIndentationPlugin, {}),
|
|
7237
|
+
floatingAnchorElem && !isSmallWidthViewport && /* @__PURE__ */ jsxs73(Fragment8, { children: [
|
|
7238
|
+
/* @__PURE__ */ jsx96(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }),
|
|
7239
|
+
/* @__PURE__ */ jsx96(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem }),
|
|
7240
|
+
/* @__PURE__ */ jsx96(TableActionMenuPlugin, { anchorElem: floatingAnchorElem }),
|
|
7241
|
+
/* @__PURE__ */ jsx96(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem })
|
|
7221
7242
|
] })
|
|
7222
7243
|
] })
|
|
7223
7244
|
] });
|