@docs.plus/extension-hyperlink 1.5.2 → 4.3.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/CHANGELOG.md +362 -0
- package/LICENSE +21 -0
- package/README.md +263 -363
- package/dist/index.cjs +22 -712
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +255 -0
- package/dist/index.d.ts +255 -9
- package/dist/index.js +22 -707
- package/dist/index.js.map +1 -1
- package/dist/styles.css +323 -0
- package/package.json +78 -31
- package/dist/helpers/autoHyperlink.d.ts +0 -8
- package/dist/helpers/clickHandler.d.ts +0 -11
- package/dist/helpers/editHyperlink.d.ts +0 -9
- package/dist/helpers/pasteHandler.d.ts +0 -9
- package/dist/helpers/tippyHelper.d.ts +0 -29
- package/dist/hyperlink.d.ts +0 -77
- package/dist/index.umd.js +0 -713
- package/dist/index.umd.js.map +0 -1
- package/dist/modals/editeHyperlink.d.ts +0 -11
- package/dist/modals/icons.d.ts +0 -9
- package/dist/modals/previewHyperlink.d.ts +0 -11
- package/dist/modals/setHyperlink.d.ts +0 -14
- package/src/helpers/autoHyperlink.ts +0 -167
- package/src/helpers/clickHandler.ts +0 -80
- package/src/helpers/editHyperlink.ts +0 -59
- package/src/helpers/pasteHandler.ts +0 -46
- package/src/helpers/tippyHelper.ts +0 -136
- package/src/hyperlink.ts +0 -277
- package/src/index.ts +0 -17
- package/src/modals/editeHyperlink.ts +0 -99
- package/src/modals/icons.ts +0 -46
- package/src/modals/previewHyperlink.ts +0 -85
- package/src/modals/setHyperlink.ts +0 -97
package/dist/index.cjs
CHANGED
|
@@ -1,712 +1,22 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const changes = core.getChangedRanges(transform);
|
|
24
|
-
changes.forEach(({ oldRange, newRange }) => {
|
|
25
|
-
// at first we check if we have to remove links
|
|
26
|
-
core.getMarksBetween(oldRange.from, oldRange.to, oldState.doc)
|
|
27
|
-
.filter((item) => item.mark.type === options.type)
|
|
28
|
-
.forEach((oldMark) => {
|
|
29
|
-
const newFrom = mapping.map(oldMark.from);
|
|
30
|
-
const newTo = mapping.map(oldMark.to);
|
|
31
|
-
const newMarks = core.getMarksBetween(newFrom, newTo, newState.doc).filter((item) => item.mark.type === options.type);
|
|
32
|
-
if (!newMarks.length) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const newMark = newMarks[0];
|
|
36
|
-
const oldLinkText = oldState.doc.textBetween(oldMark.from, oldMark.to, undefined, " ");
|
|
37
|
-
const newLinkText = newState.doc.textBetween(newMark.from, newMark.to, undefined, " ");
|
|
38
|
-
const wasLink = linkifyjs.test(oldLinkText);
|
|
39
|
-
const isLink = linkifyjs.test(newLinkText);
|
|
40
|
-
// remove only the link, if it was a link before too
|
|
41
|
-
// because we don’t want to remove links that were set manually
|
|
42
|
-
if (wasLink && !isLink) {
|
|
43
|
-
tr.removeMark(newMark.from, newMark.to, options.type);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
// now let’s see if we can add new links
|
|
47
|
-
const nodesInChangedRanges = core.findChildrenInRange(newState.doc, newRange, (node) => node.isTextblock);
|
|
48
|
-
let textBlock;
|
|
49
|
-
let textBeforeWhitespace;
|
|
50
|
-
if (nodesInChangedRanges.length > 1) {
|
|
51
|
-
// Grab the first node within the changed ranges (ex. the first of two paragraphs when hitting enter)
|
|
52
|
-
textBlock = nodesInChangedRanges[0];
|
|
53
|
-
textBeforeWhitespace = newState.doc.textBetween(textBlock.pos, textBlock.pos + textBlock.node.nodeSize, undefined, " ");
|
|
54
|
-
}
|
|
55
|
-
else if (nodesInChangedRanges.length &&
|
|
56
|
-
// We want to make sure to include the block seperator argument to treat hard breaks like spaces
|
|
57
|
-
newState.doc
|
|
58
|
-
.textBetween(newRange.from, newRange.to, " ", " ")
|
|
59
|
-
.endsWith(" ")) {
|
|
60
|
-
textBlock = nodesInChangedRanges[0];
|
|
61
|
-
textBeforeWhitespace = newState.doc.textBetween(textBlock.pos, newRange.to, undefined, " ");
|
|
62
|
-
}
|
|
63
|
-
if (textBlock && textBeforeWhitespace) {
|
|
64
|
-
const wordsBeforeWhitespace = textBeforeWhitespace
|
|
65
|
-
.split(" ")
|
|
66
|
-
.filter((s) => s !== "");
|
|
67
|
-
if (wordsBeforeWhitespace.length <= 0) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
const lastWordBeforeSpace = wordsBeforeWhitespace[wordsBeforeWhitespace.length - 1];
|
|
71
|
-
const lastWordAndBlockOffset = textBlock.pos +
|
|
72
|
-
textBeforeWhitespace.lastIndexOf(lastWordBeforeSpace);
|
|
73
|
-
if (!lastWordBeforeSpace) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
linkifyjs.find(lastWordBeforeSpace)
|
|
77
|
-
.filter((link) => link.isLink)
|
|
78
|
-
.filter((link) => {
|
|
79
|
-
if (options.validate) {
|
|
80
|
-
return options.validate(link.value);
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
83
|
-
})
|
|
84
|
-
// calculate link position
|
|
85
|
-
.map((link) => ({
|
|
86
|
-
...link,
|
|
87
|
-
from: lastWordAndBlockOffset + link.start + 1,
|
|
88
|
-
to: lastWordAndBlockOffset + link.end + 1,
|
|
89
|
-
}))
|
|
90
|
-
// add link mark
|
|
91
|
-
.forEach((link) => {
|
|
92
|
-
tr.addMark(link.from, link.to, options.type.create({
|
|
93
|
-
href: link.href,
|
|
94
|
-
}));
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
if (!tr.steps.length) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
return tr;
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
class Tooltip {
|
|
107
|
-
constructor(options) {
|
|
108
|
-
this.preventHide = false;
|
|
109
|
-
this.mousedownHandler = () => {
|
|
110
|
-
this.preventHide = true;
|
|
111
|
-
};
|
|
112
|
-
this.dragstartHandler = () => {
|
|
113
|
-
this.hide();
|
|
114
|
-
};
|
|
115
|
-
this.blurHandler = ({ event }) => {
|
|
116
|
-
var _a;
|
|
117
|
-
if (this.preventHide) {
|
|
118
|
-
this.preventHide = false;
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if ((event === null || event === void 0 ? void 0 : event.relatedTarget) &&
|
|
122
|
-
((_a = this.tippyWrapper.parentNode) === null || _a === void 0 ? void 0 : _a.contains(event.relatedTarget))) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
this.hide();
|
|
126
|
-
};
|
|
127
|
-
this.tippyBlurHandler = (event) => {
|
|
128
|
-
this.blurHandler({ event });
|
|
129
|
-
};
|
|
130
|
-
this.editor = options.editor;
|
|
131
|
-
this.view = this.editor.view;
|
|
132
|
-
this.tippyWrapper = document.createElement("div");
|
|
133
|
-
this.tippyWrapper.addEventListener("mousedown", this.mousedownHandler, {
|
|
134
|
-
capture: true,
|
|
135
|
-
});
|
|
136
|
-
this.view.dom.addEventListener("dragstart", this.dragstartHandler);
|
|
137
|
-
this.editor.on("blur", this.blurHandler);
|
|
138
|
-
}
|
|
139
|
-
init() {
|
|
140
|
-
this.tippyWrapper.innerHTML = "";
|
|
141
|
-
return { tippyModal: this.tippyWrapper, tippyInstance: this.tippyInstance };
|
|
142
|
-
}
|
|
143
|
-
show() {
|
|
144
|
-
var _a;
|
|
145
|
-
(_a = this.tippyInstance) === null || _a === void 0 ? void 0 : _a.show();
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
hide() {
|
|
149
|
-
setTimeout(() => { var _a; return (_a = this.tippyInstance) === null || _a === void 0 ? void 0 : _a.hide(); });
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
createTooltip() {
|
|
153
|
-
if (!this.editor || !this.editor.options)
|
|
154
|
-
return;
|
|
155
|
-
const { element: editorElement } = this.editor.options;
|
|
156
|
-
const editorIsAttached = !!editorElement.parentElement;
|
|
157
|
-
if (this.tippyInstance || !editorIsAttached) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
this.tippyInstance = tippy(editorElement, {
|
|
161
|
-
duration: 0,
|
|
162
|
-
getReferenceClientRect: null,
|
|
163
|
-
content: this.tippyWrapper,
|
|
164
|
-
interactive: true,
|
|
165
|
-
trigger: "manual",
|
|
166
|
-
placement: "bottom",
|
|
167
|
-
hideOnClick: true,
|
|
168
|
-
onClickOutside: (instance, event) => {
|
|
169
|
-
this.hide();
|
|
170
|
-
},
|
|
171
|
-
onAfterUpdate: (instance, partialProps) => {
|
|
172
|
-
this.show();
|
|
173
|
-
},
|
|
174
|
-
});
|
|
175
|
-
if (this.tippyInstance.popper.firstChild) {
|
|
176
|
-
this.tippyInstance.popper.firstChild.addEventListener("blur", this.tippyBlurHandler);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
update(view, option = {}) {
|
|
180
|
-
var _a;
|
|
181
|
-
this.createTooltip();
|
|
182
|
-
option.arrow = (_a = option === null || option === void 0 ? void 0 : option.arrow) !== null && _a !== void 0 ? _a : false;
|
|
183
|
-
if (this.tippyInstance) {
|
|
184
|
-
this.tippyInstance.setProps({
|
|
185
|
-
...option,
|
|
186
|
-
getReferenceClientRect: () => {
|
|
187
|
-
const pos = view.state.selection.from;
|
|
188
|
-
// width: 0 is a hack to prevent tippy display in the wrong position
|
|
189
|
-
return { ...core.posToDOMRect(view, pos, pos), width: 0 };
|
|
190
|
-
},
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
return {};
|
|
194
|
-
}
|
|
195
|
-
destroyTooltip() {
|
|
196
|
-
if (this.tippyInstance) {
|
|
197
|
-
this.tippyInstance.destroy();
|
|
198
|
-
this.tippyInstance = undefined;
|
|
199
|
-
this.tippyWrapper.removeEventListener("mousedown", this.mousedownHandler, {
|
|
200
|
-
capture: true,
|
|
201
|
-
});
|
|
202
|
-
this.view.dom.removeEventListener("dragstart", this.dragstartHandler);
|
|
203
|
-
this.editor.off("blur", this.blurHandler);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function clickHandler(options) {
|
|
209
|
-
// Create the tooltip instance
|
|
210
|
-
let tooltip = new Tooltip(options);
|
|
211
|
-
// Initialize the tooltip
|
|
212
|
-
let { tippyModal, tippyInstance } = tooltip.init();
|
|
213
|
-
return new state.Plugin({
|
|
214
|
-
key: new state.PluginKey("handleClickHyperlink"),
|
|
215
|
-
props: {
|
|
216
|
-
handleClick: (view, pos, event) => {
|
|
217
|
-
var _a, _b;
|
|
218
|
-
if (event.button !== 0)
|
|
219
|
-
return false;
|
|
220
|
-
// Get the target HTML element and its position
|
|
221
|
-
const nodeTarget = event.target;
|
|
222
|
-
const nodePos = view.posAtDOM(nodeTarget, 0);
|
|
223
|
-
// Find the closest link element to the target element
|
|
224
|
-
const link = nodeTarget === null || nodeTarget === void 0 ? void 0 : nodeTarget.closest("a");
|
|
225
|
-
// Extract attributes from the state
|
|
226
|
-
const attrs = core.getAttributes(view.state, options.type.name);
|
|
227
|
-
// Extract href and target attributes from the link element or the state
|
|
228
|
-
const href = (_a = link === null || link === void 0 ? void 0 : link.href) !== null && _a !== void 0 ? _a : attrs.href;
|
|
229
|
-
const target = (_b = link === null || link === void 0 ? void 0 : link.target) !== null && _b !== void 0 ? _b : attrs.target;
|
|
230
|
-
// If there is no previewHyperlink modal provided, then open the link in new window
|
|
231
|
-
if (!options.modal) {
|
|
232
|
-
if (link && href) {
|
|
233
|
-
window.open(href, target);
|
|
234
|
-
}
|
|
235
|
-
return true;
|
|
236
|
-
}
|
|
237
|
-
// if the link does not contain href attribute, hide the tooltip
|
|
238
|
-
if (!(link === null || link === void 0 ? void 0 : link.href))
|
|
239
|
-
return tooltip.hide();
|
|
240
|
-
// Create a preview of the hyperlink
|
|
241
|
-
const hyperlinkPreview = options.modal({
|
|
242
|
-
link,
|
|
243
|
-
nodePos,
|
|
244
|
-
tippy: tooltip,
|
|
245
|
-
...options,
|
|
246
|
-
});
|
|
247
|
-
// If there is no hyperlink preview, hide the modal
|
|
248
|
-
if (!hyperlinkPreview)
|
|
249
|
-
return tooltip.hide();
|
|
250
|
-
// Empty the modal and append the hyperlink preview box
|
|
251
|
-
while (tippyModal.firstChild) {
|
|
252
|
-
tippyModal.removeChild(tippyModal.firstChild);
|
|
253
|
-
}
|
|
254
|
-
tippyModal.append(hyperlinkPreview);
|
|
255
|
-
// Update the modal position
|
|
256
|
-
tooltip.update(options.editor.view);
|
|
257
|
-
return false;
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function pasteHandler(options) {
|
|
264
|
-
return new state.Plugin({
|
|
265
|
-
key: new state.PluginKey("handlePasteHyperlink"),
|
|
266
|
-
props: {
|
|
267
|
-
handlePaste: (view, event, slice) => {
|
|
268
|
-
const { state } = view;
|
|
269
|
-
const { selection } = state;
|
|
270
|
-
const { empty } = selection;
|
|
271
|
-
if (empty) {
|
|
272
|
-
return false;
|
|
273
|
-
}
|
|
274
|
-
let textContent = "";
|
|
275
|
-
slice.content.forEach((node) => {
|
|
276
|
-
textContent += node.textContent;
|
|
277
|
-
});
|
|
278
|
-
const link = linkifyjs.find(textContent).find((item) => item.isLink && item.value === textContent);
|
|
279
|
-
if (!textContent || !link) {
|
|
280
|
-
return false;
|
|
281
|
-
}
|
|
282
|
-
options.editor.commands.setMark(options.type, {
|
|
283
|
-
href: link.href,
|
|
284
|
-
});
|
|
285
|
-
return true;
|
|
286
|
-
},
|
|
287
|
-
},
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function editHyperlink(options) {
|
|
292
|
-
var _a;
|
|
293
|
-
const { state, dispatch } = options.editor.view;
|
|
294
|
-
const { from, to } = state.selection;
|
|
295
|
-
let link = null;
|
|
296
|
-
const selectedNode = options.editor.view.domAtPos(from - 1).node;
|
|
297
|
-
const nodeName = selectedNode === null || selectedNode === void 0 ? void 0 : selectedNode.nodeName;
|
|
298
|
-
if (nodeName === "#text") {
|
|
299
|
-
link = (_a = selectedNode.parentNode) === null || _a === void 0 ? void 0 : _a.closest("a");
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
link = selectedNode === null || selectedNode === void 0 ? void 0 : selectedNode.closest("a");
|
|
303
|
-
}
|
|
304
|
-
// If no link found and node is paragraph, try finding link in sibling/parent
|
|
305
|
-
if (!link && options.editor.view.domAtPos(from).node.nodeName === "P" && selectedNode.nextSibling)
|
|
306
|
-
link =
|
|
307
|
-
selectedNode.nextSibling ||
|
|
308
|
-
selectedNode.parentElement;
|
|
309
|
-
if (!link)
|
|
310
|
-
return true;
|
|
311
|
-
const text = options.newText || (link === null || link === void 0 ? void 0 : link.innerText);
|
|
312
|
-
// Get the position of the link in the editor view
|
|
313
|
-
const nodePos = options.editor.view.posAtDOM(link, 0);
|
|
314
|
-
const sanitizeURL = linkifyjs.find(options.newURL || link.href)
|
|
315
|
-
.filter((link) => link.isLink)
|
|
316
|
-
.filter((link) => (options.validate ? options.validate(link.value) : true))
|
|
317
|
-
.at(0);
|
|
318
|
-
return options.editor
|
|
319
|
-
.chain()
|
|
320
|
-
.focus()
|
|
321
|
-
.command(({ tr }) => {
|
|
322
|
-
var _a;
|
|
323
|
-
tr.deleteRange(nodePos, nodePos + ((_a = ((link === null || link === void 0 ? void 0 : link.innerText) || "")) === null || _a === void 0 ? void 0 : _a.length)).replaceWith(nodePos, nodePos, options.editor.schema.text(text, [
|
|
324
|
-
options.editor.schema.marks.hyperlink.create({
|
|
325
|
-
href: sanitizeURL === null || sanitizeURL === void 0 ? void 0 : sanitizeURL.href,
|
|
326
|
-
}),
|
|
327
|
-
]));
|
|
328
|
-
return true;
|
|
329
|
-
})
|
|
330
|
-
.run();
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
const Hyperlink = core.Mark.create({
|
|
334
|
-
name: "hyperlink",
|
|
335
|
-
priority: 1000,
|
|
336
|
-
keepOnSplit: false,
|
|
337
|
-
onCreate() {
|
|
338
|
-
this.options.protocols.forEach((protocol) => {
|
|
339
|
-
if (typeof protocol === "string") {
|
|
340
|
-
linkifyjs.registerCustomProtocol(protocol);
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
linkifyjs.registerCustomProtocol(protocol.scheme, protocol.optionalSlashes);
|
|
344
|
-
});
|
|
345
|
-
},
|
|
346
|
-
onDestroy() {
|
|
347
|
-
linkifyjs.reset();
|
|
348
|
-
},
|
|
349
|
-
inclusive() {
|
|
350
|
-
return this.options.autoHyperlink;
|
|
351
|
-
},
|
|
352
|
-
addOptions() {
|
|
353
|
-
return {
|
|
354
|
-
openOnClick: true,
|
|
355
|
-
hyperlinkOnPaste: true,
|
|
356
|
-
autoHyperlink: true,
|
|
357
|
-
protocols: [],
|
|
358
|
-
HTMLAttributes: {
|
|
359
|
-
target: "_blank",
|
|
360
|
-
rel: "noopener noreferrer nofollow",
|
|
361
|
-
class: null,
|
|
362
|
-
},
|
|
363
|
-
modals: {
|
|
364
|
-
previewHyperlink: null,
|
|
365
|
-
setHyperlink: null,
|
|
366
|
-
},
|
|
367
|
-
validate: undefined,
|
|
368
|
-
};
|
|
369
|
-
},
|
|
370
|
-
addAttributes() {
|
|
371
|
-
return {
|
|
372
|
-
href: {
|
|
373
|
-
default: null,
|
|
374
|
-
},
|
|
375
|
-
target: {
|
|
376
|
-
default: this.options.HTMLAttributes.target,
|
|
377
|
-
},
|
|
378
|
-
class: {
|
|
379
|
-
default: this.options.HTMLAttributes.class,
|
|
380
|
-
},
|
|
381
|
-
};
|
|
382
|
-
},
|
|
383
|
-
parseHTML() {
|
|
384
|
-
return [{ tag: 'a[href]:not([href *= "javascript:" i])' }];
|
|
385
|
-
},
|
|
386
|
-
renderHTML({ HTMLAttributes }) {
|
|
387
|
-
return ["a", core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
388
|
-
},
|
|
389
|
-
addCommands() {
|
|
390
|
-
return {
|
|
391
|
-
setHyperlink: (attributes) => ({ editor, chain }) => {
|
|
392
|
-
if (!this.options.modals.setHyperlink) {
|
|
393
|
-
return chain()
|
|
394
|
-
.setMark(this.name, attributes)
|
|
395
|
-
.setMeta("preventAutohyperlink", true)
|
|
396
|
-
.run();
|
|
397
|
-
}
|
|
398
|
-
else {
|
|
399
|
-
this.options.modals.setHyperlink({
|
|
400
|
-
editor,
|
|
401
|
-
validate: this.options.validate,
|
|
402
|
-
extentionName: this.name,
|
|
403
|
-
attributes,
|
|
404
|
-
Tooltip,
|
|
405
|
-
roundArrow: tippy.roundArrow,
|
|
406
|
-
});
|
|
407
|
-
return true;
|
|
408
|
-
}
|
|
409
|
-
},
|
|
410
|
-
editHyperlink: (attributes) => ({ editor }) => {
|
|
411
|
-
return editHyperlink({
|
|
412
|
-
...attributes,
|
|
413
|
-
editor,
|
|
414
|
-
validate: this.options.validate,
|
|
415
|
-
});
|
|
416
|
-
},
|
|
417
|
-
editHyperLinkText: (newText) => ({ editor }) => {
|
|
418
|
-
return editHyperlink({
|
|
419
|
-
editor,
|
|
420
|
-
newText,
|
|
421
|
-
validate: this.options.validate,
|
|
422
|
-
});
|
|
423
|
-
},
|
|
424
|
-
editHyperLinkHref: (newURL) => ({ editor }) => {
|
|
425
|
-
return editHyperlink({
|
|
426
|
-
editor,
|
|
427
|
-
validate: this.options.validate,
|
|
428
|
-
newURL,
|
|
429
|
-
});
|
|
430
|
-
},
|
|
431
|
-
unsetHyperlink: () => ({ chain }) => {
|
|
432
|
-
return chain()
|
|
433
|
-
.unsetMark(this.name, { extendEmptyMarkRange: true })
|
|
434
|
-
.setMeta("preventAutohyperlink", true)
|
|
435
|
-
.run();
|
|
436
|
-
},
|
|
437
|
-
};
|
|
438
|
-
},
|
|
439
|
-
addPasteRules() {
|
|
440
|
-
return [
|
|
441
|
-
core.markPasteRule({
|
|
442
|
-
find: (text) => linkifyjs.find(text)
|
|
443
|
-
.filter((link) => {
|
|
444
|
-
if (this.options.validate) {
|
|
445
|
-
return this.options.validate(link.value);
|
|
446
|
-
}
|
|
447
|
-
return true;
|
|
448
|
-
})
|
|
449
|
-
.filter((link) => link.isLink)
|
|
450
|
-
.map((link) => ({
|
|
451
|
-
text: link.value,
|
|
452
|
-
index: link.start,
|
|
453
|
-
data: link,
|
|
454
|
-
})),
|
|
455
|
-
type: this.type,
|
|
456
|
-
getAttributes: (match) => {
|
|
457
|
-
var _a;
|
|
458
|
-
return ({
|
|
459
|
-
href: (_a = match.data) === null || _a === void 0 ? void 0 : _a.href,
|
|
460
|
-
});
|
|
461
|
-
},
|
|
462
|
-
}),
|
|
463
|
-
];
|
|
464
|
-
},
|
|
465
|
-
addProseMirrorPlugins() {
|
|
466
|
-
const plugins = [];
|
|
467
|
-
if (this.options.autoHyperlink) {
|
|
468
|
-
plugins.push(autoHyperlink({
|
|
469
|
-
type: this.type,
|
|
470
|
-
validate: this.options.validate,
|
|
471
|
-
}));
|
|
472
|
-
}
|
|
473
|
-
if (this.options.openOnClick) {
|
|
474
|
-
plugins.push(clickHandler({
|
|
475
|
-
type: this.type,
|
|
476
|
-
editor: this.editor,
|
|
477
|
-
validate: this.options.validate,
|
|
478
|
-
modal: this.options.modals.previewHyperlink,
|
|
479
|
-
}));
|
|
480
|
-
}
|
|
481
|
-
if (this.options.hyperlinkOnPaste) {
|
|
482
|
-
plugins.push(pasteHandler({
|
|
483
|
-
editor: this.editor,
|
|
484
|
-
type: this.type,
|
|
485
|
-
}));
|
|
486
|
-
}
|
|
487
|
-
return plugins;
|
|
488
|
-
},
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
const editHyperlinkHandler = (options) => {
|
|
492
|
-
var _a;
|
|
493
|
-
// Create the form
|
|
494
|
-
const form = document.createElement("form");
|
|
495
|
-
const buttonsWrapper = document.createElement("div");
|
|
496
|
-
const inputsWrapper = document.createElement("div");
|
|
497
|
-
const linkTextInput = document.createElement("input");
|
|
498
|
-
const hrefInput = document.createElement("input");
|
|
499
|
-
const applyButton = document.createElement("button");
|
|
500
|
-
buttonsWrapper.classList.add("hyperlink-edit-modal__buttons-wrapper");
|
|
501
|
-
inputsWrapper.classList.add("hyperlink-edit-modal__inputs-wrapper");
|
|
502
|
-
linkTextInput.type = "text";
|
|
503
|
-
linkTextInput.value = ((_a = options.link) === null || _a === void 0 ? void 0 : _a.innerText) || "";
|
|
504
|
-
linkTextInput.placeholder = "Enter link text";
|
|
505
|
-
hrefInput.type = "text";
|
|
506
|
-
hrefInput.value = options.link.href;
|
|
507
|
-
hrefInput.placeholder = "Enter href";
|
|
508
|
-
applyButton.type = "submit";
|
|
509
|
-
applyButton.classList.add("hyperlink-edit-modal__apply-button");
|
|
510
|
-
applyButton.innerText = "Apply";
|
|
511
|
-
buttonsWrapper.append(applyButton);
|
|
512
|
-
inputsWrapper.append(linkTextInput, hrefInput);
|
|
513
|
-
// Append to form
|
|
514
|
-
form.append(inputsWrapper, buttonsWrapper);
|
|
515
|
-
options.hyperlinkModal.innerHTML = "";
|
|
516
|
-
options.hyperlinkModal.appendChild(form);
|
|
517
|
-
hrefInput.addEventListener("keydown", () => {
|
|
518
|
-
hrefInput.style.outlineColor = " #dadce0";
|
|
519
|
-
});
|
|
520
|
-
hrefInput.addEventListener("keydown", () => {
|
|
521
|
-
linkTextInput.style.outlineColor = " #dadce0";
|
|
522
|
-
});
|
|
523
|
-
// Handle form submission
|
|
524
|
-
form.addEventListener("submit", (e) => {
|
|
525
|
-
e.preventDefault();
|
|
526
|
-
const newLinkText = linkTextInput.value;
|
|
527
|
-
const newHref = hrefInput.value;
|
|
528
|
-
if (!newHref || !newLinkText) {
|
|
529
|
-
if (!newHref)
|
|
530
|
-
hrefInput.style.outlineColor = "red";
|
|
531
|
-
if (!newLinkText)
|
|
532
|
-
linkTextInput.style.outlineColor = "red";
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
const sanitizeURL = linkifyjs.find(newHref)
|
|
536
|
-
.filter((link) => link.isLink)
|
|
537
|
-
.filter((link) => {
|
|
538
|
-
if (options.validate) {
|
|
539
|
-
return options.validate(link.value);
|
|
540
|
-
}
|
|
541
|
-
return true;
|
|
542
|
-
})
|
|
543
|
-
.at(0);
|
|
544
|
-
if (!(sanitizeURL === null || sanitizeURL === void 0 ? void 0 : sanitizeURL.href)) {
|
|
545
|
-
hrefInput.style.outlineColor = "red";
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
548
|
-
options.editor.chain().focus().extendMarkRange("hyperlink").editHyperlink({
|
|
549
|
-
newURL: newHref,
|
|
550
|
-
newText: newLinkText,
|
|
551
|
-
});
|
|
552
|
-
options.tippy.hide();
|
|
553
|
-
});
|
|
554
|
-
// Show tooltip
|
|
555
|
-
options.tippy.update(options.editor.view, {
|
|
556
|
-
arrow: tippy.roundArrow,
|
|
557
|
-
});
|
|
558
|
-
setTimeout(() => linkTextInput.focus());
|
|
559
|
-
};
|
|
560
|
-
|
|
561
|
-
// prettier-ignore
|
|
562
|
-
const Copy = ({ size = 24, fill = 'rgb(104, 81, 255)' } = {}) => {
|
|
563
|
-
return `
|
|
564
|
-
<svg fill=${fill} viewBox="0 0 24 24" width=${size} xmlns="http://www.w3.org/2000/svg">
|
|
565
|
-
<path d="m13 20a5.006 5.006 0 0 0 5-5v-8.757a3.972 3.972 0 0 0 -1.172-2.829l-2.242-2.242a3.972 3.972 0 0 0 -2.829-1.172h-4.757a5.006 5.006 0 0 0 -5 5v10a5.006 5.006 0 0 0 5 5zm-9-5v-10a3 3 0 0 1 3-3s4.919.014 5 .024v1.976a2 2 0 0 0 2 2h1.976c.01.081.024 9 .024 9a3 3 0 0 1 -3 3h-6a3 3 0 0 1 -3-3zm18-7v11a5.006 5.006 0 0 1 -5 5h-9a1 1 0 0 1 0-2h9a3 3 0 0 0 3-3v-11a1 1 0 0 1 2 0z"/>
|
|
566
|
-
</svg>
|
|
567
|
-
`;
|
|
568
|
-
};
|
|
569
|
-
const LinkSlash = ({ size = 24, fill = "rgb(104, 81, 255)", } = {}) => {
|
|
570
|
-
return `
|
|
571
|
-
<svg fill=${fill} viewBox="0 0 24 24" width=${size} xmlns="http://www.w3.org/2000/svg">
|
|
572
|
-
<path d="M11.953,17.993c-1.557-.074-3.021-.722-4.121-1.823-.23-.23-.446-.482-.641-.748-.325-.446-.227-1.072,.22-1.397,.446-.325,1.071-.227,1.397,.219,.129,.178,.274,.349,.437,.511,.749,.75,1.744,1.19,2.802,1.24,.552,.026,.979,.495,.952,1.046-.025,.536-.468,.953-.998,.953h-.048ZM1.831,13.331C.65,14.511,0,16.081,0,17.75c0,1.669,.65,3.239,1.831,4.419,1.18,1.181,2.749,1.831,4.419,1.831s3.239-.65,4.419-1.831l1.058-1.058c.391-.391,.391-1.023,0-1.414s-1.023-.391-1.414,0l-1.058,1.058c-.803,.803-1.87,1.245-3.005,1.245s-2.202-.442-3.005-1.245-1.245-1.87-1.245-3.005,.442-2.203,1.245-3.005l3.037-3.038c.391-.391,.391-1.024,0-1.414-.391-.391-1.023-.391-1.414,0l-3.037,3.038ZM.293,1.707L22.293,23.707c.195,.195,.451,.293,.707,.293s.512-.098,.707-.293c.391-.391,.391-1.023,0-1.414l-6.581-6.581,5.043-5.043c1.181-1.18,1.831-2.75,1.831-4.419,0-1.669-.65-3.239-1.831-4.419C20.989,.65,19.42,0,17.75,0s-3.239,.65-4.419,1.831l-1.058,1.058c-.391,.391-.391,1.023,0,1.414s1.023,.391,1.414,0l1.058-1.058c.803-.803,1.87-1.245,3.005-1.245s2.202,.442,3.005,1.245,1.245,1.87,1.245,3.005-.442,2.203-1.245,3.005l-5.043,5.043-5.852-5.852c1.612-.808,3.575-.52,4.894,.798,.162,.162,.308,.333,.437,.511,.196,.269,.501,.411,.81,.411,.204,0,.41-.063,.588-.192,.446-.325,.545-.951,.22-1.397-.194-.266-.41-.518-.641-.748-2.095-2.095-5.297-2.408-7.76-.835L1.707,.293c-.391-.391-1.023-.391-1.414,0s-.391,1.023,0,1.414Z"/>
|
|
573
|
-
</svg>
|
|
574
|
-
`;
|
|
575
|
-
};
|
|
576
|
-
const Pencil = ({ size = 24, fill = "rgb(104, 81, 255)", } = {}) => {
|
|
577
|
-
return `
|
|
578
|
-
<svg fill=${fill} viewBox="0 0 24 24" width=${size} xmlns="http://www.w3.org/2000/svg">
|
|
579
|
-
<path d="M22.853,1.148a3.626,3.626,0,0,0-5.124,0L1.465,17.412A4.968,4.968,0,0,0,0,20.947V23a1,1,0,0,0,1,1H3.053a4.966,4.966,0,0,0,3.535-1.464L22.853,6.271A3.626,3.626,0,0,0,22.853,1.148ZM5.174,21.122A3.022,3.022,0,0,1,3.053,22H2V20.947a2.98,2.98,0,0,1,.879-2.121L15.222,6.483l2.3,2.3ZM21.438,4.857,18.932,7.364l-2.3-2.295,2.507-2.507a1.623,1.623,0,1,1,2.295,2.3Z"/>
|
|
580
|
-
</svg>
|
|
581
|
-
`;
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
function previewHyperlinkModal(options) {
|
|
585
|
-
const href = options.link.href;
|
|
586
|
-
const hyperlinkModal = document.createElement("div");
|
|
587
|
-
const removeButton = document.createElement("button");
|
|
588
|
-
const copyButton = document.createElement("button");
|
|
589
|
-
const editButton = document.createElement("button");
|
|
590
|
-
const newBubble = document.createElement("div");
|
|
591
|
-
newBubble.classList.add("hyperlink-preview-modal__metadata");
|
|
592
|
-
const hrefTitle = document.createElement("a");
|
|
593
|
-
hrefTitle.setAttribute("target", "_blank");
|
|
594
|
-
hrefTitle.setAttribute("rel", "noreferrer");
|
|
595
|
-
hrefTitle.setAttribute("href", href);
|
|
596
|
-
hrefTitle.innerText = href;
|
|
597
|
-
newBubble.append(hrefTitle);
|
|
598
|
-
fetch("/api/metadata", {
|
|
599
|
-
method: "POST",
|
|
600
|
-
headers: { "Content-Type": "application/json" },
|
|
601
|
-
body: JSON.stringify({ url: href }),
|
|
602
|
-
})
|
|
603
|
-
.then((response) => response.json())
|
|
604
|
-
.then((data) => {
|
|
605
|
-
// Create a new bubble with the title
|
|
606
|
-
hrefTitle.setAttribute("href", href);
|
|
607
|
-
hrefTitle.innerText = data.title || data["og:title"] || href;
|
|
608
|
-
newBubble.replaceChildren(hrefTitle);
|
|
609
|
-
// Create an image element if image exists in metadata
|
|
610
|
-
if (data.icon || data.image || data["og:image"]) {
|
|
611
|
-
const img = document.createElement("img");
|
|
612
|
-
img.src = data.icon || data.image || data["og:image"];
|
|
613
|
-
img.alt = data.title || data["og:title"] || "hyperlink image";
|
|
614
|
-
newBubble.appendChild(img);
|
|
615
|
-
}
|
|
616
|
-
})
|
|
617
|
-
.catch((error) => {
|
|
618
|
-
console.error("Error fetching metadata:", error);
|
|
619
|
-
});
|
|
620
|
-
hyperlinkModal.classList.add("hyperlink-preview-modal");
|
|
621
|
-
removeButton.classList.add("hyperlink-preview-modal__remove-button");
|
|
622
|
-
removeButton.innerHTML = LinkSlash();
|
|
623
|
-
editButton.classList.add("hyperlink-preview-modal__edit-button");
|
|
624
|
-
editButton.innerHTML = Pencil();
|
|
625
|
-
copyButton.classList.add("hyperlink-preview-modal__copy-button");
|
|
626
|
-
copyButton.innerHTML = Copy();
|
|
627
|
-
removeButton.addEventListener("click", () => {
|
|
628
|
-
options.tippy.hide();
|
|
629
|
-
return options.editor.chain().focus().unsetHyperlink().run();
|
|
630
|
-
});
|
|
631
|
-
editButton.addEventListener("click", () => editHyperlinkHandler({ ...options, hyperlinkModal }));
|
|
632
|
-
copyButton.addEventListener("click", () => {
|
|
633
|
-
options.tippy.hide();
|
|
634
|
-
navigator.clipboard.writeText(href);
|
|
635
|
-
});
|
|
636
|
-
hyperlinkModal.append(newBubble, copyButton, editButton, removeButton);
|
|
637
|
-
return hyperlinkModal;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
let tooltip = undefined;
|
|
641
|
-
function setHyperlinkModal(options) {
|
|
642
|
-
// Create the tooltip instance
|
|
643
|
-
if (!tooltip)
|
|
644
|
-
tooltip = new options.Tooltip(options);
|
|
645
|
-
// Initialize the tooltip
|
|
646
|
-
let { tippyModal } = tooltip.init();
|
|
647
|
-
const hyperlinkModal = document.createElement("div");
|
|
648
|
-
const buttonsWrapper = document.createElement("div");
|
|
649
|
-
const inputsWrapper = document.createElement("div");
|
|
650
|
-
hyperlinkModal.classList.add("hyperlink-set-modal");
|
|
651
|
-
buttonsWrapper.classList.add("hyperlink-set-modal__buttons-wrapper");
|
|
652
|
-
inputsWrapper.classList.add("hyperlink-set-modal__inputs-wrapper");
|
|
653
|
-
// create a form that contain url input and a button for submit
|
|
654
|
-
const form = document.createElement("form");
|
|
655
|
-
const input = document.createElement("input");
|
|
656
|
-
const button = document.createElement("button");
|
|
657
|
-
input.setAttribute("type", "text");
|
|
658
|
-
input.setAttribute("placeholder", "https://example.com");
|
|
659
|
-
button.setAttribute("type", "submit");
|
|
660
|
-
button.innerText = "Submit";
|
|
661
|
-
inputsWrapper.append(input);
|
|
662
|
-
buttonsWrapper.append(button);
|
|
663
|
-
form.append(inputsWrapper, buttonsWrapper);
|
|
664
|
-
hyperlinkModal.append(form);
|
|
665
|
-
tippyModal.innerHTML = "";
|
|
666
|
-
tippyModal.append(hyperlinkModal);
|
|
667
|
-
tooltip.update(options.editor.view, {
|
|
668
|
-
arrow: options.roundArrow,
|
|
669
|
-
});
|
|
670
|
-
// make sure
|
|
671
|
-
setTimeout(() => {
|
|
672
|
-
input.focus();
|
|
673
|
-
input.style.outlineColor = " #dadce0";
|
|
674
|
-
}, 100);
|
|
675
|
-
input.addEventListener("keydown", () => {
|
|
676
|
-
input.style.outlineColor = " #dadce0";
|
|
677
|
-
});
|
|
678
|
-
// event listenr for submit button
|
|
679
|
-
form.addEventListener("submit", (event) => {
|
|
680
|
-
event.preventDefault();
|
|
681
|
-
const url = input.value;
|
|
682
|
-
if (!url) {
|
|
683
|
-
input.style.outlineColor = "red";
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
const sanitizeURL = linkifyjs.find(url)
|
|
687
|
-
.filter((link) => link.isLink)
|
|
688
|
-
.filter((link) => {
|
|
689
|
-
if (options.validate) {
|
|
690
|
-
return options.validate(link.value);
|
|
691
|
-
}
|
|
692
|
-
return true;
|
|
693
|
-
})
|
|
694
|
-
.at(0);
|
|
695
|
-
if (!(sanitizeURL === null || sanitizeURL === void 0 ? void 0 : sanitizeURL.href)) {
|
|
696
|
-
input.style.outlineColor = "red";
|
|
697
|
-
return;
|
|
698
|
-
}
|
|
699
|
-
tooltip === null || tooltip === void 0 ? void 0 : tooltip.hide();
|
|
700
|
-
return options.editor
|
|
701
|
-
.chain()
|
|
702
|
-
.setMark(options.extentionName, { href: sanitizeURL.href })
|
|
703
|
-
.setMeta("preventautohyperlink", true)
|
|
704
|
-
.run();
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
exports.Hyperlink = Hyperlink;
|
|
709
|
-
exports.Tooltip = Tooltip;
|
|
710
|
-
exports.previewHyperlinkModal = previewHyperlinkModal;
|
|
711
|
-
exports.setHyperlinkModal = setHyperlinkModal;
|
|
712
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
"use strict";var J=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Le=Object.prototype.hasOwnProperty;var xe=(e,t)=>{for(var o in t)J(e,o,{get:t[o],enumerable:!0})},Me=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of we(t))!Le.call(e,r)&&r!==o&&J(e,r,{get:()=>t[r],enumerable:!(n=He(t,r))||n.enumerable});return e};var Ce=e=>Me(J({},"__esModule",{value:!0}),e);var mt={};xe(mt,{Copy:()=>se,DANGEROUS_SCHEME_RE:()=>I,DEFAULT_OFFSET:()=>Z,Hyperlink:()=>ie,Link:()=>V,LinkOff:()=>le,Pencil:()=>ce,Title:()=>pe,copyToClipboard:()=>ae,createFloatingToolbar:()=>R,createHTMLElement:()=>p,createHyperlinkPopover:()=>de,default:()=>ut,destroyCurrentToolbar:()=>Xe,editHyperlinkPopover:()=>q,getCategories:()=>Ue,getCurrentToolbar:()=>je,getSpecialUrlInfo:()=>ee,getUrlScheme:()=>te,getUrlsByCategory:()=>_e,hideCurrentToolbar:()=>w,isSpecialSchemeUrl:()=>qe,isToolbarVisible:()=>Ye,normalizeHref:()=>P,normalizeLinkifyHref:()=>N,previewHyperlinkPopover:()=>X,registerCustomProtocol:()=>Ee.registerCustomProtocol,updateCurrentToolbarPosition:()=>Je,validateURL:()=>C});module.exports=Ce(mt);var F=require("@tiptap/core"),W=require("linkifyjs");var he=require("@tiptap/core");var Ae=/^[a-z][a-z0-9+.-]*:/i,P=e=>{let t=e.trim();return t?Ae.test(t)||t.startsWith("//")?t:`https://${t}`:""},N=e=>e.type==="url"?P(e.value):e.href;var ye=require("linkifyjs");var Pe={"mailto:":{type:"email",title:"Email",icon:"HiMail",category:"communication"},"tel:":{type:"phone",title:"Phone",icon:"HiPhone",category:"communication"},"telprompt:":{type:"phone",title:"Phone",icon:"HiPhone",category:"communication"},"sms:":{type:"sms",title:"SMS",icon:"HiChatBubbleLeftRight",category:"communication"},"facetime:":{type:"facetime",title:"FaceTime",icon:"HiVideoCamera",category:"communication"},"facetime-audio:":{type:"facetime-audio",title:"FaceTime Audio",icon:"HiPhone",category:"communication"}},Se={"whatsapp:":{type:"whatsapp",title:"WhatsApp",icon:"FaWhatsapp",category:"social"},"tg:":{type:"telegram",title:"Telegram",icon:"FaTelegram",category:"social"},"discord:":{type:"discord",title:"Discord",icon:"FaDiscord",category:"social"},"skype:":{type:"skype",title:"Skype",icon:"FaSkype",category:"social"},"slack:":{type:"slack",title:"Slack",icon:"FaSlack",category:"social"},"twitter:":{type:"twitter",title:"Twitter",icon:"FaTwitter",category:"social"},"fb:":{type:"facebook",title:"Facebook",icon:"FaFacebook",category:"social"},"instagram:":{type:"instagram",title:"Instagram",icon:"FaInstagram",category:"social"},"linkedin:":{type:"linkedin",title:"LinkedIn",icon:"FaLinkedin",category:"social"},"snapchat:":{type:"snapchat",title:"Snapchat",icon:"FaSnapchat",category:"social"},"reddit:":{type:"reddit",title:"Reddit",icon:"FaReddit",category:"social"},"tiktok:":{type:"tiktok",title:"TikTok",icon:"SiTiktok",category:"social"}},Re={"zoommtg:":{type:"zoom",title:"Zoom Meeting",icon:"SiZoom",category:"communication"},"zoomus:":{type:"zoom",title:"Zoom",icon:"SiZoom",category:"communication"},"msteams:":{type:"teams",title:"Microsoft Teams",icon:"SiMicrosoftteams",category:"communication"},"webex:":{type:"webex",title:"Cisco Webex",icon:"SiCisco",category:"communication"}},Oe={"calshow:":{type:"calendar",title:"Calendar",icon:"HiCalendar",category:"apple"},"x-apple-calevent:":{type:"calendar",title:"Calendar Event",icon:"HiCalendar",category:"apple"},"contacts:":{type:"contacts",title:"Contacts",icon:"HiUsers",category:"apple"},"maps:":{type:"maps",title:"Maps",icon:"HiMapPin",category:"apple"},"map:":{type:"maps",title:"Maps",icon:"HiMapPin",category:"apple"},"music:":{type:"music",title:"Apple Music",icon:"HiMusicalNote",category:"apple"},"videos:":{type:"tv",title:"Apple TV",icon:"HiTv",category:"apple"},"mobilenotes:":{type:"notes",title:"Notes",icon:"HiDocumentText",category:"apple"},"x-apple-reminder:":{type:"reminders",title:"Reminders",icon:"HiCheckCircle",category:"apple"},"photos-redirect:":{type:"photos",title:"Photos",icon:"HiPhoto",category:"apple"},"shortcuts:":{type:"shortcuts",title:"Shortcuts",icon:"HiLightningBolt",category:"apple"},"itms-apps:":{type:"appstore",title:"App Store",icon:"SiAppstore",category:"apple"}},Ie={"github:":{type:"github",title:"GitHub",icon:"FaGithub",category:"development"},"gitlab:":{type:"gitlab",title:"GitLab",icon:"FaGitlab",category:"development"},"vscode:":{type:"vscode",title:"VS Code",icon:"SiVisualstudiocode",category:"development"},"notion:":{type:"notion",title:"Notion",icon:"SiNotion",category:"productivity"},"obsidian:":{type:"obsidian",title:"Obsidian",icon:"SiObsidian",category:"productivity"},"figma:":{type:"figma",title:"Figma",icon:"FaFigma",category:"development"}},Fe={"youtube:":{type:"youtube",title:"YouTube",icon:"FaYoutube",category:"entertainment"},"spotify:":{type:"spotify",title:"Spotify",icon:"FaSpotify",category:"entertainment"},"netflix:":{type:"netflix",title:"Netflix",icon:"SiNetflix",category:"entertainment"},"twitch:":{type:"twitch",title:"Twitch",icon:"FaTwitch",category:"entertainment"}},Ne={"amazon:":{type:"amazon",title:"Amazon",icon:"FaAmazon",category:"shopping"},"uber:":{type:"uber",title:"Uber",icon:"SiUber",category:"other"},"lyft:":{type:"lyft",title:"Lyft",icon:"SiLyft",category:"other"}},Q={...Pe,...Se,...Re,...Oe,...Ie,...Fe,...Ne},B={"wa.me":{type:"whatsapp",title:"WhatsApp",icon:"FaWhatsapp",category:"social"},"t.me":{type:"telegram",title:"Telegram",icon:"FaTelegram",category:"social"},"discord.gg":{type:"discord",title:"Discord Invite",icon:"FaDiscord",category:"social"},"zoom.us":{type:"zoom",title:"Zoom Meeting",icon:"SiZoom",category:"communication"},"meet.google.com":{type:"meet",title:"Google Meet",icon:"SiGooglemeet",category:"communication"},"teams.microsoft.com":{type:"teams",title:"Microsoft Teams",icon:"SiMicrosoftteams",category:"communication"},"github.com":{type:"github",title:"GitHub",icon:"FaGithub",category:"development"},"gitlab.com":{type:"gitlab",title:"GitLab",icon:"FaGitlab",category:"development"},"figma.com":{type:"figma",title:"Figma",icon:"FaFigma",category:"development"},"notion.so":{type:"notion",title:"Notion",icon:"SiNotion",category:"productivity"},"twitter.com":{type:"twitter",title:"Twitter",icon:"FaTwitter",category:"social"},"x.com":{type:"twitter",title:"X (Twitter)",icon:"FaTwitter",category:"social"},"instagram.com":{type:"instagram",title:"Instagram",icon:"FaInstagram",category:"social"},"linkedin.com":{type:"linkedin",title:"LinkedIn",icon:"FaLinkedin",category:"social"},"youtube.com":{type:"youtube",title:"YouTube",icon:"FaYoutube",category:"entertainment"},"spotify.com":{type:"spotify",title:"Spotify",icon:"FaSpotify",category:"entertainment"}},ee=e=>{let t=e.toLowerCase();for(let[o,n]of Object.entries(Q))if(t.startsWith(o))return n;try{let n=new URL(e).hostname.toLowerCase(),r=n.startsWith("www.")?n.slice(4):n;if(B[r])return B[r];for(let[a,i]of Object.entries(B))if(r.endsWith(`.${a}`)||r===a)return i}catch{}return null},Ue=()=>{let e=new Set;return Object.values(Q).forEach(t=>e.add(t.category)),Object.values(B).forEach(t=>e.add(t.category)),Array.from(e).sort()},_e=e=>{let t={};return Object.entries(Q).forEach(([o,n])=>{n.category===e&&(t[o]=n)}),Object.entries(B).forEach(([o,n])=>{n.category===e&&(t[o]=n)}),t};var I=/^\s*(javascript|data|vbscript):/i,De=new Set(["http","https","ftp","ftps"]),Be=/^\d{1,3}(\.\d{1,3}){3}$/,We=e=>ee(e)!==null,Ve=e=>{let t;try{t=new URL(e)}catch{return!1}let o=t.hostname;return o?o==="localhost"||Be.test(o)||o.includes(":")?!0:o.includes("."):!1},C=(e,t)=>{if(!e.trim())return!1;try{if(We(e))return t?.customValidator?t.customValidator(e):!0;let o=(0,ye.find)(e).find(r=>r.isLink&&(t?.customValidator?t.customValidator(r.value):!0));if(!o?.href)return!1;let n=te(o.href);return n&&De.has(n)?Ve(o.href):!0}catch(o){return console.error("URL validation error:",o),!1}},te=e=>{if(!e.trim())return null;let t=e.indexOf(":");return t===-1?null:e.substring(0,t).toLowerCase()},qe=e=>{let t=te(e);return t!==null&&!["http","https","ftp","ftps"].includes(t)};var z=(e={})=>()=>({tr:t,dispatch:o})=>{let{newURL:n,newText:r,title:a,image:i,validate:l,markName:m="hyperlink"}=e;if(n&&!C(n,{customValidator:l}))return!1;let s=t.doc.type.schema.marks[m];if(!s)return!1;let{from:f}=t.selection,h=t.doc.resolve(f),y=(0,he.getMarkRange)(h,s);if(!y)return!1;let d;try{d=t.doc.nodeAt(y.from)?.marks.find(b=>b.type===s)}catch(b){return console.warn("[hyperlink] editHyperlink: failed to read mark at position",b),!1}if(!d)return!1;if(!o)return!0;let T=r||t.doc.textBetween(y.from,y.to),c=n?P(n):d.attrs.href,g=s.create({...d.attrs,href:c,...a!==void 0&&{title:a},...i!==void 0&&{image:i}});return t.replaceWith(y.from,y.to,t.doc.type.schema.text(T,[g])),!0};var E=require("@floating-ui/dom"),Z=8,ze=9999,Ze=8,$e="-5px",Ge=50,S=null;function ge(e){let{x:t,y:o,width:n=0,height:r=0}=e;return{getBoundingClientRect:()=>({width:n,height:r,top:o,right:t+n,bottom:o+r,left:t,x:t,y:o}),contextElement:e.contextElement||document.body}}function Ke(e){let t=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');t.length&&t.forEach((o,n)=>{o.addEventListener("keydown",r=>{if(r.key!=="Tab")return;r.preventDefault();let a=r.shiftKey?(n-1+t.length)%t.length:(n+1)%t.length;t[a].focus()})})}function R(e){S?.destroy();let{referenceElement:t,coordinates:o,content:n,placement:r="bottom-start",offset:a=Z,showArrow:i=!1,className:l="",zIndex:m=ze,onShow:s,onHide:f}=e;if(!t&&!o)throw new Error("Either referenceElement or coordinates must be provided");let h=t||ge(o),y=[],d=!1,T=null,c=document.createElement("div");c.className=`floating-toolbar ${l}`.trim(),c.setAttribute("role","toolbar"),c.setAttribute("tabindex","-1"),c.style.zIndex=String(m),c.style.position="fixed";let g=null;i&&(g=document.createElement("div"),g.className="floating-toolbar-arrow",c.appendChild(g));let b=document.createElement("div");b.className="floating-toolbar-content",c.appendChild(b);let u=v=>{b.innerHTML="",b.appendChild(v),Ke(c)};u(n);let x=async()=>{if(!d)return;let v=[(0,E.offset)(a),(0,E.flip)(),(0,E.shift)({padding:Ze})];g&&v.push((0,E.arrow)({element:g})),v.push((0,E.hide)({strategy:"referenceHidden"}));let{x:k,y:_,placement:A,middlewareData:D}=await(0,E.computePosition)(h,c,{placement:r,strategy:"fixed",middleware:v});if(d&&(Object.assign(c.style,{left:`${k}px`,top:`${_}px`}),c.style.visibility=D.hide?.referenceHidden?"hidden":"visible",g&&D.arrow)){let{x:ue,y:me}=D.arrow,fe=A.split("-")[0],Te={top:"bottom",right:"left",bottom:"top",left:"right"}[fe];g.className=`floating-toolbar-arrow floating-toolbar-arrow-${fe}`,Object.assign(g.style,{left:ue!=null?`${ue}px`:"",top:me!=null?`${me}px`:"",right:"",bottom:"",[Te]:$e})}},H=()=>{d&&(d=!1,T?.(),T=null,c.classList.remove("visible"),c.remove(),y.forEach(v=>v()),y.length=0,f?.())},L={element:c,show:()=>{if(d)return;document.body.appendChild(c),d=!0,T=(0,E.autoUpdate)(h,c,x),requestAnimationFrame(()=>c.classList.add("visible")),setTimeout(()=>{if(!d)return;let k=A=>{c.contains(A.target)||H()},_=A=>{if(!A.touches.length)return;let D=document.elementFromPoint(A.touches[0].clientX,A.touches[0].clientY);c.contains(D)||H()};document.addEventListener("mousedown",k,{passive:!0}),document.addEventListener("touchstart",_,{passive:!0}),y.push(()=>document.removeEventListener("mousedown",k),()=>document.removeEventListener("touchstart",_))},Ge);let v=k=>{k.key==="Escape"&&(k.preventDefault(),H())};c.addEventListener("keydown",v),y.push(()=>c.removeEventListener("keydown",v)),s?.()},hide:H,destroy:()=>{H(),S===L&&(S=null)},isVisible:()=>d,setContent:u,updateReference:(v,k)=>{v?h=v:k&&(h=ge(k)),x()}};return S=L,L}var je=()=>S,Ye=()=>S?.isVisible()??!1,w=()=>{S?.hide()},Xe=()=>{S?.destroy()},Je=(e,t)=>{S?.updateReference(e,t)};var O=require("@tiptap/core"),$=require("@tiptap/pm/state"),G=require("linkifyjs");var Qe=/\b[a-zA-Z][a-zA-Z0-9+.-]*:[^\s]+/g,et=/\b[a-zA-Z][a-zA-Z0-9+.-]*:[^\s]+/,tt=15,ot=/[.,;:!?)\]}]+$/,nt=e=>{let t=e.value.match(ot);if(!t)return e;let o=t[0].length;return{...e,value:e.value.slice(0,-o),href:e.href.endsWith(t[0])?e.href.slice(0,-o):e.href,end:e.end-o}},rt=e=>{let t=[],o=(0,G.find)(e).filter(n=>n.isLink);t.push(...o);for(let n of e.matchAll(Qe)){let r=n[0],a=n.index,i=a+r.length;!o.some(m=>a>=m.start&&i<=m.end)&&C(r)&&t.push({type:"url",href:r,value:r,start:a,end:i,isLink:!0})}return t.map(nt)},ve=e=>(0,G.test)(e)?!0:et.test(e)&&C(e);function oe(e){return new $.Plugin({key:new $.PluginKey("hyperlinkAutolink"),appendTransaction:(t,o,n)=>{let r=t.some(f=>f.docChanged)&&!o.doc.eq(n.doc),a=t.some(f=>f.getMeta("preventAutolink"));if(!r||a)return;let{tr:i}=n,l=(0,O.combineTransactionSteps)(o.doc,[...t]),{mapping:m}=l,s=(0,O.getChangedRanges)(l);for(let{oldRange:f,newRange:h}of s){for(let u of(0,O.getMarksBetween)(f.from,f.to,o.doc).filter(x=>x.mark.type===e.type)){let x=m.map(u.from),H=m.map(u.to),U=(0,O.getMarksBetween)(x,H,n.doc).filter(A=>A.mark.type===e.type);if(!U.length)continue;let M=U[0],L=o.doc.textBetween(u.from,u.to,void 0," "),v=n.doc.textBetween(M.from,M.to,void 0," "),k=ve(L),_=ve(v);k&&!_&&i.removeMark(M.from,M.to,e.type)}let y=(0,O.findChildrenInRange)(n.doc,h,u=>u.isTextblock),d,T;if(y.length>1?(d=y[0],T=n.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):y.length&&n.doc.textBetween(h.from,h.to," "," ").endsWith(" ")&&(d=y[0],T=n.doc.textBetween(d.pos,h.to,void 0," ")),!d||!T)continue;let c=T.split(" ").filter(u=>u!=="");if(c.length<=0)continue;let g=c[c.length-1];if(!g)continue;let b=d.pos+T.lastIndexOf(g);rt(g).filter(u=>u.isLink).filter(u=>e.validate?e.validate(u.value):!0).map(u=>({...u,from:b+u.start+1,to:b+u.end+1})).filter(u=>{let x=Math.max(0,u.from-tt),H=n.doc.textBetween(x,u.from," "," ");return!(H.includes(")}).forEach(u=>{i.addMark(u.from,u.to,e.type.create({href:N(u)}))})}if(i.steps.length)return i}})}var j=require("@tiptap/pm/state");var it=e=>{let t=e.getBoundingClientRect();return{x:t.left,y:t.top,width:t.width,height:t.height}};function K(e,t){let o=e.target;if(!o)return null;let n=o.closest("a");return!n||!t.contains(n)?null:n}function at(e,t,o){return e.state.doc.nodeAt(t)?.marks.find(a=>a.type===o)?.attrs??{href:null,target:null,rel:null,class:null,title:null,image:null}}function ke(e,t,o,n){let r=e.posAtDOM(t,0),a=at(e,r,o.type),i=a.href??t.getAttribute("href"),l=t.target||a.target;if(!o.popover)return i&&!e.editable&&!I.test(i)&&window.open(i,l??void 0),!e.editable;if(!i)return w(),!0;let m=it(t),s=o.popover({editor:o.editor,view:e,link:t,nodePos:r,attrs:a,linkCoords:m,validate:o.validate});if(!s)return w(),!0;if(n!==void 0){let{from:h,to:y}=e.state.selection,d=h===y?n:{from:h,to:y};o.editor.chain().focus(n===0?"start":n).setTextSelection(d).run()}return R({referenceElement:t,content:s,placement:"bottom",offset:Z,showArrow:!0}).show(),!0}function ne(e){return new j.Plugin({key:new j.PluginKey("hyperlinkClickHandler"),view(t){let o=r=>{r.button!==0||!K(r,t.dom)||(r.preventDefault(),r.stopPropagation())},n=r=>{if(r.button!==0)return;K(r,t.dom)&&r.preventDefault()};return t.dom.addEventListener("mousedown",o,!0),t.dom.addEventListener("click",n,!0),{destroy(){t.dom.removeEventListener("mousedown",o,!0),t.dom.removeEventListener("click",n,!0)}}},props:{handleDOMEvents:{touchend:(t,o)=>{let n=K(o,t.dom);if(!n)return!1;o.preventDefault();let{clientX:r,clientY:a}=o.changedTouches[0],i=t.posAtCoords({left:r,top:a});return ke(t,n,e,i?.pos)},click:(t,o)=>{if(o.button!==0)return!1;let n=K(o,t.dom);if(!n)return!1;o.preventDefault();let r=t.posAtCoords({left:o.clientX,top:o.clientY});return ke(t,n,e,r?.pos)}}}})}var Y=require("@tiptap/pm/state"),be=require("linkifyjs");function re(e){return new Y.Plugin({key:new Y.PluginKey("hyperlinkPasteHandler"),props:{handlePaste:(t,o,n)=>{let{state:r}=t,{selection:a}=r,{empty:i}=a;if(i)return!1;let l="";n.content.forEach(s=>{l+=s.textContent});let m=(0,be.find)(l).find(s=>s.isLink&&s.value===l);return!l||!m||e.validate&&!e.validate(m.href)?!1:(e.editor.commands.setMark(e.type,{href:N(m)}),!0)}}})}var st=100,ie=F.Mark.create({name:"hyperlink",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(e=>{typeof e=="string"?(0,W.registerCustomProtocol)(e):(0,W.registerCustomProtocol)(e.scheme,e.optionalSlashes)})},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:null,rel:"noopener noreferrer nofollow",class:null},popovers:{previewHyperlink:null,createHyperlink:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target,rendered:!1},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null},image:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{if(typeof e=="string")return!1;let t=e.getAttribute("href")??"";return I.test(t)?!1:null}}]},renderHTML({HTMLAttributes:e}){return["a",(0,F.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setHyperlink:e=>({editor:t,chain:o})=>{if(!this.options.popovers.createHyperlink){let f=e?.href?{...e,href:P(e.href)}:e;return o().setMark(this.name,f).setMeta("preventAutolink",!0).run()}let n=this.options.popovers.createHyperlink({editor:t,validate:this.options.validate,extensionName:this.name,attributes:e||{}});if(!n)return!0;let{from:r,to:a}=t.state.selection,i=t.view.coordsAtPos(r),l=t.view.coordsAtPos(a);R({coordinates:{x:i.left,y:i.top,width:l.left-i.left,height:l.bottom-i.top,contextElement:t.view.dom},content:n,placement:"bottom",showArrow:!0}).show();let s=n.querySelector("input");return s&&setTimeout(()=>s.focus(),st),!0},editHyperlink:e=>z({...e,validate:this.options.validate,markName:this.name})(),editHyperlinkText:e=>z({newText:e,validate:this.options.validate,markName:this.name})(),editHyperlinkHref:e=>z({newURL:e,validate:this.options.validate,markName:this.name})(),unsetHyperlink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addKeyboardShortcuts(){return{"Mod-k":()=>this.editor.commands.setHyperlink()}},addInputRules(){return[new F.InputRule({find:/(\[([^\]]+)\]\(([^)]+)\))$/,handler:({state:e,range:t,match:o})=>{let[n,,r,a]=o,{tr:i}=e,l=t.from,m=t.to,s=a.trim();if(I.test(s))return;let f=P(s);i.replaceWith(l,m,e.schema.text(r)),i.addMark(l,l+r.length,this.type.create({href:f}))}})]},addPasteRules(){return[(0,F.markPasteRule)({find:e=>(0,W.find)(e).filter(t=>this.options.validate?this.options.validate(t.value):!0).filter(t=>t.isLink).map(t=>({text:t.value,index:t.start,data:t})),type:this.type,getAttributes:e=>({href:N(e.data)})})]},addProseMirrorPlugins(){let e=[];return this.options.autolink&&e.push(oe({type:this.type,validate:this.options.validate})),this.options.openOnClick&&e.push(ne({type:this.type,editor:this.editor,validate:this.options.validate,popover:this.options.popovers.previewHyperlink})),this.options.linkOnPaste&&e.push(re({editor:this.editor,type:this.type,validate:this.options.validate})),e}});var ae=async(e,t)=>{try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(e);else{let o=document.createElement("textarea");o.value=e,document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o)}return t?.(!0),!0}catch(o){return console.warn("Failed to copy to clipboard:",o),t?.(!1),!1}};var p=(e,t)=>{let o=document.createElement(e);return t&&Object.assign(o,t),o};var se=({size:e=24,fill:t="currentColor"}={})=>`
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="${e}" viewBox="0 -960 960 960" width="${e}" fill="${t}">
|
|
3
|
+
<path d="M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"/>
|
|
4
|
+
</svg>
|
|
5
|
+
`,le=({size:e=24,fill:t="currentColor"}={})=>`
|
|
6
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="${e}" viewBox="0 -960 960 960" width="${e}" fill="${t}">
|
|
7
|
+
<path d="m770-302-60-62q40-11 65-42.5t25-73.5q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 57-29.5 105T770-302ZM634-440l-80-80h86v80h-6ZM792-56 56-792l56-56 736 736-56 56ZM440-280H280q-83 0-141.5-58.5T80-480q0-69 42-123t108-71l74 74h-24q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h65l79 80H320Z"/>
|
|
8
|
+
</svg>
|
|
9
|
+
`,V=({size:e=24,fill:t="currentColor"}={})=>`
|
|
10
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="${e}" viewBox="0 -960 960 960" width="${e}" fill="${t}">
|
|
11
|
+
<path d="M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"/>
|
|
12
|
+
</svg>
|
|
13
|
+
`,ce=({size:e=24,fill:t="currentColor"}={})=>`
|
|
14
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="${e}" viewBox="0 -960 960 960" width="${e}" fill="${t}">
|
|
15
|
+
<path d="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z"/>
|
|
16
|
+
</svg>
|
|
17
|
+
`,pe=({size:e=24,fill:t="currentColor"}={})=>`
|
|
18
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="${e}" viewBox="0 -960 960 960" width="${e}" fill="${t}">
|
|
19
|
+
<path d="M420-160v-520H200v-120h560v120H540v520H420Z"/>
|
|
20
|
+
</svg>
|
|
21
|
+
`;var lt=()=>{try{let e=p("div",{className:"hyperlink-create-popover"}),t=p("div",{className:"buttons-wrapper"}),o=p("div",{className:"inputs-wrapper"}),n=p("form",{}),r=p("input",{type:"text",inputMode:"url",name:"hyperlink-url",placeholder:"https://example.com",autocomplete:"new-password",spellcheck:!1}),a=p("button",{type:"submit",textContent:"Apply",disabled:!0}),i=p("div",{className:"error-message",textContent:"Please enter a valid URL"}),l=p("div",{className:"search-icon",innerHTML:V({size:24})});return o.append(l,r,i),t.append(a),n.append(o,t),e.append(n),{root:e,form:n,input:r,button:a,inputsWrapper:o,errorMessage:i}}catch(e){return console.error("Failed to create hyperlink elements:",e),null}},ct=(e,t)=>{let{form:o,input:n,button:r,inputsWrapper:a,errorMessage:i}=e,l=()=>{a.classList.add("error"),i.classList.add("show")},m=()=>{a.classList.remove("error"),i.classList.remove("show")},s=()=>{let f=n.value.trim().length>0;r.disabled=!f,f&&m()};n.addEventListener("input",s),n.addEventListener("paste",()=>setTimeout(s,0)),a.addEventListener("click",()=>n.focus()),n.addEventListener("keydown",f=>{f.key==="Escape"&&(f.preventDefault(),w(),t.editor.commands.focus())}),o.addEventListener("submit",f=>{if(f.preventDefault(),r.disabled)return;let h=n.value.trim();if(!C(h,{customValidator:t.validate})){l();return}let y=P(h);w(),t.editor.chain().setMark(t.extensionName,{href:y}).setMeta("preventAutolink",!0).run()})};function de(e){let t=lt();return t?(ct(t,e),t.root):null}var pt=100;function q(e){let{editor:t,link:o,linkCoords:n,validate:r,view:a}=e,i=p("form",{className:"hyperlink-edit-popover"}),l=p("div",{className:"inputs-wrapper"}),m=p("div",{className:"buttons-wrapper"}),s=p("div",{className:"text-wrapper"}),f=p("div",{className:"search-icon",innerHTML:pe({size:24})}),h=p("input",{type:"text",value:o?.innerText||"",placeholder:"Enter link text"}),y=p("div",{className:"error-message",textContent:"Please enter link text"}),d=p("div",{className:"href-wrapper"}),T=p("div",{className:"search-icon",innerHTML:V({size:24})}),c=p("input",{type:"text",inputMode:"url",value:o.href,placeholder:"Enter URL",autocomplete:"new-password",spellcheck:!1}),g=p("div",{className:"error-message",textContent:"Please enter a valid URL"}),b=p("button",{type:"button",textContent:"Back",className:"back-button"}),u=p("button",{type:"submit",textContent:"Apply",className:"apply-button"}),x=(M,L)=>{M.classList.add("error"),L.classList.add("show")},H=(M,L)=>{M.classList.remove("error"),L.classList.remove("show")};h.addEventListener("input",()=>H(s,y)),c.addEventListener("input",()=>H(d,g)),b.addEventListener("click",()=>{e.onBack&&e.onBack()}),i.addEventListener("submit",M=>{M.preventDefault();let L=h.value.trim(),v=c.value.trim(),k=!1;L||(x(s,y),k=!0),C(v,{customValidator:r})||(x(d,g),k=!0),!k&&(t.chain().focus().extendMarkRange(e.markName??"hyperlink").editHyperlink({newURL:v,newText:L}).run(),w())}),s.append(f,h,y),d.append(T,c,g),l.append(s,d),m.append(b,u),i.append(l,m),w();let U=R({coordinates:{x:n.x,y:n.y,width:n.width,height:n.height,contextElement:a.dom},content:i,placement:"bottom",showArrow:!0,onShow:()=>h.focus()});setTimeout(()=>U.show(),pt)}function dt(e){let t=X(e);R({referenceElement:e.link,content:t,placement:"bottom",showArrow:!0}).show()}function X(e){let{link:t,editor:o}=e,n=e.attrs?.href??t.getAttribute("href")??"",r=p("div",{className:"hyperlink-preview-popover"}),a=p("button",{className:"remove",innerHTML:le()}),i=p("button",{className:"copy",innerHTML:se()}),l=p("button",{className:"edit",innerHTML:ce()}),m=p("a",{target:"_blank",rel:"noreferrer",href:n,innerText:n});return m.addEventListener("click",s=>{s.preventDefault(),I.test(n)||window.open(n,"_blank")}),a.addEventListener("click",()=>{w(),o.chain().focus().unsetHyperlink().run()}),l.addEventListener("click",()=>{q({...e,onBack:()=>dt(e)})}),i.addEventListener("click",()=>{ae(n,s=>{s?w():console.error("Failed to copy to clipboard")})}),r.append(m,i,l,a),r}var Ee=require("linkifyjs"),ut=ie;0&&(module.exports={Copy,DANGEROUS_SCHEME_RE,DEFAULT_OFFSET,Hyperlink,Link,LinkOff,Pencil,Title,copyToClipboard,createFloatingToolbar,createHTMLElement,createHyperlinkPopover,destroyCurrentToolbar,editHyperlinkPopover,getCategories,getCurrentToolbar,getSpecialUrlInfo,getUrlScheme,getUrlsByCategory,hideCurrentToolbar,isSpecialSchemeUrl,isToolbarVisible,normalizeHref,normalizeLinkifyHref,previewHyperlinkPopover,registerCustomProtocol,updateCurrentToolbarPosition,validateURL});
|
|
22
|
+
//# sourceMappingURL=index.cjs.map
|