@tnd028/strapi-plugin-tiptap-editor 0.0.1

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.
Files changed (126) hide show
  1. package/README.md +3 -0
  2. package/dist/_chunks/Alignment-B0f2-LO0.js +135 -0
  3. package/dist/_chunks/Alignment-qMOzO-n2.mjs +133 -0
  4. package/dist/_chunks/Blockquote-9wBGDz3L.mjs +34 -0
  5. package/dist/_chunks/Blockquote-DeGUfK27.js +36 -0
  6. package/dist/_chunks/Bold-C-0g6Ayd.mjs +46 -0
  7. package/dist/_chunks/Bold-ClnPsPHt.js +48 -0
  8. package/dist/_chunks/ColorAndHighlight-BMmtoSpj.js +217 -0
  9. package/dist/_chunks/ColorAndHighlight-t1Ui5tcL.mjs +215 -0
  10. package/dist/_chunks/Emoji-Bm1_vSh5.mjs +263 -0
  11. package/dist/_chunks/Emoji-C-LQZ4Z3.js +265 -0
  12. package/dist/_chunks/Heading-BDJqd1Qw.js +125 -0
  13. package/dist/_chunks/Heading-BycRob5M.mjs +123 -0
  14. package/dist/_chunks/HorizontalRule-CJlDmdma.js +34 -0
  15. package/dist/_chunks/HorizontalRule-CzQCeC3b.mjs +32 -0
  16. package/dist/_chunks/Iframe-DCBWSb0v.mjs +165 -0
  17. package/dist/_chunks/Iframe-Dyn_2cMB.js +167 -0
  18. package/dist/_chunks/ImagePlaceholder-C14kojd5.js +71 -0
  19. package/dist/_chunks/ImagePlaceholder-DtrSuhf_.mjs +69 -0
  20. package/dist/_chunks/Italic-BfpKX0KX.mjs +34 -0
  21. package/dist/_chunks/Italic-DdhVL78v.js +36 -0
  22. package/dist/_chunks/Link-BuYDqSqo.js +61 -0
  23. package/dist/_chunks/Link-DUV5Ybep.mjs +59 -0
  24. package/dist/_chunks/Lists-BKopoFR6.js +107 -0
  25. package/dist/_chunks/Lists-DsKxj3MD.mjs +105 -0
  26. package/dist/_chunks/Redo-1mEX1yOd.js +35 -0
  27. package/dist/_chunks/Redo-Ca3VQxSe.mjs +33 -0
  28. package/dist/_chunks/SearchAndReplace-DmU5DlWv.mjs +347 -0
  29. package/dist/_chunks/SearchAndReplace-DzNdbTWJ.js +349 -0
  30. package/dist/_chunks/Strikethrough-BygxCHak.mjs +121 -0
  31. package/dist/_chunks/Strikethrough-DQfR4OFk.js +123 -0
  32. package/dist/_chunks/Table-BhbZ2Blv.mjs +123 -0
  33. package/dist/_chunks/Table-DLaqBAbz.js +125 -0
  34. package/dist/_chunks/TiptapEditorInput-BDE09h5-.mjs +6802 -0
  35. package/dist/_chunks/TiptapEditorInput-vfLsCt1p.js +6854 -0
  36. package/dist/_chunks/Undo-BuT4OkoE.js +32 -0
  37. package/dist/_chunks/Undo-PL5n4axf.mjs +30 -0
  38. package/dist/_chunks/en-B4KWt_jN.js +4 -0
  39. package/dist/_chunks/en-Byx4XI2L.mjs +4 -0
  40. package/dist/_chunks/index-ku90UbIF.mjs +1397 -0
  41. package/dist/_chunks/index-wYDv8vsJ.js +1398 -0
  42. package/dist/admin/index.js +6 -0
  43. package/dist/admin/index.mjs +6 -0
  44. package/dist/admin/src/components/ContentEditorInput.d.ts +10 -0
  45. package/dist/admin/src/components/GlobalStyling.d.ts +4 -0
  46. package/dist/admin/src/components/Initializer.d.ts +5 -0
  47. package/dist/admin/src/components/MediaLibraryModal.d.ts +27 -0
  48. package/dist/admin/src/components/PluginIcon.d.ts +2 -0
  49. package/dist/admin/src/components/TextEditorInput.d.ts +10 -0
  50. package/dist/admin/src/components/TiptapEditorInput.d.ts +6 -0
  51. package/dist/admin/src/components/editor/BaseEditor.d.ts +22 -0
  52. package/dist/admin/src/components/editor/ContentEditor.d.ts +10 -0
  53. package/dist/admin/src/components/editor/TextEditor.d.ts +10 -0
  54. package/dist/admin/src/components/editor/extensions/Heading.d.ts +2 -0
  55. package/dist/admin/src/components/editor/extensions/Iframe.d.ts +24 -0
  56. package/dist/admin/src/components/editor/extensions/Image.d.ts +3 -0
  57. package/dist/admin/src/components/editor/extensions/ImagePlaceholder.d.ts +15 -0
  58. package/dist/admin/src/components/editor/extensions/custom-component/CustomComponentEditPopover.d.ts +1 -0
  59. package/dist/admin/src/components/editor/extensions/custom-component/CustomComponentExtension.d.ts +3 -0
  60. package/dist/admin/src/components/editor/extensions/custom-component/CustomComponentInsertPopover.d.ts +13 -0
  61. package/dist/admin/src/components/editor/extensions/custom-component/CustomComponentRenderer.d.ts +1 -0
  62. package/dist/admin/src/components/editor/extensions/custom-component/Store.d.ts +20 -0
  63. package/dist/admin/src/components/editor/extensions/custom-component/types.d.ts +33 -0
  64. package/dist/admin/src/components/editor/extensions/fileHandler.d.ts +12 -0
  65. package/dist/admin/src/components/editor/extensions/link.d.ts +1 -0
  66. package/dist/admin/src/components/editor/extensions/noNewLine.d.ts +2 -0
  67. package/dist/admin/src/components/editor/extensions/resetMarksOnEnter.d.ts +2 -0
  68. package/dist/admin/src/components/editor/extensions/searchAndReplace.d.ts +53 -0
  69. package/dist/admin/src/components/editor/partials/EditorProvider.d.ts +13 -0
  70. package/dist/admin/src/components/editor/partials/LinkBubbleMenu.d.ts +5 -0
  71. package/dist/admin/src/components/editor/partials/LinkEditBlock.d.ts +9 -0
  72. package/dist/admin/src/components/editor/partials/LinkPopoverBlock.d.ts +8 -0
  73. package/dist/admin/src/components/editor/partials/ToolbarButton.d.ts +11 -0
  74. package/dist/admin/src/components/editor/partials/ToolbarButtons.d.ts +25 -0
  75. package/dist/admin/src/components/editor/toolbars/Alignment.d.ts +1 -0
  76. package/dist/admin/src/components/editor/toolbars/Blockquote.d.ts +4 -0
  77. package/dist/admin/src/components/editor/toolbars/Bold.d.ts +4 -0
  78. package/dist/admin/src/components/editor/toolbars/BulletList.d.ts +4 -0
  79. package/dist/admin/src/components/editor/toolbars/ColorAndHighlight.d.ts +5 -0
  80. package/dist/admin/src/components/editor/toolbars/Emoji.d.ts +4 -0
  81. package/dist/admin/src/components/editor/toolbars/Heading.d.ts +1 -0
  82. package/dist/admin/src/components/editor/toolbars/HorizontalRule.d.ts +4 -0
  83. package/dist/admin/src/components/editor/toolbars/Iframe.d.ts +3 -0
  84. package/dist/admin/src/components/editor/toolbars/ImagePlaceholder.d.ts +4 -0
  85. package/dist/admin/src/components/editor/toolbars/Italic.d.ts +4 -0
  86. package/dist/admin/src/components/editor/toolbars/Link.d.ts +4 -0
  87. package/dist/admin/src/components/editor/toolbars/Lists.d.ts +1 -0
  88. package/dist/admin/src/components/editor/toolbars/OrderedList.d.ts +4 -0
  89. package/dist/admin/src/components/editor/toolbars/Redo.d.ts +4 -0
  90. package/dist/admin/src/components/editor/toolbars/SearchAndReplace.d.ts +1 -0
  91. package/dist/admin/src/components/editor/toolbars/Strikethrough.d.ts +4 -0
  92. package/dist/admin/src/components/editor/toolbars/Table.d.ts +1 -0
  93. package/dist/admin/src/components/editor/toolbars/Undo.d.ts +4 -0
  94. package/dist/admin/src/components/editor/useEditor.d.ts +18 -0
  95. package/dist/admin/src/components/editor/utils.d.ts +28 -0
  96. package/dist/admin/src/components/ui/button.d.ts +9 -0
  97. package/dist/admin/src/components/ui/dropdown-menu.d.ts +27 -0
  98. package/dist/admin/src/components/ui/input.d.ts +6 -0
  99. package/dist/admin/src/components/ui/label.d.ts +7 -0
  100. package/dist/admin/src/components/ui/separator.d.ts +7 -0
  101. package/dist/admin/src/components/ui/toggle.d.ts +17 -0
  102. package/dist/admin/src/components/ui/tooltip.d.ts +7 -0
  103. package/dist/admin/src/config/index.d.ts +2 -0
  104. package/dist/admin/src/config/pluginConfig.d.ts +20 -0
  105. package/dist/admin/src/config/types.d.ts +109 -0
  106. package/dist/admin/src/errorSlicer.d.ts +4 -0
  107. package/dist/admin/src/exports.d.ts +4 -0
  108. package/dist/admin/src/hooks/useDebounceCallback.d.ts +9 -0
  109. package/dist/admin/src/index.d.ts +25 -0
  110. package/dist/admin/src/pluginId.d.ts +5 -0
  111. package/dist/admin/src/theme/additional.d.ts +1 -0
  112. package/dist/admin/src/theme/colorScheme.d.ts +2 -0
  113. package/dist/admin/src/theme/colors.d.ts +1 -0
  114. package/dist/admin/src/theme/common.d.ts +1 -0
  115. package/dist/admin/src/theme/index.d.ts +2 -0
  116. package/dist/admin/src/types.d.ts +15 -0
  117. package/dist/admin/src/utils/dom.d.ts +7 -0
  118. package/dist/admin/src/utils/getTranslation.d.ts +7 -0
  119. package/dist/admin/src/utils/isImageResponsive.d.ts +8 -0
  120. package/dist/admin/src/utils/localStorage.d.ts +21 -0
  121. package/dist/admin/src/utils/prefixWithBackendUrl.d.ts +6 -0
  122. package/dist/admin/src/utils/utils.d.ts +7 -0
  123. package/dist/server/index.js +15 -0
  124. package/dist/server/index.mjs +16 -0
  125. package/dist/server/src/index.d.ts +7 -0
  126. package/package.json +116 -0
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const lucideReact = require("lucide-react");
5
+ const styled = require("styled-components");
6
+ const TiptapEditorInput = require("./TiptapEditorInput-vfLsCt1p.js");
7
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
8
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
9
+ const DropdownMenuItemStyled = styled__default.default(TiptapEditorInput.DropdownMenuItem)`
10
+ display: flex;
11
+ align-items: center;
12
+ gap: 2px;
13
+ padding: 6px 8px 6px 4px;
14
+ font-size: 14px;
15
+
16
+ &:hover {
17
+ background-color: ${(props) => props.theme.colors.neutral100};
18
+ }
19
+
20
+ &:focus {
21
+ background-color: ${(props) => props.theme.colors.neutral100};
22
+ }
23
+
24
+ svg {
25
+ width: 16px;
26
+ height: 16px;
27
+ }
28
+ `;
29
+ const CheckIcon = styled__default.default(lucideReact.Check)`
30
+ width: 12px;
31
+ height: 12px;
32
+ color: ${(props) => props.theme.colors.primary500};
33
+ `;
34
+ const IconWrapper = styled__default.default.div`
35
+ display: flex;
36
+ align-items: center;
37
+ justify-content: center;
38
+ width: 16px;
39
+ height: 20px;
40
+ margin-right: 4px;
41
+ `;
42
+ const ListsToolbar = () => {
43
+ const { editor } = TiptapEditorInput.useEditorContext();
44
+ const items = [
45
+ {
46
+ action: () => editor.commands.toggleBulletList(),
47
+ isActive: () => editor.isActive("bulletList"),
48
+ disabled: !editor.can().toggleBulletList(),
49
+ title: "Bullet List",
50
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.List, {})
51
+ },
52
+ {
53
+ action: () => editor.commands.toggleOrderedList(),
54
+ isActive: () => editor.isActive("orderedList"),
55
+ disabled: !editor.can().toggleOrderedList(),
56
+ title: "Ordered List",
57
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListOrdered, {})
58
+ },
59
+ {
60
+ action: () => editor.commands.toggleTaskList(),
61
+ isActive: () => editor.isActive("taskList"),
62
+ disabled: !editor.can().toggleTaskList(),
63
+ title: "Task List",
64
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListTodo, {})
65
+ }
66
+ ];
67
+ const isDisabled = items.every((item) => item.disabled);
68
+ const activeItem = items.find((item) => item.isActive());
69
+ return /* @__PURE__ */ jsxRuntime.jsxs(TiptapEditorInput.DropdownMenu, { children: [
70
+ /* @__PURE__ */ jsxRuntime.jsx(TiptapEditorInput.DropdownMenuTrigger, { disabled: isDisabled, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
71
+ TiptapEditorInput.ToolbarButton,
72
+ {
73
+ tooltip: "Lists",
74
+ "aria-label": "Lists",
75
+ disabled: isDisabled,
76
+ isActive: !!activeItem,
77
+ hasArrow: true,
78
+ children: /* @__PURE__ */ jsxRuntime.jsx(IconWrapper, { children: activeItem ? activeItem.icon : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.List, { size: 16 }) })
79
+ }
80
+ ) }),
81
+ /* @__PURE__ */ jsxRuntime.jsx(
82
+ TiptapEditorInput.DropdownMenuContent,
83
+ {
84
+ align: "start",
85
+ loop: true,
86
+ onCloseAutoFocus: (e) => {
87
+ e.preventDefault();
88
+ },
89
+ children: /* @__PURE__ */ jsxRuntime.jsx(TiptapEditorInput.DropdownMenuGroup, { children: items.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs(
90
+ DropdownMenuItemStyled,
91
+ {
92
+ onSelect: () => {
93
+ option.action();
94
+ },
95
+ children: [
96
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: 12, height: 12, display: "flex", alignItems: "center", justifyContent: "center" }, children: option.isActive() && /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}) }),
97
+ /* @__PURE__ */ jsxRuntime.jsx(IconWrapper, { children: option.icon }),
98
+ option.title
99
+ ]
100
+ },
101
+ index
102
+ )) })
103
+ }
104
+ )
105
+ ] });
106
+ };
107
+ exports.ListsToolbar = ListsToolbar;
@@ -0,0 +1,105 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { List, ListOrdered, ListTodo, Check } from "lucide-react";
3
+ import styled from "styled-components";
4
+ import { u as useEditorContext, D as DropdownMenu, a as DropdownMenuTrigger, T as ToolbarButton, b as DropdownMenuContent, c as DropdownMenuGroup, d as DropdownMenuItem } from "./TiptapEditorInput-BDE09h5-.mjs";
5
+ const DropdownMenuItemStyled = styled(DropdownMenuItem)`
6
+ display: flex;
7
+ align-items: center;
8
+ gap: 2px;
9
+ padding: 6px 8px 6px 4px;
10
+ font-size: 14px;
11
+
12
+ &:hover {
13
+ background-color: ${(props) => props.theme.colors.neutral100};
14
+ }
15
+
16
+ &:focus {
17
+ background-color: ${(props) => props.theme.colors.neutral100};
18
+ }
19
+
20
+ svg {
21
+ width: 16px;
22
+ height: 16px;
23
+ }
24
+ `;
25
+ const CheckIcon = styled(Check)`
26
+ width: 12px;
27
+ height: 12px;
28
+ color: ${(props) => props.theme.colors.primary500};
29
+ `;
30
+ const IconWrapper = styled.div`
31
+ display: flex;
32
+ align-items: center;
33
+ justify-content: center;
34
+ width: 16px;
35
+ height: 20px;
36
+ margin-right: 4px;
37
+ `;
38
+ const ListsToolbar = () => {
39
+ const { editor } = useEditorContext();
40
+ const items = [
41
+ {
42
+ action: () => editor.commands.toggleBulletList(),
43
+ isActive: () => editor.isActive("bulletList"),
44
+ disabled: !editor.can().toggleBulletList(),
45
+ title: "Bullet List",
46
+ icon: /* @__PURE__ */ jsx(List, {})
47
+ },
48
+ {
49
+ action: () => editor.commands.toggleOrderedList(),
50
+ isActive: () => editor.isActive("orderedList"),
51
+ disabled: !editor.can().toggleOrderedList(),
52
+ title: "Ordered List",
53
+ icon: /* @__PURE__ */ jsx(ListOrdered, {})
54
+ },
55
+ {
56
+ action: () => editor.commands.toggleTaskList(),
57
+ isActive: () => editor.isActive("taskList"),
58
+ disabled: !editor.can().toggleTaskList(),
59
+ title: "Task List",
60
+ icon: /* @__PURE__ */ jsx(ListTodo, {})
61
+ }
62
+ ];
63
+ const isDisabled = items.every((item) => item.disabled);
64
+ const activeItem = items.find((item) => item.isActive());
65
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
66
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { disabled: isDisabled, asChild: true, children: /* @__PURE__ */ jsx(
67
+ ToolbarButton,
68
+ {
69
+ tooltip: "Lists",
70
+ "aria-label": "Lists",
71
+ disabled: isDisabled,
72
+ isActive: !!activeItem,
73
+ hasArrow: true,
74
+ children: /* @__PURE__ */ jsx(IconWrapper, { children: activeItem ? activeItem.icon : /* @__PURE__ */ jsx(List, { size: 16 }) })
75
+ }
76
+ ) }),
77
+ /* @__PURE__ */ jsx(
78
+ DropdownMenuContent,
79
+ {
80
+ align: "start",
81
+ loop: true,
82
+ onCloseAutoFocus: (e) => {
83
+ e.preventDefault();
84
+ },
85
+ children: /* @__PURE__ */ jsx(DropdownMenuGroup, { children: items.map((option, index) => /* @__PURE__ */ jsxs(
86
+ DropdownMenuItemStyled,
87
+ {
88
+ onSelect: () => {
89
+ option.action();
90
+ },
91
+ children: [
92
+ /* @__PURE__ */ jsx("div", { style: { width: 12, height: 12, display: "flex", alignItems: "center", justifyContent: "center" }, children: option.isActive() && /* @__PURE__ */ jsx(CheckIcon, {}) }),
93
+ /* @__PURE__ */ jsx(IconWrapper, { children: option.icon }),
94
+ option.title
95
+ ]
96
+ },
97
+ index
98
+ )) })
99
+ }
100
+ )
101
+ ] });
102
+ };
103
+ export {
104
+ ListsToolbar
105
+ };
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const lucideReact = require("lucide-react");
6
+ const TiptapEditorInput = require("./TiptapEditorInput-vfLsCt1p.js");
7
+ const styled = require("styled-components");
8
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
9
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
10
+ const RedoIcon = styled__default.default(lucideReact.Redo2)`
11
+ width: 16px;
12
+ height: 16px;
13
+ `;
14
+ const RedoToolbar = React.forwardRef(
15
+ ({ className, onClick, children, ...props }, ref) => {
16
+ const { editor } = TiptapEditorInput.useEditorContext();
17
+ return /* @__PURE__ */ jsxRuntime.jsx(
18
+ TiptapEditorInput.ToolbarButton,
19
+ {
20
+ tooltip: "Redo",
21
+ "aria-label": "Redo",
22
+ onClick: (e) => {
23
+ editor?.chain().focus().redo().run();
24
+ onClick?.(e);
25
+ },
26
+ disabled: !editor?.can().chain().focus().redo().run(),
27
+ ref,
28
+ ...props,
29
+ children: children || /* @__PURE__ */ jsxRuntime.jsx(RedoIcon, {})
30
+ }
31
+ );
32
+ }
33
+ );
34
+ RedoToolbar.displayName = "RedoToolbar";
35
+ exports.RedoToolbar = RedoToolbar;
@@ -0,0 +1,33 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { Redo2 } from "lucide-react";
4
+ import { u as useEditorContext, T as ToolbarButton } from "./TiptapEditorInput-BDE09h5-.mjs";
5
+ import styled from "styled-components";
6
+ const RedoIcon = styled(Redo2)`
7
+ width: 16px;
8
+ height: 16px;
9
+ `;
10
+ const RedoToolbar = forwardRef(
11
+ ({ className, onClick, children, ...props }, ref) => {
12
+ const { editor } = useEditorContext();
13
+ return /* @__PURE__ */ jsx(
14
+ ToolbarButton,
15
+ {
16
+ tooltip: "Redo",
17
+ "aria-label": "Redo",
18
+ onClick: (e) => {
19
+ editor?.chain().focus().redo().run();
20
+ onClick?.(e);
21
+ },
22
+ disabled: !editor?.can().chain().focus().redo().run(),
23
+ ref,
24
+ ...props,
25
+ children: children || /* @__PURE__ */ jsx(RedoIcon, {})
26
+ }
27
+ );
28
+ }
29
+ );
30
+ RedoToolbar.displayName = "RedoToolbar";
31
+ export {
32
+ RedoToolbar
33
+ };
@@ -0,0 +1,347 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
3
+ import { ArrowLeft, ArrowRight, Repeat, X } from "lucide-react";
4
+ import { u as useEditorContext, I as Input, T as ToolbarButton, B as Button, S as Separator, h as Label } from "./TiptapEditorInput-BDE09h5-.mjs";
5
+ import { Popover, Checkbox } from "@strapi/design-system";
6
+ import styled from "styled-components";
7
+ const RepeatIcon = styled(Repeat)`
8
+ width: 16px;
9
+ height: 16px;
10
+ margin-right: 8px;
11
+ `;
12
+ const ArrowIcon = styled.div`
13
+ width: 16px;
14
+ height: 16px;
15
+ `;
16
+ const CloseIcon = styled(X)`
17
+ width: 16px;
18
+ height: 16px;
19
+ cursor: pointer;
20
+ `;
21
+ const PopoverContent = styled(Popover.Content)`
22
+ position: relative;
23
+ display: flex;
24
+ width: 400px;
25
+ padding: 10px 12px;
26
+ `;
27
+ const SearchContainer = styled.div`
28
+ position: relative;
29
+ display: flex;
30
+ gap: 6px;
31
+ align-items: center;
32
+ `;
33
+ const SearchInput = styled(Input)`
34
+ width: 192px;
35
+ `;
36
+ const ResultCount = styled.span`
37
+ font-size: 14px;
38
+ `;
39
+ const IconButton = styled(Button)`
40
+ width: 28px;
41
+ height: 28px;
42
+ `;
43
+ const VerticalSeparator = styled(Separator)`
44
+ height: 28px;
45
+ margin: 0 2px;
46
+ `;
47
+ const ReplaceContainer = styled.div`
48
+ position: relative;
49
+ width: 100%;
50
+ `;
51
+ const CloseButton = styled(CloseIcon)`
52
+ position: absolute;
53
+ right: 12px;
54
+ top: 12px;
55
+ `;
56
+ const Header = styled.div`
57
+ display: flex;
58
+ width: 100%;
59
+ align-items: center;
60
+ gap: 12px;
61
+ `;
62
+ const BackButton = styled(IconButton)`
63
+ border-radius: 50%;
64
+ `;
65
+ const Title = styled.h2`
66
+ font-size: 14px;
67
+ font-weight: 500;
68
+ `;
69
+ const FormSection = styled.div`
70
+ margin: 8px 0;
71
+ width: 100%;
72
+ `;
73
+ const InputGroup = styled.div`
74
+ margin-bottom: 12px;
75
+ `;
76
+ const InputLabel = styled(Label)`
77
+ margin-bottom: 4px;
78
+ font-size: 12px;
79
+ color: ${(props) => props.theme.colors.neutral600};
80
+ `;
81
+ const CheckboxContainer = styled.div`
82
+ margin-top: 12px;
83
+ display: flex;
84
+ align-items: center;
85
+ gap: 8px;
86
+ `;
87
+ const CheckboxLabel = styled(Label)`
88
+ font-size: 14px;
89
+ font-weight: 500;
90
+ `;
91
+ const ActionsContainer = styled.div`
92
+ margin-top: 24px;
93
+ display: flex;
94
+ align-items: center;
95
+ justify-content: space-between;
96
+ `;
97
+ const NavigationButtons = styled.div`
98
+ display: flex;
99
+ align-items: center;
100
+ gap: 8px;
101
+ `;
102
+ const MainActions = styled.div`
103
+ display: flex;
104
+ align-items: center;
105
+ gap: 8px;
106
+ `;
107
+ const ActionButton = styled(Button)`
108
+ height: 28px;
109
+ padding: 0 12px;
110
+ font-size: 12px;
111
+ `;
112
+ const TriggerButton = styled(ToolbarButton)`
113
+ height: 32px;
114
+ width: auto !important;
115
+ padding: 0 12px;
116
+ font-weight: 400;
117
+ display: flex;
118
+ min-width: fit-content;
119
+ align-items: center;
120
+ `;
121
+ function SearchAndReplaceToolbar() {
122
+ const { editor } = useEditorContext();
123
+ const [open, setOpen] = useState(false);
124
+ const [replacing, setReplacing] = useState(false);
125
+ const [searchText, setSearchText] = useState("");
126
+ const [replaceText, setReplaceText] = useState("");
127
+ const [checked, setChecked] = useState(false);
128
+ const results = editor?.storage?.searchAndReplace.results;
129
+ const selectedResult = editor?.storage?.searchAndReplace.selectedResult;
130
+ const replace = () => editor?.chain().replace().run();
131
+ const replaceAll = () => editor?.chain().replaceAll().run();
132
+ const selectNext = () => editor?.chain().selectNextResult().run();
133
+ const selectPrevious = () => editor?.chain().selectPreviousResult().run();
134
+ useEffect(() => {
135
+ editor?.chain().setSearchTerm(searchText).run();
136
+ }, [searchText, editor]);
137
+ useEffect(() => {
138
+ editor?.chain().setReplaceTerm(replaceText).run();
139
+ }, [replaceText, editor]);
140
+ useEffect(() => {
141
+ editor?.chain().setCaseSensitive(checked).run();
142
+ }, [checked, editor]);
143
+ useEffect(() => {
144
+ if (!open) {
145
+ setReplaceText("");
146
+ setSearchText("");
147
+ setReplacing(false);
148
+ }
149
+ }, [open]);
150
+ return /* @__PURE__ */ jsxs(Popover.Root, { open, children: [
151
+ /* @__PURE__ */ jsx(Popover.Trigger, { disabled: !editor, children: /* @__PURE__ */ jsxs(
152
+ TriggerButton,
153
+ {
154
+ tooltip: "Search & Replace",
155
+ style: { minWidth: "fit-content" },
156
+ onClick: () => {
157
+ setOpen(!open);
158
+ },
159
+ children: [
160
+ /* @__PURE__ */ jsx(RepeatIcon, {}),
161
+ /* @__PURE__ */ jsx("p", { children: "Search & Replace" })
162
+ ]
163
+ }
164
+ ) }),
165
+ /* @__PURE__ */ jsx(
166
+ PopoverContent,
167
+ {
168
+ align: "end",
169
+ onCloseAutoFocus: (e) => {
170
+ e.preventDefault();
171
+ },
172
+ onEscapeKeyDown: () => {
173
+ setOpen(false);
174
+ },
175
+ children: !replacing ? /* @__PURE__ */ jsxs(SearchContainer, { children: [
176
+ /* @__PURE__ */ jsx(
177
+ SearchInput,
178
+ {
179
+ value: searchText,
180
+ onChange: (e) => {
181
+ setSearchText(e.target.value);
182
+ },
183
+ placeholder: "Search..."
184
+ }
185
+ ),
186
+ /* @__PURE__ */ jsxs(ResultCount, { children: [
187
+ results?.length === 0 ? selectedResult : selectedResult + 1,
188
+ "/",
189
+ results?.length
190
+ ] }),
191
+ /* @__PURE__ */ jsx(
192
+ IconButton,
193
+ {
194
+ onClick: selectPrevious,
195
+ size: "icon",
196
+ variant: "ghost",
197
+ children: /* @__PURE__ */ jsx(ArrowIcon, { as: ArrowLeft })
198
+ }
199
+ ),
200
+ /* @__PURE__ */ jsx(
201
+ IconButton,
202
+ {
203
+ onClick: selectNext,
204
+ size: "icon",
205
+ variant: "ghost",
206
+ children: /* @__PURE__ */ jsx(ArrowIcon, { as: ArrowRight })
207
+ }
208
+ ),
209
+ /* @__PURE__ */ jsx(VerticalSeparator, { orientation: "vertical" }),
210
+ /* @__PURE__ */ jsx(
211
+ IconButton,
212
+ {
213
+ onClick: () => {
214
+ setReplacing(true);
215
+ },
216
+ size: "icon",
217
+ variant: "ghost",
218
+ children: /* @__PURE__ */ jsx(ArrowIcon, { as: Repeat })
219
+ }
220
+ ),
221
+ /* @__PURE__ */ jsx(
222
+ IconButton,
223
+ {
224
+ onClick: () => {
225
+ setOpen(false);
226
+ },
227
+ size: "icon",
228
+ variant: "ghost",
229
+ children: /* @__PURE__ */ jsx(ArrowIcon, { as: X })
230
+ }
231
+ )
232
+ ] }) : /* @__PURE__ */ jsxs(ReplaceContainer, { children: [
233
+ /* @__PURE__ */ jsx(
234
+ CloseButton,
235
+ {
236
+ onClick: () => {
237
+ setOpen(false);
238
+ }
239
+ }
240
+ ),
241
+ /* @__PURE__ */ jsxs(Header, { children: [
242
+ /* @__PURE__ */ jsx(
243
+ BackButton,
244
+ {
245
+ size: "icon",
246
+ variant: "ghost",
247
+ onClick: () => {
248
+ setReplacing(false);
249
+ },
250
+ children: /* @__PURE__ */ jsx(ArrowIcon, { as: ArrowLeft })
251
+ }
252
+ ),
253
+ /* @__PURE__ */ jsx(Title, { children: "Search and replace" })
254
+ ] }),
255
+ /* @__PURE__ */ jsxs(FormSection, { children: [
256
+ /* @__PURE__ */ jsxs(InputGroup, { children: [
257
+ /* @__PURE__ */ jsx(InputLabel, { children: "Search" }),
258
+ /* @__PURE__ */ jsx(
259
+ Input,
260
+ {
261
+ value: searchText,
262
+ onChange: (e) => {
263
+ setSearchText(e.target.value);
264
+ },
265
+ placeholder: "Search..."
266
+ }
267
+ ),
268
+ /* @__PURE__ */ jsxs(ResultCount, { children: [
269
+ results?.length === 0 ? selectedResult : selectedResult + 1,
270
+ "/",
271
+ results?.length
272
+ ] })
273
+ ] }),
274
+ /* @__PURE__ */ jsxs(InputGroup, { children: [
275
+ /* @__PURE__ */ jsx(InputLabel, { children: "Replace with" }),
276
+ /* @__PURE__ */ jsx(
277
+ Input,
278
+ {
279
+ value: replaceText,
280
+ onChange: (e) => {
281
+ setReplaceText(e.target.value);
282
+ },
283
+ placeholder: "Replace..."
284
+ }
285
+ )
286
+ ] }),
287
+ /* @__PURE__ */ jsxs(CheckboxContainer, { children: [
288
+ /* @__PURE__ */ jsx(
289
+ Checkbox,
290
+ {
291
+ checked,
292
+ onCheckedChange: (checked2) => {
293
+ setChecked(checked2);
294
+ },
295
+ id: "match_case"
296
+ }
297
+ ),
298
+ /* @__PURE__ */ jsx(CheckboxLabel, { htmlFor: "match_case", children: "Match case" })
299
+ ] })
300
+ ] }),
301
+ /* @__PURE__ */ jsxs(ActionsContainer, { children: [
302
+ /* @__PURE__ */ jsxs(NavigationButtons, { children: [
303
+ /* @__PURE__ */ jsx(
304
+ IconButton,
305
+ {
306
+ onClick: selectPrevious,
307
+ size: "icon",
308
+ variant: "secondary",
309
+ children: /* @__PURE__ */ jsx(ArrowIcon, { as: ArrowLeft })
310
+ }
311
+ ),
312
+ /* @__PURE__ */ jsx(
313
+ IconButton,
314
+ {
315
+ onClick: selectNext,
316
+ size: "icon",
317
+ variant: "secondary",
318
+ children: /* @__PURE__ */ jsx(ArrowIcon, { as: ArrowRight })
319
+ }
320
+ )
321
+ ] }),
322
+ /* @__PURE__ */ jsxs(MainActions, { children: [
323
+ /* @__PURE__ */ jsx(
324
+ ActionButton,
325
+ {
326
+ variant: "secondary",
327
+ onClick: replaceAll,
328
+ children: "Replace All"
329
+ }
330
+ ),
331
+ /* @__PURE__ */ jsx(
332
+ ActionButton,
333
+ {
334
+ onClick: replace,
335
+ children: "Replace"
336
+ }
337
+ )
338
+ ] })
339
+ ] })
340
+ ] })
341
+ }
342
+ )
343
+ ] });
344
+ }
345
+ export {
346
+ SearchAndReplaceToolbar
347
+ };