@kopexa/tiptap 1.0.0 → 2.0.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/{chunk-AASYBJDX.mjs → chunk-2SI7MRAE.mjs} +1 -1
- package/dist/{chunk-6W7J7PHZ.mjs → chunk-B2DHYFSH.mjs} +6 -7
- package/dist/{chunk-RQPJU4UB.mjs → chunk-B7WJOQ3X.mjs} +1 -1
- package/dist/{chunk-ACWAVTTK.mjs → chunk-BEV5U2DK.mjs} +6 -6
- package/dist/{chunk-TGQP45HH.mjs → chunk-EHY2NAW7.mjs} +1 -3
- package/dist/{chunk-O5P45H3I.mjs → chunk-GYIYX2JH.mjs} +1 -1
- package/dist/{chunk-QCULSZRZ.mjs → chunk-IOB3REX6.mjs} +1 -3
- package/dist/{chunk-ILPDDC4W.mjs → chunk-IQERE7KP.mjs} +1 -4
- package/dist/{chunk-6SS62RYU.mjs → chunk-JNL4KY45.mjs} +1 -3
- package/dist/{chunk-R2RRQUU5.mjs → chunk-LHXRE26G.mjs} +2 -2
- package/dist/{chunk-F2HHFSM4.mjs → chunk-LNVWG34E.mjs} +1 -4
- package/dist/chunk-NUCXXNTA.mjs +131 -0
- package/dist/{chunk-GLQRF7PR.mjs → chunk-OEVR5N7X.mjs} +2 -10
- package/dist/{chunk-YYHNT322.mjs → chunk-OZWCQMRA.mjs} +27 -19
- package/dist/{chunk-OX2A52WL.mjs → chunk-Q7DFJ5NI.mjs} +2 -4
- package/dist/{chunk-ODBSAQ5V.mjs → chunk-QF3YHPWM.mjs} +2 -4
- package/dist/{chunk-R5AMMJTQ.mjs → chunk-REJEJXOZ.mjs} +3 -3
- package/dist/chunk-TZQQ6C2Q.mjs +101 -0
- package/dist/{chunk-KI3YOPAA.mjs → chunk-UJ4BNZ63.mjs} +1 -4
- package/dist/{chunk-4LAWYE7B.mjs → chunk-V6TAZMQN.mjs} +2 -4
- package/dist/{chunk-QP2LCU5N.mjs → chunk-VX3HSJ76.mjs} +2 -2
- package/dist/{chunk-WCBSINO5.mjs → chunk-W2FLOOJ6.mjs} +1 -1
- package/dist/{chunk-JHMEXFB3.mjs → chunk-WHJ4B43N.mjs} +1 -1
- package/dist/{chunk-YD56B5SG.mjs → chunk-WPRDVMPN.mjs} +19 -18
- package/dist/{chunk-44V2Y6IU.mjs → chunk-XL5FS7LN.mjs} +3 -3
- package/dist/{chunk-ZSYXHD7D.mjs → chunk-YJAHZXLG.mjs} +1 -4
- package/dist/{chunk-T7LL5ZSR.mjs → chunk-ZVTJ6XD7.mjs} +1 -3
- package/dist/{chunk-I7WKP3OM.mjs → chunk-ZZ4OU46C.mjs} +6 -6
- package/dist/context/editor-context.d.mts +4 -4
- package/dist/context/editor-context.d.ts +4 -4
- package/dist/context/editor-context.js +5 -5
- package/dist/context/editor-context.mjs +5 -6
- package/dist/extensions/link/index.mjs +0 -1
- package/dist/extensions/selection/index.mjs +0 -1
- package/dist/extensions/trailing-node/index.mjs +0 -1
- package/dist/extensions/ui-state/index.mjs +0 -1
- package/dist/hooks/use-create-editor.d.mts +16 -5
- package/dist/hooks/use-create-editor.d.ts +16 -5
- package/dist/hooks/use-create-editor.js +84 -1062
- package/dist/hooks/use-create-editor.mjs +5 -18
- package/dist/hooks/use-cursor-visibility.mjs +0 -1
- package/dist/hooks/use-floating-element.mjs +0 -1
- package/dist/hooks/use-floating-toolbar-visibility.mjs +0 -1
- package/dist/hooks/use-menu-navigation.mjs +0 -1
- package/dist/hooks/use-tiptap-editor.mjs +0 -1
- package/dist/hooks/use-ui-editor-state.mjs +0 -1
- package/dist/hooks/use-window-size.mjs +0 -1
- package/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +483 -1584
- package/dist/index.mjs +39 -60
- package/dist/presets/basic/editor-header.js +112 -167
- package/dist/presets/basic/editor-header.mjs +25 -25
- package/dist/presets/basic/index.d.mts +6 -3
- package/dist/presets/basic/index.d.ts +6 -3
- package/dist/presets/basic/index.js +386 -1468
- package/dist/presets/basic/index.mjs +32 -46
- package/dist/ui/blockquote-button/blockquote-button.js +12 -67
- package/dist/ui/blockquote-button/blockquote-button.mjs +2 -4
- package/dist/ui/blockquote-button/index.js +12 -67
- package/dist/ui/blockquote-button/index.mjs +2 -4
- package/dist/ui/blockquote-button/use-blockquote.js +12 -65
- package/dist/ui/blockquote-button/use-blockquote.mjs +1 -3
- package/dist/ui/codeblock-button/code-block-button.js +13 -76
- package/dist/ui/codeblock-button/code-block-button.mjs +2 -4
- package/dist/ui/codeblock-button/index.js +13 -76
- package/dist/ui/codeblock-button/index.mjs +2 -4
- package/dist/ui/codeblock-button/use-code-block.js +12 -65
- package/dist/ui/codeblock-button/use-code-block.mjs +1 -3
- package/dist/ui/color-highlight-button/color-highlight-button.js +3 -23
- package/dist/ui/color-highlight-button/color-highlight-button.mjs +2 -4
- package/dist/ui/color-highlight-button/index.js +3 -23
- package/dist/ui/color-highlight-button/index.mjs +2 -4
- package/dist/ui/color-highlight-button/use-color-highlight.js +3 -21
- package/dist/ui/color-highlight-button/use-color-highlight.mjs +1 -3
- package/dist/ui/color-highlight-popover/color-highlight-popover.js +4 -24
- package/dist/ui/color-highlight-popover/color-highlight-popover.mjs +3 -5
- package/dist/ui/color-highlight-popover/index.js +4 -24
- package/dist/ui/color-highlight-popover/index.mjs +3 -5
- package/dist/ui/copy-anchor-link-button/use-scroll-to-hash.js +2 -18
- package/dist/ui/copy-anchor-link-button/use-scroll-to-hash.mjs +1 -3
- package/dist/ui/heading-button/index.js +2 -9
- package/dist/ui/heading-button/index.mjs +1 -3
- package/dist/ui/heading-button/utils.mjs +0 -1
- package/dist/ui/heading-dropdown-menu/index.js +4 -10
- package/dist/ui/heading-dropdown-menu/index.mjs +2 -4
- package/dist/ui/link-popover/index.js +2 -6
- package/dist/ui/link-popover/index.mjs +3 -4
- package/dist/ui/link-popover/link-popover.js +2 -6
- package/dist/ui/link-popover/link-popover.mjs +3 -4
- package/dist/ui/link-popover/use-link-popover.js +2 -6
- package/dist/ui/link-popover/use-link-popover.mjs +2 -3
- package/dist/ui/list-button/index.js +2 -9
- package/dist/ui/list-button/index.mjs +1 -3
- package/dist/ui/list-dropdown-menu/index.js +4 -10
- package/dist/ui/list-dropdown-menu/index.mjs +2 -4
- package/dist/ui/mark-button/index.js +3 -21
- package/dist/ui/mark-button/index.mjs +1 -3
- package/dist/ui/reset-all-formatting-button/index.mjs +0 -1
- package/dist/ui/reset-all-formatting-button/reset-all-formatting-button.mjs +0 -1
- package/dist/ui/reset-all-formatting-button/use-reset-all-formatting.mjs +0 -1
- package/dist/ui/slash-dropdown-menu/index.js +27 -129
- package/dist/ui/slash-dropdown-menu/index.mjs +3 -5
- package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.js +27 -129
- package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.mjs +3 -5
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.js +23 -116
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.mjs +2 -4
- package/dist/ui/suggestion-menu/index.mjs +0 -1
- package/dist/ui/suggestion-menu/suggestion-menu-utils.mjs +0 -1
- package/dist/ui/suggestion-menu/suggestion-menu.mjs +0 -1
- package/dist/ui/table-button/index.js +4 -24
- package/dist/ui/table-button/index.mjs +2 -4
- package/dist/ui/table-button/use-table.js +3 -21
- package/dist/ui/table-button/use-table.mjs +1 -3
- package/dist/ui/text-align-button/index.js +3 -32
- package/dist/ui/text-align-button/index.mjs +2 -4
- package/dist/ui/text-align-button/text-align-button.js +3 -32
- package/dist/ui/text-align-button/text-align-button.mjs +2 -4
- package/dist/ui/text-align-button/use-text-align.js +3 -30
- package/dist/ui/text-align-button/use-text-align.mjs +1 -3
- package/dist/ui/undo-redo-button/index.js +2 -18
- package/dist/ui/undo-redo-button/index.mjs +2 -4
- package/dist/ui/undo-redo-button/undo-redo-button.js +2 -18
- package/dist/ui/undo-redo-button/undo-redo-button.mjs +2 -4
- package/dist/ui/undo-redo-button/use-undo-redo.js +2 -16
- package/dist/ui/undo-redo-button/use-undo-redo.mjs +1 -3
- package/dist/utils/index.d.mts +1 -101
- package/dist/utils/index.d.ts +1 -101
- package/dist/utils/index.js +0 -166
- package/dist/utils/index.mjs +1 -28
- package/dist/utils/safe-parse.mjs +0 -1
- package/package.json +36 -30
- package/dist/chunk-4HTILXJM.mjs +0 -104
- package/dist/chunk-4IIGLBTD.mjs +0 -81
- package/dist/chunk-574UV65T.mjs +0 -111
- package/dist/chunk-7HC7D256.mjs +0 -91
- package/dist/chunk-AC22DSDA.mjs +0 -540
- package/dist/chunk-AGOMESFC.mjs +0 -1
- package/dist/chunk-BXPGSCTT.mjs +0 -39
- package/dist/chunk-C6M3CDOK.mjs +0 -254
- package/dist/chunk-EN3J5AMF.mjs +0 -12
- package/dist/chunk-HYDS6H67.mjs +0 -58
- package/dist/chunk-KRLE4MMD.mjs +0 -116
- package/dist/chunk-LKOQAQPZ.mjs +0 -13
- package/dist/chunk-LXZ53XU7.mjs +0 -1
- package/dist/chunk-T6P7CS4F.mjs +0 -42
- package/dist/chunk-TVFWG7IC.mjs +0 -43
- package/dist/chunk-VULWMVYS.mjs +0 -11
- package/dist/chunk-WKV76XOR.mjs +0 -8
- package/dist/extensions/table/index.d.mts +0 -8
- package/dist/extensions/table/index.d.ts +0 -8
- package/dist/extensions/table/index.js +0 -1044
- package/dist/extensions/table/index.mjs +0 -33
- package/dist/extensions/table/kit.d.mts +0 -30
- package/dist/extensions/table/kit.d.ts +0 -30
- package/dist/extensions/table/kit.js +0 -1034
- package/dist/extensions/table/kit.mjs +0 -20
- package/dist/extensions/table/table/icons.d.mts +0 -13
- package/dist/extensions/table/table/icons.d.ts +0 -13
- package/dist/extensions/table/table/icons.js +0 -81
- package/dist/extensions/table/table/icons.mjs +0 -8
- package/dist/extensions/table/table/index.d.mts +0 -3
- package/dist/extensions/table/table/index.d.ts +0 -3
- package/dist/extensions/table/table/index.js +0 -818
- package/dist/extensions/table/table/index.mjs +0 -16
- package/dist/extensions/table/table/table-controls.d.mts +0 -10
- package/dist/extensions/table/table/table-controls.d.ts +0 -10
- package/dist/extensions/table/table/table-controls.js +0 -129
- package/dist/extensions/table/table/table-controls.mjs +0 -8
- package/dist/extensions/table/table/table-view.d.mts +0 -43
- package/dist/extensions/table/table/table-view.d.ts +0 -43
- package/dist/extensions/table/table/table-view.js +0 -610
- package/dist/extensions/table/table/table-view.mjs +0 -12
- package/dist/extensions/table/table/table.d.mts +0 -17
- package/dist/extensions/table/table/table.d.ts +0 -17
- package/dist/extensions/table/table/table.js +0 -816
- package/dist/extensions/table/table/table.mjs +0 -15
- package/dist/extensions/table/table/utilities/col-style.d.mts +0 -3
- package/dist/extensions/table/table/utilities/col-style.d.ts +0 -3
- package/dist/extensions/table/table/utilities/col-style.js +0 -36
- package/dist/extensions/table/table/utilities/col-style.mjs +0 -8
- package/dist/extensions/table/table/utilities/delete-table-when-all-cells-selected.d.mts +0 -5
- package/dist/extensions/table/table/utilities/delete-table-when-all-cells-selected.d.ts +0 -5
- package/dist/extensions/table/table/utilities/delete-table-when-all-cells-selected.js +0 -66
- package/dist/extensions/table/table/utilities/delete-table-when-all-cells-selected.mjs +0 -40
- package/dist/extensions/table/table/utilities/get-table-node-types.d.mts +0 -7
- package/dist/extensions/table/table/utilities/get-table-node-types.d.ts +0 -7
- package/dist/extensions/table/table/utilities/get-table-node-types.js +0 -44
- package/dist/extensions/table/table/utilities/get-table-node-types.mjs +0 -21
- package/dist/extensions/table/table/utilities/insert-line-above-table-action.d.mts +0 -5
- package/dist/extensions/table/table/utilities/insert-line-above-table-action.d.ts +0 -5
- package/dist/extensions/table/table/utilities/insert-line-above-table-action.js +0 -80
- package/dist/extensions/table/table/utilities/insert-line-above-table-action.mjs +0 -9
- package/dist/extensions/table/table/utilities/insert-line-below-table-action.d.mts +0 -5
- package/dist/extensions/table/table/utilities/insert-line-below-table-action.d.ts +0 -5
- package/dist/extensions/table/table/utilities/insert-line-below-table-action.js +0 -79
- package/dist/extensions/table/table/utilities/insert-line-below-table-action.mjs +0 -9
- package/dist/extensions/table/table/utilities/is-cell-selection.d.mts +0 -5
- package/dist/extensions/table/table/utilities/is-cell-selection.d.ts +0 -5
- package/dist/extensions/table/table/utilities/is-cell-selection.js +0 -34
- package/dist/extensions/table/table/utilities/is-cell-selection.mjs +0 -8
- package/dist/extensions/table/table-cell.d.mts +0 -8
- package/dist/extensions/table/table-cell.d.ts +0 -8
- package/dist/extensions/table/table-cell.js +0 -139
- package/dist/extensions/table/table-cell.mjs +0 -8
- package/dist/extensions/table/table-header.d.mts +0 -6
- package/dist/extensions/table/table-header.d.ts +0 -6
- package/dist/extensions/table/table-header.js +0 -104
- package/dist/extensions/table/table-header.mjs +0 -8
- package/dist/extensions/table/table-row.d.mts +0 -6
- package/dist/extensions/table/table-row.d.ts +0 -6
- package/dist/extensions/table/table-row.js +0 -35
- package/dist/extensions/table/table-row.mjs +0 -8
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
CodeBlockButton
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-C6M3CDOK.mjs";
|
|
4
|
+
} from "../../chunk-OEVR5N7X.mjs";
|
|
5
|
+
import "../../chunk-BEV5U2DK.mjs";
|
|
7
6
|
import "../../chunk-P55PLOHR.mjs";
|
|
8
|
-
import "../../chunk-WKV76XOR.mjs";
|
|
9
7
|
export {
|
|
10
8
|
CodeBlockButton
|
|
11
9
|
};
|
|
@@ -75,70 +75,15 @@ function useTiptapEditor(providedEditor) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// src/ui/codeblock-button/use-code-block.ts
|
|
78
|
+
var import_editor_utils = require("@kopexa/editor-utils");
|
|
78
79
|
var import_icons = require("@kopexa/icons");
|
|
79
|
-
var import_state2 = require("@tiptap/pm/state");
|
|
80
|
-
var React = __toESM(require("react"));
|
|
81
|
-
|
|
82
|
-
// src/utils/index.ts
|
|
83
80
|
var import_state = require("@tiptap/pm/state");
|
|
84
|
-
var
|
|
85
|
-
var isNodeInSchema = (nodeName, editor) => {
|
|
86
|
-
if (!(editor == null ? void 0 : editor.schema)) return false;
|
|
87
|
-
return editor.schema.spec.nodes.get(nodeName) !== void 0;
|
|
88
|
-
};
|
|
89
|
-
function findNodePosition(props) {
|
|
90
|
-
var _a;
|
|
91
|
-
const { editor, node, nodePos } = props;
|
|
92
|
-
if (!editor || !((_a = editor.state) == null ? void 0 : _a.doc)) return null;
|
|
93
|
-
const hasValidNode = node !== void 0 && node !== null;
|
|
94
|
-
const hasValidPos = nodePos !== void 0 && nodePos !== null;
|
|
95
|
-
if (!hasValidNode && !hasValidPos) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
if (hasValidPos) {
|
|
99
|
-
try {
|
|
100
|
-
const nodeAtPos = editor.state.doc.nodeAt(nodePos);
|
|
101
|
-
if (nodeAtPos) {
|
|
102
|
-
return { pos: nodePos, node: nodeAtPos };
|
|
103
|
-
}
|
|
104
|
-
} catch (error) {
|
|
105
|
-
console.error("Error checking node at position:", error);
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
let foundPos = -1;
|
|
110
|
-
let foundNode = null;
|
|
111
|
-
editor.state.doc.descendants((currentNode, pos) => {
|
|
112
|
-
if (currentNode === node) {
|
|
113
|
-
foundPos = pos;
|
|
114
|
-
foundNode = currentNode;
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
return true;
|
|
118
|
-
});
|
|
119
|
-
return foundPos !== -1 && foundNode !== null ? { pos: foundPos, node: foundNode } : null;
|
|
120
|
-
}
|
|
121
|
-
function isNodeTypeSelected(editor, types = []) {
|
|
122
|
-
if (!editor || !editor.state.selection) return false;
|
|
123
|
-
const { state } = editor;
|
|
124
|
-
const { selection } = state;
|
|
125
|
-
if (selection.empty) return false;
|
|
126
|
-
if (selection instanceof import_state.NodeSelection) {
|
|
127
|
-
const node = selection.node;
|
|
128
|
-
return node ? types.includes(node.type.name) : false;
|
|
129
|
-
}
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
function isValidPosition(pos) {
|
|
133
|
-
return typeof pos === "number" && pos >= 0;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// src/ui/codeblock-button/use-code-block.ts
|
|
81
|
+
var React = __toESM(require("react"));
|
|
137
82
|
var CODE_BLOCK_SHORTCUT_KEY = "mod+alt+c";
|
|
138
83
|
function canToggle(editor, turnInto = true) {
|
|
139
84
|
var _a;
|
|
140
85
|
if (!editor || !editor.isEditable) return false;
|
|
141
|
-
if (!isNodeInSchema("codeBlock", editor) || isNodeTypeSelected(editor, ["image"]))
|
|
86
|
+
if (!(0, import_editor_utils.isNodeInSchema)("codeBlock", editor) || (0, import_editor_utils.isNodeTypeSelected)(editor, ["image"]))
|
|
142
87
|
return false;
|
|
143
88
|
if (!turnInto) {
|
|
144
89
|
return editor.can().toggleNode("codeBlock", "paragraph");
|
|
@@ -147,12 +92,12 @@ function canToggle(editor, turnInto = true) {
|
|
|
147
92
|
const view = editor.view;
|
|
148
93
|
const state = view.state;
|
|
149
94
|
const selection = state.selection;
|
|
150
|
-
if (selection.empty || selection instanceof
|
|
151
|
-
const pos = (_a = findNodePosition({
|
|
95
|
+
if (selection.empty || selection instanceof import_state.TextSelection) {
|
|
96
|
+
const pos = (_a = (0, import_editor_utils.findNodePosition)({
|
|
152
97
|
editor,
|
|
153
98
|
node: state.selection.$anchor.node(1)
|
|
154
99
|
})) == null ? void 0 : _a.pos;
|
|
155
|
-
if (!isValidPosition(pos)) return false;
|
|
100
|
+
if (!(0, import_editor_utils.isValidPosition)(pos)) return false;
|
|
156
101
|
}
|
|
157
102
|
return true;
|
|
158
103
|
} catch {
|
|
@@ -167,19 +112,19 @@ function toggleCodeBlock(editor) {
|
|
|
167
112
|
const view = editor.view;
|
|
168
113
|
let state = view.state;
|
|
169
114
|
let tr = state.tr;
|
|
170
|
-
if (state.selection.empty || state.selection instanceof
|
|
171
|
-
const pos = (_a = findNodePosition({
|
|
115
|
+
if (state.selection.empty || state.selection instanceof import_state.TextSelection) {
|
|
116
|
+
const pos = (_a = (0, import_editor_utils.findNodePosition)({
|
|
172
117
|
editor,
|
|
173
118
|
node: state.selection.$anchor.node(1)
|
|
174
119
|
})) == null ? void 0 : _a.pos;
|
|
175
|
-
if (!isValidPosition(pos)) return false;
|
|
176
|
-
tr = tr.setSelection(
|
|
120
|
+
if (!(0, import_editor_utils.isValidPosition)(pos)) return false;
|
|
121
|
+
tr = tr.setSelection(import_state.NodeSelection.create(state.doc, pos));
|
|
177
122
|
view.dispatch(tr);
|
|
178
123
|
state = view.state;
|
|
179
124
|
}
|
|
180
125
|
const selection = state.selection;
|
|
181
126
|
let chain = editor.chain().focus();
|
|
182
|
-
if (selection instanceof
|
|
127
|
+
if (selection instanceof import_state.NodeSelection) {
|
|
183
128
|
const firstChild = (_b = selection.node.firstChild) == null ? void 0 : _b.firstChild;
|
|
184
129
|
const lastChild = (_c = selection.node.lastChild) == null ? void 0 : _c.lastChild;
|
|
185
130
|
const from = firstChild ? selection.from + firstChild.nodeSize : selection.from + 1;
|
|
@@ -197,7 +142,7 @@ function toggleCodeBlock(editor) {
|
|
|
197
142
|
function shouldShowButton(props) {
|
|
198
143
|
const { editor, hideWhenUnavailable } = props;
|
|
199
144
|
if (!editor || !editor.isEditable) return false;
|
|
200
|
-
if (!isNodeInSchema("codeBlock", editor)) return false;
|
|
145
|
+
if (!(0, import_editor_utils.isNodeInSchema)("codeBlock", editor)) return false;
|
|
201
146
|
if (hideWhenUnavailable && !editor.isActive("code")) {
|
|
202
147
|
return canToggle(editor);
|
|
203
148
|
}
|
|
@@ -256,15 +201,7 @@ var CodeBlockButton = ({
|
|
|
256
201
|
...buttonProps
|
|
257
202
|
}) => {
|
|
258
203
|
const { editor } = useTiptapEditor(providedEditor);
|
|
259
|
-
const {
|
|
260
|
-
isVisible,
|
|
261
|
-
canToggle: canToggle2,
|
|
262
|
-
isActive,
|
|
263
|
-
handleToggle,
|
|
264
|
-
label,
|
|
265
|
-
shortcutKeys,
|
|
266
|
-
Icon
|
|
267
|
-
} = useCodeBlock({
|
|
204
|
+
const { isVisible, canToggle: canToggle2, isActive, handleToggle, label, shortcutKeys } = useCodeBlock({
|
|
268
205
|
editor,
|
|
269
206
|
hideWhenUnavailable,
|
|
270
207
|
onToggled
|
|
@@ -2,17 +2,15 @@
|
|
|
2
2
|
import "../../chunk-ATRHILCH.mjs";
|
|
3
3
|
import {
|
|
4
4
|
CodeBlockButton
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-OEVR5N7X.mjs";
|
|
6
6
|
import {
|
|
7
7
|
CODE_BLOCK_SHORTCUT_KEY,
|
|
8
8
|
canToggle,
|
|
9
9
|
shouldShowButton,
|
|
10
10
|
toggleCodeBlock,
|
|
11
11
|
useCodeBlock
|
|
12
|
-
} from "../../chunk-
|
|
13
|
-
import "../../chunk-C6M3CDOK.mjs";
|
|
12
|
+
} from "../../chunk-BEV5U2DK.mjs";
|
|
14
13
|
import "../../chunk-P55PLOHR.mjs";
|
|
15
|
-
import "../../chunk-WKV76XOR.mjs";
|
|
16
14
|
export {
|
|
17
15
|
CODE_BLOCK_SHORTCUT_KEY,
|
|
18
16
|
CodeBlockButton,
|
|
@@ -39,8 +39,9 @@ __export(use_code_block_exports, {
|
|
|
39
39
|
useCodeBlock: () => useCodeBlock
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(use_code_block_exports);
|
|
42
|
+
var import_editor_utils = require("@kopexa/editor-utils");
|
|
42
43
|
var import_icons = require("@kopexa/icons");
|
|
43
|
-
var
|
|
44
|
+
var import_state = require("@tiptap/pm/state");
|
|
44
45
|
var React = __toESM(require("react"));
|
|
45
46
|
|
|
46
47
|
// src/hooks/use-tiptap-editor.ts
|
|
@@ -72,66 +73,12 @@ function useTiptapEditor(providedEditor) {
|
|
|
72
73
|
return editorState || { editor: null };
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
// src/utils/index.ts
|
|
76
|
-
var import_state = require("@tiptap/pm/state");
|
|
77
|
-
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
78
|
-
var isNodeInSchema = (nodeName, editor) => {
|
|
79
|
-
if (!(editor == null ? void 0 : editor.schema)) return false;
|
|
80
|
-
return editor.schema.spec.nodes.get(nodeName) !== void 0;
|
|
81
|
-
};
|
|
82
|
-
function findNodePosition(props) {
|
|
83
|
-
var _a;
|
|
84
|
-
const { editor, node, nodePos } = props;
|
|
85
|
-
if (!editor || !((_a = editor.state) == null ? void 0 : _a.doc)) return null;
|
|
86
|
-
const hasValidNode = node !== void 0 && node !== null;
|
|
87
|
-
const hasValidPos = nodePos !== void 0 && nodePos !== null;
|
|
88
|
-
if (!hasValidNode && !hasValidPos) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
if (hasValidPos) {
|
|
92
|
-
try {
|
|
93
|
-
const nodeAtPos = editor.state.doc.nodeAt(nodePos);
|
|
94
|
-
if (nodeAtPos) {
|
|
95
|
-
return { pos: nodePos, node: nodeAtPos };
|
|
96
|
-
}
|
|
97
|
-
} catch (error) {
|
|
98
|
-
console.error("Error checking node at position:", error);
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
let foundPos = -1;
|
|
103
|
-
let foundNode = null;
|
|
104
|
-
editor.state.doc.descendants((currentNode, pos) => {
|
|
105
|
-
if (currentNode === node) {
|
|
106
|
-
foundPos = pos;
|
|
107
|
-
foundNode = currentNode;
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
return true;
|
|
111
|
-
});
|
|
112
|
-
return foundPos !== -1 && foundNode !== null ? { pos: foundPos, node: foundNode } : null;
|
|
113
|
-
}
|
|
114
|
-
function isNodeTypeSelected(editor, types = []) {
|
|
115
|
-
if (!editor || !editor.state.selection) return false;
|
|
116
|
-
const { state } = editor;
|
|
117
|
-
const { selection } = state;
|
|
118
|
-
if (selection.empty) return false;
|
|
119
|
-
if (selection instanceof import_state.NodeSelection) {
|
|
120
|
-
const node = selection.node;
|
|
121
|
-
return node ? types.includes(node.type.name) : false;
|
|
122
|
-
}
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
function isValidPosition(pos) {
|
|
126
|
-
return typeof pos === "number" && pos >= 0;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
76
|
// src/ui/codeblock-button/use-code-block.ts
|
|
130
77
|
var CODE_BLOCK_SHORTCUT_KEY = "mod+alt+c";
|
|
131
78
|
function canToggle(editor, turnInto = true) {
|
|
132
79
|
var _a;
|
|
133
80
|
if (!editor || !editor.isEditable) return false;
|
|
134
|
-
if (!isNodeInSchema("codeBlock", editor) || isNodeTypeSelected(editor, ["image"]))
|
|
81
|
+
if (!(0, import_editor_utils.isNodeInSchema)("codeBlock", editor) || (0, import_editor_utils.isNodeTypeSelected)(editor, ["image"]))
|
|
135
82
|
return false;
|
|
136
83
|
if (!turnInto) {
|
|
137
84
|
return editor.can().toggleNode("codeBlock", "paragraph");
|
|
@@ -140,12 +87,12 @@ function canToggle(editor, turnInto = true) {
|
|
|
140
87
|
const view = editor.view;
|
|
141
88
|
const state = view.state;
|
|
142
89
|
const selection = state.selection;
|
|
143
|
-
if (selection.empty || selection instanceof
|
|
144
|
-
const pos = (_a = findNodePosition({
|
|
90
|
+
if (selection.empty || selection instanceof import_state.TextSelection) {
|
|
91
|
+
const pos = (_a = (0, import_editor_utils.findNodePosition)({
|
|
145
92
|
editor,
|
|
146
93
|
node: state.selection.$anchor.node(1)
|
|
147
94
|
})) == null ? void 0 : _a.pos;
|
|
148
|
-
if (!isValidPosition(pos)) return false;
|
|
95
|
+
if (!(0, import_editor_utils.isValidPosition)(pos)) return false;
|
|
149
96
|
}
|
|
150
97
|
return true;
|
|
151
98
|
} catch {
|
|
@@ -160,19 +107,19 @@ function toggleCodeBlock(editor) {
|
|
|
160
107
|
const view = editor.view;
|
|
161
108
|
let state = view.state;
|
|
162
109
|
let tr = state.tr;
|
|
163
|
-
if (state.selection.empty || state.selection instanceof
|
|
164
|
-
const pos = (_a = findNodePosition({
|
|
110
|
+
if (state.selection.empty || state.selection instanceof import_state.TextSelection) {
|
|
111
|
+
const pos = (_a = (0, import_editor_utils.findNodePosition)({
|
|
165
112
|
editor,
|
|
166
113
|
node: state.selection.$anchor.node(1)
|
|
167
114
|
})) == null ? void 0 : _a.pos;
|
|
168
|
-
if (!isValidPosition(pos)) return false;
|
|
169
|
-
tr = tr.setSelection(
|
|
115
|
+
if (!(0, import_editor_utils.isValidPosition)(pos)) return false;
|
|
116
|
+
tr = tr.setSelection(import_state.NodeSelection.create(state.doc, pos));
|
|
170
117
|
view.dispatch(tr);
|
|
171
118
|
state = view.state;
|
|
172
119
|
}
|
|
173
120
|
const selection = state.selection;
|
|
174
121
|
let chain = editor.chain().focus();
|
|
175
|
-
if (selection instanceof
|
|
122
|
+
if (selection instanceof import_state.NodeSelection) {
|
|
176
123
|
const firstChild = (_b = selection.node.firstChild) == null ? void 0 : _b.firstChild;
|
|
177
124
|
const lastChild = (_c = selection.node.lastChild) == null ? void 0 : _c.lastChild;
|
|
178
125
|
const from = firstChild ? selection.from + firstChild.nodeSize : selection.from + 1;
|
|
@@ -190,7 +137,7 @@ function toggleCodeBlock(editor) {
|
|
|
190
137
|
function shouldShowButton(props) {
|
|
191
138
|
const { editor, hideWhenUnavailable } = props;
|
|
192
139
|
if (!editor || !editor.isEditable) return false;
|
|
193
|
-
if (!isNodeInSchema("codeBlock", editor)) return false;
|
|
140
|
+
if (!(0, import_editor_utils.isNodeInSchema)("codeBlock", editor)) return false;
|
|
194
141
|
if (hideWhenUnavailable && !editor.isActive("code")) {
|
|
195
142
|
return canToggle(editor);
|
|
196
143
|
}
|
|
@@ -6,10 +6,8 @@ import {
|
|
|
6
6
|
shouldShowButton,
|
|
7
7
|
toggleCodeBlock,
|
|
8
8
|
useCodeBlock
|
|
9
|
-
} from "../../chunk-
|
|
10
|
-
import "../../chunk-C6M3CDOK.mjs";
|
|
9
|
+
} from "../../chunk-BEV5U2DK.mjs";
|
|
11
10
|
import "../../chunk-P55PLOHR.mjs";
|
|
12
|
-
import "../../chunk-WKV76XOR.mjs";
|
|
13
11
|
export {
|
|
14
12
|
CODE_BLOCK_SHORTCUT_KEY,
|
|
15
13
|
canToggle,
|
|
@@ -68,35 +68,15 @@ function useTiptapEditor(providedEditor) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
71
|
+
var import_editor_utils = require("@kopexa/editor-utils");
|
|
71
72
|
var import_icons = require("@kopexa/icons");
|
|
72
73
|
var import_use_is_mobile = require("@kopexa/use-is-mobile");
|
|
73
74
|
var React = __toESM(require("react"));
|
|
74
75
|
var import_react_hotkeys_hook = require("react-hotkeys-hook");
|
|
75
|
-
|
|
76
|
-
// src/utils/index.ts
|
|
77
|
-
var import_state = require("@tiptap/pm/state");
|
|
78
|
-
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
79
|
-
var isMarkInSchema = (markName, editor) => {
|
|
80
|
-
if (!(editor == null ? void 0 : editor.schema)) return false;
|
|
81
|
-
return editor.schema.spec.marks.get(markName) !== void 0;
|
|
82
|
-
};
|
|
83
|
-
function isNodeTypeSelected(editor, types = []) {
|
|
84
|
-
if (!editor || !editor.state.selection) return false;
|
|
85
|
-
const { state } = editor;
|
|
86
|
-
const { selection } = state;
|
|
87
|
-
if (selection.empty) return false;
|
|
88
|
-
if (selection instanceof import_state.NodeSelection) {
|
|
89
|
-
const node = selection.node;
|
|
90
|
-
return node ? types.includes(node.type.name) : false;
|
|
91
|
-
}
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
96
76
|
var COLOR_HIGHLIGHT_SHORTCUT_KEY = "mod+shift+h";
|
|
97
77
|
function canColorHighlight(editor) {
|
|
98
78
|
if (!editor || !editor.isEditable) return false;
|
|
99
|
-
if (!isMarkInSchema("highlight", editor) || isNodeTypeSelected(editor, ["image"]))
|
|
79
|
+
if (!(0, import_editor_utils.isMarkInSchema)("highlight", editor) || (0, import_editor_utils.isNodeTypeSelected)(editor, ["image"]))
|
|
100
80
|
return false;
|
|
101
81
|
return editor.can().setMark("highlight");
|
|
102
82
|
}
|
|
@@ -112,7 +92,7 @@ function removeHighlight(editor) {
|
|
|
112
92
|
function shouldShowButton(props) {
|
|
113
93
|
const { editor, hideWhenUnavailable } = props;
|
|
114
94
|
if (!editor || !editor.isEditable) return false;
|
|
115
|
-
if (!isMarkInSchema("highlight", editor)) return false;
|
|
95
|
+
if (!(0, import_editor_utils.isMarkInSchema)("highlight", editor)) return false;
|
|
116
96
|
if (hideWhenUnavailable && !editor.isActive("code")) {
|
|
117
97
|
return canColorHighlight(editor);
|
|
118
98
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
ColorHighlightButton
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-C6M3CDOK.mjs";
|
|
4
|
+
} from "../../chunk-B7WJOQ3X.mjs";
|
|
5
|
+
import "../../chunk-UJ4BNZ63.mjs";
|
|
7
6
|
import "../../chunk-P55PLOHR.mjs";
|
|
8
|
-
import "../../chunk-WKV76XOR.mjs";
|
|
9
7
|
export {
|
|
10
8
|
ColorHighlightButton
|
|
11
9
|
};
|
|
@@ -78,31 +78,11 @@ function useTiptapEditor(providedEditor) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
81
|
+
var import_editor_utils = require("@kopexa/editor-utils");
|
|
81
82
|
var import_icons = require("@kopexa/icons");
|
|
82
83
|
var import_use_is_mobile = require("@kopexa/use-is-mobile");
|
|
83
84
|
var React = __toESM(require("react"));
|
|
84
85
|
var import_react_hotkeys_hook = require("react-hotkeys-hook");
|
|
85
|
-
|
|
86
|
-
// src/utils/index.ts
|
|
87
|
-
var import_state = require("@tiptap/pm/state");
|
|
88
|
-
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
89
|
-
var isMarkInSchema = (markName, editor) => {
|
|
90
|
-
if (!(editor == null ? void 0 : editor.schema)) return false;
|
|
91
|
-
return editor.schema.spec.marks.get(markName) !== void 0;
|
|
92
|
-
};
|
|
93
|
-
function isNodeTypeSelected(editor, types = []) {
|
|
94
|
-
if (!editor || !editor.state.selection) return false;
|
|
95
|
-
const { state } = editor;
|
|
96
|
-
const { selection } = state;
|
|
97
|
-
if (selection.empty) return false;
|
|
98
|
-
if (selection instanceof import_state.NodeSelection) {
|
|
99
|
-
const node = selection.node;
|
|
100
|
-
return node ? types.includes(node.type.name) : false;
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
106
86
|
var COLOR_HIGHLIGHT_SHORTCUT_KEY = "mod+shift+h";
|
|
107
87
|
var HIGHLIGHT_COLORS = [
|
|
108
88
|
{
|
|
@@ -164,7 +144,7 @@ function pickHighlightColorsByValue(values) {
|
|
|
164
144
|
}
|
|
165
145
|
function canColorHighlight(editor) {
|
|
166
146
|
if (!editor || !editor.isEditable) return false;
|
|
167
|
-
if (!isMarkInSchema("highlight", editor) || isNodeTypeSelected(editor, ["image"]))
|
|
147
|
+
if (!(0, import_editor_utils.isMarkInSchema)("highlight", editor) || (0, import_editor_utils.isNodeTypeSelected)(editor, ["image"]))
|
|
168
148
|
return false;
|
|
169
149
|
return editor.can().setMark("highlight");
|
|
170
150
|
}
|
|
@@ -180,7 +160,7 @@ function removeHighlight(editor) {
|
|
|
180
160
|
function shouldShowButton(props) {
|
|
181
161
|
const { editor, hideWhenUnavailable } = props;
|
|
182
162
|
if (!editor || !editor.isEditable) return false;
|
|
183
|
-
if (!isMarkInSchema("highlight", editor)) return false;
|
|
163
|
+
if (!(0, import_editor_utils.isMarkInSchema)("highlight", editor)) return false;
|
|
184
164
|
if (hideWhenUnavailable && !editor.isActive("code")) {
|
|
185
165
|
return canColorHighlight(editor);
|
|
186
166
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "../../chunk-2Z2QVW67.mjs";
|
|
3
3
|
import {
|
|
4
4
|
ColorHighlightButton
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-B7WJOQ3X.mjs";
|
|
6
6
|
import {
|
|
7
7
|
COLOR_HIGHLIGHT_SHORTCUT_KEY,
|
|
8
8
|
HIGHLIGHT_COLORS,
|
|
@@ -12,10 +12,8 @@ import {
|
|
|
12
12
|
removeHighlight,
|
|
13
13
|
shouldShowButton,
|
|
14
14
|
useColorHighlight
|
|
15
|
-
} from "../../chunk-
|
|
16
|
-
import "../../chunk-C6M3CDOK.mjs";
|
|
15
|
+
} from "../../chunk-UJ4BNZ63.mjs";
|
|
17
16
|
import "../../chunk-P55PLOHR.mjs";
|
|
18
|
-
import "../../chunk-WKV76XOR.mjs";
|
|
19
17
|
export {
|
|
20
18
|
COLOR_HIGHLIGHT_SHORTCUT_KEY,
|
|
21
19
|
ColorHighlightButton,
|
|
@@ -42,6 +42,7 @@ __export(use_color_highlight_exports, {
|
|
|
42
42
|
useColorHighlight: () => useColorHighlight
|
|
43
43
|
});
|
|
44
44
|
module.exports = __toCommonJS(use_color_highlight_exports);
|
|
45
|
+
var import_editor_utils = require("@kopexa/editor-utils");
|
|
45
46
|
var import_icons = require("@kopexa/icons");
|
|
46
47
|
var import_use_is_mobile = require("@kopexa/use-is-mobile");
|
|
47
48
|
var React = __toESM(require("react"));
|
|
@@ -76,25 +77,6 @@ function useTiptapEditor(providedEditor) {
|
|
|
76
77
|
return editorState || { editor: null };
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
// src/utils/index.ts
|
|
80
|
-
var import_state = require("@tiptap/pm/state");
|
|
81
|
-
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
82
|
-
var isMarkInSchema = (markName, editor) => {
|
|
83
|
-
if (!(editor == null ? void 0 : editor.schema)) return false;
|
|
84
|
-
return editor.schema.spec.marks.get(markName) !== void 0;
|
|
85
|
-
};
|
|
86
|
-
function isNodeTypeSelected(editor, types = []) {
|
|
87
|
-
if (!editor || !editor.state.selection) return false;
|
|
88
|
-
const { state } = editor;
|
|
89
|
-
const { selection } = state;
|
|
90
|
-
if (selection.empty) return false;
|
|
91
|
-
if (selection instanceof import_state.NodeSelection) {
|
|
92
|
-
const node = selection.node;
|
|
93
|
-
return node ? types.includes(node.type.name) : false;
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
80
|
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
99
81
|
var COLOR_HIGHLIGHT_SHORTCUT_KEY = "mod+shift+h";
|
|
100
82
|
var HIGHLIGHT_COLORS = [
|
|
@@ -157,7 +139,7 @@ function pickHighlightColorsByValue(values) {
|
|
|
157
139
|
}
|
|
158
140
|
function canColorHighlight(editor) {
|
|
159
141
|
if (!editor || !editor.isEditable) return false;
|
|
160
|
-
if (!isMarkInSchema("highlight", editor) || isNodeTypeSelected(editor, ["image"]))
|
|
142
|
+
if (!(0, import_editor_utils.isMarkInSchema)("highlight", editor) || (0, import_editor_utils.isNodeTypeSelected)(editor, ["image"]))
|
|
161
143
|
return false;
|
|
162
144
|
return editor.can().setMark("highlight");
|
|
163
145
|
}
|
|
@@ -173,7 +155,7 @@ function removeHighlight(editor) {
|
|
|
173
155
|
function shouldShowButton(props) {
|
|
174
156
|
const { editor, hideWhenUnavailable } = props;
|
|
175
157
|
if (!editor || !editor.isEditable) return false;
|
|
176
|
-
if (!isMarkInSchema("highlight", editor)) return false;
|
|
158
|
+
if (!(0, import_editor_utils.isMarkInSchema)("highlight", editor)) return false;
|
|
177
159
|
if (hideWhenUnavailable && !editor.isActive("code")) {
|
|
178
160
|
return canColorHighlight(editor);
|
|
179
161
|
}
|
|
@@ -9,10 +9,8 @@ import {
|
|
|
9
9
|
removeHighlight,
|
|
10
10
|
shouldShowButton,
|
|
11
11
|
useColorHighlight
|
|
12
|
-
} from "../../chunk-
|
|
13
|
-
import "../../chunk-C6M3CDOK.mjs";
|
|
12
|
+
} from "../../chunk-UJ4BNZ63.mjs";
|
|
14
13
|
import "../../chunk-P55PLOHR.mjs";
|
|
15
|
-
import "../../chunk-WKV76XOR.mjs";
|
|
16
14
|
export {
|
|
17
15
|
COLOR_HIGHLIGHT_SHORTCUT_KEY,
|
|
18
16
|
HIGHLIGHT_COLORS,
|
|
@@ -202,31 +202,11 @@ var import_toolbar = require("@kopexa/toolbar");
|
|
|
202
202
|
var import_react3 = require("react");
|
|
203
203
|
|
|
204
204
|
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
205
|
+
var import_editor_utils = require("@kopexa/editor-utils");
|
|
205
206
|
var import_icons = require("@kopexa/icons");
|
|
206
207
|
var import_use_is_mobile = require("@kopexa/use-is-mobile");
|
|
207
208
|
var React2 = __toESM(require("react"));
|
|
208
209
|
var import_react_hotkeys_hook = require("react-hotkeys-hook");
|
|
209
|
-
|
|
210
|
-
// src/utils/index.ts
|
|
211
|
-
var import_state = require("@tiptap/pm/state");
|
|
212
|
-
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
213
|
-
var isMarkInSchema = (markName, editor) => {
|
|
214
|
-
if (!(editor == null ? void 0 : editor.schema)) return false;
|
|
215
|
-
return editor.schema.spec.marks.get(markName) !== void 0;
|
|
216
|
-
};
|
|
217
|
-
function isNodeTypeSelected(editor, types = []) {
|
|
218
|
-
if (!editor || !editor.state.selection) return false;
|
|
219
|
-
const { state } = editor;
|
|
220
|
-
const { selection } = state;
|
|
221
|
-
if (selection.empty) return false;
|
|
222
|
-
if (selection instanceof import_state.NodeSelection) {
|
|
223
|
-
const node = selection.node;
|
|
224
|
-
return node ? types.includes(node.type.name) : false;
|
|
225
|
-
}
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
230
210
|
var COLOR_HIGHLIGHT_SHORTCUT_KEY = "mod+shift+h";
|
|
231
211
|
var HIGHLIGHT_COLORS = [
|
|
232
212
|
{
|
|
@@ -288,7 +268,7 @@ function pickHighlightColorsByValue(values) {
|
|
|
288
268
|
}
|
|
289
269
|
function canColorHighlight(editor) {
|
|
290
270
|
if (!editor || !editor.isEditable) return false;
|
|
291
|
-
if (!isMarkInSchema("highlight", editor) || isNodeTypeSelected(editor, ["image"]))
|
|
271
|
+
if (!(0, import_editor_utils.isMarkInSchema)("highlight", editor) || (0, import_editor_utils.isNodeTypeSelected)(editor, ["image"]))
|
|
292
272
|
return false;
|
|
293
273
|
return editor.can().setMark("highlight");
|
|
294
274
|
}
|
|
@@ -304,7 +284,7 @@ function removeHighlight(editor) {
|
|
|
304
284
|
function shouldShowButton(props) {
|
|
305
285
|
const { editor, hideWhenUnavailable } = props;
|
|
306
286
|
if (!editor || !editor.isEditable) return false;
|
|
307
|
-
if (!isMarkInSchema("highlight", editor)) return false;
|
|
287
|
+
if (!(0, import_editor_utils.isMarkInSchema)("highlight", editor)) return false;
|
|
308
288
|
if (hideWhenUnavailable && !editor.isActive("code")) {
|
|
309
289
|
return canColorHighlight(editor);
|
|
310
290
|
}
|
|
@@ -575,7 +555,7 @@ function ColorHighlightPopover({
|
|
|
575
555
|
}) {
|
|
576
556
|
const { editor } = useTiptapEditor(providedEditor);
|
|
577
557
|
const [isOpen, setIsOpen] = (0, import_react4.useState)(false);
|
|
578
|
-
const { isVisible, canColorHighlight: canColorHighlight2, isActive, label
|
|
558
|
+
const { isVisible, canColorHighlight: canColorHighlight2, isActive, label } = useColorHighlight({
|
|
579
559
|
editor,
|
|
580
560
|
hideWhenUnavailable,
|
|
581
561
|
onApplied
|
|
@@ -4,14 +4,12 @@ import {
|
|
|
4
4
|
ColorHighlightPopover,
|
|
5
5
|
ColorHighlightPopoverButton,
|
|
6
6
|
ColorHighlightPopoverContent
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-XL5FS7LN.mjs";
|
|
8
8
|
import "../../chunk-2Z2QVW67.mjs";
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-C6M3CDOK.mjs";
|
|
9
|
+
import "../../chunk-B7WJOQ3X.mjs";
|
|
10
|
+
import "../../chunk-UJ4BNZ63.mjs";
|
|
12
11
|
import "../../chunk-42HKGCOO.mjs";
|
|
13
12
|
import "../../chunk-P55PLOHR.mjs";
|
|
14
|
-
import "../../chunk-WKV76XOR.mjs";
|
|
15
13
|
export {
|
|
16
14
|
ColorHighlightPopover,
|
|
17
15
|
ColorHighlightPopoverButton,
|
|
@@ -203,31 +203,11 @@ var import_toolbar = require("@kopexa/toolbar");
|
|
|
203
203
|
var import_react3 = require("react");
|
|
204
204
|
|
|
205
205
|
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
206
|
+
var import_editor_utils = require("@kopexa/editor-utils");
|
|
206
207
|
var import_icons = require("@kopexa/icons");
|
|
207
208
|
var import_use_is_mobile = require("@kopexa/use-is-mobile");
|
|
208
209
|
var React2 = __toESM(require("react"));
|
|
209
210
|
var import_react_hotkeys_hook = require("react-hotkeys-hook");
|
|
210
|
-
|
|
211
|
-
// src/utils/index.ts
|
|
212
|
-
var import_state = require("@tiptap/pm/state");
|
|
213
|
-
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
214
|
-
var isMarkInSchema = (markName, editor) => {
|
|
215
|
-
if (!(editor == null ? void 0 : editor.schema)) return false;
|
|
216
|
-
return editor.schema.spec.marks.get(markName) !== void 0;
|
|
217
|
-
};
|
|
218
|
-
function isNodeTypeSelected(editor, types = []) {
|
|
219
|
-
if (!editor || !editor.state.selection) return false;
|
|
220
|
-
const { state } = editor;
|
|
221
|
-
const { selection } = state;
|
|
222
|
-
if (selection.empty) return false;
|
|
223
|
-
if (selection instanceof import_state.NodeSelection) {
|
|
224
|
-
const node = selection.node;
|
|
225
|
-
return node ? types.includes(node.type.name) : false;
|
|
226
|
-
}
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
231
211
|
var COLOR_HIGHLIGHT_SHORTCUT_KEY = "mod+shift+h";
|
|
232
212
|
var HIGHLIGHT_COLORS = [
|
|
233
213
|
{
|
|
@@ -289,7 +269,7 @@ function pickHighlightColorsByValue(values) {
|
|
|
289
269
|
}
|
|
290
270
|
function canColorHighlight(editor) {
|
|
291
271
|
if (!editor || !editor.isEditable) return false;
|
|
292
|
-
if (!isMarkInSchema("highlight", editor) || isNodeTypeSelected(editor, ["image"]))
|
|
272
|
+
if (!(0, import_editor_utils.isMarkInSchema)("highlight", editor) || (0, import_editor_utils.isNodeTypeSelected)(editor, ["image"]))
|
|
293
273
|
return false;
|
|
294
274
|
return editor.can().setMark("highlight");
|
|
295
275
|
}
|
|
@@ -305,7 +285,7 @@ function removeHighlight(editor) {
|
|
|
305
285
|
function shouldShowButton(props) {
|
|
306
286
|
const { editor, hideWhenUnavailable } = props;
|
|
307
287
|
if (!editor || !editor.isEditable) return false;
|
|
308
|
-
if (!isMarkInSchema("highlight", editor)) return false;
|
|
288
|
+
if (!(0, import_editor_utils.isMarkInSchema)("highlight", editor)) return false;
|
|
309
289
|
if (hideWhenUnavailable && !editor.isActive("code")) {
|
|
310
290
|
return canColorHighlight(editor);
|
|
311
291
|
}
|
|
@@ -576,7 +556,7 @@ function ColorHighlightPopover({
|
|
|
576
556
|
}) {
|
|
577
557
|
const { editor } = useTiptapEditor(providedEditor);
|
|
578
558
|
const [isOpen, setIsOpen] = (0, import_react4.useState)(false);
|
|
579
|
-
const { isVisible, canColorHighlight: canColorHighlight2, isActive, label
|
|
559
|
+
const { isVisible, canColorHighlight: canColorHighlight2, isActive, label } = useColorHighlight({
|
|
580
560
|
editor,
|
|
581
561
|
hideWhenUnavailable,
|
|
582
562
|
onApplied
|
|
@@ -4,14 +4,12 @@ import {
|
|
|
4
4
|
ColorHighlightPopover,
|
|
5
5
|
ColorHighlightPopoverButton,
|
|
6
6
|
ColorHighlightPopoverContent
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-XL5FS7LN.mjs";
|
|
8
8
|
import "../../chunk-2Z2QVW67.mjs";
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-C6M3CDOK.mjs";
|
|
9
|
+
import "../../chunk-B7WJOQ3X.mjs";
|
|
10
|
+
import "../../chunk-UJ4BNZ63.mjs";
|
|
12
11
|
import "../../chunk-42HKGCOO.mjs";
|
|
13
12
|
import "../../chunk-P55PLOHR.mjs";
|
|
14
|
-
import "../../chunk-WKV76XOR.mjs";
|
|
15
13
|
export {
|
|
16
14
|
ColorHighlightPopover,
|
|
17
15
|
ColorHighlightPopoverButton,
|