@kopexa/tiptap 17.9.2 → 17.10.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/dist/index.mjs CHANGED
@@ -1,5 +1,8 @@
1
1
  "use client";
2
2
 
3
+ // src/index.ts
4
+ import { useCurrentEditor } from "@tiptap/react";
5
+
3
6
  // src/context/collaboration-context.tsx
4
7
  import { HocuspocusProvider, WebSocketStatus } from "@hocuspocus/provider";
5
8
  import {
@@ -3357,7 +3360,7 @@ import {
3357
3360
  useEditor
3358
3361
  } from "@tiptap/react";
3359
3362
  import { StarterKit } from "@tiptap/starter-kit";
3360
- import { useEffect as useEffect14, useState as useState13 } from "react";
3363
+ import { useEffect as useEffect14, useRef as useRef8, useState as useState13 } from "react";
3361
3364
 
3362
3365
  // src/extensions/link/index.ts
3363
3366
  import TiptapLink from "@tiptap/extension-link";
@@ -3728,9 +3731,67 @@ var Selection = Extension3.create({
3728
3731
  }
3729
3732
  });
3730
3733
 
3734
+ // src/extensions/tab-handler/index.ts
3735
+ import { Extension as Extension4 } from "@tiptap/core";
3736
+ var TabHandler = Extension4.create({
3737
+ name: "tabHandler",
3738
+ addOptions() {
3739
+ return {
3740
+ spaces: 4
3741
+ };
3742
+ },
3743
+ addKeyboardShortcuts() {
3744
+ return {
3745
+ Tab: ({ editor }) => {
3746
+ if (editor.isActive("listItem") || editor.isActive("taskItem")) {
3747
+ if (editor.can().sinkListItem("listItem")) {
3748
+ return editor.commands.sinkListItem("listItem");
3749
+ }
3750
+ if (editor.can().sinkListItem("taskItem")) {
3751
+ return editor.commands.sinkListItem("taskItem");
3752
+ }
3753
+ }
3754
+ const spaces = " ".repeat(this.options.spaces);
3755
+ return editor.commands.insertContent(spaces);
3756
+ },
3757
+ "Shift-Tab": ({ editor }) => {
3758
+ if (editor.isActive("listItem") || editor.isActive("taskItem")) {
3759
+ if (editor.can().liftListItem("listItem")) {
3760
+ return editor.commands.liftListItem("listItem");
3761
+ }
3762
+ if (editor.can().liftListItem("taskItem")) {
3763
+ return editor.commands.liftListItem("taskItem");
3764
+ }
3765
+ }
3766
+ const { state } = editor;
3767
+ const { $from, from } = state.selection;
3768
+ const spacesToCheck = this.options.spaces;
3769
+ const parent = $from.parent;
3770
+ const offsetInParent = $from.parentOffset;
3771
+ if (offsetInParent === 0 || !parent.isTextblock) {
3772
+ return true;
3773
+ }
3774
+ const textBeforeCursor = parent.textContent.slice(0, offsetInParent);
3775
+ const trailingSpaces = textBeforeCursor.match(/[ ]+$/);
3776
+ if (trailingSpaces) {
3777
+ const spacesToRemove = Math.min(
3778
+ trailingSpaces[0].length,
3779
+ spacesToCheck
3780
+ );
3781
+ return editor.commands.deleteRange({
3782
+ from: from - spacesToRemove,
3783
+ to: from
3784
+ });
3785
+ }
3786
+ return true;
3787
+ }
3788
+ };
3789
+ }
3790
+ });
3791
+
3731
3792
  // src/extensions/trailing-node/index.ts
3732
3793
  import { Plugin as Plugin3, PluginKey as PluginKey5 } from "@tiptap/pm/state";
3733
- import { Extension as Extension4 } from "@tiptap/react";
3794
+ import { Extension as Extension5 } from "@tiptap/react";
3734
3795
  function nodeEqualsType({
3735
3796
  types,
3736
3797
  node
@@ -3741,7 +3802,7 @@ function nodeEqualsType({
3741
3802
  }
3742
3803
  return node.type === types;
3743
3804
  }
3744
- var TrailingNode = Extension4.create({
3805
+ var TrailingNode = Extension5.create({
3745
3806
  name: "trailingNode",
3746
3807
  addOptions() {
3747
3808
  return {
@@ -3787,7 +3848,7 @@ var TrailingNode = Extension4.create({
3787
3848
  });
3788
3849
 
3789
3850
  // src/extensions/ui-state/index.ts
3790
- import { Extension as Extension5 } from "@tiptap/core";
3851
+ import { Extension as Extension6 } from "@tiptap/core";
3791
3852
  var defaultUiState = {
3792
3853
  aiGenerationIsSelection: false,
3793
3854
  aiGenerationIsLoading: false,
@@ -3797,7 +3858,7 @@ var defaultUiState = {
3797
3858
  lockDragHandle: false,
3798
3859
  isDragging: false
3799
3860
  };
3800
- var UiState = Extension5.create({
3861
+ var UiState = Extension6.create({
3801
3862
  name: "uiState",
3802
3863
  addStorage() {
3803
3864
  return {
@@ -4023,10 +4084,15 @@ var useCreateEditor = ({
4023
4084
  const fileHandler = fileHandlerProp != null ? fileHandlerProp : fileHandlerFromContext;
4024
4085
  const collaboration = useCollaboration();
4025
4086
  const [collabSyncing, setCollabSyncing] = useState13(!!collaboration);
4087
+ const placeholderRef = useRef8(placeholder);
4088
+ placeholderRef.current = placeholder;
4026
4089
  const [extensions] = useState13(
4027
4090
  () => getExtensions({
4028
4091
  editable,
4029
- placeholder,
4092
+ placeholder: () => {
4093
+ const current = placeholderRef.current;
4094
+ return typeof current === "function" ? current() : current;
4095
+ },
4030
4096
  enableControls,
4031
4097
  controlResolver,
4032
4098
  fileHandler,
@@ -4150,6 +4216,7 @@ function getExtensions({
4150
4216
  }),
4151
4217
  UiState,
4152
4218
  TableKit,
4219
+ TabHandler,
4153
4220
  NodeAlignment,
4154
4221
  NodeBackground,
4155
4222
  TocNode,
@@ -4313,7 +4380,11 @@ import {
4313
4380
  EditorContent,
4314
4381
  EditorContext
4315
4382
  } from "@tiptap/react";
4316
- import { useCallback as useCallback38, useContext as useContext4 } from "react";
4383
+ import {
4384
+ useCallback as useCallback38,
4385
+ useContext as useContext4
4386
+ } from "react";
4387
+ import { useIntl as useIntl19 } from "react-intl";
4317
4388
 
4318
4389
  // src/context/editor-context.ts
4319
4390
  import { createContext as createContext4 } from "@kopexa/react-utils";
@@ -4832,6 +4903,425 @@ import {
4832
4903
  import { ToolbarButton as ToolbarButton2 } from "@kopexa/toolbar";
4833
4904
  import { isNodeSelection as isNodeSelection2 } from "@tiptap/react";
4834
4905
  import { useCallback as useCallback15, useMemo as useMemo13 } from "react";
4906
+ import { useIntl as useIntl9 } from "react-intl";
4907
+
4908
+ // src/ui/messages.ts
4909
+ import { defineMessages as defineMessages7 } from "react-intl";
4910
+ var messages7 = defineMessages7({
4911
+ // Turn Into Dropdown - Block Types
4912
+ block_text: {
4913
+ id: "editor.toolbar.block.text",
4914
+ defaultMessage: "Text",
4915
+ description: "Regular text paragraph block type"
4916
+ },
4917
+ block_heading_1: {
4918
+ id: "editor.toolbar.block.heading_1",
4919
+ defaultMessage: "Heading 1",
4920
+ description: "Heading level 1 block type"
4921
+ },
4922
+ block_heading_2: {
4923
+ id: "editor.toolbar.block.heading_2",
4924
+ defaultMessage: "Heading 2",
4925
+ description: "Heading level 2 block type"
4926
+ },
4927
+ block_heading_3: {
4928
+ id: "editor.toolbar.block.heading_3",
4929
+ defaultMessage: "Heading 3",
4930
+ description: "Heading level 3 block type"
4931
+ },
4932
+ block_heading_4: {
4933
+ id: "editor.toolbar.block.heading_4",
4934
+ defaultMessage: "Heading 4",
4935
+ description: "Heading level 4 block type"
4936
+ },
4937
+ block_bullet_list: {
4938
+ id: "editor.toolbar.block.bullet_list",
4939
+ defaultMessage: "Bulleted list",
4940
+ description: "Bulleted/unordered list block type"
4941
+ },
4942
+ block_ordered_list: {
4943
+ id: "editor.toolbar.block.ordered_list",
4944
+ defaultMessage: "Numbered list",
4945
+ description: "Numbered/ordered list block type"
4946
+ },
4947
+ block_task_list: {
4948
+ id: "editor.toolbar.block.task_list",
4949
+ defaultMessage: "To-do list",
4950
+ description: "Task/to-do list block type"
4951
+ },
4952
+ block_blockquote: {
4953
+ id: "editor.toolbar.block.blockquote",
4954
+ defaultMessage: "Blockquote",
4955
+ description: "Blockquote block type"
4956
+ },
4957
+ block_code_block: {
4958
+ id: "editor.toolbar.block.code_block",
4959
+ defaultMessage: "Code block",
4960
+ description: "Code block type"
4961
+ },
4962
+ // Turn Into Dropdown
4963
+ turn_into: {
4964
+ id: "editor.toolbar.turn_into",
4965
+ defaultMessage: "Turn into",
4966
+ description: "Turn into dropdown tooltip"
4967
+ },
4968
+ turn_into_current: {
4969
+ id: "editor.toolbar.turn_into_current",
4970
+ defaultMessage: "Turn into (current: {current})",
4971
+ description: "Turn into dropdown aria-label with current block type"
4972
+ },
4973
+ // Formatting
4974
+ reset_formatting: {
4975
+ id: "editor.toolbar.reset_formatting",
4976
+ defaultMessage: "Reset formatting",
4977
+ description: "Reset all formatting button tooltip"
4978
+ },
4979
+ bold: {
4980
+ id: "editor.toolbar.bold",
4981
+ defaultMessage: "Bold",
4982
+ description: "Bold formatting button"
4983
+ },
4984
+ italic: {
4985
+ id: "editor.toolbar.italic",
4986
+ defaultMessage: "Italic",
4987
+ description: "Italic formatting button"
4988
+ },
4989
+ underline: {
4990
+ id: "editor.toolbar.underline",
4991
+ defaultMessage: "Underline",
4992
+ description: "Underline formatting button"
4993
+ },
4994
+ strikethrough: {
4995
+ id: "editor.toolbar.strikethrough",
4996
+ defaultMessage: "Strikethrough",
4997
+ description: "Strikethrough formatting button"
4998
+ },
4999
+ code: {
5000
+ id: "editor.toolbar.code",
5001
+ defaultMessage: "Code",
5002
+ description: "Inline code formatting button"
5003
+ },
5004
+ superscript: {
5005
+ id: "editor.toolbar.superscript",
5006
+ defaultMessage: "Superscript",
5007
+ description: "Superscript formatting button"
5008
+ },
5009
+ subscript: {
5010
+ id: "editor.toolbar.subscript",
5011
+ defaultMessage: "Subscript",
5012
+ description: "Subscript formatting button"
5013
+ },
5014
+ // Link Bubble
5015
+ link_save: {
5016
+ id: "editor.toolbar.link.save",
5017
+ defaultMessage: "Save link",
5018
+ description: "Save link button"
5019
+ },
5020
+ link_open: {
5021
+ id: "editor.toolbar.link.open",
5022
+ defaultMessage: "Open link in new tab",
5023
+ description: "Open link in new tab button"
5024
+ },
5025
+ link_edit: {
5026
+ id: "editor.toolbar.link.edit",
5027
+ defaultMessage: "Edit link",
5028
+ description: "Edit link button"
5029
+ },
5030
+ link_remove: {
5031
+ id: "editor.toolbar.link.remove",
5032
+ defaultMessage: "Remove link",
5033
+ description: "Remove link button"
5034
+ },
5035
+ link_placeholder: {
5036
+ id: "editor.toolbar.link.placeholder",
5037
+ defaultMessage: "Enter URL...",
5038
+ description: "Link input placeholder"
5039
+ },
5040
+ // Undo/Redo
5041
+ undo: {
5042
+ id: "editor.toolbar.undo",
5043
+ defaultMessage: "Undo",
5044
+ description: "Undo button"
5045
+ },
5046
+ redo: {
5047
+ id: "editor.toolbar.redo",
5048
+ defaultMessage: "Redo",
5049
+ description: "Redo button"
5050
+ },
5051
+ // Slash Menu - Groups
5052
+ group_ai: {
5053
+ id: "editor.slash.group.ai",
5054
+ defaultMessage: "AI",
5055
+ description: "AI commands group"
5056
+ },
5057
+ group_style: {
5058
+ id: "editor.slash.group.style",
5059
+ defaultMessage: "Style",
5060
+ description: "Style/formatting commands group"
5061
+ },
5062
+ group_insert: {
5063
+ id: "editor.slash.group.insert",
5064
+ defaultMessage: "Insert",
5065
+ description: "Insert elements commands group"
5066
+ },
5067
+ group_upload: {
5068
+ id: "editor.slash.group.upload",
5069
+ defaultMessage: "Upload",
5070
+ description: "Upload commands group"
5071
+ },
5072
+ // Slash Menu - AI
5073
+ slash_continue_writing: {
5074
+ id: "editor.slash.continue_writing",
5075
+ defaultMessage: "Continue Writing",
5076
+ description: "Continue writing with AI command"
5077
+ },
5078
+ slash_continue_writing_subtext: {
5079
+ id: "editor.slash.continue_writing.subtext",
5080
+ defaultMessage: "Continue writing from the current position",
5081
+ description: "Continue writing command description"
5082
+ },
5083
+ slash_ask_ai: {
5084
+ id: "editor.slash.ask_ai",
5085
+ defaultMessage: "Ask AI",
5086
+ description: "Ask AI command"
5087
+ },
5088
+ slash_ask_ai_subtext: {
5089
+ id: "editor.slash.ask_ai.subtext",
5090
+ defaultMessage: "Ask AI to generate content",
5091
+ description: "Ask AI command description"
5092
+ },
5093
+ // Slash Menu - Style
5094
+ slash_text: {
5095
+ id: "editor.slash.text",
5096
+ defaultMessage: "Text",
5097
+ description: "Text paragraph command"
5098
+ },
5099
+ slash_text_subtext: {
5100
+ id: "editor.slash.text.subtext",
5101
+ defaultMessage: "Regular text paragraph",
5102
+ description: "Text command description"
5103
+ },
5104
+ slash_heading_1: {
5105
+ id: "editor.slash.heading_1",
5106
+ defaultMessage: "Heading 1",
5107
+ description: "Heading 1 command"
5108
+ },
5109
+ slash_heading_1_subtext: {
5110
+ id: "editor.slash.heading_1.subtext",
5111
+ defaultMessage: "Top-level heading",
5112
+ description: "Heading 1 command description"
5113
+ },
5114
+ slash_heading_2: {
5115
+ id: "editor.slash.heading_2",
5116
+ defaultMessage: "Heading 2",
5117
+ description: "Heading 2 command"
5118
+ },
5119
+ slash_heading_2_subtext: {
5120
+ id: "editor.slash.heading_2.subtext",
5121
+ defaultMessage: "Key section heading",
5122
+ description: "Heading 2 command description"
5123
+ },
5124
+ slash_heading_3: {
5125
+ id: "editor.slash.heading_3",
5126
+ defaultMessage: "Heading 3",
5127
+ description: "Heading 3 command"
5128
+ },
5129
+ slash_heading_3_subtext: {
5130
+ id: "editor.slash.heading_3.subtext",
5131
+ defaultMessage: "Subsection and group heading",
5132
+ description: "Heading 3 command description"
5133
+ },
5134
+ slash_bullet_list: {
5135
+ id: "editor.slash.bullet_list",
5136
+ defaultMessage: "Bullet List",
5137
+ description: "Bullet list command"
5138
+ },
5139
+ slash_bullet_list_subtext: {
5140
+ id: "editor.slash.bullet_list.subtext",
5141
+ defaultMessage: "List with unordered items",
5142
+ description: "Bullet list command description"
5143
+ },
5144
+ slash_ordered_list: {
5145
+ id: "editor.slash.ordered_list",
5146
+ defaultMessage: "Numbered List",
5147
+ description: "Numbered list command"
5148
+ },
5149
+ slash_ordered_list_subtext: {
5150
+ id: "editor.slash.ordered_list.subtext",
5151
+ defaultMessage: "List with ordered items",
5152
+ description: "Numbered list command description"
5153
+ },
5154
+ slash_task_list: {
5155
+ id: "editor.slash.task_list",
5156
+ defaultMessage: "To-do list",
5157
+ description: "To-do list command"
5158
+ },
5159
+ slash_task_list_subtext: {
5160
+ id: "editor.slash.task_list.subtext",
5161
+ defaultMessage: "List with tasks",
5162
+ description: "To-do list command description"
5163
+ },
5164
+ slash_blockquote: {
5165
+ id: "editor.slash.blockquote",
5166
+ defaultMessage: "Blockquote",
5167
+ description: "Blockquote command"
5168
+ },
5169
+ slash_blockquote_subtext: {
5170
+ id: "editor.slash.blockquote.subtext",
5171
+ defaultMessage: "Blockquote block",
5172
+ description: "Blockquote command description"
5173
+ },
5174
+ slash_code_block: {
5175
+ id: "editor.slash.code_block",
5176
+ defaultMessage: "Code Block",
5177
+ description: "Code block command"
5178
+ },
5179
+ slash_code_block_subtext: {
5180
+ id: "editor.slash.code_block.subtext",
5181
+ defaultMessage: "Code block with syntax highlighting",
5182
+ description: "Code block command description"
5183
+ },
5184
+ // Slash Menu - Insert
5185
+ slash_control: {
5186
+ id: "editor.slash.control",
5187
+ defaultMessage: "Control",
5188
+ description: "Control block command"
5189
+ },
5190
+ slash_control_subtext: {
5191
+ id: "editor.slash.control.subtext",
5192
+ defaultMessage: "Insert a control block",
5193
+ description: "Control block command description"
5194
+ },
5195
+ slash_separator: {
5196
+ id: "editor.slash.separator",
5197
+ defaultMessage: "Separator",
5198
+ description: "Horizontal separator command"
5199
+ },
5200
+ slash_separator_subtext: {
5201
+ id: "editor.slash.separator.subtext",
5202
+ defaultMessage: "Horizontal line to separate content",
5203
+ description: "Separator command description"
5204
+ },
5205
+ slash_table: {
5206
+ id: "editor.slash.table",
5207
+ defaultMessage: "Table",
5208
+ description: "Table command"
5209
+ },
5210
+ slash_table_subtext: {
5211
+ id: "editor.slash.table.subtext",
5212
+ defaultMessage: "Insert a table",
5213
+ description: "Table command description"
5214
+ },
5215
+ slash_toc: {
5216
+ id: "editor.slash.toc",
5217
+ defaultMessage: "Table of Contents",
5218
+ description: "Table of contents command"
5219
+ },
5220
+ slash_toc_subtext: {
5221
+ id: "editor.slash.toc.subtext",
5222
+ defaultMessage: "Auto-generated list of headings",
5223
+ description: "Table of contents command description"
5224
+ },
5225
+ slash_callout: {
5226
+ id: "editor.slash.callout",
5227
+ defaultMessage: "Callout",
5228
+ description: "Callout command"
5229
+ },
5230
+ slash_callout_subtext: {
5231
+ id: "editor.slash.callout.subtext",
5232
+ defaultMessage: "Highlighted block for important information",
5233
+ description: "Callout command description"
5234
+ },
5235
+ slash_warning: {
5236
+ id: "editor.slash.warning",
5237
+ defaultMessage: "Warning",
5238
+ description: "Warning callout command"
5239
+ },
5240
+ slash_warning_subtext: {
5241
+ id: "editor.slash.warning.subtext",
5242
+ defaultMessage: "Warning callout block",
5243
+ description: "Warning callout command description"
5244
+ },
5245
+ slash_formula: {
5246
+ id: "editor.slash.formula",
5247
+ defaultMessage: "Formula",
5248
+ description: "Math formula command"
5249
+ },
5250
+ slash_formula_subtext: {
5251
+ id: "editor.slash.formula.subtext",
5252
+ defaultMessage: "LaTeX math formula block",
5253
+ description: "Formula command description"
5254
+ },
5255
+ // Slash Menu - Upload
5256
+ slash_image: {
5257
+ id: "editor.slash.image",
5258
+ defaultMessage: "Image",
5259
+ description: "Image upload command"
5260
+ },
5261
+ slash_image_subtext: {
5262
+ id: "editor.slash.image.subtext",
5263
+ defaultMessage: "Resizable image with caption",
5264
+ description: "Image command description"
5265
+ },
5266
+ // Slash Menu - Filter
5267
+ slash_filter_placeholder: {
5268
+ id: "editor.slash.filter_placeholder",
5269
+ defaultMessage: "Filter...",
5270
+ description: "Slash menu filter placeholder"
5271
+ },
5272
+ // Table
5273
+ table_insert: {
5274
+ id: "editor.toolbar.table.insert",
5275
+ defaultMessage: "Insert table",
5276
+ description: "Insert table button"
5277
+ },
5278
+ // Color/Highlight
5279
+ text_color: {
5280
+ id: "editor.toolbar.text_color",
5281
+ defaultMessage: "Text color",
5282
+ description: "Text color button"
5283
+ },
5284
+ highlight_color: {
5285
+ id: "editor.toolbar.highlight_color",
5286
+ defaultMessage: "Highlight color",
5287
+ description: "Highlight color button"
5288
+ },
5289
+ // Alignment
5290
+ align_left: {
5291
+ id: "editor.toolbar.align.left",
5292
+ defaultMessage: "Align left",
5293
+ description: "Align left button"
5294
+ },
5295
+ align_center: {
5296
+ id: "editor.toolbar.align.center",
5297
+ defaultMessage: "Align center",
5298
+ description: "Align center button"
5299
+ },
5300
+ align_right: {
5301
+ id: "editor.toolbar.align.right",
5302
+ defaultMessage: "Align right",
5303
+ description: "Align right button"
5304
+ },
5305
+ align_justify: {
5306
+ id: "editor.toolbar.align.justify",
5307
+ defaultMessage: "Justify",
5308
+ description: "Justify text button"
5309
+ },
5310
+ // Editor placeholder
5311
+ editor_placeholder: {
5312
+ id: "editor.placeholder",
5313
+ defaultMessage: "Write, type '/' for commands\u2026",
5314
+ description: "Empty editor placeholder text"
5315
+ },
5316
+ // Toolbar misc
5317
+ more_options: {
5318
+ id: "editor.toolbar.more_options",
5319
+ defaultMessage: "More options",
5320
+ description: "More options button in toolbar"
5321
+ }
5322
+ });
5323
+
5324
+ // src/ui/mark-button/index.tsx
4835
5325
  import { jsx as jsx17 } from "react/jsx-runtime";
4836
5326
  var markIcons = {
4837
5327
  bold: BoldIcon,
@@ -4884,16 +5374,26 @@ function shouldShowMarkButton(params) {
4884
5374
  }
4885
5375
  return true;
4886
5376
  }
4887
- function getFormattedMarkName(type) {
4888
- return type.charAt(0).toUpperCase() + type.slice(1);
5377
+ var markMessages = {
5378
+ bold: messages7.bold,
5379
+ italic: messages7.italic,
5380
+ underline: messages7.underline,
5381
+ strike: messages7.strikethrough,
5382
+ code: messages7.code,
5383
+ superscript: messages7.superscript,
5384
+ subscript: messages7.subscript
5385
+ };
5386
+ function getTranslatedMarkName(type, intl) {
5387
+ return intl.formatMessage(markMessages[type]);
4889
5388
  }
4890
5389
  function useMarkState(editor, type, disabled = false) {
5390
+ const intl = useIntl9();
4891
5391
  const markInSchema = isMarkInSchema2(type, editor);
4892
5392
  const isDisabled = isMarkButtonDisabled(editor, type, disabled);
4893
5393
  const isActive = isMarkActive(editor, type);
4894
5394
  const Icon = markIcons[type];
4895
5395
  const shortcutKey = markShortcutKeys[type];
4896
- const formattedName = getFormattedMarkName(type);
5396
+ const formattedName = getTranslatedMarkName(type, intl);
4897
5397
  return {
4898
5398
  markInSchema,
4899
5399
  isDisabled,
@@ -4954,7 +5454,7 @@ var MarkButton = ({
4954
5454
  "data-active-state": isActive ? "on" : "off",
4955
5455
  "data-disabled": isDisabled,
4956
5456
  tabIndex: -1,
4957
- "aria-label": type,
5457
+ "aria-label": formattedName,
4958
5458
  "aria-pressed": isActive,
4959
5459
  title: formattedName,
4960
5460
  shortcutKeys: shortcutKey,
@@ -5115,8 +5615,10 @@ import { EditIcon as EditIcon3, ExternalLinkIcon as ExternalLinkIcon2, TrashIcon
5115
5615
  import { Input as Input4 } from "@kopexa/input";
5116
5616
  import { BubbleMenu as TiptapBubbleMenu2 } from "@tiptap/react/menus";
5117
5617
  import { useCallback as useCallback17, useEffect as useEffect19, useState as useState17 } from "react";
5618
+ import { useIntl as useIntl10 } from "react-intl";
5118
5619
  import { Fragment as Fragment3, jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
5119
5620
  function LinkBubble({ editor }) {
5621
+ const intl = useIntl10();
5120
5622
  const [isEditing, setIsEditing] = useState17(false);
5121
5623
  const [url, setUrl] = useState17("");
5122
5624
  const getCurrentUrl = useCallback17(() => {
@@ -5190,7 +5692,7 @@ function LinkBubble({ editor }) {
5190
5692
  value: url,
5191
5693
  onChange: (e) => setUrl(e.target.value),
5192
5694
  onKeyDown: handleKeyDown,
5193
- placeholder: "Enter URL...",
5695
+ placeholder: intl.formatMessage(messages7.link_placeholder),
5194
5696
  className: "flex-1 h-8 text-sm",
5195
5697
  autoFocus: true
5196
5698
  }
@@ -5202,7 +5704,7 @@ function LinkBubble({ editor }) {
5202
5704
  size: "sm",
5203
5705
  variant: "ghost",
5204
5706
  onClick: handleSave,
5205
- "aria-label": "Save link",
5707
+ "aria-label": intl.formatMessage(messages7.link_save),
5206
5708
  children: /* @__PURE__ */ jsx19(EditIcon3, { className: "size-4" })
5207
5709
  }
5208
5710
  )
@@ -5229,7 +5731,7 @@ function LinkBubble({ editor }) {
5229
5731
  size: "sm",
5230
5732
  variant: "ghost",
5231
5733
  onClick: handleOpenLink,
5232
- "aria-label": "Open link in new tab",
5734
+ "aria-label": intl.formatMessage(messages7.link_open),
5233
5735
  children: /* @__PURE__ */ jsx19(ExternalLinkIcon2, { className: "size-4" })
5234
5736
  }
5235
5737
  ),
@@ -5240,7 +5742,7 @@ function LinkBubble({ editor }) {
5240
5742
  size: "sm",
5241
5743
  variant: "ghost",
5242
5744
  onClick: handleEdit,
5243
- "aria-label": "Edit link",
5745
+ "aria-label": intl.formatMessage(messages7.link_edit),
5244
5746
  children: /* @__PURE__ */ jsx19(EditIcon3, { className: "size-4" })
5245
5747
  }
5246
5748
  ),
@@ -5251,7 +5753,7 @@ function LinkBubble({ editor }) {
5251
5753
  size: "sm",
5252
5754
  variant: "ghost",
5253
5755
  onClick: handleRemoveLink,
5254
- "aria-label": "Remove link",
5756
+ "aria-label": intl.formatMessage(messages7.link_remove),
5255
5757
  children: /* @__PURE__ */ jsx19(TrashIcon4, { className: "size-4" })
5256
5758
  }
5257
5759
  )
@@ -5295,6 +5797,7 @@ import {
5295
5797
  TypeIcon
5296
5798
  } from "@kopexa/icons";
5297
5799
  import * as React10 from "react";
5800
+ import { useIntl as useIntl12 } from "react-intl";
5298
5801
 
5299
5802
  // src/ui/table-button/use-table.ts
5300
5803
  import {
@@ -5305,6 +5808,7 @@ import {
5305
5808
  import { TableIcon } from "@kopexa/icons";
5306
5809
  import { isNodeSelection as isNodeSelection4 } from "@tiptap/react";
5307
5810
  import { useCallback as useCallback18, useEffect as useEffect20, useState as useState18 } from "react";
5811
+ import { useIntl as useIntl11 } from "react-intl";
5308
5812
  function canToggle(editor) {
5309
5813
  if (!editor || !editor.isEditable) return false;
5310
5814
  if (!isNodeInSchema("table", editor) || isNodeTypeSelected2(editor, ["image"])) {
@@ -5347,6 +5851,7 @@ function useTableBlock(config) {
5347
5851
  hideWhenUnavailable = false,
5348
5852
  onToggled
5349
5853
  } = config || {};
5854
+ const intl = useIntl11();
5350
5855
  const { editor } = useTiptapEditor6(providedEditor);
5351
5856
  const [isVisible, setIsVisible] = useState18(true);
5352
5857
  const canToggleState = canToggle(editor);
@@ -5375,174 +5880,162 @@ function useTableBlock(config) {
5375
5880
  isActive,
5376
5881
  handleToggle,
5377
5882
  canToggle: canToggleState,
5378
- label: "Table",
5883
+ label: intl.formatMessage(messages7.table_insert),
5379
5884
  // shortcutKeys: CODE_BLOCK_SHORTCUT_KEY,
5380
5885
  Icon: TableIcon
5381
5886
  };
5382
5887
  }
5383
5888
 
5384
5889
  // src/ui/slash-dropdown-menu/use-slash-dropdown-menu.ts
5385
- var texts = {
5386
- // AI
5387
- continue_writing: {
5388
- title: "Continue Writing",
5389
- subtext: "Continue writing from the current position",
5390
- keywords: ["continue", "write", "continue writing", "ai"],
5391
- badge: AiSparklesIcon,
5392
- group: "AI"
5393
- },
5394
- ai_ask_button: {
5395
- title: "Ask AI",
5396
- subtext: "Ask AI to generate content",
5397
- keywords: ["ai", "ask", "generate"],
5398
- badge: AiSparklesIcon,
5399
- group: "AI"
5400
- },
5401
- // Style
5402
- text: {
5403
- title: "Text",
5404
- subtext: "Regular text paragraph",
5405
- keywords: ["p", "paragraph", "text"],
5406
- badge: TypeIcon,
5407
- group: "Style"
5408
- },
5409
- heading_1: {
5410
- title: "Heading 1",
5411
- subtext: "Top-level heading",
5412
- keywords: ["h", "heading1", "h1"],
5413
- badge: HeadingOneIcon,
5414
- group: "Style"
5415
- },
5416
- heading_2: {
5417
- title: "Heading 2",
5418
- subtext: "Key section heading",
5419
- keywords: ["h2", "heading2", "subheading"],
5420
- badge: HeadingTwoIcon,
5421
- group: "Style"
5422
- },
5423
- heading_3: {
5424
- title: "Heading 3",
5425
- subtext: "Subsection and group heading",
5426
- keywords: ["h3", "heading3", "subheading"],
5427
- badge: HeadingThreeIcon,
5428
- group: "Style"
5429
- },
5430
- bullet_list: {
5431
- title: "Bullet List",
5432
- subtext: "List with unordered items",
5433
- keywords: ["ul", "li", "list", "bulletlist", "bullet list"],
5434
- badge: ListIcon2,
5435
- group: "Style"
5436
- },
5437
- ordered_list: {
5438
- title: "Numbered List",
5439
- subtext: "List with ordered items",
5440
- keywords: ["ol", "li", "list", "numberedlist", "numbered list"],
5441
- badge: ListOrderedIcon,
5442
- group: "Style"
5443
- },
5444
- task_list: {
5445
- title: "To-do list",
5446
- subtext: "List with tasks",
5447
- keywords: ["tasklist", "task list", "todo", "checklist"],
5448
- badge: ListTodoIcon,
5449
- group: "Style"
5450
- },
5451
- quote: {
5452
- title: "Blockquote",
5453
- subtext: "Blockquote block",
5454
- keywords: ["quote", "blockquote"],
5455
- badge: BlockquoteIcon,
5456
- group: "Style"
5457
- },
5458
- code_block: {
5459
- title: "Code Block",
5460
- subtext: "Code block with syntax highlighting",
5461
- keywords: ["code", "pre"],
5462
- badge: CodeBlockIcon,
5463
- group: "Style"
5464
- },
5465
- // Insert
5466
- // mention: {
5467
- // title: "Mention",
5468
- // subtext: "Mention a user or item",
5469
- // keywords: ["mention", "user", "item", "tag"],
5470
- // badge: AtSignIcon,
5471
- // group: "Insert",
5472
- // },
5473
- // emoji: {
5474
- // title: "Emoji",
5475
- // subtext: "Insert an emoji",
5476
- // keywords: ["emoji", "emoticon", "smiley"],
5477
- // badge: SmilePlusIcon,
5478
- // group: "Insert",
5479
- // },
5480
- control: {
5481
- title: "Control",
5482
- subtext: "Insert a control block",
5483
- keywords: ["control"],
5484
- badge: ControlsIcon,
5485
- group: "Insert"
5486
- },
5487
- divider: {
5488
- title: "Separator",
5489
- subtext: "Horizontal line to separate content",
5490
- keywords: ["hr", "horizontalRule", "line", "separator"],
5491
- badge: MinusIcon,
5492
- group: "Insert"
5493
- },
5494
- table: {
5495
- title: "Table",
5496
- subtext: "Insert a table",
5497
- keywords: ["table", "grid", "spreadsheet"],
5498
- badge: TableIcon2,
5499
- group: "Insert"
5500
- },
5501
- table_of_contents: {
5502
- title: "Table of Contents",
5503
- subtext: "Auto-generated list of headings",
5504
- keywords: ["toc", "table of contents", "index", "navigation", "headings"],
5505
- badge: TableOfContentsIcon,
5506
- group: "Insert"
5507
- },
5508
- callout: {
5509
- title: "Callout",
5510
- subtext: "Highlighted block for important information",
5511
- keywords: ["callout", "info", "warning", "alert", "note", "tip"],
5512
- badge: InfoIcon2,
5513
- group: "Insert"
5514
- },
5515
- callout_warning: {
5516
- title: "Warning",
5517
- subtext: "Warning callout block",
5518
- keywords: ["warning", "caution", "attention"],
5519
- badge: AlertIcon2,
5520
- group: "Insert"
5521
- },
5522
- math: {
5523
- title: "Formula",
5524
- subtext: "LaTeX math formula block",
5525
- keywords: ["math", "latex", "formula", "equation", "katex"],
5526
- badge: TypeIcon,
5527
- group: "Insert"
5528
- },
5529
- // Upload
5530
- image: {
5531
- title: "Image",
5532
- subtext: "Resizable image with caption",
5533
- keywords: [
5534
- "image",
5535
- "imageUpload",
5536
- "upload",
5537
- "img",
5538
- "picture",
5539
- "media",
5540
- "url"
5541
- ],
5542
- badge: ImageIcon2,
5543
- group: "Upload"
5544
- }
5545
- };
5890
+ function createSlashMenuTexts(formatMessage) {
5891
+ return {
5892
+ // AI
5893
+ continue_writing: {
5894
+ title: formatMessage(messages7.slash_continue_writing),
5895
+ subtext: formatMessage(messages7.slash_continue_writing_subtext),
5896
+ keywords: ["continue", "write", "continue writing", "ai"],
5897
+ badge: AiSparklesIcon,
5898
+ group: formatMessage(messages7.group_ai)
5899
+ },
5900
+ ai_ask_button: {
5901
+ title: formatMessage(messages7.slash_ask_ai),
5902
+ subtext: formatMessage(messages7.slash_ask_ai_subtext),
5903
+ keywords: ["ai", "ask", "generate"],
5904
+ badge: AiSparklesIcon,
5905
+ group: formatMessage(messages7.group_ai)
5906
+ },
5907
+ // Style
5908
+ text: {
5909
+ title: formatMessage(messages7.slash_text),
5910
+ subtext: formatMessage(messages7.slash_text_subtext),
5911
+ keywords: ["p", "paragraph", "text"],
5912
+ badge: TypeIcon,
5913
+ group: formatMessage(messages7.group_style)
5914
+ },
5915
+ heading_1: {
5916
+ title: formatMessage(messages7.slash_heading_1),
5917
+ subtext: formatMessage(messages7.slash_heading_1_subtext),
5918
+ keywords: ["h", "heading1", "h1"],
5919
+ badge: HeadingOneIcon,
5920
+ group: formatMessage(messages7.group_style)
5921
+ },
5922
+ heading_2: {
5923
+ title: formatMessage(messages7.slash_heading_2),
5924
+ subtext: formatMessage(messages7.slash_heading_2_subtext),
5925
+ keywords: ["h2", "heading2", "subheading"],
5926
+ badge: HeadingTwoIcon,
5927
+ group: formatMessage(messages7.group_style)
5928
+ },
5929
+ heading_3: {
5930
+ title: formatMessage(messages7.slash_heading_3),
5931
+ subtext: formatMessage(messages7.slash_heading_3_subtext),
5932
+ keywords: ["h3", "heading3", "subheading"],
5933
+ badge: HeadingThreeIcon,
5934
+ group: formatMessage(messages7.group_style)
5935
+ },
5936
+ bullet_list: {
5937
+ title: formatMessage(messages7.slash_bullet_list),
5938
+ subtext: formatMessage(messages7.slash_bullet_list_subtext),
5939
+ keywords: ["ul", "li", "list", "bulletlist", "bullet list"],
5940
+ badge: ListIcon2,
5941
+ group: formatMessage(messages7.group_style)
5942
+ },
5943
+ ordered_list: {
5944
+ title: formatMessage(messages7.slash_ordered_list),
5945
+ subtext: formatMessage(messages7.slash_ordered_list_subtext),
5946
+ keywords: ["ol", "li", "list", "numberedlist", "numbered list"],
5947
+ badge: ListOrderedIcon,
5948
+ group: formatMessage(messages7.group_style)
5949
+ },
5950
+ task_list: {
5951
+ title: formatMessage(messages7.slash_task_list),
5952
+ subtext: formatMessage(messages7.slash_task_list_subtext),
5953
+ keywords: ["tasklist", "task list", "todo", "checklist"],
5954
+ badge: ListTodoIcon,
5955
+ group: formatMessage(messages7.group_style)
5956
+ },
5957
+ quote: {
5958
+ title: formatMessage(messages7.slash_blockquote),
5959
+ subtext: formatMessage(messages7.slash_blockquote_subtext),
5960
+ keywords: ["quote", "blockquote"],
5961
+ badge: BlockquoteIcon,
5962
+ group: formatMessage(messages7.group_style)
5963
+ },
5964
+ code_block: {
5965
+ title: formatMessage(messages7.slash_code_block),
5966
+ subtext: formatMessage(messages7.slash_code_block_subtext),
5967
+ keywords: ["code", "pre"],
5968
+ badge: CodeBlockIcon,
5969
+ group: formatMessage(messages7.group_style)
5970
+ },
5971
+ // Insert
5972
+ control: {
5973
+ title: formatMessage(messages7.slash_control),
5974
+ subtext: formatMessage(messages7.slash_control_subtext),
5975
+ keywords: ["control"],
5976
+ badge: ControlsIcon,
5977
+ group: formatMessage(messages7.group_insert)
5978
+ },
5979
+ divider: {
5980
+ title: formatMessage(messages7.slash_separator),
5981
+ subtext: formatMessage(messages7.slash_separator_subtext),
5982
+ keywords: ["hr", "horizontalRule", "line", "separator"],
5983
+ badge: MinusIcon,
5984
+ group: formatMessage(messages7.group_insert)
5985
+ },
5986
+ table: {
5987
+ title: formatMessage(messages7.slash_table),
5988
+ subtext: formatMessage(messages7.slash_table_subtext),
5989
+ keywords: ["table", "grid", "spreadsheet"],
5990
+ badge: TableIcon2,
5991
+ group: formatMessage(messages7.group_insert)
5992
+ },
5993
+ table_of_contents: {
5994
+ title: formatMessage(messages7.slash_toc),
5995
+ subtext: formatMessage(messages7.slash_toc_subtext),
5996
+ keywords: ["toc", "table of contents", "index", "navigation", "headings"],
5997
+ badge: TableOfContentsIcon,
5998
+ group: formatMessage(messages7.group_insert)
5999
+ },
6000
+ callout: {
6001
+ title: formatMessage(messages7.slash_callout),
6002
+ subtext: formatMessage(messages7.slash_callout_subtext),
6003
+ keywords: ["callout", "info", "warning", "alert", "note", "tip"],
6004
+ badge: InfoIcon2,
6005
+ group: formatMessage(messages7.group_insert)
6006
+ },
6007
+ callout_warning: {
6008
+ title: formatMessage(messages7.slash_warning),
6009
+ subtext: formatMessage(messages7.slash_warning_subtext),
6010
+ keywords: ["warning", "caution", "attention"],
6011
+ badge: AlertIcon2,
6012
+ group: formatMessage(messages7.group_insert)
6013
+ },
6014
+ math: {
6015
+ title: formatMessage(messages7.slash_formula),
6016
+ subtext: formatMessage(messages7.slash_formula_subtext),
6017
+ keywords: ["math", "latex", "formula", "equation", "katex"],
6018
+ badge: TypeIcon,
6019
+ group: formatMessage(messages7.group_insert)
6020
+ },
6021
+ // Upload
6022
+ image: {
6023
+ title: formatMessage(messages7.slash_image),
6024
+ subtext: formatMessage(messages7.slash_image_subtext),
6025
+ keywords: [
6026
+ "image",
6027
+ "imageUpload",
6028
+ "upload",
6029
+ "img",
6030
+ "picture",
6031
+ "media",
6032
+ "url"
6033
+ ],
6034
+ badge: ImageIcon2,
6035
+ group: formatMessage(messages7.group_upload)
6036
+ }
6037
+ };
6038
+ }
5546
6039
  var getItemImplementations = () => {
5547
6040
  return {
5548
6041
  // AI
@@ -5726,11 +6219,34 @@ function organizeItemsByGroups(items, showGroups) {
5726
6219
  });
5727
6220
  return organizedItems;
5728
6221
  }
6222
+ var ALL_SLASH_MENU_ITEMS = [
6223
+ "continue_writing",
6224
+ "ai_ask_button",
6225
+ "text",
6226
+ "heading_1",
6227
+ "heading_2",
6228
+ "heading_3",
6229
+ "bullet_list",
6230
+ "ordered_list",
6231
+ "task_list",
6232
+ "quote",
6233
+ "code_block",
6234
+ "control",
6235
+ "divider",
6236
+ "table",
6237
+ "table_of_contents",
6238
+ "callout",
6239
+ "callout_warning",
6240
+ "math",
6241
+ "image"
6242
+ ];
5729
6243
  function useSlashDropdownMenu(config) {
6244
+ const intl = useIntl12();
5730
6245
  const getSlashMenuItems = React10.useCallback(
5731
6246
  (editor) => {
5732
6247
  const items = [];
5733
- const enabledItems = (config == null ? void 0 : config.enabledItems) || Object.keys(texts);
6248
+ const texts = createSlashMenuTexts(intl.formatMessage);
6249
+ const enabledItems = (config == null ? void 0 : config.enabledItems) || ALL_SLASH_MENU_ITEMS;
5734
6250
  const showGroups = (config == null ? void 0 : config.showGroups) !== false;
5735
6251
  const itemImplementations = getItemImplementations();
5736
6252
  enabledItems.forEach((itemType) => {
@@ -5755,7 +6271,7 @@ function useSlashDropdownMenu(config) {
5755
6271
  }
5756
6272
  return organizeItemsByGroups(items, showGroups);
5757
6273
  },
5758
- [config]
6274
+ [config, intl]
5759
6275
  );
5760
6276
  return {
5761
6277
  getSlashMenuItems,
@@ -5918,7 +6434,8 @@ import {
5918
6434
  ToolbarSeparator as ToolbarSeparator3
5919
6435
  } from "@kopexa/toolbar";
5920
6436
  import { useIsMobile as useIsMobile3 } from "@kopexa/use-is-mobile";
5921
- import { useEffect as useEffect31, useRef as useRef11, useState as useState30 } from "react";
6437
+ import { useEffect as useEffect31, useRef as useRef12, useState as useState30 } from "react";
6438
+ import { useIntl as useIntl18 } from "react-intl";
5922
6439
 
5923
6440
  // src/hooks/use-cursor-visibility.ts
5924
6441
  import * as React13 from "react";
@@ -6028,7 +6545,7 @@ import { useTiptapEditor as useTiptapEditor9 } from "@kopexa/editor-utils";
6028
6545
  import { BanIcon, HighlighterIcon as HighlighterIcon2 } from "@kopexa/icons";
6029
6546
  import { Popover as Popover2 } from "@kopexa/popover";
6030
6547
  import { ToolbarSeparator as ToolbarSeparator2 } from "@kopexa/toolbar";
6031
- import { useMemo as useMemo16, useRef as useRef10, useState as useState22 } from "react";
6548
+ import { useMemo as useMemo16, useRef as useRef11, useState as useState22 } from "react";
6032
6549
 
6033
6550
  // src/ui/color-highlight-button/color-highlight-button.tsx
6034
6551
  import { useTiptapEditor as useTiptapEditor8 } from "@kopexa/editor-utils";
@@ -6046,6 +6563,7 @@ import { HighlighterIcon } from "@kopexa/icons";
6046
6563
  import { useIsMobile } from "@kopexa/use-is-mobile";
6047
6564
  import * as React14 from "react";
6048
6565
  import { useHotkeys } from "react-hotkeys-hook";
6566
+ import { useIntl as useIntl13 } from "react-intl";
6049
6567
  var COLOR_HIGHLIGHT_SHORTCUT_KEY = "mod+shift+h";
6050
6568
  var HIGHLIGHT_COLORS = [
6051
6569
  {
@@ -6137,6 +6655,7 @@ function useColorHighlight(config) {
6137
6655
  hideWhenUnavailable = false,
6138
6656
  onApplied
6139
6657
  } = config;
6658
+ const intl = useIntl13();
6140
6659
  const { editor } = useTiptapEditor7(providedEditor);
6141
6660
  const isMobile = useIsMobile();
6142
6661
  const [isVisible, setIsVisible] = React14.useState(true);
@@ -6197,7 +6716,7 @@ function useColorHighlight(config) {
6197
6716
  handleColorHighlight,
6198
6717
  handleRemoveHighlight,
6199
6718
  canColorHighlight: canColorHighlightState,
6200
- label: label || `Highlight`,
6719
+ label: label || intl.formatMessage(messages7.highlight_color),
6201
6720
  shortcutKeys: COLOR_HIGHLIGHT_SHORTCUT_KEY,
6202
6721
  Icon: HighlighterIcon
6203
6722
  };
@@ -6324,7 +6843,7 @@ function ColorHighlightPopoverContent({
6324
6843
  ])
6325
6844
  }) {
6326
6845
  const { handleRemoveHighlight } = useColorHighlight({ editor });
6327
- const containerRef = useRef10(null);
6846
+ const containerRef = useRef11(null);
6328
6847
  const menuItems = useMemo16(
6329
6848
  () => [...colors, { label: "Remove highlight", value: "none" }],
6330
6849
  [colors]
@@ -6795,6 +7314,7 @@ import {
6795
7314
  AlignRightIcon
6796
7315
  } from "@kopexa/icons";
6797
7316
  import { useCallback as useCallback26, useEffect as useEffect25, useState as useState24 } from "react";
7317
+ import { useIntl as useIntl14 } from "react-intl";
6798
7318
  var TEXT_ALIGN_SHORTCUT_KEYS = {
6799
7319
  left: "mod+shift+l",
6800
7320
  center: "mod+shift+e",
@@ -6807,11 +7327,11 @@ var textAlignIcons = {
6807
7327
  right: AlignRightIcon,
6808
7328
  justify: AlignJustifyIcon
6809
7329
  };
6810
- var textAlignLabels = {
6811
- left: "Align left",
6812
- center: "Align center",
6813
- right: "Align right",
6814
- justify: "Align justify"
7330
+ var textAlignMessages = {
7331
+ left: messages7.align_left,
7332
+ center: messages7.align_center,
7333
+ right: messages7.align_right,
7334
+ justify: messages7.align_justify
6815
7335
  };
6816
7336
  function canSetTextAlign(editor, align) {
6817
7337
  if (!editor || !editor.isEditable) return false;
@@ -6851,6 +7371,7 @@ function useTextAlign(config) {
6851
7371
  hideWhenUnavailable = false,
6852
7372
  onAligned
6853
7373
  } = config;
7374
+ const intl = useIntl14();
6854
7375
  const { editor } = useTiptapEditor13(providedEditor);
6855
7376
  const [isVisible, setIsVisible] = useState24(true);
6856
7377
  const canAlign = canSetTextAlign(editor, align);
@@ -6879,7 +7400,7 @@ function useTextAlign(config) {
6879
7400
  isActive,
6880
7401
  handleTextAlign,
6881
7402
  canAlign,
6882
- label: textAlignLabels[align],
7403
+ label: intl.formatMessage(textAlignMessages[align]),
6883
7404
  shortcutKeys: TEXT_ALIGN_SHORTCUT_KEYS[align],
6884
7405
  Icon: textAlignIcons[align]
6885
7406
  };
@@ -6928,11 +7449,11 @@ var TextAlignButton = ({
6928
7449
  IconButton9,
6929
7450
  {
6930
7451
  type: "button",
6931
- disabled: canAlign,
7452
+ disabled: !canAlign,
6932
7453
  variant: "ghost",
6933
7454
  color: "default",
6934
7455
  "data-active-state": isActive ? "on" : "off",
6935
- "data-disabled": canAlign,
7456
+ "data-disabled": !canAlign,
6936
7457
  tabIndex: -1,
6937
7458
  "aria-label": label,
6938
7459
  "aria-pressed": isActive,
@@ -6949,7 +7470,8 @@ var TextAlignButton = ({
6949
7470
  import { Button as Button11 } from "@kopexa/button";
6950
7471
  import { DropdownMenu as DropdownMenu2 } from "@kopexa/dropdown-menu";
6951
7472
  import { useTiptapEditor as useTiptapEditor23 } from "@kopexa/editor-utils";
6952
- import { forwardRef } from "react";
7473
+ import { forwardRef, useMemo as useMemo21 } from "react";
7474
+ import { useIntl as useIntl16 } from "react-intl";
6953
7475
 
6954
7476
  // src/ui/blockquote-button/blockquote-button.tsx
6955
7477
  import { useTiptapEditor as useTiptapEditor16 } from "@kopexa/editor-utils";
@@ -7704,7 +8226,8 @@ var TextButton = ({
7704
8226
  import { useTiptapEditor as useTiptapEditor22 } from "@kopexa/editor-utils";
7705
8227
  import { ChevronDownIcon as ChevronDownIcon2 } from "@kopexa/icons";
7706
8228
  import { NodeSelection as NodeSelection5 } from "@tiptap/pm/state";
7707
- import { useCallback as useCallback35, useEffect as useEffect29, useState as useState28 } from "react";
8229
+ import { useCallback as useCallback35, useEffect as useEffect29, useMemo as useMemo20, useState as useState28 } from "react";
8230
+ import { useIntl as useIntl15 } from "react-intl";
7708
8231
  var TURN_INTO_BLOCKS = [
7709
8232
  "paragraph",
7710
8233
  "heading",
@@ -7714,62 +8237,64 @@ var TURN_INTO_BLOCKS = [
7714
8237
  "blockquote",
7715
8238
  "codeBlock"
7716
8239
  ];
7717
- var blockTypeOptions = [
7718
- {
7719
- type: "paragraph",
7720
- label: "Text",
7721
- isActive: (editor) => editor.isActive("paragraph") && !editor.isActive("heading") && !editor.isActive("bulletList") && !editor.isActive("orderedList") && !editor.isActive("taskList") && !editor.isActive("blockquote") && !editor.isActive("codeBlock")
7722
- },
7723
- {
7724
- type: "heading",
7725
- label: "Heading 1",
7726
- level: 1,
7727
- isActive: (editor) => editor.isActive("heading", { level: 1 })
7728
- },
7729
- {
7730
- type: "heading",
7731
- label: "Heading 2",
7732
- level: 2,
7733
- isActive: (editor) => editor.isActive("heading", { level: 2 })
7734
- },
7735
- {
7736
- type: "heading",
7737
- label: "Heading 3",
7738
- level: 3,
7739
- isActive: (editor) => editor.isActive("heading", { level: 3 })
7740
- },
7741
- {
7742
- type: "heading",
7743
- label: "Heading 4",
7744
- level: 4,
7745
- isActive: (editor) => editor.isActive("heading", { level: 4 })
7746
- },
7747
- {
7748
- type: "bulletList",
7749
- label: "Bulleted list",
7750
- isActive: (editor) => editor.isActive("bulletList")
7751
- },
7752
- {
7753
- type: "orderedList",
7754
- label: "Numbered list",
7755
- isActive: (editor) => editor.isActive("orderedList")
7756
- },
7757
- {
7758
- type: "taskList",
7759
- label: "To-do list",
7760
- isActive: (editor) => editor.isActive("taskList")
7761
- },
7762
- {
7763
- type: "blockquote",
7764
- label: "Blockquote",
7765
- isActive: (editor) => editor.isActive("blockquote")
7766
- },
7767
- {
7768
- type: "codeBlock",
7769
- label: "Code block",
7770
- isActive: (editor) => editor.isActive("codeBlock")
7771
- }
7772
- ];
8240
+ function createBlockTypeOptions(formatMessage) {
8241
+ return [
8242
+ {
8243
+ type: "paragraph",
8244
+ label: formatMessage(messages7.block_text),
8245
+ isActive: (editor) => editor.isActive("paragraph") && !editor.isActive("heading") && !editor.isActive("bulletList") && !editor.isActive("orderedList") && !editor.isActive("taskList") && !editor.isActive("blockquote") && !editor.isActive("codeBlock")
8246
+ },
8247
+ {
8248
+ type: "heading",
8249
+ label: formatMessage(messages7.block_heading_1),
8250
+ level: 1,
8251
+ isActive: (editor) => editor.isActive("heading", { level: 1 })
8252
+ },
8253
+ {
8254
+ type: "heading",
8255
+ label: formatMessage(messages7.block_heading_2),
8256
+ level: 2,
8257
+ isActive: (editor) => editor.isActive("heading", { level: 2 })
8258
+ },
8259
+ {
8260
+ type: "heading",
8261
+ label: formatMessage(messages7.block_heading_3),
8262
+ level: 3,
8263
+ isActive: (editor) => editor.isActive("heading", { level: 3 })
8264
+ },
8265
+ {
8266
+ type: "heading",
8267
+ label: formatMessage(messages7.block_heading_4),
8268
+ level: 4,
8269
+ isActive: (editor) => editor.isActive("heading", { level: 4 })
8270
+ },
8271
+ {
8272
+ type: "bulletList",
8273
+ label: formatMessage(messages7.block_bullet_list),
8274
+ isActive: (editor) => editor.isActive("bulletList")
8275
+ },
8276
+ {
8277
+ type: "orderedList",
8278
+ label: formatMessage(messages7.block_ordered_list),
8279
+ isActive: (editor) => editor.isActive("orderedList")
8280
+ },
8281
+ {
8282
+ type: "taskList",
8283
+ label: formatMessage(messages7.block_task_list),
8284
+ isActive: (editor) => editor.isActive("taskList")
8285
+ },
8286
+ {
8287
+ type: "blockquote",
8288
+ label: formatMessage(messages7.block_blockquote),
8289
+ isActive: (editor) => editor.isActive("blockquote")
8290
+ },
8291
+ {
8292
+ type: "codeBlock",
8293
+ label: formatMessage(messages7.block_code_block),
8294
+ isActive: (editor) => editor.isActive("codeBlock")
8295
+ }
8296
+ ];
8297
+ }
7773
8298
  function canTurnInto(editor, allowedBlockTypes) {
7774
8299
  if (!editor || !editor.isEditable) return false;
7775
8300
  const blockTypes = allowedBlockTypes || TURN_INTO_BLOCKS;
@@ -7782,20 +8307,6 @@ function canTurnInto(editor, allowedBlockTypes) {
7782
8307
  const nodeType = $anchor.parent.type.name;
7783
8308
  return blockTypes.includes(nodeType);
7784
8309
  }
7785
- function getFilteredBlockTypeOptions(blockTypes) {
7786
- if (!blockTypes) return blockTypeOptions;
7787
- return blockTypeOptions.filter((option) => {
7788
- return blockTypes.includes(option.type);
7789
- });
7790
- }
7791
- function getActiveBlockType(editor, blockTypes) {
7792
- if (!editor) return getFilteredBlockTypeOptions(blockTypes)[0];
7793
- const filteredOptions = getFilteredBlockTypeOptions(blockTypes);
7794
- const activeOption = filteredOptions.find(
7795
- (option) => option.isActive(editor)
7796
- );
7797
- return activeOption || filteredOptions[0];
7798
- }
7799
8310
  function shouldShowTurnInto(params) {
7800
8311
  const { editor, hideWhenUnavailable, blockTypes } = params;
7801
8312
  if (!editor || !editor.isEditable) return false;
@@ -7811,11 +8322,31 @@ function useTurnIntoDropdown(config) {
7811
8322
  blockTypes,
7812
8323
  onOpenChange
7813
8324
  } = config || {};
8325
+ const intl = useIntl15();
7814
8326
  const { editor } = useTiptapEditor22(providedEditor);
7815
8327
  const [isOpen, setIsOpen] = useState28(false);
7816
8328
  const [isVisible, setIsVisible] = useState28(true);
8329
+ const translatedBlockTypeOptions = useMemo20(
8330
+ () => createBlockTypeOptions(intl.formatMessage),
8331
+ [intl]
8332
+ );
7817
8333
  const canToggle3 = canTurnInto(editor, blockTypes);
7818
- const activeBlockType = getActiveBlockType(editor, blockTypes);
8334
+ const activeBlockType = useMemo20(() => {
8335
+ if (!editor) return translatedBlockTypeOptions[0];
8336
+ const filteredOptions2 = blockTypes ? translatedBlockTypeOptions.filter(
8337
+ (opt) => blockTypes.includes(opt.type)
8338
+ ) : translatedBlockTypeOptions;
8339
+ const activeOption = filteredOptions2.find(
8340
+ (option) => option.isActive(editor)
8341
+ );
8342
+ return activeOption || filteredOptions2[0];
8343
+ }, [editor, blockTypes, translatedBlockTypeOptions]);
8344
+ const filteredOptions = useMemo20(() => {
8345
+ if (!blockTypes) return translatedBlockTypeOptions;
8346
+ return translatedBlockTypeOptions.filter(
8347
+ (opt) => blockTypes.includes(opt.type)
8348
+ );
8349
+ }, [blockTypes, translatedBlockTypeOptions]);
7819
8350
  const handleOpenChange = useCallback35(
7820
8351
  (open) => {
7821
8352
  if (!editor || !canToggle3) return;
@@ -7841,6 +8372,8 @@ function useTurnIntoDropdown(config) {
7841
8372
  editor.off("selectionUpdate", handleSelectionUpdate);
7842
8373
  };
7843
8374
  }, [editor, hideWhenUnavailable, blockTypes]);
8375
+ const turnIntoLabel = intl.formatMessage(messages7.turn_into);
8376
+ const textLabel = intl.formatMessage(messages7.block_text);
7844
8377
  return {
7845
8378
  isVisible,
7846
8379
  canToggle: canToggle3,
@@ -7848,8 +8381,11 @@ function useTurnIntoDropdown(config) {
7848
8381
  setIsOpen,
7849
8382
  activeBlockType,
7850
8383
  handleOpenChange,
7851
- filteredOptions: getFilteredBlockTypeOptions(blockTypes),
7852
- label: `Turn into (current: ${(activeBlockType == null ? void 0 : activeBlockType.label) || "Text"})`,
8384
+ filteredOptions,
8385
+ label: intl.formatMessage(messages7.turn_into_current, {
8386
+ current: (activeBlockType == null ? void 0 : activeBlockType.label) || textLabel
8387
+ }),
8388
+ tooltip: turnIntoLabel,
7853
8389
  Icon: ChevronDownIcon2
7854
8390
  };
7855
8391
  }
@@ -7857,7 +8393,12 @@ function useTurnIntoDropdown(config) {
7857
8393
  // src/ui/turn-into-dropdown/turn-into-dropdown.tsx
7858
8394
  import { jsx as jsx31, jsxs as jsxs23 } from "react/jsx-runtime";
7859
8395
  var TurnIntoDropdownContent = ({ blockTypes }) => {
7860
- const filteredOptions = getFilteredBlockTypeOptions(blockTypes);
8396
+ const intl = useIntl16();
8397
+ const filteredOptions = useMemo21(() => {
8398
+ const allOptions = createBlockTypeOptions(intl.formatMessage);
8399
+ if (!blockTypes) return allOptions;
8400
+ return allOptions.filter((opt) => blockTypes.includes(opt.type));
8401
+ }, [intl, blockTypes]);
7861
8402
  return /* @__PURE__ */ jsx31(DropdownMenu2.Group, { children: filteredOptions.map(
7862
8403
  (option, index) => {
7863
8404
  var _a;
@@ -7968,6 +8509,7 @@ var TurnIntoDropdown = forwardRef(
7968
8509
  activeBlockType,
7969
8510
  handleOpenChange,
7970
8511
  label,
8512
+ tooltip,
7971
8513
  Icon
7972
8514
  } = useTurnIntoDropdown({
7973
8515
  editor,
@@ -7989,14 +8531,24 @@ var TurnIntoDropdown = forwardRef(
7989
8531
  "data-disabled": !canToggle3,
7990
8532
  tabIndex: -1,
7991
8533
  "aria-label": label,
7992
- tooltip: "Turn into",
8534
+ tooltip,
7993
8535
  endContent: /* @__PURE__ */ jsx31(Icon, {}),
7994
8536
  ...buttonProps,
7995
8537
  ref,
7996
- children: children != null ? children : /* @__PURE__ */ jsx31("span", { children: (activeBlockType == null ? void 0 : activeBlockType.label) || "Text" })
8538
+ children: children != null ? children : /* @__PURE__ */ jsx31("span", { children: activeBlockType == null ? void 0 : activeBlockType.label })
7997
8539
  }
7998
8540
  ) }),
7999
- /* @__PURE__ */ jsx31(DropdownMenu2.Content, { align: "start", children: /* @__PURE__ */ jsx31(TurnIntoDropdownContent, { blockTypes }) })
8541
+ /* @__PURE__ */ jsx31(
8542
+ DropdownMenu2.Content,
8543
+ {
8544
+ align: "start",
8545
+ onCloseAutoFocus: (e) => {
8546
+ e.preventDefault();
8547
+ editor == null ? void 0 : editor.commands.focus();
8548
+ },
8549
+ children: /* @__PURE__ */ jsx31(TurnIntoDropdownContent, { blockTypes })
8550
+ }
8551
+ )
8000
8552
  ] });
8001
8553
  }
8002
8554
  );
@@ -8011,13 +8563,14 @@ import { useCallback as useCallback37 } from "react";
8011
8563
  import { isNodeTypeSelected as isNodeTypeSelected7, useTiptapEditor as useTiptapEditor24 } from "@kopexa/editor-utils";
8012
8564
  import { RedoIcon, UndoIcon } from "@kopexa/icons";
8013
8565
  import { useCallback as useCallback36, useEffect as useEffect30, useState as useState29 } from "react";
8566
+ import { useIntl as useIntl17 } from "react-intl";
8014
8567
  var UNDO_REDO_SHORTCUT_KEYS = {
8015
8568
  undo: "mod+z",
8016
8569
  redo: "mod+shift+z"
8017
8570
  };
8018
- var historyActionLabels = {
8019
- undo: "Undo",
8020
- redo: "Redo"
8571
+ var historyActionMessages = {
8572
+ undo: messages7.undo,
8573
+ redo: messages7.redo
8021
8574
  };
8022
8575
  var historyIcons = {
8023
8576
  undo: UndoIcon,
@@ -8049,6 +8602,7 @@ function useUndoRedo(config) {
8049
8602
  hideWhenUnavailable = false,
8050
8603
  onExecuted
8051
8604
  } = config;
8605
+ const intl = useIntl17();
8052
8606
  const { editor } = useTiptapEditor24(providedEditor);
8053
8607
  const [isVisible, setIsVisible] = useState29(true);
8054
8608
  const canExecute = canExecuteUndoRedoAction(editor, action);
@@ -8075,7 +8629,7 @@ function useUndoRedo(config) {
8075
8629
  isVisible,
8076
8630
  handleAction,
8077
8631
  canExecute,
8078
- label: historyActionLabels[action],
8632
+ label: intl.formatMessage(historyActionMessages[action]),
8079
8633
  shortcutKeys: UNDO_REDO_SHORTCUT_KEYS[action],
8080
8634
  Icon: historyIcons[action]
8081
8635
  };
@@ -8143,7 +8697,7 @@ var EditorHeader = ({
8143
8697
  const isMobile = useIsMobile3();
8144
8698
  const windowSize = useWindowSize();
8145
8699
  const { styles } = useEditorUIContext();
8146
- const toolbarRef = useRef11(null);
8700
+ const toolbarRef = useRef12(null);
8147
8701
  const bodyRect = useCursorVisibility({
8148
8702
  editor,
8149
8703
  overlayHeight: (_b = (_a = toolbarRef.current) == null ? void 0 : _a.getBoundingClientRect().height) != null ? _b : 0
@@ -8181,7 +8735,7 @@ var MainToolbarContent = () => /* @__PURE__ */ jsxs24(Fragment9, { children: [
8181
8735
  /* @__PURE__ */ jsx33(MarkButton, { type: "code" }),
8182
8736
  /* @__PURE__ */ jsx33(MarkButton, { type: "underline" }),
8183
8737
  /* @__PURE__ */ jsx33(ColorHighlightPopover, {}),
8184
- /* @__PURE__ */ jsx33(LinkPopover, {})
8738
+ /* @__PURE__ */ jsx33(LinkPopover, { autoOpenOnLinkActive: false })
8185
8739
  ] }),
8186
8740
  /* @__PURE__ */ jsx33(ToolbarSeparator3, {}),
8187
8741
  /* @__PURE__ */ jsx33(ToolbarGroup2, { children: /* @__PURE__ */ jsx33(TableButton, {}) }),
@@ -8196,7 +8750,7 @@ var CommentToolbarContent = () => /* @__PURE__ */ jsxs24(Fragment9, { children:
8196
8750
  ] }),
8197
8751
  /* @__PURE__ */ jsx33(ToolbarSeparator3, {}),
8198
8752
  /* @__PURE__ */ jsxs24(ToolbarGroup2, { children: [
8199
- /* @__PURE__ */ jsx33(LinkPopover, {}),
8753
+ /* @__PURE__ */ jsx33(LinkPopover, { autoOpenOnLinkActive: false }),
8200
8754
  /* @__PURE__ */ jsx33(ListDropdownMenu, { types: ["bulletList", "orderedList"] })
8201
8755
  ] })
8202
8756
  ] });
@@ -8204,15 +8758,17 @@ var FieldToolbarContent = () => /* @__PURE__ */ jsxs24(ToolbarGroup2, { children
8204
8758
  /* @__PURE__ */ jsx33(MarkButton, { type: "bold" }),
8205
8759
  /* @__PURE__ */ jsx33(MarkButton, { type: "italic" }),
8206
8760
  /* @__PURE__ */ jsx33(MarkButton, { type: "strike" }),
8207
- /* @__PURE__ */ jsx33(LinkPopover, {})
8761
+ /* @__PURE__ */ jsx33(LinkPopover, { autoOpenOnLinkActive: false })
8208
8762
  ] });
8209
8763
  function MoreOptions({
8210
8764
  editor: providedEditor,
8211
8765
  hideWhenUnavailable = false,
8212
8766
  ...props
8213
8767
  }) {
8768
+ const intl = useIntl18();
8214
8769
  const { editor } = useTiptapEditor26(providedEditor);
8215
8770
  const [show, setShow] = useState30(false);
8771
+ const moreOptionsLabel = intl.formatMessage(messages7.more_options);
8216
8772
  useEffect31(() => {
8217
8773
  if (!editor) return;
8218
8774
  const handleSelectionUpdate = () => {
@@ -8246,8 +8802,8 @@ function MoreOptions({
8246
8802
  color: "default",
8247
8803
  tabIndex: -1,
8248
8804
  size: "md",
8249
- "aria-label": "More options",
8250
- title: "More options",
8805
+ "aria-label": moreOptionsLabel,
8806
+ title: moreOptionsLabel,
8251
8807
  isIconOnly: true,
8252
8808
  ...props,
8253
8809
  children: /* @__PURE__ */ jsx33(MoreVerticalIcon, {})
@@ -8312,13 +8868,17 @@ var BasicEditor = ({
8312
8868
  variables,
8313
8869
  variableValues,
8314
8870
  showToolbar = true,
8871
+ slotOverlay,
8315
8872
  pagesOptions,
8316
8873
  ...options
8317
8874
  }) => {
8875
+ const intl = useIntl19();
8876
+ const placeholder = intl.formatMessage(messages7.editor_placeholder);
8318
8877
  const { editor, collabSyncing } = useCreateEditor({
8319
8878
  content,
8320
8879
  enableVariables: !!(variables == null ? void 0 : variables.length),
8321
8880
  pagesOptions,
8881
+ placeholder,
8322
8882
  ...options
8323
8883
  });
8324
8884
  const styles = editorBasic({ variant, bordered });
@@ -8342,7 +8902,8 @@ var BasicEditor = ({
8342
8902
  hasPagination
8343
8903
  }
8344
8904
  ),
8345
- showToolbar && isBottomToolbar && /* @__PURE__ */ jsx34(EditorHeader, { editor, variant })
8905
+ showToolbar && isBottomToolbar && /* @__PURE__ */ jsx34(EditorHeader, { editor, variant }),
8906
+ slotOverlay
8346
8907
  ] }) }) });
8347
8908
  if (hasVariables) {
8348
8909
  return /* @__PURE__ */ jsx34(VariableProvider, { variables, resolveVariable, children: editorContent });
@@ -8499,7 +9060,7 @@ function EditorView({
8499
9060
  // src/presets/view/static.tsx
8500
9061
  import { editorBasic as editorBasic3 } from "@kopexa/theme";
8501
9062
  import { generateHTML } from "@tiptap/html";
8502
- import { useMemo as useMemo20 } from "react";
9063
+ import { useMemo as useMemo22 } from "react";
8503
9064
  import { jsx as jsx36 } from "react/jsx-runtime";
8504
9065
  function EditorStaticView({
8505
9066
  content,
@@ -8509,7 +9070,7 @@ function EditorStaticView({
8509
9070
  customExtensions,
8510
9071
  disabled
8511
9072
  }) {
8512
- const extensions = useMemo20(
9073
+ const extensions = useMemo22(
8513
9074
  () => getExtensions({
8514
9075
  editable: false,
8515
9076
  customExtensions,
@@ -8517,7 +9078,7 @@ function EditorStaticView({
8517
9078
  }),
8518
9079
  [customExtensions, disabled]
8519
9080
  );
8520
- const html = useMemo20(() => {
9081
+ const html = useMemo22(() => {
8521
9082
  const parsed = safeParseContent(content);
8522
9083
  if (!parsed) return "";
8523
9084
  const json = parsed;
@@ -8567,6 +9128,7 @@ export {
8567
9128
  sanitizeUrl,
8568
9129
  useCollaboration,
8569
9130
  useCollaborationRequired,
9131
+ useCurrentEditor,
8570
9132
  useDocumentVisibility,
8571
9133
  useEditorFile,
8572
9134
  useEditorFileRequired,