@kopexa/tiptap 17.10.2 → 17.11.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.
- package/dist/index.js +177 -121
- package/dist/index.mjs +56 -0
- package/package.json +24 -24
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ __export(index_exports, {
|
|
|
55
55
|
sanitizeUrl: () => sanitizeUrl,
|
|
56
56
|
useCollaboration: () => useCollaboration,
|
|
57
57
|
useCollaborationRequired: () => useCollaborationRequired,
|
|
58
|
-
useCurrentEditor: () =>
|
|
58
|
+
useCurrentEditor: () => import_react66.useCurrentEditor,
|
|
59
59
|
useDocumentVisibility: () => useDocumentVisibility,
|
|
60
60
|
useEditorFile: () => useEditorFile,
|
|
61
61
|
useEditorFileRequired: () => useEditorFileRequired,
|
|
@@ -64,7 +64,7 @@ __export(index_exports, {
|
|
|
64
64
|
useVariablesWithFallback: () => useVariablesWithFallback
|
|
65
65
|
});
|
|
66
66
|
module.exports = __toCommonJS(index_exports);
|
|
67
|
-
var
|
|
67
|
+
var import_react66 = require("@tiptap/react");
|
|
68
68
|
|
|
69
69
|
// src/context/collaboration-context.tsx
|
|
70
70
|
var import_provider = require("@hocuspocus/provider");
|
|
@@ -3345,14 +3345,68 @@ var import_extension_text_style = require("@tiptap/extension-text-style");
|
|
|
3345
3345
|
var import_extension_typography = require("@tiptap/extension-typography");
|
|
3346
3346
|
var import_extension_unique_id = require("@tiptap/extension-unique-id");
|
|
3347
3347
|
var import_extensions = require("@tiptap/extensions");
|
|
3348
|
-
var
|
|
3348
|
+
var import_react34 = require("@tiptap/react");
|
|
3349
3349
|
var import_starter_kit = require("@tiptap/starter-kit");
|
|
3350
|
-
var
|
|
3350
|
+
var import_react35 = require("react");
|
|
3351
|
+
|
|
3352
|
+
// src/extensions/custom-color/index.ts
|
|
3353
|
+
var import_react30 = require("@tiptap/react");
|
|
3354
|
+
var CustomColor = import_react30.Mark.create({
|
|
3355
|
+
name: "customColor",
|
|
3356
|
+
addAttributes() {
|
|
3357
|
+
return {
|
|
3358
|
+
color: {
|
|
3359
|
+
default: null,
|
|
3360
|
+
parseHTML: (element) => element.getAttribute("data-text-color"),
|
|
3361
|
+
renderHTML: (attributes) => {
|
|
3362
|
+
const { color } = attributes;
|
|
3363
|
+
if (!color) {
|
|
3364
|
+
return {};
|
|
3365
|
+
}
|
|
3366
|
+
return {
|
|
3367
|
+
"data-text-color": color,
|
|
3368
|
+
style: `color: ${color}`
|
|
3369
|
+
};
|
|
3370
|
+
}
|
|
3371
|
+
},
|
|
3372
|
+
backgroundColor: {
|
|
3373
|
+
default: null,
|
|
3374
|
+
parseHTML: (element) => element.getAttribute("data-background-color"),
|
|
3375
|
+
renderHTML: (attributes) => {
|
|
3376
|
+
const { backgroundColor } = attributes;
|
|
3377
|
+
if (!backgroundColor) {
|
|
3378
|
+
return {};
|
|
3379
|
+
}
|
|
3380
|
+
return {
|
|
3381
|
+
"data-background-color": backgroundColor,
|
|
3382
|
+
style: `background-color: ${backgroundColor}`
|
|
3383
|
+
};
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
};
|
|
3387
|
+
},
|
|
3388
|
+
parseHTML() {
|
|
3389
|
+
return [
|
|
3390
|
+
{
|
|
3391
|
+
tag: "span[data-text-color]"
|
|
3392
|
+
},
|
|
3393
|
+
{
|
|
3394
|
+
tag: "span[data-background-color]"
|
|
3395
|
+
}
|
|
3396
|
+
];
|
|
3397
|
+
},
|
|
3398
|
+
renderHTML({ HTMLAttributes }) {
|
|
3399
|
+
if (!HTMLAttributes["data-text-color"] && !HTMLAttributes["data-background-color"]) {
|
|
3400
|
+
return ["span", (0, import_react30.mergeAttributes)(HTMLAttributes), 0];
|
|
3401
|
+
}
|
|
3402
|
+
return ["span", (0, import_react30.mergeAttributes)(HTMLAttributes), 0];
|
|
3403
|
+
}
|
|
3404
|
+
});
|
|
3351
3405
|
|
|
3352
3406
|
// src/extensions/link/index.ts
|
|
3353
3407
|
var import_extension_link = __toESM(require("@tiptap/extension-link"));
|
|
3354
3408
|
var import_state3 = require("@tiptap/pm/state");
|
|
3355
|
-
var
|
|
3409
|
+
var import_react31 = require("@tiptap/react");
|
|
3356
3410
|
var Link = import_extension_link.default.extend({
|
|
3357
3411
|
inclusive: false,
|
|
3358
3412
|
parseHTML() {
|
|
@@ -3381,7 +3435,7 @@ var Link = import_extension_link.default.extend({
|
|
|
3381
3435
|
const { schema, doc, tr } = view.state;
|
|
3382
3436
|
let range;
|
|
3383
3437
|
if (schema.marks.link) {
|
|
3384
|
-
range = (0,
|
|
3438
|
+
range = (0, import_react31.getMarkRange)(doc.resolve(pos), schema.marks.link);
|
|
3385
3439
|
}
|
|
3386
3440
|
if (!range) {
|
|
3387
3441
|
return;
|
|
@@ -3687,8 +3741,8 @@ var NodeBackground = import_core8.Extension.create({
|
|
|
3687
3741
|
// src/extensions/selection/index.ts
|
|
3688
3742
|
var import_state4 = require("@tiptap/pm/state");
|
|
3689
3743
|
var import_view = require("@tiptap/pm/view");
|
|
3690
|
-
var
|
|
3691
|
-
var Selection =
|
|
3744
|
+
var import_react32 = require("@tiptap/react");
|
|
3745
|
+
var Selection = import_react32.Extension.create({
|
|
3692
3746
|
name: "selection",
|
|
3693
3747
|
addProseMirrorPlugins() {
|
|
3694
3748
|
const { editor } = this;
|
|
@@ -3703,7 +3757,7 @@ var Selection = import_react31.Extension.create({
|
|
|
3703
3757
|
if (editor.isFocused === true || !editor.isEditable) {
|
|
3704
3758
|
return null;
|
|
3705
3759
|
}
|
|
3706
|
-
if ((0,
|
|
3760
|
+
if ((0, import_react32.isNodeSelection)(state.selection)) {
|
|
3707
3761
|
return null;
|
|
3708
3762
|
}
|
|
3709
3763
|
return import_view.DecorationSet.create(state.doc, [
|
|
@@ -3778,7 +3832,7 @@ var TabHandler = import_core9.Extension.create({
|
|
|
3778
3832
|
|
|
3779
3833
|
// src/extensions/trailing-node/index.ts
|
|
3780
3834
|
var import_state5 = require("@tiptap/pm/state");
|
|
3781
|
-
var
|
|
3835
|
+
var import_react33 = require("@tiptap/react");
|
|
3782
3836
|
function nodeEqualsType({
|
|
3783
3837
|
types,
|
|
3784
3838
|
node
|
|
@@ -3789,7 +3843,7 @@ function nodeEqualsType({
|
|
|
3789
3843
|
}
|
|
3790
3844
|
return node.type === types;
|
|
3791
3845
|
}
|
|
3792
|
-
var TrailingNode =
|
|
3846
|
+
var TrailingNode = import_react33.Extension.create({
|
|
3793
3847
|
name: "trailingNode",
|
|
3794
3848
|
addOptions() {
|
|
3795
3849
|
return {
|
|
@@ -4070,10 +4124,10 @@ var useCreateEditor = ({
|
|
|
4070
4124
|
const fileHandlerFromContext = useEditorFile();
|
|
4071
4125
|
const fileHandler = fileHandlerProp != null ? fileHandlerProp : fileHandlerFromContext;
|
|
4072
4126
|
const collaboration = useCollaboration();
|
|
4073
|
-
const [collabSyncing, setCollabSyncing] = (0,
|
|
4074
|
-
const placeholderRef = (0,
|
|
4127
|
+
const [collabSyncing, setCollabSyncing] = (0, import_react35.useState)(!!collaboration);
|
|
4128
|
+
const placeholderRef = (0, import_react35.useRef)(placeholder);
|
|
4075
4129
|
placeholderRef.current = placeholder;
|
|
4076
|
-
const [extensions] = (0,
|
|
4130
|
+
const [extensions] = (0, import_react35.useState)(
|
|
4077
4131
|
() => getExtensions({
|
|
4078
4132
|
editable,
|
|
4079
4133
|
placeholder: () => {
|
|
@@ -4091,7 +4145,7 @@ var useCreateEditor = ({
|
|
|
4091
4145
|
})
|
|
4092
4146
|
);
|
|
4093
4147
|
const { onCreate: userOnCreate, ...restOptions } = options;
|
|
4094
|
-
const editor = (0,
|
|
4148
|
+
const editor = (0, import_react34.useEditor)({
|
|
4095
4149
|
editorProps: {
|
|
4096
4150
|
attributes: {
|
|
4097
4151
|
autocomplete: "off",
|
|
@@ -4136,7 +4190,7 @@ var useCreateEditor = ({
|
|
|
4136
4190
|
},
|
|
4137
4191
|
...restOptions
|
|
4138
4192
|
});
|
|
4139
|
-
(0,
|
|
4193
|
+
(0, import_react35.useEffect)(() => {
|
|
4140
4194
|
if (editor && editor.isEditable !== editable) {
|
|
4141
4195
|
editor.setEditable(editable);
|
|
4142
4196
|
}
|
|
@@ -4210,6 +4264,8 @@ function getExtensions({
|
|
|
4210
4264
|
CalloutNode,
|
|
4211
4265
|
MathBlock,
|
|
4212
4266
|
InlineMath,
|
|
4267
|
+
// Legacy support for old documents with customColor marks
|
|
4268
|
+
CustomColor,
|
|
4213
4269
|
// Image support - extended with file reference resolution
|
|
4214
4270
|
ImageNode.configure({
|
|
4215
4271
|
allowBase64: true
|
|
@@ -4356,8 +4412,8 @@ async function handleFileUpload(editor, file, fileHandler, pos) {
|
|
|
4356
4412
|
// src/presets/basic/index.tsx
|
|
4357
4413
|
var import_extension_table2 = require("@kopexa/extension-table");
|
|
4358
4414
|
var import_theme9 = require("@kopexa/theme");
|
|
4359
|
-
var
|
|
4360
|
-
var
|
|
4415
|
+
var import_react62 = require("@tiptap/react");
|
|
4416
|
+
var import_react63 = require("react");
|
|
4361
4417
|
var import_react_intl26 = require("react-intl");
|
|
4362
4418
|
|
|
4363
4419
|
// src/context/editor-context.ts
|
|
@@ -4365,10 +4421,10 @@ var import_react_utils = require("@kopexa/react-utils");
|
|
|
4365
4421
|
var [EditorUIProvider, useEditorUIContext] = (0, import_react_utils.createContext)();
|
|
4366
4422
|
|
|
4367
4423
|
// src/hooks/use-ui-editor-state.ts
|
|
4368
|
-
var
|
|
4424
|
+
var import_react36 = require("@tiptap/react");
|
|
4369
4425
|
function useUiEditorState(editor) {
|
|
4370
4426
|
var _a;
|
|
4371
|
-
return (_a = (0,
|
|
4427
|
+
return (_a = (0, import_react36.useEditorState)({
|
|
4372
4428
|
editor,
|
|
4373
4429
|
selector: ({ editor: editor2 }) => {
|
|
4374
4430
|
if (!editor2) return defaultUiState;
|
|
@@ -4395,7 +4451,7 @@ var import_icons9 = require("@kopexa/icons");
|
|
|
4395
4451
|
var import_input3 = require("@kopexa/input");
|
|
4396
4452
|
var import_popover = require("@kopexa/popover");
|
|
4397
4453
|
var import_toolbar = require("@kopexa/toolbar");
|
|
4398
|
-
var
|
|
4454
|
+
var import_react37 = require("react");
|
|
4399
4455
|
|
|
4400
4456
|
// src/ui/link-popover/use-link-popover.ts
|
|
4401
4457
|
var import_editor_utils5 = require("@kopexa/editor-utils");
|
|
@@ -4651,8 +4707,8 @@ var LinkMain = ({
|
|
|
4651
4707
|
isActive,
|
|
4652
4708
|
onSave
|
|
4653
4709
|
}) => {
|
|
4654
|
-
const [isEditing, setIsEditing] = (0,
|
|
4655
|
-
(0,
|
|
4710
|
+
const [isEditing, setIsEditing] = (0, import_react37.useState)(!isActive || !url);
|
|
4711
|
+
(0, import_react37.useEffect)(() => {
|
|
4656
4712
|
setIsEditing(!isActive || !url);
|
|
4657
4713
|
}, [isActive, url]);
|
|
4658
4714
|
const handleKeyDown = (event) => {
|
|
@@ -4768,7 +4824,7 @@ function LinkPopover({
|
|
|
4768
4824
|
...buttonProps
|
|
4769
4825
|
}) {
|
|
4770
4826
|
const { editor } = (0, import_editor_utils6.useTiptapEditor)(providedEditor);
|
|
4771
|
-
const [isOpen, setIsOpen] = (0,
|
|
4827
|
+
const [isOpen, setIsOpen] = (0, import_react37.useState)(false);
|
|
4772
4828
|
const {
|
|
4773
4829
|
isVisible,
|
|
4774
4830
|
canSet,
|
|
@@ -4784,18 +4840,18 @@ function LinkPopover({
|
|
|
4784
4840
|
hideWhenUnavailable,
|
|
4785
4841
|
onSetLink
|
|
4786
4842
|
});
|
|
4787
|
-
const handleOnOpenChange = (0,
|
|
4843
|
+
const handleOnOpenChange = (0, import_react37.useCallback)(
|
|
4788
4844
|
(nextIsOpen) => {
|
|
4789
4845
|
setIsOpen(nextIsOpen);
|
|
4790
4846
|
onOpenChange == null ? void 0 : onOpenChange(nextIsOpen);
|
|
4791
4847
|
},
|
|
4792
4848
|
[onOpenChange]
|
|
4793
4849
|
);
|
|
4794
|
-
const handleSetLink = (0,
|
|
4850
|
+
const handleSetLink = (0, import_react37.useCallback)(() => {
|
|
4795
4851
|
setLink();
|
|
4796
4852
|
setIsOpen(false);
|
|
4797
4853
|
}, [setLink]);
|
|
4798
|
-
const handleClick = (0,
|
|
4854
|
+
const handleClick = (0, import_react37.useCallback)(
|
|
4799
4855
|
(event) => {
|
|
4800
4856
|
onClick == null ? void 0 : onClick(event);
|
|
4801
4857
|
if (event.defaultPrevented) return;
|
|
@@ -4803,7 +4859,7 @@ function LinkPopover({
|
|
|
4803
4859
|
},
|
|
4804
4860
|
[onClick, isOpen]
|
|
4805
4861
|
);
|
|
4806
|
-
(0,
|
|
4862
|
+
(0, import_react37.useEffect)(() => {
|
|
4807
4863
|
if (autoOpenOnLinkActive && isActive) {
|
|
4808
4864
|
setIsOpen(true);
|
|
4809
4865
|
}
|
|
@@ -4857,8 +4913,8 @@ LinkButton.displayName = "LinkButton";
|
|
|
4857
4913
|
var import_editor_utils7 = require("@kopexa/editor-utils");
|
|
4858
4914
|
var import_icons10 = require("@kopexa/icons");
|
|
4859
4915
|
var import_toolbar2 = require("@kopexa/toolbar");
|
|
4860
|
-
var
|
|
4861
|
-
var
|
|
4916
|
+
var import_react38 = require("@tiptap/react");
|
|
4917
|
+
var import_react39 = require("react");
|
|
4862
4918
|
var import_react_intl16 = require("react-intl");
|
|
4863
4919
|
|
|
4864
4920
|
// src/ui/messages.ts
|
|
@@ -5324,7 +5380,7 @@ function shouldShowMarkButton(params) {
|
|
|
5324
5380
|
return false;
|
|
5325
5381
|
}
|
|
5326
5382
|
if (hideWhenUnavailable) {
|
|
5327
|
-
if ((0,
|
|
5383
|
+
if ((0, import_react38.isNodeSelection)(editor.state.selection) || !canToggleMark(editor, type)) {
|
|
5328
5384
|
return false;
|
|
5329
5385
|
}
|
|
5330
5386
|
}
|
|
@@ -5379,7 +5435,7 @@ var MarkButton = ({
|
|
|
5379
5435
|
shortcutKey,
|
|
5380
5436
|
formattedName
|
|
5381
5437
|
} = useMarkState(editor, type, disabled);
|
|
5382
|
-
const handleClick = (0,
|
|
5438
|
+
const handleClick = (0, import_react39.useCallback)(
|
|
5383
5439
|
(e) => {
|
|
5384
5440
|
onClick == null ? void 0 : onClick(e);
|
|
5385
5441
|
if (!e.defaultPrevented && !isDisabled && editor) {
|
|
@@ -5388,7 +5444,7 @@ var MarkButton = ({
|
|
|
5388
5444
|
},
|
|
5389
5445
|
[onClick, isDisabled, editor, type]
|
|
5390
5446
|
);
|
|
5391
|
-
const show = (0,
|
|
5447
|
+
const show = (0, import_react39.useMemo)(() => {
|
|
5392
5448
|
return shouldShowMarkButton({
|
|
5393
5449
|
editor,
|
|
5394
5450
|
type,
|
|
@@ -5468,7 +5524,7 @@ var React9 = __toESM(require("react"));
|
|
|
5468
5524
|
|
|
5469
5525
|
// src/hooks/use-floating-toolbar-visibility.ts
|
|
5470
5526
|
var import_state6 = require("@tiptap/pm/state");
|
|
5471
|
-
var
|
|
5527
|
+
var import_react40 = require("@tiptap/react");
|
|
5472
5528
|
var React8 = __toESM(require("react"));
|
|
5473
5529
|
var HIDE_FLOATING_META = "hideFloatingToolbar";
|
|
5474
5530
|
var selectNodeAndHideFloating = (editor, pos) => {
|
|
@@ -5570,39 +5626,39 @@ var import_button9 = require("@kopexa/button");
|
|
|
5570
5626
|
var import_icons11 = require("@kopexa/icons");
|
|
5571
5627
|
var import_input4 = require("@kopexa/input");
|
|
5572
5628
|
var import_menus2 = require("@tiptap/react/menus");
|
|
5573
|
-
var
|
|
5629
|
+
var import_react41 = require("react");
|
|
5574
5630
|
var import_react_intl17 = require("react-intl");
|
|
5575
5631
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
5576
5632
|
function LinkBubble({ editor }) {
|
|
5577
5633
|
const intl = (0, import_react_intl17.useIntl)();
|
|
5578
|
-
const [isEditing, setIsEditing] = (0,
|
|
5579
|
-
const [url, setUrl] = (0,
|
|
5580
|
-
const getCurrentUrl = (0,
|
|
5634
|
+
const [isEditing, setIsEditing] = (0, import_react41.useState)(false);
|
|
5635
|
+
const [url, setUrl] = (0, import_react41.useState)("");
|
|
5636
|
+
const getCurrentUrl = (0, import_react41.useCallback)(() => {
|
|
5581
5637
|
if (!editor) return "";
|
|
5582
5638
|
const attrs = editor.getAttributes("link");
|
|
5583
5639
|
return attrs.href || "";
|
|
5584
5640
|
}, [editor]);
|
|
5585
|
-
(0,
|
|
5641
|
+
(0, import_react41.useEffect)(() => {
|
|
5586
5642
|
const isLinkActive2 = editor == null ? void 0 : editor.isActive("link");
|
|
5587
5643
|
if (isLinkActive2) {
|
|
5588
5644
|
setUrl(getCurrentUrl());
|
|
5589
5645
|
setIsEditing(false);
|
|
5590
5646
|
}
|
|
5591
5647
|
}, [editor, getCurrentUrl]);
|
|
5592
|
-
const handleOpenLink = (0,
|
|
5648
|
+
const handleOpenLink = (0, import_react41.useCallback)(() => {
|
|
5593
5649
|
const href = getCurrentUrl();
|
|
5594
5650
|
if (href) {
|
|
5595
5651
|
window.open(href, "_blank", "noopener,noreferrer");
|
|
5596
5652
|
}
|
|
5597
5653
|
}, [getCurrentUrl]);
|
|
5598
|
-
const handleRemoveLink = (0,
|
|
5654
|
+
const handleRemoveLink = (0, import_react41.useCallback)(() => {
|
|
5599
5655
|
editor == null ? void 0 : editor.chain().focus().unsetLink().run();
|
|
5600
5656
|
}, [editor]);
|
|
5601
|
-
const handleEdit = (0,
|
|
5657
|
+
const handleEdit = (0, import_react41.useCallback)(() => {
|
|
5602
5658
|
setUrl(getCurrentUrl());
|
|
5603
5659
|
setIsEditing(true);
|
|
5604
5660
|
}, [getCurrentUrl]);
|
|
5605
|
-
const handleSave = (0,
|
|
5661
|
+
const handleSave = (0, import_react41.useCallback)(() => {
|
|
5606
5662
|
if (url) {
|
|
5607
5663
|
editor == null ? void 0 : editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
|
|
5608
5664
|
} else {
|
|
@@ -5610,7 +5666,7 @@ function LinkBubble({ editor }) {
|
|
|
5610
5666
|
}
|
|
5611
5667
|
setIsEditing(false);
|
|
5612
5668
|
}, [editor, url]);
|
|
5613
|
-
const handleKeyDown = (0,
|
|
5669
|
+
const handleKeyDown = (0, import_react41.useCallback)(
|
|
5614
5670
|
(e) => {
|
|
5615
5671
|
if (e.key === "Enter") {
|
|
5616
5672
|
e.preventDefault();
|
|
@@ -5735,8 +5791,8 @@ var import_react_intl19 = require("react-intl");
|
|
|
5735
5791
|
// src/ui/table-button/use-table.ts
|
|
5736
5792
|
var import_editor_utils9 = require("@kopexa/editor-utils");
|
|
5737
5793
|
var import_icons12 = require("@kopexa/icons");
|
|
5738
|
-
var
|
|
5739
|
-
var
|
|
5794
|
+
var import_react42 = require("@tiptap/react");
|
|
5795
|
+
var import_react43 = require("react");
|
|
5740
5796
|
var import_react_intl18 = require("react-intl");
|
|
5741
5797
|
function canToggle(editor) {
|
|
5742
5798
|
if (!editor || !editor.isEditable) return false;
|
|
@@ -5768,7 +5824,7 @@ function shouldShowButton(props) {
|
|
|
5768
5824
|
if (!editor || !editor.isEditable) return false;
|
|
5769
5825
|
if (!(0, import_editor_utils9.isNodeInSchema)("table", editor)) return false;
|
|
5770
5826
|
if (hideWhenUnavailable) {
|
|
5771
|
-
if ((0,
|
|
5827
|
+
if ((0, import_react42.isNodeSelection)(editor.state.selection) || !canToggle) {
|
|
5772
5828
|
return false;
|
|
5773
5829
|
}
|
|
5774
5830
|
}
|
|
@@ -5782,10 +5838,10 @@ function useTableBlock(config) {
|
|
|
5782
5838
|
} = config || {};
|
|
5783
5839
|
const intl = (0, import_react_intl18.useIntl)();
|
|
5784
5840
|
const { editor } = (0, import_editor_utils9.useTiptapEditor)(providedEditor);
|
|
5785
|
-
const [isVisible, setIsVisible] = (0,
|
|
5841
|
+
const [isVisible, setIsVisible] = (0, import_react43.useState)(true);
|
|
5786
5842
|
const canToggleState = canToggle(editor);
|
|
5787
5843
|
const isActive = (editor == null ? void 0 : editor.isActive("table")) || false;
|
|
5788
|
-
(0,
|
|
5844
|
+
(0, import_react43.useEffect)(() => {
|
|
5789
5845
|
if (!editor) return;
|
|
5790
5846
|
const handleSelectionUpdate = () => {
|
|
5791
5847
|
setIsVisible(shouldShowButton({ editor, hideWhenUnavailable }));
|
|
@@ -5796,7 +5852,7 @@ function useTableBlock(config) {
|
|
|
5796
5852
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
5797
5853
|
};
|
|
5798
5854
|
}, [editor, hideWhenUnavailable]);
|
|
5799
|
-
const handleToggle = (0,
|
|
5855
|
+
const handleToggle = (0, import_react43.useCallback)(() => {
|
|
5800
5856
|
if (!editor) return false;
|
|
5801
5857
|
const success = toggleTable(editor);
|
|
5802
5858
|
if (success) {
|
|
@@ -6358,7 +6414,7 @@ var import_icons26 = require("@kopexa/icons");
|
|
|
6358
6414
|
var import_popover3 = require("@kopexa/popover");
|
|
6359
6415
|
var import_toolbar10 = require("@kopexa/toolbar");
|
|
6360
6416
|
var import_use_is_mobile3 = require("@kopexa/use-is-mobile");
|
|
6361
|
-
var
|
|
6417
|
+
var import_react61 = require("react");
|
|
6362
6418
|
var import_react_intl25 = require("react-intl");
|
|
6363
6419
|
|
|
6364
6420
|
// src/hooks/use-cursor-visibility.ts
|
|
@@ -6469,13 +6525,13 @@ var import_editor_utils14 = require("@kopexa/editor-utils");
|
|
|
6469
6525
|
var import_icons15 = require("@kopexa/icons");
|
|
6470
6526
|
var import_popover2 = require("@kopexa/popover");
|
|
6471
6527
|
var import_toolbar5 = require("@kopexa/toolbar");
|
|
6472
|
-
var
|
|
6528
|
+
var import_react45 = require("react");
|
|
6473
6529
|
|
|
6474
6530
|
// src/ui/color-highlight-button/color-highlight-button.tsx
|
|
6475
6531
|
var import_editor_utils13 = require("@kopexa/editor-utils");
|
|
6476
6532
|
var import_theme8 = require("@kopexa/theme");
|
|
6477
6533
|
var import_toolbar4 = require("@kopexa/toolbar");
|
|
6478
|
-
var
|
|
6534
|
+
var import_react44 = require("react");
|
|
6479
6535
|
|
|
6480
6536
|
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
6481
6537
|
var import_editor_utils12 = require("@kopexa/editor-utils");
|
|
@@ -6672,7 +6728,7 @@ var ColorHighlightButton = ({
|
|
|
6672
6728
|
hideWhenUnavailable,
|
|
6673
6729
|
onApplied
|
|
6674
6730
|
});
|
|
6675
|
-
const handleClick = (0,
|
|
6731
|
+
const handleClick = (0, import_react44.useCallback)(
|
|
6676
6732
|
(event) => {
|
|
6677
6733
|
onClick == null ? void 0 : onClick(event);
|
|
6678
6734
|
if (event.defaultPrevented) return;
|
|
@@ -6680,7 +6736,7 @@ var ColorHighlightButton = ({
|
|
|
6680
6736
|
},
|
|
6681
6737
|
[handleColorHighlight, onClick]
|
|
6682
6738
|
);
|
|
6683
|
-
const buttonStyle = (0,
|
|
6739
|
+
const buttonStyle = (0, import_react44.useMemo)(
|
|
6684
6740
|
() => ({
|
|
6685
6741
|
...style,
|
|
6686
6742
|
"--highlight-color": highlightColor
|
|
@@ -6763,8 +6819,8 @@ function ColorHighlightPopoverContent({
|
|
|
6763
6819
|
])
|
|
6764
6820
|
}) {
|
|
6765
6821
|
const { handleRemoveHighlight } = useColorHighlight({ editor });
|
|
6766
|
-
const containerRef = (0,
|
|
6767
|
-
const menuItems = (0,
|
|
6822
|
+
const containerRef = (0, import_react45.useRef)(null);
|
|
6823
|
+
const menuItems = (0, import_react45.useMemo)(
|
|
6768
6824
|
() => [...colors, { label: "Remove highlight", value: "none" }],
|
|
6769
6825
|
[colors]
|
|
6770
6826
|
);
|
|
@@ -6832,7 +6888,7 @@ function ColorHighlightPopover({
|
|
|
6832
6888
|
...props
|
|
6833
6889
|
}) {
|
|
6834
6890
|
const { editor } = (0, import_editor_utils14.useTiptapEditor)(providedEditor);
|
|
6835
|
-
const [isOpen, setIsOpen] = (0,
|
|
6891
|
+
const [isOpen, setIsOpen] = (0, import_react45.useState)(false);
|
|
6836
6892
|
const { isVisible, canColorHighlight: canColorHighlight2, isActive, label } = useColorHighlight({
|
|
6837
6893
|
editor,
|
|
6838
6894
|
hideWhenUnavailable,
|
|
@@ -6866,15 +6922,15 @@ var import_button13 = require("@kopexa/button");
|
|
|
6866
6922
|
var import_dropdown_menu = require("@kopexa/dropdown-menu");
|
|
6867
6923
|
var import_editor_utils16 = require("@kopexa/editor-utils");
|
|
6868
6924
|
var import_icons17 = require("@kopexa/icons");
|
|
6869
|
-
var
|
|
6870
|
-
var
|
|
6925
|
+
var import_react48 = require("@tiptap/react");
|
|
6926
|
+
var import_react49 = require("react");
|
|
6871
6927
|
|
|
6872
6928
|
// src/ui/list-button/index.tsx
|
|
6873
6929
|
var import_button12 = require("@kopexa/button");
|
|
6874
6930
|
var import_editor_utils15 = require("@kopexa/editor-utils");
|
|
6875
6931
|
var import_icons16 = require("@kopexa/icons");
|
|
6876
|
-
var
|
|
6877
|
-
var
|
|
6932
|
+
var import_react46 = require("@tiptap/react");
|
|
6933
|
+
var import_react47 = require("react");
|
|
6878
6934
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
6879
6935
|
var listOptions = [
|
|
6880
6936
|
{
|
|
@@ -6949,7 +7005,7 @@ function shouldShowListButton(params) {
|
|
|
6949
7005
|
return false;
|
|
6950
7006
|
}
|
|
6951
7007
|
if (hideWhenUnavailable) {
|
|
6952
|
-
if ((0,
|
|
7008
|
+
if ((0, import_react46.isNodeSelection)(editor.state.selection) || !canToggleList(editor, type)) {
|
|
6953
7009
|
return false;
|
|
6954
7010
|
}
|
|
6955
7011
|
}
|
|
@@ -6984,7 +7040,7 @@ var ListButton = ({
|
|
|
6984
7040
|
type
|
|
6985
7041
|
);
|
|
6986
7042
|
const Icon = (listOption == null ? void 0 : listOption.icon) || import_icons16.ListIcon;
|
|
6987
|
-
const handleClick = (0,
|
|
7043
|
+
const handleClick = (0, import_react47.useCallback)(
|
|
6988
7044
|
(e) => {
|
|
6989
7045
|
onClick == null ? void 0 : onClick(e);
|
|
6990
7046
|
if (!e.defaultPrevented && editor) {
|
|
@@ -6993,7 +7049,7 @@ var ListButton = ({
|
|
|
6993
7049
|
},
|
|
6994
7050
|
[onClick, editor, type]
|
|
6995
7051
|
);
|
|
6996
|
-
const show = (0,
|
|
7052
|
+
const show = (0, import_react47.useMemo)(() => {
|
|
6997
7053
|
return shouldShowListButton({
|
|
6998
7054
|
editor,
|
|
6999
7055
|
type,
|
|
@@ -7047,24 +7103,24 @@ function shouldShowListDropdown(params) {
|
|
|
7047
7103
|
return false;
|
|
7048
7104
|
}
|
|
7049
7105
|
if (hideWhenUnavailable) {
|
|
7050
|
-
if ((0,
|
|
7106
|
+
if ((0, import_react48.isNodeSelection)(editor.state.selection) || !canToggleAny) {
|
|
7051
7107
|
return false;
|
|
7052
7108
|
}
|
|
7053
7109
|
}
|
|
7054
7110
|
return true;
|
|
7055
7111
|
}
|
|
7056
7112
|
function useListDropdownState(editor, availableTypes) {
|
|
7057
|
-
const [isOpen, setIsOpen] = (0,
|
|
7113
|
+
const [isOpen, setIsOpen] = (0, import_react49.useState)(false);
|
|
7058
7114
|
const listInSchema = availableTypes.some(
|
|
7059
7115
|
(type) => (0, import_editor_utils16.isNodeInSchema)(type, editor)
|
|
7060
7116
|
);
|
|
7061
|
-
const filteredLists = (0,
|
|
7117
|
+
const filteredLists = (0, import_react49.useMemo)(
|
|
7062
7118
|
() => getFilteredListOptions(availableTypes),
|
|
7063
7119
|
[availableTypes]
|
|
7064
7120
|
);
|
|
7065
7121
|
const canToggleAny = canToggleAnyList(editor, availableTypes);
|
|
7066
7122
|
const isAnyActive = isAnyListActive(editor, availableTypes);
|
|
7067
|
-
const handleOpenChange = (0,
|
|
7123
|
+
const handleOpenChange = (0, import_react49.useCallback)(
|
|
7068
7124
|
(open, callback) => {
|
|
7069
7125
|
setIsOpen(open);
|
|
7070
7126
|
callback == null ? void 0 : callback(open);
|
|
@@ -7082,7 +7138,7 @@ function useListDropdownState(editor, availableTypes) {
|
|
|
7082
7138
|
};
|
|
7083
7139
|
}
|
|
7084
7140
|
function useActiveListIcon(editor, filteredLists) {
|
|
7085
|
-
return (0,
|
|
7141
|
+
return (0, import_react49.useCallback)(() => {
|
|
7086
7142
|
const activeOption = filteredLists.find(
|
|
7087
7143
|
(option) => isListActive(editor, option.type)
|
|
7088
7144
|
);
|
|
@@ -7106,7 +7162,7 @@ function ListDropdownMenu({
|
|
|
7106
7162
|
handleOpenChange
|
|
7107
7163
|
} = useListDropdownState(editor, types);
|
|
7108
7164
|
const getActiveIcon = useActiveListIcon(editor, filteredLists);
|
|
7109
|
-
const show = (0,
|
|
7165
|
+
const show = (0, import_react49.useMemo)(() => {
|
|
7110
7166
|
return shouldShowListDropdown({
|
|
7111
7167
|
editor,
|
|
7112
7168
|
listTypes: types,
|
|
@@ -7115,7 +7171,7 @@ function ListDropdownMenu({
|
|
|
7115
7171
|
canToggleAny
|
|
7116
7172
|
});
|
|
7117
7173
|
}, [editor, types, hideWhenUnavailable, listInSchema, canToggleAny]);
|
|
7118
|
-
const handleOnOpenChange = (0,
|
|
7174
|
+
const handleOnOpenChange = (0, import_react49.useCallback)(
|
|
7119
7175
|
(open) => handleOpenChange(open, onOpenChange),
|
|
7120
7176
|
[handleOpenChange, onOpenChange]
|
|
7121
7177
|
);
|
|
@@ -7156,7 +7212,7 @@ function ListDropdownMenu({
|
|
|
7156
7212
|
// src/ui/table-button/index.tsx
|
|
7157
7213
|
var import_editor_utils17 = require("@kopexa/editor-utils");
|
|
7158
7214
|
var import_toolbar6 = require("@kopexa/toolbar");
|
|
7159
|
-
var
|
|
7215
|
+
var import_react50 = require("react");
|
|
7160
7216
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
7161
7217
|
var TableButton = ({
|
|
7162
7218
|
editor: providedEditor,
|
|
@@ -7181,7 +7237,7 @@ var TableButton = ({
|
|
|
7181
7237
|
hideWhenUnavailable,
|
|
7182
7238
|
onToggled
|
|
7183
7239
|
});
|
|
7184
|
-
const handleClick = (0,
|
|
7240
|
+
const handleClick = (0, import_react50.useCallback)(
|
|
7185
7241
|
(event) => {
|
|
7186
7242
|
onClick == null ? void 0 : onClick(event);
|
|
7187
7243
|
if (event.defaultPrevented) return;
|
|
@@ -7219,12 +7275,12 @@ var TableButton = ({
|
|
|
7219
7275
|
// src/ui/text-align-button/text-align-button.tsx
|
|
7220
7276
|
var import_button14 = require("@kopexa/button");
|
|
7221
7277
|
var import_editor_utils19 = require("@kopexa/editor-utils");
|
|
7222
|
-
var
|
|
7278
|
+
var import_react52 = require("react");
|
|
7223
7279
|
|
|
7224
7280
|
// src/ui/text-align-button/use-text-align.ts
|
|
7225
7281
|
var import_editor_utils18 = require("@kopexa/editor-utils");
|
|
7226
7282
|
var import_icons18 = require("@kopexa/icons");
|
|
7227
|
-
var
|
|
7283
|
+
var import_react51 = require("react");
|
|
7228
7284
|
var import_react_intl21 = require("react-intl");
|
|
7229
7285
|
var TEXT_ALIGN_SHORTCUT_KEYS = {
|
|
7230
7286
|
left: "mod+shift+l",
|
|
@@ -7284,10 +7340,10 @@ function useTextAlign(config) {
|
|
|
7284
7340
|
} = config;
|
|
7285
7341
|
const intl = (0, import_react_intl21.useIntl)();
|
|
7286
7342
|
const { editor } = (0, import_editor_utils18.useTiptapEditor)(providedEditor);
|
|
7287
|
-
const [isVisible, setIsVisible] = (0,
|
|
7343
|
+
const [isVisible, setIsVisible] = (0, import_react51.useState)(true);
|
|
7288
7344
|
const canAlign = canSetTextAlign(editor, align);
|
|
7289
7345
|
const isActive = isTextAlignActive(editor, align);
|
|
7290
|
-
(0,
|
|
7346
|
+
(0, import_react51.useEffect)(() => {
|
|
7291
7347
|
if (!editor) return;
|
|
7292
7348
|
const handleSelectionUpdate = () => {
|
|
7293
7349
|
setIsVisible(shouldShowButton3({ editor, align, hideWhenUnavailable }));
|
|
@@ -7298,7 +7354,7 @@ function useTextAlign(config) {
|
|
|
7298
7354
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
7299
7355
|
};
|
|
7300
7356
|
}, [editor, hideWhenUnavailable, align]);
|
|
7301
|
-
const handleTextAlign = (0,
|
|
7357
|
+
const handleTextAlign = (0, import_react51.useCallback)(() => {
|
|
7302
7358
|
if (!editor) return false;
|
|
7303
7359
|
const success = setTextAlign(editor, align);
|
|
7304
7360
|
if (success) {
|
|
@@ -7345,7 +7401,7 @@ var TextAlignButton = ({
|
|
|
7345
7401
|
hideWhenUnavailable,
|
|
7346
7402
|
onAligned
|
|
7347
7403
|
});
|
|
7348
|
-
const handleClick = (0,
|
|
7404
|
+
const handleClick = (0, import_react52.useCallback)(
|
|
7349
7405
|
(e) => {
|
|
7350
7406
|
onClick == null ? void 0 : onClick(e);
|
|
7351
7407
|
if (e.defaultPrevented) return;
|
|
@@ -7381,7 +7437,7 @@ var TextAlignButton = ({
|
|
|
7381
7437
|
var import_button17 = require("@kopexa/button");
|
|
7382
7438
|
var import_dropdown_menu2 = require("@kopexa/dropdown-menu");
|
|
7383
7439
|
var import_editor_utils28 = require("@kopexa/editor-utils");
|
|
7384
|
-
var
|
|
7440
|
+
var import_react58 = require("react");
|
|
7385
7441
|
var import_react_intl23 = require("react-intl");
|
|
7386
7442
|
|
|
7387
7443
|
// src/ui/blockquote-button/blockquote-button.tsx
|
|
@@ -7569,7 +7625,7 @@ var BlockquoteButton = ({
|
|
|
7569
7625
|
var import_editor_utils23 = require("@kopexa/editor-utils");
|
|
7570
7626
|
var import_icons21 = require("@kopexa/icons");
|
|
7571
7627
|
var import_toolbar8 = require("@kopexa/toolbar");
|
|
7572
|
-
var
|
|
7628
|
+
var import_react53 = require("react");
|
|
7573
7629
|
|
|
7574
7630
|
// src/ui/codeblock-button/use-code-block.ts
|
|
7575
7631
|
var import_editor_utils22 = require("@kopexa/editor-utils");
|
|
@@ -7703,7 +7759,7 @@ var CodeBlockButton = ({
|
|
|
7703
7759
|
hideWhenUnavailable,
|
|
7704
7760
|
onToggled
|
|
7705
7761
|
});
|
|
7706
|
-
const handleClick = (0,
|
|
7762
|
+
const handleClick = (0, import_react53.useCallback)(
|
|
7707
7763
|
(event) => {
|
|
7708
7764
|
onClick == null ? void 0 : onClick(event);
|
|
7709
7765
|
if (event.defaultPrevented) return;
|
|
@@ -7746,7 +7802,7 @@ var import_icons22 = require("@kopexa/icons");
|
|
|
7746
7802
|
var React18 = __toESM(require("react"));
|
|
7747
7803
|
|
|
7748
7804
|
// src/ui/heading-button/utils.ts
|
|
7749
|
-
var
|
|
7805
|
+
var import_react54 = require("@tiptap/react");
|
|
7750
7806
|
var headingShortcutKeys = {
|
|
7751
7807
|
1: "Ctrl-Alt-1",
|
|
7752
7808
|
2: "Ctrl-Alt-2",
|
|
@@ -7787,7 +7843,7 @@ function shouldShowHeadingButton(params) {
|
|
|
7787
7843
|
return false;
|
|
7788
7844
|
}
|
|
7789
7845
|
if (hideWhenUnavailable) {
|
|
7790
|
-
if ((0,
|
|
7846
|
+
if ((0, import_react54.isNodeSelection)(editor.state.selection)) {
|
|
7791
7847
|
return false;
|
|
7792
7848
|
}
|
|
7793
7849
|
}
|
|
@@ -7893,14 +7949,14 @@ var import_button16 = require("@kopexa/button");
|
|
|
7893
7949
|
var import_chip = require("@kopexa/chip");
|
|
7894
7950
|
var import_editor_utils26 = require("@kopexa/editor-utils");
|
|
7895
7951
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
7896
|
-
var
|
|
7952
|
+
var import_react56 = require("react");
|
|
7897
7953
|
|
|
7898
7954
|
// src/ui/text-button/use-text.ts
|
|
7899
7955
|
var import_editor_utils25 = require("@kopexa/editor-utils");
|
|
7900
7956
|
var import_icons23 = require("@kopexa/icons");
|
|
7901
7957
|
var import_use_is_mobile2 = require("@kopexa/use-is-mobile");
|
|
7902
7958
|
var import_state9 = require("@tiptap/pm/state");
|
|
7903
|
-
var
|
|
7959
|
+
var import_react55 = require("react");
|
|
7904
7960
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
|
7905
7961
|
var TEXT_SHORTCUT_KEY = "mod+alt+0";
|
|
7906
7962
|
function canToggleText(editor, turnInto = true) {
|
|
@@ -7993,10 +8049,10 @@ function useText(config) {
|
|
|
7993
8049
|
} = config || {};
|
|
7994
8050
|
const { editor } = (0, import_editor_utils25.useTiptapEditor)(providedEditor);
|
|
7995
8051
|
const isMobile = (0, import_use_is_mobile2.useIsMobile)();
|
|
7996
|
-
const [isVisible, setIsVisible] = (0,
|
|
8052
|
+
const [isVisible, setIsVisible] = (0, import_react55.useState)(true);
|
|
7997
8053
|
const canToggle3 = canToggleText(editor);
|
|
7998
8054
|
const isActive = isParagraphActive(editor);
|
|
7999
|
-
(0,
|
|
8055
|
+
(0, import_react55.useEffect)(() => {
|
|
8000
8056
|
if (!editor) return;
|
|
8001
8057
|
const handleSelectionUpdate = () => {
|
|
8002
8058
|
setIsVisible(shouldShowButton6({ editor, hideWhenUnavailable }));
|
|
@@ -8007,7 +8063,7 @@ function useText(config) {
|
|
|
8007
8063
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
8008
8064
|
};
|
|
8009
8065
|
}, [editor, hideWhenUnavailable]);
|
|
8010
|
-
const handleToggle = (0,
|
|
8066
|
+
const handleToggle = (0, import_react55.useCallback)(() => {
|
|
8011
8067
|
if (!editor) return false;
|
|
8012
8068
|
const success = toggleParagraph(editor);
|
|
8013
8069
|
if (success) {
|
|
@@ -8070,7 +8126,7 @@ var TextButton = ({
|
|
|
8070
8126
|
hideWhenUnavailable,
|
|
8071
8127
|
onToggled
|
|
8072
8128
|
});
|
|
8073
|
-
const handleClick = (0,
|
|
8129
|
+
const handleClick = (0, import_react56.useCallback)(
|
|
8074
8130
|
(event) => {
|
|
8075
8131
|
onClick == null ? void 0 : onClick(event);
|
|
8076
8132
|
if (event.defaultPrevented) return;
|
|
@@ -8111,7 +8167,7 @@ var TextButton = ({
|
|
|
8111
8167
|
var import_editor_utils27 = require("@kopexa/editor-utils");
|
|
8112
8168
|
var import_icons24 = require("@kopexa/icons");
|
|
8113
8169
|
var import_state10 = require("@tiptap/pm/state");
|
|
8114
|
-
var
|
|
8170
|
+
var import_react57 = require("react");
|
|
8115
8171
|
var import_react_intl22 = require("react-intl");
|
|
8116
8172
|
var TURN_INTO_BLOCKS = [
|
|
8117
8173
|
"paragraph",
|
|
@@ -8209,14 +8265,14 @@ function useTurnIntoDropdown(config) {
|
|
|
8209
8265
|
} = config || {};
|
|
8210
8266
|
const intl = (0, import_react_intl22.useIntl)();
|
|
8211
8267
|
const { editor } = (0, import_editor_utils27.useTiptapEditor)(providedEditor);
|
|
8212
|
-
const [isOpen, setIsOpen] = (0,
|
|
8213
|
-
const [isVisible, setIsVisible] = (0,
|
|
8214
|
-
const translatedBlockTypeOptions = (0,
|
|
8268
|
+
const [isOpen, setIsOpen] = (0, import_react57.useState)(false);
|
|
8269
|
+
const [isVisible, setIsVisible] = (0, import_react57.useState)(true);
|
|
8270
|
+
const translatedBlockTypeOptions = (0, import_react57.useMemo)(
|
|
8215
8271
|
() => createBlockTypeOptions(intl.formatMessage),
|
|
8216
8272
|
[intl]
|
|
8217
8273
|
);
|
|
8218
8274
|
const canToggle3 = canTurnInto(editor, blockTypes);
|
|
8219
|
-
const activeBlockType = (0,
|
|
8275
|
+
const activeBlockType = (0, import_react57.useMemo)(() => {
|
|
8220
8276
|
if (!editor) return translatedBlockTypeOptions[0];
|
|
8221
8277
|
const filteredOptions2 = blockTypes ? translatedBlockTypeOptions.filter(
|
|
8222
8278
|
(opt) => blockTypes.includes(opt.type)
|
|
@@ -8226,13 +8282,13 @@ function useTurnIntoDropdown(config) {
|
|
|
8226
8282
|
);
|
|
8227
8283
|
return activeOption || filteredOptions2[0];
|
|
8228
8284
|
}, [editor, blockTypes, translatedBlockTypeOptions]);
|
|
8229
|
-
const filteredOptions = (0,
|
|
8285
|
+
const filteredOptions = (0, import_react57.useMemo)(() => {
|
|
8230
8286
|
if (!blockTypes) return translatedBlockTypeOptions;
|
|
8231
8287
|
return translatedBlockTypeOptions.filter(
|
|
8232
8288
|
(opt) => blockTypes.includes(opt.type)
|
|
8233
8289
|
);
|
|
8234
8290
|
}, [blockTypes, translatedBlockTypeOptions]);
|
|
8235
|
-
const handleOpenChange = (0,
|
|
8291
|
+
const handleOpenChange = (0, import_react57.useCallback)(
|
|
8236
8292
|
(open) => {
|
|
8237
8293
|
if (!editor || !canToggle3) return;
|
|
8238
8294
|
setIsOpen(open);
|
|
@@ -8240,7 +8296,7 @@ function useTurnIntoDropdown(config) {
|
|
|
8240
8296
|
},
|
|
8241
8297
|
[canToggle3, editor, onOpenChange]
|
|
8242
8298
|
);
|
|
8243
|
-
(0,
|
|
8299
|
+
(0, import_react57.useEffect)(() => {
|
|
8244
8300
|
if (!editor) return;
|
|
8245
8301
|
const handleSelectionUpdate = () => {
|
|
8246
8302
|
setIsVisible(
|
|
@@ -8279,7 +8335,7 @@ function useTurnIntoDropdown(config) {
|
|
|
8279
8335
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
8280
8336
|
var TurnIntoDropdownContent = ({ blockTypes }) => {
|
|
8281
8337
|
const intl = (0, import_react_intl23.useIntl)();
|
|
8282
|
-
const filteredOptions = (0,
|
|
8338
|
+
const filteredOptions = (0, import_react58.useMemo)(() => {
|
|
8283
8339
|
const allOptions = createBlockTypeOptions(intl.formatMessage);
|
|
8284
8340
|
if (!blockTypes) return allOptions;
|
|
8285
8341
|
return allOptions.filter((opt) => blockTypes.includes(opt.type));
|
|
@@ -8377,7 +8433,7 @@ function renderBlockTypeButton(option, key) {
|
|
|
8377
8433
|
return null;
|
|
8378
8434
|
}
|
|
8379
8435
|
}
|
|
8380
|
-
var TurnIntoDropdown = (0,
|
|
8436
|
+
var TurnIntoDropdown = (0, import_react58.forwardRef)(
|
|
8381
8437
|
({
|
|
8382
8438
|
editor: providedEditor,
|
|
8383
8439
|
hideWhenUnavailable = false,
|
|
@@ -8442,12 +8498,12 @@ TurnIntoDropdown.displayName = "TurnIntoDropdown";
|
|
|
8442
8498
|
// src/ui/undo-redo-button/undo-redo-button.tsx
|
|
8443
8499
|
var import_editor_utils30 = require("@kopexa/editor-utils");
|
|
8444
8500
|
var import_toolbar9 = require("@kopexa/toolbar");
|
|
8445
|
-
var
|
|
8501
|
+
var import_react60 = require("react");
|
|
8446
8502
|
|
|
8447
8503
|
// src/ui/undo-redo-button/use-undo-redo.ts
|
|
8448
8504
|
var import_editor_utils29 = require("@kopexa/editor-utils");
|
|
8449
8505
|
var import_icons25 = require("@kopexa/icons");
|
|
8450
|
-
var
|
|
8506
|
+
var import_react59 = require("react");
|
|
8451
8507
|
var import_react_intl24 = require("react-intl");
|
|
8452
8508
|
var UNDO_REDO_SHORTCUT_KEYS = {
|
|
8453
8509
|
undo: "mod+z",
|
|
@@ -8489,9 +8545,9 @@ function useUndoRedo(config) {
|
|
|
8489
8545
|
} = config;
|
|
8490
8546
|
const intl = (0, import_react_intl24.useIntl)();
|
|
8491
8547
|
const { editor } = (0, import_editor_utils29.useTiptapEditor)(providedEditor);
|
|
8492
|
-
const [isVisible, setIsVisible] = (0,
|
|
8548
|
+
const [isVisible, setIsVisible] = (0, import_react59.useState)(true);
|
|
8493
8549
|
const canExecute = canExecuteUndoRedoAction(editor, action);
|
|
8494
|
-
(0,
|
|
8550
|
+
(0, import_react59.useEffect)(() => {
|
|
8495
8551
|
if (!editor) return;
|
|
8496
8552
|
const handleUpdate = () => {
|
|
8497
8553
|
setIsVisible(shouldShowButton7({ editor, hideWhenUnavailable, action }));
|
|
@@ -8502,7 +8558,7 @@ function useUndoRedo(config) {
|
|
|
8502
8558
|
editor.off("transaction", handleUpdate);
|
|
8503
8559
|
};
|
|
8504
8560
|
}, [editor, hideWhenUnavailable, action]);
|
|
8505
|
-
const handleAction = (0,
|
|
8561
|
+
const handleAction = (0, import_react59.useCallback)(() => {
|
|
8506
8562
|
if (!editor) return false;
|
|
8507
8563
|
const success = executeUndoRedoAction(editor, action);
|
|
8508
8564
|
if (success) {
|
|
@@ -8540,7 +8596,7 @@ var UndoRedoButton = ({
|
|
|
8540
8596
|
hideWhenUnavailable,
|
|
8541
8597
|
onExecuted
|
|
8542
8598
|
});
|
|
8543
|
-
const handleClick = (0,
|
|
8599
|
+
const handleClick = (0, import_react60.useCallback)(
|
|
8544
8600
|
(event) => {
|
|
8545
8601
|
onClick == null ? void 0 : onClick(event);
|
|
8546
8602
|
if (event.defaultPrevented) return;
|
|
@@ -8582,7 +8638,7 @@ var EditorHeader = ({
|
|
|
8582
8638
|
const isMobile = (0, import_use_is_mobile3.useIsMobile)();
|
|
8583
8639
|
const windowSize = useWindowSize();
|
|
8584
8640
|
const { styles } = useEditorUIContext();
|
|
8585
|
-
const toolbarRef = (0,
|
|
8641
|
+
const toolbarRef = (0, import_react61.useRef)(null);
|
|
8586
8642
|
const bodyRect = useCursorVisibility({
|
|
8587
8643
|
editor,
|
|
8588
8644
|
overlayHeight: (_b = (_a = toolbarRef.current) == null ? void 0 : _a.getBoundingClientRect().height) != null ? _b : 0
|
|
@@ -8652,9 +8708,9 @@ function MoreOptions({
|
|
|
8652
8708
|
}) {
|
|
8653
8709
|
const intl = (0, import_react_intl25.useIntl)();
|
|
8654
8710
|
const { editor } = (0, import_editor_utils31.useTiptapEditor)(providedEditor);
|
|
8655
|
-
const [show, setShow] = (0,
|
|
8711
|
+
const [show, setShow] = (0, import_react61.useState)(false);
|
|
8656
8712
|
const moreOptionsLabel = intl.formatMessage(messages7.more_options);
|
|
8657
|
-
(0,
|
|
8713
|
+
(0, import_react61.useEffect)(() => {
|
|
8658
8714
|
if (!editor) return;
|
|
8659
8715
|
const handleSelectionUpdate = () => {
|
|
8660
8716
|
setShow(
|
|
@@ -8767,7 +8823,7 @@ var BasicEditor = ({
|
|
|
8767
8823
|
...options
|
|
8768
8824
|
});
|
|
8769
8825
|
const styles = (0, import_theme9.editorBasic)({ variant, bordered });
|
|
8770
|
-
const resolveVariable = (0,
|
|
8826
|
+
const resolveVariable = (0, import_react63.useCallback)(
|
|
8771
8827
|
(name) => variableValues == null ? void 0 : variableValues[name],
|
|
8772
8828
|
[variableValues]
|
|
8773
8829
|
);
|
|
@@ -8777,7 +8833,7 @@ var BasicEditor = ({
|
|
|
8777
8833
|
const isBottomToolbar = variant === "field";
|
|
8778
8834
|
const hasVariables = variables && variables.length > 0;
|
|
8779
8835
|
const hasPagination = !!pagesOptions;
|
|
8780
|
-
const editorContent = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(EditorUIProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: styles.root(), "data-slot": "editor", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
8836
|
+
const editorContent = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(EditorUIProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: styles.root(), "data-slot": "editor", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_react62.EditorContext.Provider, { value: { editor }, children: [
|
|
8781
8837
|
showToolbar && !isBottomToolbar && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(EditorHeader, { editor, variant }),
|
|
8782
8838
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
8783
8839
|
EditorContentArea,
|
|
@@ -8801,10 +8857,10 @@ var EditorContentArea = ({
|
|
|
8801
8857
|
hasPagination
|
|
8802
8858
|
}) => {
|
|
8803
8859
|
const styles = (0, import_theme9.editorBasic)({ variant });
|
|
8804
|
-
const { editor } = (0,
|
|
8860
|
+
const { editor } = (0, import_react63.useContext)(import_react62.EditorContext);
|
|
8805
8861
|
const { isDragging } = useUiEditorState(editor);
|
|
8806
8862
|
useScrollToHash();
|
|
8807
|
-
const handleKeyDown = (0,
|
|
8863
|
+
const handleKeyDown = (0, import_react63.useCallback)(
|
|
8808
8864
|
(e) => {
|
|
8809
8865
|
if (!(editor == null ? void 0 : editor.isFocused)) return;
|
|
8810
8866
|
const isMod = e.metaKey || e.ctrlKey;
|
|
@@ -8848,7 +8904,7 @@ var EditorContentArea = ({
|
|
|
8848
8904
|
// biome-ignore lint/a11y/noStaticElementInteractions: Wrapper intercepts keyboard shortcuts to prevent propagation
|
|
8849
8905
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: styles.wrapper(), onKeyDown: handleKeyDown, children: [
|
|
8850
8906
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
8851
|
-
|
|
8907
|
+
import_react62.EditorContent,
|
|
8852
8908
|
{
|
|
8853
8909
|
editor,
|
|
8854
8910
|
role: "presentation",
|
|
@@ -8912,7 +8968,7 @@ function LoadingSpinner({ text = "Connecting..." }) {
|
|
|
8912
8968
|
|
|
8913
8969
|
// src/presets/view/index.tsx
|
|
8914
8970
|
var import_theme10 = require("@kopexa/theme");
|
|
8915
|
-
var
|
|
8971
|
+
var import_react64 = require("@tiptap/react");
|
|
8916
8972
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
8917
8973
|
function EditorView({
|
|
8918
8974
|
content,
|
|
@@ -8932,8 +8988,8 @@ function EditorView({
|
|
|
8932
8988
|
if (!editor) {
|
|
8933
8989
|
return null;
|
|
8934
8990
|
}
|
|
8935
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: styles.root({ className }), "data-slot": "editor-view", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
8936
|
-
|
|
8991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: styles.root({ className }), "data-slot": "editor-view", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_react64.EditorContext.Provider, { value: { editor }, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: styles.wrapper(), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
8992
|
+
import_react64.EditorContent,
|
|
8937
8993
|
{
|
|
8938
8994
|
editor,
|
|
8939
8995
|
role: "presentation",
|
|
@@ -8945,7 +9001,7 @@ function EditorView({
|
|
|
8945
9001
|
// src/presets/view/static.tsx
|
|
8946
9002
|
var import_theme11 = require("@kopexa/theme");
|
|
8947
9003
|
var import_html = require("@tiptap/html");
|
|
8948
|
-
var
|
|
9004
|
+
var import_react65 = require("react");
|
|
8949
9005
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
8950
9006
|
function EditorStaticView({
|
|
8951
9007
|
content,
|
|
@@ -8955,7 +9011,7 @@ function EditorStaticView({
|
|
|
8955
9011
|
customExtensions,
|
|
8956
9012
|
disabled
|
|
8957
9013
|
}) {
|
|
8958
|
-
const extensions = (0,
|
|
9014
|
+
const extensions = (0, import_react65.useMemo)(
|
|
8959
9015
|
() => getExtensions({
|
|
8960
9016
|
editable: false,
|
|
8961
9017
|
customExtensions,
|
|
@@ -8963,7 +9019,7 @@ function EditorStaticView({
|
|
|
8963
9019
|
}),
|
|
8964
9020
|
[customExtensions, disabled]
|
|
8965
9021
|
);
|
|
8966
|
-
const html = (0,
|
|
9022
|
+
const html = (0, import_react65.useMemo)(() => {
|
|
8967
9023
|
const parsed = safeParseContent(content);
|
|
8968
9024
|
if (!parsed) return "";
|
|
8969
9025
|
const json = parsed;
|
package/dist/index.mjs
CHANGED
|
@@ -3330,6 +3330,60 @@ import {
|
|
|
3330
3330
|
import { StarterKit } from "@tiptap/starter-kit";
|
|
3331
3331
|
import { useEffect as useEffect14, useRef as useRef8, useState as useState13 } from "react";
|
|
3332
3332
|
|
|
3333
|
+
// src/extensions/custom-color/index.ts
|
|
3334
|
+
import { Mark, mergeAttributes as mergeAttributes6 } from "@tiptap/react";
|
|
3335
|
+
var CustomColor = Mark.create({
|
|
3336
|
+
name: "customColor",
|
|
3337
|
+
addAttributes() {
|
|
3338
|
+
return {
|
|
3339
|
+
color: {
|
|
3340
|
+
default: null,
|
|
3341
|
+
parseHTML: (element) => element.getAttribute("data-text-color"),
|
|
3342
|
+
renderHTML: (attributes) => {
|
|
3343
|
+
const { color } = attributes;
|
|
3344
|
+
if (!color) {
|
|
3345
|
+
return {};
|
|
3346
|
+
}
|
|
3347
|
+
return {
|
|
3348
|
+
"data-text-color": color,
|
|
3349
|
+
style: `color: ${color}`
|
|
3350
|
+
};
|
|
3351
|
+
}
|
|
3352
|
+
},
|
|
3353
|
+
backgroundColor: {
|
|
3354
|
+
default: null,
|
|
3355
|
+
parseHTML: (element) => element.getAttribute("data-background-color"),
|
|
3356
|
+
renderHTML: (attributes) => {
|
|
3357
|
+
const { backgroundColor } = attributes;
|
|
3358
|
+
if (!backgroundColor) {
|
|
3359
|
+
return {};
|
|
3360
|
+
}
|
|
3361
|
+
return {
|
|
3362
|
+
"data-background-color": backgroundColor,
|
|
3363
|
+
style: `background-color: ${backgroundColor}`
|
|
3364
|
+
};
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
};
|
|
3368
|
+
},
|
|
3369
|
+
parseHTML() {
|
|
3370
|
+
return [
|
|
3371
|
+
{
|
|
3372
|
+
tag: "span[data-text-color]"
|
|
3373
|
+
},
|
|
3374
|
+
{
|
|
3375
|
+
tag: "span[data-background-color]"
|
|
3376
|
+
}
|
|
3377
|
+
];
|
|
3378
|
+
},
|
|
3379
|
+
renderHTML({ HTMLAttributes }) {
|
|
3380
|
+
if (!HTMLAttributes["data-text-color"] && !HTMLAttributes["data-background-color"]) {
|
|
3381
|
+
return ["span", mergeAttributes6(HTMLAttributes), 0];
|
|
3382
|
+
}
|
|
3383
|
+
return ["span", mergeAttributes6(HTMLAttributes), 0];
|
|
3384
|
+
}
|
|
3385
|
+
});
|
|
3386
|
+
|
|
3333
3387
|
// src/extensions/link/index.ts
|
|
3334
3388
|
import TiptapLink from "@tiptap/extension-link";
|
|
3335
3389
|
import { Plugin, PluginKey as PluginKey3, TextSelection } from "@tiptap/pm/state";
|
|
@@ -4191,6 +4245,8 @@ function getExtensions({
|
|
|
4191
4245
|
CalloutNode,
|
|
4192
4246
|
MathBlock,
|
|
4193
4247
|
InlineMath,
|
|
4248
|
+
// Legacy support for old documents with customColor marks
|
|
4249
|
+
CustomColor,
|
|
4194
4250
|
// Image support - extended with file reference resolution
|
|
4195
4251
|
ImageNode.configure({
|
|
4196
4252
|
allowBase64: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kopexa/tiptap",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.11.1",
|
|
4
4
|
"description": "our tiptap components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tiptap"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"react": ">=19.0.0-rc.0",
|
|
31
31
|
"react-dom": ">=19.0.0-rc.0",
|
|
32
32
|
"yjs": "^13.6.0",
|
|
33
|
-
"@kopexa/theme": "17.
|
|
33
|
+
"@kopexa/theme": "17.26.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@floating-ui/dom": "^1.7.6",
|
|
@@ -67,29 +67,29 @@
|
|
|
67
67
|
"react-hotkeys-hook": "^5.2.4",
|
|
68
68
|
"react-intl": "^7.1.14",
|
|
69
69
|
"y-indexeddb": "^9.0.12",
|
|
70
|
-
"@kopexa/button": "17.0.
|
|
71
|
-
"@kopexa/
|
|
72
|
-
"@kopexa/dropdown-menu": "17.0.
|
|
73
|
-
"@kopexa/
|
|
70
|
+
"@kopexa/button": "17.0.63",
|
|
71
|
+
"@kopexa/callout": "17.0.63",
|
|
72
|
+
"@kopexa/dropdown-menu": "17.0.63",
|
|
73
|
+
"@kopexa/dialog": "17.2.28",
|
|
74
|
+
"@kopexa/chip": "17.1.60",
|
|
75
|
+
"@kopexa/editor-utils": "17.2.4",
|
|
74
76
|
"@kopexa/extension-pages": "17.0.45",
|
|
75
|
-
"@kopexa/
|
|
76
|
-
"@kopexa/
|
|
77
|
-
"@kopexa/extension-table": "17.1.
|
|
78
|
-
"@kopexa/extension-
|
|
79
|
-
"@kopexa/input": "17.0.
|
|
80
|
-
"@kopexa/
|
|
81
|
-
"@kopexa/
|
|
82
|
-
"@kopexa/
|
|
83
|
-
"@kopexa/
|
|
84
|
-
"@kopexa/
|
|
85
|
-
"@kopexa/
|
|
86
|
-
"@kopexa/
|
|
87
|
-
"@kopexa/shared-utils": "17.0.
|
|
88
|
-
"@kopexa/tabs": "17.0.
|
|
89
|
-
"@kopexa/
|
|
90
|
-
"@kopexa/use-
|
|
91
|
-
"@kopexa/separator": "17.0.61",
|
|
92
|
-
"@kopexa/use-is-mobile": "17.0.61"
|
|
77
|
+
"@kopexa/extension-code": "17.0.63",
|
|
78
|
+
"@kopexa/icons": "17.7.28",
|
|
79
|
+
"@kopexa/extension-table": "17.1.15",
|
|
80
|
+
"@kopexa/extension-controlref": "17.1.45",
|
|
81
|
+
"@kopexa/input": "17.0.63",
|
|
82
|
+
"@kopexa/label": "17.0.63",
|
|
83
|
+
"@kopexa/popover": "17.2.28",
|
|
84
|
+
"@kopexa/select": "17.2.28",
|
|
85
|
+
"@kopexa/switch": "17.2.28",
|
|
86
|
+
"@kopexa/separator": "17.0.63",
|
|
87
|
+
"@kopexa/react-utils": "17.1.5",
|
|
88
|
+
"@kopexa/toolbar": "17.2.28",
|
|
89
|
+
"@kopexa/shared-utils": "17.0.63",
|
|
90
|
+
"@kopexa/tabs": "17.0.63",
|
|
91
|
+
"@kopexa/use-composed-ref": "17.0.63",
|
|
92
|
+
"@kopexa/use-is-mobile": "17.0.63"
|
|
93
93
|
},
|
|
94
94
|
"clean-package": "../../../clean-package.config.json",
|
|
95
95
|
"module": "dist/index.mjs",
|