@mekari/pixel3-rich-text-editor 0.1.2 → 0.1.3-dev.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-25RKPG44.mjs → chunk-47IOAHWN.mjs} +4 -2
- package/dist/{chunk-7BEXEMOE.mjs → chunk-6O4HSL2C.mjs} +4 -0
- package/dist/chunk-76GEEOAG.mjs +189 -0
- package/dist/{chunk-MKTM47RO.mjs → chunk-AIWY3FHJ.mjs} +1 -1
- package/dist/chunk-BWRU2WZN.mjs +202 -0
- package/dist/{chunk-ZO6THAT6.mjs → chunk-COZ45QUD.mjs} +1 -1
- package/dist/chunk-ENKUUZPM.mjs +124 -0
- package/dist/{chunk-Q7QLZISF.mjs → chunk-IFRJVX2K.mjs} +29 -1
- package/dist/{chunk-YE6FEVD4.mjs → chunk-UD5PDCGC.mjs} +18 -9
- package/dist/{chunk-YIEQVTEO.mjs → chunk-X2CB42A3.mjs} +1 -1
- package/dist/{chunk-5S2LSGJV.mjs → chunk-Y6UPQ6EU.mjs} +1 -1
- package/dist/{chunk-UBJOZ2IA.mjs → chunk-YWVVMJGP.mjs} +1 -1
- package/dist/{chunk-XNM3YX37.mjs → chunk-ZYSEHV5N.mjs} +13 -3
- package/dist/editor-toolbar.d.mts +2 -1
- package/dist/editor-toolbar.d.ts +2 -1
- package/dist/editor-toolbar.js +366 -16
- package/dist/editor-toolbar.mjs +10 -8
- package/dist/extensions/align-extension.js +27 -0
- package/dist/extensions/align-extension.mjs +2 -2
- package/dist/extensions/color-extension.js +27 -0
- package/dist/extensions/color-extension.mjs +2 -2
- package/dist/extensions/heading-extension.js +27 -0
- package/dist/extensions/heading-extension.mjs +2 -2
- package/dist/extensions/icons.d.mts +2 -1
- package/dist/extensions/icons.d.ts +2 -1
- package/dist/extensions/icons.js +31 -2
- package/dist/extensions/icons.mjs +5 -3
- package/dist/extensions/index.d.mts +6 -0
- package/dist/extensions/index.d.ts +6 -0
- package/dist/extensions/index.js +347 -2
- package/dist/extensions/index.mjs +18 -10
- package/dist/extensions/link-extension.js +27 -0
- package/dist/extensions/link-extension.mjs +2 -2
- package/dist/extensions/single-extension.d.mts +1 -1
- package/dist/extensions/single-extension.d.ts +1 -1
- package/dist/extensions/single-extension.js +28 -0
- package/dist/extensions/single-extension.mjs +2 -2
- package/dist/extensions/variable-extension.d.mts +19 -0
- package/dist/extensions/variable-extension.d.ts +19 -0
- package/dist/extensions/variable-extension.js +158 -0
- package/dist/extensions/variable-extension.mjs +7 -0
- package/dist/extensions/variable-list-extension.d.mts +33 -0
- package/dist/extensions/variable-list-extension.d.ts +33 -0
- package/dist/extensions/variable-list-extension.js +210 -0
- package/dist/extensions/variable-list-extension.mjs +7 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +596 -57
- package/dist/index.mjs +14 -11
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/modules/rich-text-editor.props.d.mts +5 -1
- package/dist/modules/rich-text-editor.props.d.ts +5 -1
- package/dist/modules/rich-text-editor.props.js +4 -0
- package/dist/modules/rich-text-editor.props.mjs +1 -1
- package/dist/modules/rich-text-editor.types.d.mts +10 -3
- package/dist/modules/rich-text-editor.types.d.ts +10 -3
- package/dist/rich-text-editor.d.mts +10 -1
- package/dist/rich-text-editor.d.ts +10 -1
- package/dist/rich-text-editor.js +596 -57
- package/dist/rich-text-editor.mjs +14 -11
- package/dist/rte-style-provider.mjs +2 -2
- package/dist/rte-variable-suggestion.d.mts +11 -0
- package/dist/rte-variable-suggestion.d.ts +11 -0
- package/dist/rte-variable-suggestion.js +405 -0
- package/dist/rte-variable-suggestion.mjs +10 -0
- package/package.json +7 -7
- /package/dist/{chunk-VYCDVS5I.mjs → chunk-HIHIKPNN.mjs} +0 -0
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MpRichTextEditor
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-ZYSEHV5N.mjs";
|
|
4
|
+
import "./chunk-UD5PDCGC.mjs";
|
|
5
|
+
import "./chunk-HIHIKPNN.mjs";
|
|
6
|
+
import "./chunk-X2CB42A3.mjs";
|
|
7
|
+
import "./chunk-COZ45QUD.mjs";
|
|
8
|
+
import "./chunk-47IOAHWN.mjs";
|
|
9
|
+
import "./chunk-ENKUUZPM.mjs";
|
|
10
|
+
import "./chunk-AIWY3FHJ.mjs";
|
|
9
11
|
import "./chunk-ZRAXSVO5.mjs";
|
|
10
12
|
import "./chunk-ZAXJ3BEP.mjs";
|
|
11
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-6O4HSL2C.mjs";
|
|
12
14
|
import "./chunk-4KJOYLJI.mjs";
|
|
13
15
|
import "./chunk-4TUA5VF4.mjs";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-BWRU2WZN.mjs";
|
|
17
|
+
import "./chunk-76GEEOAG.mjs";
|
|
18
|
+
import "./chunk-YWVVMJGP.mjs";
|
|
19
|
+
import "./chunk-Y6UPQ6EU.mjs";
|
|
20
|
+
import "./chunk-IFRJVX2K.mjs";
|
|
18
21
|
import "./chunk-QZ7VFGWC.mjs";
|
|
19
22
|
export {
|
|
20
23
|
MpRichTextEditor
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MpRTEStyleProvider
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AIWY3FHJ.mjs";
|
|
4
4
|
import "./chunk-ZRAXSVO5.mjs";
|
|
5
5
|
import "./chunk-ZAXJ3BEP.mjs";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-6O4HSL2C.mjs";
|
|
7
7
|
import "./chunk-QZ7VFGWC.mjs";
|
|
8
8
|
export {
|
|
9
9
|
MpRTEStyleProvider
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PluginKey } from '@tiptap/pm/state';
|
|
2
|
+
import { VariableSuggestionItem } from './modules/rich-text-editor.types.mjs';
|
|
3
|
+
import { VariableOptions } from './extensions/variable-extension.mjs';
|
|
4
|
+
import '@mekari/pixel3-utils';
|
|
5
|
+
import '@tiptap/core';
|
|
6
|
+
import '@tiptap/suggestion';
|
|
7
|
+
|
|
8
|
+
declare const VariablePluginKey: PluginKey<any>;
|
|
9
|
+
declare const createVariableSuggestion: (getSuggestionItems?: () => VariableSuggestionItem[]) => VariableOptions['suggestion'];
|
|
10
|
+
|
|
11
|
+
export { VariablePluginKey, createVariableSuggestion };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PluginKey } from '@tiptap/pm/state';
|
|
2
|
+
import { VariableSuggestionItem } from './modules/rich-text-editor.types.js';
|
|
3
|
+
import { VariableOptions } from './extensions/variable-extension.js';
|
|
4
|
+
import '@mekari/pixel3-utils';
|
|
5
|
+
import '@tiptap/core';
|
|
6
|
+
import '@tiptap/suggestion';
|
|
7
|
+
|
|
8
|
+
declare const VariablePluginKey: PluginKey<any>;
|
|
9
|
+
declare const createVariableSuggestion: (getSuggestionItems?: () => VariableSuggestionItem[]) => VariableOptions['suggestion'];
|
|
10
|
+
|
|
11
|
+
export { VariablePluginKey, createVariableSuggestion };
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/rte-variable-suggestion.ts
|
|
22
|
+
var rte_variable_suggestion_exports = {};
|
|
23
|
+
__export(rte_variable_suggestion_exports, {
|
|
24
|
+
VariablePluginKey: () => VariablePluginKey,
|
|
25
|
+
createVariableSuggestion: () => createVariableSuggestion
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(rte_variable_suggestion_exports);
|
|
28
|
+
var import_vue_3 = require("@tiptap/vue-3");
|
|
29
|
+
var import_core = require("@popperjs/core");
|
|
30
|
+
var import_state = require("@tiptap/pm/state");
|
|
31
|
+
|
|
32
|
+
// src/extensions/variable-list-extension.tsx
|
|
33
|
+
var import_vue = require("vue");
|
|
34
|
+
var import_vue2 = require("vue");
|
|
35
|
+
var import_css = require("@mekari/pixel3-styled-system/css");
|
|
36
|
+
var import_pixel3_popover = require("@mekari/pixel3-popover");
|
|
37
|
+
var import_pixel3_text = require("@mekari/pixel3-text");
|
|
38
|
+
var VariableList = (0, import_vue2.defineComponent)({
|
|
39
|
+
name: "VariableList",
|
|
40
|
+
props: {
|
|
41
|
+
items: {
|
|
42
|
+
type: Array,
|
|
43
|
+
default: () => []
|
|
44
|
+
},
|
|
45
|
+
command: {
|
|
46
|
+
type: Function,
|
|
47
|
+
required: true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
setup(props, {
|
|
51
|
+
expose
|
|
52
|
+
}) {
|
|
53
|
+
const selectedIndex = (0, import_vue2.ref)(0);
|
|
54
|
+
const listRef = (0, import_vue2.ref)(null);
|
|
55
|
+
const groupedItems = (0, import_vue2.computed)(() => {
|
|
56
|
+
const groups = {};
|
|
57
|
+
props.items.forEach((item) => {
|
|
58
|
+
const category = item.category || "OTHER";
|
|
59
|
+
if (!groups[category]) {
|
|
60
|
+
groups[category] = [];
|
|
61
|
+
}
|
|
62
|
+
groups[category].push(item);
|
|
63
|
+
});
|
|
64
|
+
return Object.entries(groups).map(([category, items]) => ({
|
|
65
|
+
category,
|
|
66
|
+
items
|
|
67
|
+
}));
|
|
68
|
+
});
|
|
69
|
+
const scrollToFocusedItem = /* @__PURE__ */ __name(() => {
|
|
70
|
+
(0, import_vue2.nextTick)(() => {
|
|
71
|
+
if (!listRef.value)
|
|
72
|
+
return;
|
|
73
|
+
const targetItem = listRef.value.querySelector('[data-active="true"], [data-highlight]');
|
|
74
|
+
if (targetItem) {
|
|
75
|
+
targetItem.scrollIntoView({
|
|
76
|
+
block: "nearest"
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}, "scrollToFocusedItem");
|
|
81
|
+
(0, import_vue2.watch)(() => props.items, () => {
|
|
82
|
+
selectedIndex.value = 0;
|
|
83
|
+
});
|
|
84
|
+
const onSelect = /* @__PURE__ */ __name((index) => {
|
|
85
|
+
const item = props.items[index];
|
|
86
|
+
if (item) {
|
|
87
|
+
props.command({
|
|
88
|
+
...item,
|
|
89
|
+
label: item.id
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}, "onSelect");
|
|
93
|
+
const onKeyDown = /* @__PURE__ */ __name(({
|
|
94
|
+
event
|
|
95
|
+
}) => {
|
|
96
|
+
if (!props.items.length) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (event.key === "ArrowUp") {
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
const total = props.items.length;
|
|
102
|
+
selectedIndex.value = (selectedIndex.value + total - 1) % total;
|
|
103
|
+
scrollToFocusedItem();
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
if (event.key === "ArrowDown") {
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
selectedIndex.value = (selectedIndex.value + 1) % props.items.length;
|
|
109
|
+
scrollToFocusedItem();
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
if (event.key === "Enter") {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
onSelect(selectedIndex.value);
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}, "onKeyDown");
|
|
119
|
+
expose({
|
|
120
|
+
onKeyDown
|
|
121
|
+
});
|
|
122
|
+
return () => (0, import_vue.createVNode)(import_pixel3_popover.MpPopover, {
|
|
123
|
+
"id": "popover-rte-variable-list",
|
|
124
|
+
"is-manual": true,
|
|
125
|
+
"is-default-open": true,
|
|
126
|
+
"is-open": true
|
|
127
|
+
}, {
|
|
128
|
+
default: () => [(0, import_vue.createVNode)(import_pixel3_popover.MpPopoverContent, {
|
|
129
|
+
"class": (0, import_css.css)({
|
|
130
|
+
width: "280px",
|
|
131
|
+
maxHeight: "284px",
|
|
132
|
+
overflowY: "auto"
|
|
133
|
+
})
|
|
134
|
+
}, {
|
|
135
|
+
default: () => [(0, import_vue.createVNode)(import_pixel3_popover.MpPopoverList, {
|
|
136
|
+
"ref": (element) => {
|
|
137
|
+
var _a;
|
|
138
|
+
if (!element) {
|
|
139
|
+
listRef.value = null;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
listRef.value = (_a = element.$el) != null ? _a : element;
|
|
143
|
+
},
|
|
144
|
+
"data-pixel-rte": true
|
|
145
|
+
}, {
|
|
146
|
+
default: () => [!props.items.length && (0, import_vue.createVNode)(import_pixel3_text.MpText, {
|
|
147
|
+
"color": "text.secondary",
|
|
148
|
+
"class": (0, import_css.css)({
|
|
149
|
+
px: "3",
|
|
150
|
+
py: "2"
|
|
151
|
+
})
|
|
152
|
+
}, {
|
|
153
|
+
default: () => [(0, import_vue.createTextVNode)("No result")]
|
|
154
|
+
}), groupedItems.value.map((group) => {
|
|
155
|
+
return (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)(import_pixel3_text.MpText, {
|
|
156
|
+
"size": "label-small",
|
|
157
|
+
"color": "text.secondary",
|
|
158
|
+
"class": (0, import_css.css)({
|
|
159
|
+
px: "3",
|
|
160
|
+
py: "2",
|
|
161
|
+
textTransform: "uppercase",
|
|
162
|
+
textAlign: "left",
|
|
163
|
+
letterSpacing: "0.05em",
|
|
164
|
+
display: "block",
|
|
165
|
+
width: "full"
|
|
166
|
+
})
|
|
167
|
+
}, {
|
|
168
|
+
default: () => [group.category]
|
|
169
|
+
}), group.items.map((item) => {
|
|
170
|
+
const itemIndex = props.items.indexOf(item);
|
|
171
|
+
return (0, import_vue.createVNode)(import_pixel3_popover.MpPopoverListItem, {
|
|
172
|
+
"key": `${item.id}-${itemIndex}`,
|
|
173
|
+
"onMousedown": (event) => event.preventDefault(),
|
|
174
|
+
"onMouseenter": () => {
|
|
175
|
+
selectedIndex.value = itemIndex;
|
|
176
|
+
},
|
|
177
|
+
"onClick": () => {
|
|
178
|
+
onSelect(itemIndex);
|
|
179
|
+
}
|
|
180
|
+
}, {
|
|
181
|
+
default: () => [(0, import_vue.createVNode)("div", {
|
|
182
|
+
"class": (0, import_css.css)({
|
|
183
|
+
display: "flex",
|
|
184
|
+
flexDirection: "column",
|
|
185
|
+
alignItems: "flex-start",
|
|
186
|
+
minWidth: "0",
|
|
187
|
+
width: "full",
|
|
188
|
+
gap: "0.5"
|
|
189
|
+
})
|
|
190
|
+
}, [(0, import_vue.createVNode)(import_pixel3_text.MpText, {
|
|
191
|
+
"size": "label",
|
|
192
|
+
"is-truncated": true
|
|
193
|
+
}, {
|
|
194
|
+
default: () => [item.name || "Unknown"]
|
|
195
|
+
}), (0, import_vue.createVNode)(import_pixel3_text.MpText, {
|
|
196
|
+
"size": "label-small",
|
|
197
|
+
"color": "text.secondary",
|
|
198
|
+
"is-truncated": true,
|
|
199
|
+
"class": (0, import_css.css)({
|
|
200
|
+
fontFamily: "mono"
|
|
201
|
+
})
|
|
202
|
+
}, {
|
|
203
|
+
default: () => [`{${item.id}}`]
|
|
204
|
+
})])]
|
|
205
|
+
});
|
|
206
|
+
})]);
|
|
207
|
+
})]
|
|
208
|
+
})]
|
|
209
|
+
})]
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// src/rte-variable-suggestion.ts
|
|
215
|
+
var VariablePluginKey = new import_state.PluginKey("variable");
|
|
216
|
+
var MAX_SUGGESTION_ITEMS = 50;
|
|
217
|
+
var getFilteredSuggestionItems = /* @__PURE__ */ __name((items, query) => {
|
|
218
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
219
|
+
return items.filter((item) => {
|
|
220
|
+
var _a, _b;
|
|
221
|
+
if (!normalizedQuery) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
const id = item.id.toLowerCase();
|
|
225
|
+
const name = ((_a = item.name) != null ? _a : "").toLowerCase();
|
|
226
|
+
const category = ((_b = item.category) != null ? _b : "").toLowerCase();
|
|
227
|
+
return id.includes(normalizedQuery) || name.includes(normalizedQuery) || category.includes(normalizedQuery);
|
|
228
|
+
}).slice(0, MAX_SUGGESTION_ITEMS);
|
|
229
|
+
}, "getFilteredSuggestionItems");
|
|
230
|
+
var createVariableSuggestion = /* @__PURE__ */ __name((getSuggestionItems = () => []) => {
|
|
231
|
+
return {
|
|
232
|
+
char: "{",
|
|
233
|
+
pluginKey: VariablePluginKey,
|
|
234
|
+
command: ({
|
|
235
|
+
editor,
|
|
236
|
+
range,
|
|
237
|
+
props
|
|
238
|
+
}) => {
|
|
239
|
+
var _a, _b;
|
|
240
|
+
const nodeAfter = editor.view.state.selection.$to.nodeAfter;
|
|
241
|
+
const overrideSpace = (_a = nodeAfter == null ? void 0 : nodeAfter.text) == null ? void 0 : _a.startsWith(" ");
|
|
242
|
+
if (overrideSpace) {
|
|
243
|
+
range.to += 1;
|
|
244
|
+
}
|
|
245
|
+
editor.chain().focus().insertContentAt(range, [{
|
|
246
|
+
type: "variable",
|
|
247
|
+
attrs: props
|
|
248
|
+
}, {
|
|
249
|
+
type: "text",
|
|
250
|
+
text: " "
|
|
251
|
+
}]).run();
|
|
252
|
+
(_b = window.getSelection()) == null ? void 0 : _b.collapseToEnd();
|
|
253
|
+
},
|
|
254
|
+
allow: ({
|
|
255
|
+
state,
|
|
256
|
+
range
|
|
257
|
+
}) => {
|
|
258
|
+
const $from = state.doc.resolve(range.from);
|
|
259
|
+
const type = state.schema.nodes["variable"];
|
|
260
|
+
const allow = !!$from.parent.type.contentMatch.matchType(type);
|
|
261
|
+
return allow;
|
|
262
|
+
},
|
|
263
|
+
items: ({
|
|
264
|
+
query
|
|
265
|
+
}) => {
|
|
266
|
+
return getFilteredSuggestionItems(getSuggestionItems(), query);
|
|
267
|
+
},
|
|
268
|
+
render: () => {
|
|
269
|
+
let component = null;
|
|
270
|
+
let popperInstance = null;
|
|
271
|
+
let popoverWrapper = null;
|
|
272
|
+
let clientRectProvider;
|
|
273
|
+
let editorElement = null;
|
|
274
|
+
let removeOutsideListeners = null;
|
|
275
|
+
const destroyVariablePopover = /* @__PURE__ */ __name(() => {
|
|
276
|
+
removeOutsideListeners == null ? void 0 : removeOutsideListeners();
|
|
277
|
+
removeOutsideListeners = null;
|
|
278
|
+
popperInstance == null ? void 0 : popperInstance.destroy();
|
|
279
|
+
popperInstance = null;
|
|
280
|
+
popoverWrapper == null ? void 0 : popoverWrapper.remove();
|
|
281
|
+
popoverWrapper = null;
|
|
282
|
+
component == null ? void 0 : component.destroy();
|
|
283
|
+
component = null;
|
|
284
|
+
}, "destroyVariablePopover");
|
|
285
|
+
const isWithinVariableContext = /* @__PURE__ */ __name((target) => {
|
|
286
|
+
if (!(target instanceof Node)) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
return Boolean((editorElement == null ? void 0 : editorElement.contains(target)) || (popoverWrapper == null ? void 0 : popoverWrapper.contains(target)));
|
|
290
|
+
}, "isWithinVariableContext");
|
|
291
|
+
const setupOutsideListeners = /* @__PURE__ */ __name(() => {
|
|
292
|
+
if (!editorElement || removeOutsideListeners) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const handleDocumentFocusIn = /* @__PURE__ */ __name((event) => {
|
|
296
|
+
if (!isWithinVariableContext(event.target)) {
|
|
297
|
+
destroyVariablePopover();
|
|
298
|
+
}
|
|
299
|
+
}, "handleDocumentFocusIn");
|
|
300
|
+
const handleDocumentPointerDown = /* @__PURE__ */ __name((event) => {
|
|
301
|
+
if (!isWithinVariableContext(event.target)) {
|
|
302
|
+
destroyVariablePopover();
|
|
303
|
+
}
|
|
304
|
+
}, "handleDocumentPointerDown");
|
|
305
|
+
const handleEditorFocusOut = /* @__PURE__ */ __name((event) => {
|
|
306
|
+
if (!isWithinVariableContext(event.relatedTarget)) {
|
|
307
|
+
destroyVariablePopover();
|
|
308
|
+
}
|
|
309
|
+
}, "handleEditorFocusOut");
|
|
310
|
+
document.addEventListener("focusin", handleDocumentFocusIn);
|
|
311
|
+
document.addEventListener("mousedown", handleDocumentPointerDown, true);
|
|
312
|
+
document.addEventListener("touchstart", handleDocumentPointerDown, true);
|
|
313
|
+
editorElement.addEventListener("focusout", handleEditorFocusOut);
|
|
314
|
+
removeOutsideListeners = /* @__PURE__ */ __name(() => {
|
|
315
|
+
document.removeEventListener("focusin", handleDocumentFocusIn);
|
|
316
|
+
document.removeEventListener("mousedown", handleDocumentPointerDown, true);
|
|
317
|
+
document.removeEventListener("touchstart", handleDocumentPointerDown, true);
|
|
318
|
+
editorElement == null ? void 0 : editorElement.removeEventListener("focusout", handleEditorFocusOut);
|
|
319
|
+
}, "removeOutsideListeners");
|
|
320
|
+
}, "setupOutsideListeners");
|
|
321
|
+
const getVirtualElement = /* @__PURE__ */ __name(() => {
|
|
322
|
+
if (!clientRectProvider) {
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
return {
|
|
326
|
+
getBoundingClientRect: () => {
|
|
327
|
+
var _a;
|
|
328
|
+
return (_a = clientRectProvider == null ? void 0 : clientRectProvider()) != null ? _a : new DOMRect();
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
}, "getVirtualElement");
|
|
332
|
+
const updatePopoverPosition = /* @__PURE__ */ __name(() => {
|
|
333
|
+
const virtualElement = getVirtualElement();
|
|
334
|
+
if (!virtualElement || !popoverWrapper) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (!popperInstance) {
|
|
338
|
+
popperInstance = (0, import_core.createPopper)(virtualElement, popoverWrapper, {
|
|
339
|
+
placement: "bottom-start",
|
|
340
|
+
modifiers: [{
|
|
341
|
+
name: "offset",
|
|
342
|
+
options: {
|
|
343
|
+
offset: [0, 8]
|
|
344
|
+
}
|
|
345
|
+
}, {
|
|
346
|
+
name: "flip",
|
|
347
|
+
options: {
|
|
348
|
+
fallbackPlacements: ["top-start"]
|
|
349
|
+
}
|
|
350
|
+
}]
|
|
351
|
+
});
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
popperInstance.update();
|
|
355
|
+
}, "updatePopoverPosition");
|
|
356
|
+
return {
|
|
357
|
+
onStart: (props) => {
|
|
358
|
+
clientRectProvider = props.clientRect;
|
|
359
|
+
editorElement = props.editor.view.dom;
|
|
360
|
+
component = new import_vue_3.VueRenderer(VariableList, {
|
|
361
|
+
editor: props.editor,
|
|
362
|
+
props: {
|
|
363
|
+
items: props.items,
|
|
364
|
+
command: props.command
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
popoverWrapper = document.createElement("div");
|
|
368
|
+
popoverWrapper.style.position = "absolute";
|
|
369
|
+
popoverWrapper.style.zIndex = "var(--mp-z-index-popover)";
|
|
370
|
+
if (component.element) {
|
|
371
|
+
popoverWrapper.append(component.element);
|
|
372
|
+
}
|
|
373
|
+
document.body.append(popoverWrapper);
|
|
374
|
+
setupOutsideListeners();
|
|
375
|
+
updatePopoverPosition();
|
|
376
|
+
},
|
|
377
|
+
onUpdate: (props) => {
|
|
378
|
+
clientRectProvider = props.clientRect;
|
|
379
|
+
component == null ? void 0 : component.updateProps({
|
|
380
|
+
items: props.items,
|
|
381
|
+
command: props.command
|
|
382
|
+
});
|
|
383
|
+
updatePopoverPosition();
|
|
384
|
+
},
|
|
385
|
+
onKeyDown: (props) => {
|
|
386
|
+
var _a, _b;
|
|
387
|
+
if (props.event.key === "Escape") {
|
|
388
|
+
destroyVariablePopover();
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
return (_b = (_a = component == null ? void 0 : component.ref) == null ? void 0 : _a.onKeyDown(props)) != null ? _b : false;
|
|
392
|
+
},
|
|
393
|
+
onExit: () => {
|
|
394
|
+
destroyVariablePopover();
|
|
395
|
+
editorElement = null;
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
}, "createVariableSuggestion");
|
|
401
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
402
|
+
0 && (module.exports = {
|
|
403
|
+
VariablePluginKey,
|
|
404
|
+
createVariableSuggestion
|
|
405
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mekari/pixel3-rich-text-editor",
|
|
3
3
|
"description": "Mekari Pixel 3 | Rich text editor component is used to content editor based Tiptap.js",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3-dev.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"@tiptap/starter-kit": "2.7.4",
|
|
42
42
|
"@tiptap/suggestion": "2.7.4",
|
|
43
43
|
"@tiptap/vue-3": "2.7.4",
|
|
44
|
-
"@mekari/pixel3-avatar": "0.0.
|
|
45
|
-
"@mekari/pixel3-button": "0.2.2",
|
|
46
|
-
"@mekari/pixel3-color-picker": "0.2.1",
|
|
47
|
-
"@mekari/pixel3-form-control": "0.0.22",
|
|
44
|
+
"@mekari/pixel3-avatar": "0.0.28-dev.0",
|
|
48
45
|
"@mekari/pixel3-divider": "0.0.22",
|
|
49
|
-
"@mekari/pixel3-
|
|
50
|
-
"@mekari/pixel3-
|
|
46
|
+
"@mekari/pixel3-button": "0.2.3-dev.0",
|
|
47
|
+
"@mekari/pixel3-form-control": "0.0.22",
|
|
48
|
+
"@mekari/pixel3-color-picker": "0.2.2-dev.0",
|
|
49
|
+
"@mekari/pixel3-popover": "0.0.28-dev.0",
|
|
51
50
|
"@mekari/pixel3-scrollbar": "0.1.6",
|
|
51
|
+
"@mekari/pixel3-input": "0.0.28-dev.0",
|
|
52
52
|
"@mekari/pixel3-styled-system": "0.2.0",
|
|
53
53
|
"@mekari/pixel3-text": "0.0.22",
|
|
54
54
|
"@mekari/pixel3-utils": "0.1.0"
|
|
File without changes
|