@docs.plus/extension-hyperlink 1.5.1 → 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/index.cjs CHANGED
@@ -1,712 +1,22 @@
1
- 'use strict';
2
-
3
- var core = require('@tiptap/core');
4
- var linkifyjs = require('linkifyjs');
5
- var state = require('@tiptap/pm/state');
6
- var tippy = require('tippy.js');
7
-
8
- function autoHyperlink(options) {
9
- return new state.Plugin({
10
- key: new state.PluginKey("autoHyperlink"),
11
- appendTransaction: (transactions, oldState, newState) => {
12
- const docChanges = transactions.some((transaction) => transaction.docChanged) &&
13
- !oldState.doc.eq(newState.doc);
14
- const preventAutoHyperlink = transactions.some((transaction) => transaction.getMeta("preventAutoHyperlink"));
15
- if (!docChanges || preventAutoHyperlink) {
16
- return;
17
- }
18
- const { tr } = newState;
19
- const transform = core.combineTransactionSteps(oldState.doc, [
20
- ...transactions,
21
- ]);
22
- const { mapping } = transform;
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 Ue=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var Ct=Object.getOwnPropertyNames;var Pt=Object.prototype.hasOwnProperty;var Tt=(e,t)=>{for(var r in t)Ue(e,r,{get:t[r],enumerable:!0})},Rt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ct(t))!Pt.call(e,o)&&o!==r&&Ue(e,o,{get:()=>t[o],enumerable:!(n=At(t,o))||n.enumerable});return e};var Mt=e=>Rt(Ue({},"__esModule",{value:!0}),e);var br={};Tt(br,{Copy:()=>ke,DANGEROUS_SCHEME_RE:()=>_e,DEFAULT_OFFSET:()=>Se,Hyperlink:()=>$e,LinkOff:()=>ve,Pencil:()=>Le,SAFE_WINDOW_FEATURES:()=>B,attachTooltip:()=>ge,buildPreviewOptionsFromAnchor:()=>F,copyToClipboard:()=>he,createHTMLElement:()=>d,createHyperlinkPopover:()=>G,createPopover:()=>_,default:()=>Hr,editHyperlinkPopover:()=>J,getDefaultController:()=>g,getSpecialUrlInfo:()=>xe,hideTooltip:()=>x,isSafeHref:()=>b,normalizeHref:()=>z,openCreateHyperlink:()=>le,openEditHyperlink:()=>ce,openPreviewHyperlink:()=>V,previewHyperlinkPopover:()=>Q,registerCustomProtocol:()=>Ht.registerCustomProtocol,validateURL:()=>I});module.exports=Mt(br);var Me=require("@tiptap/core"),xt=require("linkifyjs");var M="hyperlink",se="preventAutolink";var B="noopener,noreferrer";function Ve({markName:e,urls:t}){let r=(o,{commands:i,tr:s,dispatch:a})=>{if(!o.href)return!1;let[l]=t.forWrite({kind:"href",href:o.href});if(!l)return!1;let c=i.setMark(e,{...o,href:l.href});return c&&a&&s.setMeta(se,!0),c},n=({commands:o,tr:i,dispatch:s})=>{let a=o.unsetMark(e,{extendEmptyMarkRange:!0});return a&&s&&i.setMeta(se,!0),a};return{set:o=>i=>r(o,i),unset:()=>o=>n(o),toggle:o=>i=>i.editor.isActive(e)?n(i):r(o,i)}}var N=require("@floating-ui/dom"),Ot=400,Ze="visible",$=null,ae=null;function It(){return $||($=document.createElement("div"),$.className="floating-tooltip",$.setAttribute("role","tooltip"),document.body.append($)),$}function Ge(){ae!==null&&(clearTimeout(ae),ae=null)}async function Ut(e,t){if(!e.isConnected)return;let r=It();r.textContent=t;let{x:n,y:o}=await(0,N.computePosition)(e,r,{strategy:"fixed",placement:"top",middleware:[(0,N.offset)(6),(0,N.flip)(),(0,N.shift)({padding:8})]});r.style.left=`${n}px`,r.style.top=`${o}px`,r.classList.add(Ze)}function x(){Ge(),$?.classList.remove(Ze)}function ge(e,t){let r=()=>{Ge(),ae=setTimeout(()=>{ae=null,Ut(e,t)},Ot)},n=()=>{e.matches(":focus-visible")&&r()};return e.addEventListener("mouseenter",r),e.addEventListener("focus",n),e.addEventListener("mouseleave",x),e.addEventListener("blur",x),e.addEventListener("pointerdown",x),e.addEventListener("click",x),()=>{e.removeEventListener("mouseenter",r),e.removeEventListener("focus",n),e.removeEventListener("mouseleave",x),e.removeEventListener("blur",x),e.removeEventListener("pointerdown",x),e.removeEventListener("click",x),x()}}var A=require("@floating-ui/dom");function St(){let e=null,t=new Set,r=()=>e===null?{kind:"idle"}:{kind:"mounted",popoverKind:e.kind,element:e.metadata.element,referenceElement:e.metadata.referenceElement},n=()=>{let o=r();t.forEach(i=>i(o))};return{adopt(o,i,s){let a=e;return e={popover:o,kind:i,metadata:s},a&&a.popover!==o&&a.popover.destroy(),n(),()=>{e?.popover===o&&(e=null,n())}},close(){if(e===null)return;let{popover:o}=e;e=null,o.hide(),n()},reposition(o,i){e?.popover.updateReference(o,i)},getState:r,subscribe(o){return t.add(o),()=>{t.delete(o)}}}}var Nt=St();function g(){return Nt}var Se=8,_t=9999,Dt=8,Ft="-5px",Wt=50,Bt=150,Ye={top:"bottom",bottom:"top",left:"right",right:"left"};function Xe(e){return{getBoundingClientRect:()=>{let{x:t,y:r,width:n,height:o}=e.getBoundingClientRect();return{width:n,height:o,top:r,right:t+n,bottom:r+o,left:t,x:t,y:r}},contextElement:e.contextElement||document.body}}function $t(e){let t=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!t.length)return[];let r=[];return t.forEach((n,o)=>{let i=s=>{if(s.key!=="Tab")return;s.preventDefault();let a=s.shiftKey?(o-1+t.length)%t.length:(o+1)%t.length;t[a].focus()};n.addEventListener("keydown",i),r.push(()=>n.removeEventListener("keydown",i))}),r}function _(e){let t=g(),{referenceElement:r,coordinates:n,content:o,placement:i="bottom-start",offset:s=Se,showArrow:a=!1,className:l="",zIndex:c=_t,role:p,ariaLabel:m,ignoreOutsideClickOn:v,crossAxisShift:f=!0,onShow:H,onHide:O}=e;if(!r&&!n)throw new Error("Either referenceElement or coordinates must be provided");let L=r||Xe(n),C=v?Array.isArray(v)?[...v]:[v]:r?[r]:[],P=[],h=!1,k=!1,y=null,w=E=>E?u.contains(E)?!1:!C.some(R=>R===E||R.contains(E)):!0,u=document.createElement("div");u.className=`floating-popover ${l}`.trim(),p&&u.setAttribute("role",p),m&&u.setAttribute("aria-label",m),u.setAttribute("tabindex","-1"),u.style.zIndex=String(c),u.style.position="fixed";let T=null;a&&(T=document.createElement("div"),T.className="floating-popover-arrow",u.appendChild(T));let U=document.createElement("div");U.className="floating-popover-content",u.appendChild(U);let ee=[],me=()=>{for(;ee.length;)ee.pop()()},de=E=>{me(),U.innerHTML="",U.appendChild(E),ee.push(...$t(u))};de(o);let te=async()=>{if(!h)return;let E=[(0,A.offset)(s),(0,A.flip)(),(0,A.shift)({padding:Dt,crossAxis:f})];T&&E.push((0,A.arrow)({element:T})),E.push((0,A.hide)({strategy:"referenceHidden"}));let{x:R,y:ye,placement:W,middlewareData:ie}=await(0,A.computePosition)(L,u,{placement:i,strategy:"fixed",middleware:E});if(!h)return;Object.assign(u.style,{left:`${R}px`,top:`${ye}px`}),u.style.visibility=ie.hide?.referenceHidden?"hidden":"visible";let Ie=W.split("-")[0];if(u.style.transformOrigin=Ye[Ie]??"center",T&&ie.arrow){let{x:Ke,y:ze}=ie.arrow,wt=Ye[Ie];T.className=`floating-popover-arrow floating-popover-arrow-${Ie}`,Object.assign(T.style,{left:Ke!=null?`${Ke}px`:"",top:ze!=null?`${ze}px`:"",right:"",bottom:"",[wt]:Ft})}},re=null,fe=null,oe=null,bt=()=>{fe&&(clearTimeout(fe),fe=null),oe&&(u.removeEventListener("transitionend",oe),oe=null)},Oe=()=>{bt(),u.remove()},ne=()=>{h&&(h=!1,k=!0,y?.(),y=null,me(),P.forEach(E=>E()),P.length=0,re?.(),re=null,u.classList.remove("visible"),oe=E=>{E.target===u&&Oe()},u.addEventListener("transitionend",oe),fe=setTimeout(Oe,Bt),O?.())},qe={element:u,show:()=>{if(h||k)return;document.body.appendChild(u),h=!0,y=(0,A.autoUpdate)(L,u,te),requestAnimationFrame(()=>u.classList.add("visible")),setTimeout(()=>{if(!h)return;let R=W=>{w(W.target)&&ne()},ye=W=>{if(!W.touches.length)return;let ie=document.elementFromPoint(W.touches[0].clientX,W.touches[0].clientY);w(ie)&&ne()};document.addEventListener("mousedown",R,{passive:!0}),document.addEventListener("touchstart",ye,{passive:!0}),P.push(()=>document.removeEventListener("mousedown",R),()=>document.removeEventListener("touchstart",ye))},Wt);let E=R=>{R.key==="Escape"&&(R.preventDefault(),ne())};u.addEventListener("keydown",E),P.push(()=>u.removeEventListener("keydown",E)),H?.()},hide:ne,destroy:()=>{ne(),k=!0,Oe()},isVisible:()=>h,setContent:de,updateReference:(E,R)=>{E?L=E:R&&(L=Xe(R)),h?(y?.(),y=(0,A.autoUpdate)(L,u,te)):te()}};return re=t.adopt(qe,"unknown",{element:u,referenceElement:r??null}),qe}var je="[extension-hyperlink]",q={warn:(...e)=>console.warn(je,...e),error:(...e)=>console.error(je,...e)};var he=async(e,t)=>{try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(e);else{let r=document.createElement("textarea");r.value=e,document.body.appendChild(r);let n=!1;try{r.select(),n=document.execCommand("copy")}finally{document.body.removeChild(r)}if(!n)return q.warn("copyToClipboard failed","execCommand returned false"),t?.(!1),!1}return t?.(!0),!0}catch(r){return q.warn("copyToClipboard failed",r),t?.(!1),!1}};var d=(e,t)=>{let r=document.createElement(e);return t&&Object.assign(r,t),r};var ke=({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}" aria-hidden="true">
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
+ `,ve=({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}" aria-hidden="true">
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
+ `,Ee=({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}" aria-hidden="true">
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
+ `,Le=({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}" aria-hidden="true">
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
+ `,Je=({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}" aria-hidden="true">
19
+ <path d="M160-560v-80h360v80H160Zm0 160v-80h640v80H160Z"/>
20
+ </svg>
21
+ `;var Qe=require("linkifyjs");var qt=/^\+\d[\d\s.\-()]{4,18}\d$/,Kt=/\D/g,Z=e=>{if(!qt.test(e))return{ok:!1};let t=e.replace(Kt,"");return t.length<8||t.length>15?{ok:!1}:{ok:!0,href:`tel:+${t}`}};var zt=/^([a-z][a-z0-9+.-]*):/i,Vt=/^([#?/]|\.\.?\/)/,Zt=e=>{if(e.startsWith("//"))return!0;let t=e.match(zt);if(!t)return!1;if(e.includes("://"))return!0;let r=t[1].toLowerCase();return!(r==="localhost"||r.includes("."))},Gt=e=>{if(!e.includes("@"))return{ok:!1};let t=(0,Qe.find)(e);if(t.length!==1)return{ok:!1};let r=t[0];return r.type!=="email"||r.value!==e?{ok:!1}:{ok:!0,href:r.href}},K="https",z=(e,t=K)=>{let r=e.trim();if(!r)return"";let n=Z(r);if(n.ok)return n.href;let o=Gt(r);return o.ok?o.href:Zt(r)||Vt.test(r)?r:`${t}://${r}`},Ne=(e,t=K)=>e.type==="url"?z(e.value,t):e.href;var Yt={"mailto:":{type:"email",title:"Email",category:"communication"},"tel:":{type:"phone",title:"Phone",category:"communication"},"telprompt:":{type:"phone",title:"Phone",category:"communication"},"sms:":{type:"sms",title:"SMS",category:"communication"},"facetime:":{type:"facetime",title:"FaceTime",category:"communication"},"facetime-audio:":{type:"facetime-audio",title:"FaceTime Audio",category:"communication"}},Xt={"whatsapp:":{type:"whatsapp",title:"WhatsApp",category:"social"},"tg:":{type:"telegram",title:"Telegram",category:"social"},"discord:":{type:"discord",title:"Discord",category:"social"},"skype:":{type:"skype",title:"Skype",category:"social"},"slack:":{type:"slack",title:"Slack",category:"social"},"twitter:":{type:"twitter",title:"Twitter",category:"social"},"fb:":{type:"facebook",title:"Facebook",category:"social"},"instagram:":{type:"instagram",title:"Instagram",category:"social"},"linkedin:":{type:"linkedin",title:"LinkedIn",category:"social"},"snapchat:":{type:"snapchat",title:"Snapchat",category:"social"},"reddit:":{type:"reddit",title:"Reddit",category:"social"},"tiktok:":{type:"tiktok",title:"TikTok",category:"social"}},jt={"zoommtg:":{type:"zoom",title:"Zoom Meeting",category:"communication"},"zoomus:":{type:"zoom",title:"Zoom",category:"communication"},"msteams:":{type:"teams",title:"Microsoft Teams",category:"communication"},"webex:":{type:"webex",title:"Cisco Webex",category:"communication"}},Jt={"calshow:":{type:"calendar",title:"Calendar",category:"apple"},"x-apple-calevent:":{type:"calendar",title:"Calendar Event",category:"apple"},"x-apple-reminder:":{type:"reminders",title:"Reminders",category:"apple"},"contacts:":{type:"contacts",title:"Contacts",category:"apple"},"maps:":{type:"maps",title:"Maps",category:"apple"},"map:":{type:"maps",title:"Maps",category:"apple"},"music:":{type:"music",title:"Apple Music",category:"apple"},"videos:":{type:"apple-tv",title:"Apple TV",category:"apple"},"mobilenotes:":{type:"notes",title:"Notes",category:"apple"},"photos-redirect:":{type:"photos",title:"Photos",category:"apple"},"shortcuts:":{type:"shortcuts",title:"Shortcuts",category:"apple"},"itms-apps:":{type:"app-store",title:"App Store",category:"apple"}},Qt={"github:":{type:"github",title:"GitHub",category:"development"},"gitlab:":{type:"gitlab",title:"GitLab",category:"development"},"vscode:":{type:"vscode",title:"VS Code",category:"development"},"notion:":{type:"notion",title:"Notion",category:"productivity"},"obsidian:":{type:"obsidian",title:"Obsidian",category:"productivity"},"figma:":{type:"figma",title:"Figma",category:"development"}},er={"youtube:":{type:"youtube",title:"YouTube",category:"entertainment"},"spotify:":{type:"spotify",title:"Spotify",category:"entertainment"},"netflix:":{type:"netflix",title:"Netflix",category:"entertainment"},"twitch:":{type:"twitch",title:"Twitch",category:"entertainment"}},tr={"amazon:":{type:"amazon",title:"Amazon",category:"shopping"},"uber:":{type:"uber",title:"Uber",category:"other"},"lyft:":{type:"lyft",title:"Lyft",category:"other"}},rr={...Yt,...Xt,...jt,...Jt,...Qt,...er,...tr},or={"wa.me":{type:"whatsapp",title:"WhatsApp",category:"social"},"t.me":{type:"telegram",title:"Telegram",category:"social"},"discord.gg":{type:"discord",title:"Discord Invite",category:"social"},"zoom.us":{type:"zoom",title:"Zoom Meeting",category:"communication"},"meet.google.com":{type:"meet",title:"Google Meet",category:"communication"},"teams.microsoft.com":{type:"teams",title:"Microsoft Teams",category:"communication"},"github.com":{type:"github",title:"GitHub",category:"development"},"gitlab.com":{type:"gitlab",title:"GitLab",category:"development"},"figma.com":{type:"figma",title:"Figma",category:"development"},"notion.so":{type:"notion",title:"Notion",category:"productivity"},"twitter.com":{type:"twitter",title:"Twitter",category:"social"},"x.com":{type:"twitter",title:"X (Twitter)",category:"social"},"instagram.com":{type:"instagram",title:"Instagram",category:"social"},"linkedin.com":{type:"linkedin",title:"LinkedIn",category:"social"},"youtube.com":{type:"youtube",title:"YouTube",category:"entertainment"},"spotify.com":{type:"spotify",title:"Spotify",category:"entertainment"}},xe=e=>{let t=e.toLowerCase();for(let[r,n]of Object.entries(rr))if(t.startsWith(r))return n;try{let n=new URL(e).hostname.toLowerCase(),o=n.startsWith("www.")?n.slice(4):n;for(let[i,s]of Object.entries(or))if(o===i||o.endsWith(`.${i}`))return s}catch{}return null};var et=require("linkifyjs");var _e=/^\s*(javascript|data|vbscript|file|blob):/i,b=e=>typeof e!="string"||e.length===0?!1:!_e.test(e.replace(/[\u0000-\u0020]+/g,"")),nr=new Set(["http","https","ftp","ftps"]),ir=/^\d{1,3}(\.\d{1,3}){3}$/,sr=e=>xe(e)!==null,ar=e=>{let t;try{t=new URL(e)}catch{return!1}let r=t.hostname;return r?r==="localhost"||ir.test(r)||r.includes(":")?!0:r.includes("."):!1},I=(e,t)=>{let r=e.trim();if(!r||!b(r))return!1;try{if(Z(r).ok||sr(e))return t?.customValidator?t.customValidator(e):!0;let n=(0,et.find)(e).find(o=>o.isLink&&(t?.customValidator?t.customValidator(o.value):!0));return n?.href?pr(n.href)?ar(n.href):!0:!1}catch(n){return q.error("validateURL threw",n),!1}},lr=e=>{if(!e.trim())return null;let t=e.indexOf(":");return t===-1?null:e.substring(0,t).toLowerCase()},pr=e=>{let t=lr(e);return t!==null&&nr.has(t)};var cr=e=>{let t=d("div",{className:"hyperlink-create-popover"}),r=d("div",{className:"buttons-wrapper"}),n=d("div",{className:"inputs-wrapper"}),o=d("form",{}),i=d("input",{type:"text",inputMode:"url",name:"hyperlink-url",placeholder:"https://example.com",autocomplete:"new-password",spellcheck:!1,value:e}),s=d("button",{type:"submit",textContent:"Apply",disabled:e.trim().length===0}),a=d("div",{className:"error-message",textContent:"Please enter a valid URL"}),l=d("div",{className:"search-icon",innerHTML:Ee({size:24})});return n.append(l,i,a),r.append(s),o.append(n,r),t.append(o),{root:t,form:o,input:i,button:s,inputsWrapper:n,errorMessage:a}},ur=(e,t)=>{let{form:r,input:n,button:o,inputsWrapper:i,errorMessage:s}=e,{editor:a}=t,l=()=>{i.classList.add("error"),s.classList.add("show")},c=()=>{i.classList.remove("error"),s.classList.remove("show")},p=()=>{let m=n.value.trim().length>0;o.disabled=!m,m&&c()};n.addEventListener("input",p),n.addEventListener("paste",()=>setTimeout(p,0)),i.addEventListener("click",()=>n.focus()),n.addEventListener("keydown",m=>{m.key==="Escape"&&(m.preventDefault(),g().close(),a.commands.focus())}),r.addEventListener("submit",m=>{if(m.preventDefault(),o.disabled)return;let v=n.value.trim();if(!I(v,{customValidator:t.validate})){l();return}if(!a.can().setHyperlink({href:v})){l();return}let f=a.chain().setHyperlink({href:v});if(a.state.selection.empty&&f.insertContent({type:"text",text:v}),!f.run()){l();return}g().close(),a.commands.focus()})};function G(e){let t=cr(e.attributes?.href??"");return ur(t,e),t.root}function Y(e,t){let r=e.extensionManager.extensions.find(n=>n.name===M);if(!r)throw new Error(`${t}: Hyperlink extension not registered on editor`);return r.options}var D=null,X=null;function j(e,t){D={editor:e,popover:t},mr()}function mr(){X||(X=g().subscribe(e=>{D&&e.kind==="mounted"&&e.element===D.popover.element||(D=null,X?.(),X=null)}))}function tt(e){if(!D||D.editor!==e)return;let{popover:t}=D;D=null,X?.(),X=null;let r=g(),n=r.getState();n.kind==="mounted"&&n.element===t.element&&r.close()}var dr=100;function le(e,t={}){let r=Y(e,"openCreateHyperlink"),n=r.popovers.createHyperlink??G,o={editor:e,validate:r.validate,extensionName:M,attributes:t},i=n(o);if(!i)return!1;let{from:s,to:a}=e.state.selection,l=null,c=_({coordinates:{getBoundingClientRect:()=>{try{let p=e.view.coordsAtPos(s),m=e.view.coordsAtPos(a);return{x:Math.min(p.left,m.left),y:p.top,width:Math.abs(m.left-p.left),height:m.bottom-p.top}}catch{return queueMicrotask(()=>c.hide()),{x:-9999,y:-9999,width:0,height:0}}},contextElement:e.view.dom},content:i,placement:"bottom",showArrow:!0,role:"dialog",ariaLabel:"Add link",onShow:()=>{let p=i.querySelector("input");p&&(l=setTimeout(()=>p.focus(),dr))},onHide:()=>{l!=null&&(clearTimeout(l),l=null),x()}});return g().adopt(c,"create",{element:c.element,referenceElement:null}),j(e,c),c.show(),!0}var nt=require("@tiptap/core");var rt=require("linkifyjs");var fr=/\b[a-zA-Z][a-zA-Z0-9+.-]*:[^\s]+/g,yr=/[.,;:!?)\]}]+$/,gr=e=>{let t=e.value.match(yr);if(!t)return e;let r=t[0].length;return{...e,value:e.value.slice(0,-r),href:e.href.endsWith(t[0])?e.href.slice(0,-r):e.href,end:e.end-r}},De=e=>{let t=[],r=(0,rt.find)(e).filter(o=>o.isLink);if(t.push(...r),e.includes(":"))for(let o of e.matchAll(fr)){let i=o[0],s=o.index,a=s+i.length;!r.some(c=>s>=c.start&&a<=c.end)&&I(i)&&t.push({type:"url",href:i,value:i,start:s,end:a,isLink:!0})}let n=Z(e);return n.ok&&t.push({type:"phone",href:n.href,value:e,start:0,end:e.length,isLink:!0}),t.map(gr)};function ot(e={}){let t=e.defaultProtocol??K,r=e.protocols??[],n=e.isAllowedUri;return o=>b(o)?n?n(o,{defaultValidate:b,protocols:r,defaultProtocol:t}):!0:!1}function be(e={}){let t=e.defaultProtocol??K,r=e.gate??b,n=(o,i)=>{if(!r(o))return!1;let s=i?.validate??e.validate;if(s&&!s(o))return!1;let a=e.shouldAutoLink;return!(a&&!a(o))};return{forWrite(o,i){if(o.kind==="href"){let s=o.href.trim();if(!s)return[];let a=z(s,t);if(!r(a))return[];let l=i?.validate??e.validate;return l&&!l(a)?[]:[{href:a,start:0,end:o.href.length}]}if(o.kind==="match"){let s=Ne(o.match,t);return n(s,i)?[{href:s,start:0,end:o.match.value.length}]:[]}return De(o.text).filter(s=>s.isLink).map(s=>({href:Ne(s,t),start:s.start,end:s.end})).filter(s=>n(s.href,i))},forRead(o){let i=typeof o=="string"?o:"";return{navigable:b(i)&&r(i)}},detect(o){return De(o).some(i=>i.isLink)}}}var we=(e={})=>({tr:t,dispatch:r})=>{let{newURL:n,newText:o,title:i,image:s,validate:a,markName:l=M,urls:c=be()}=e;if(n&&!I(n,{customValidator:a}))return!1;let p=t.doc.type.schema.marks[l];if(!p)return!1;let{from:m}=t.selection,v=t.doc.resolve(m),f=(0,nt.getMarkRange)(v,p);if(!f)return!1;let H;try{H=t.doc.nodeAt(f.from)?.marks.find(k=>k.type===p)}catch(k){return q.warn("editHyperlink: failed to read mark at position",k),!1}if(!H)return!1;let O=H.attrs.href;if(n){let[k]=c.forWrite({kind:"href",href:n},{validate:a});if(!k)return!1;O=k.href}if(!r)return!0;let L=t.doc.textBetween(f.from,f.to),C=o||L,P=p.create({...H.attrs,href:O,...i!==void 0&&{title:i},...s!==void 0&&{image:s}});if(C===L)return t.removeMark(f.from,f.to,p),t.addMark(f.from,f.to,P),!0;let h=t.doc.nodeAt(f.from)?.marks.filter(k=>k.type!==p)??[];return t.replaceWith(f.from,f.to,t.doc.type.schema.text(C,[...h,P])),!0};function it(e){return{setHyperlink:e.set,unsetHyperlink:e.unset,toggleHyperlink:e.toggle,setLink:e.set,unsetLink:e.unset,toggleLink:e.toggle}}function st(e){let t={markName:e.markName,urls:e.urls,validate:e.validate};return{editHyperlink:r=>we({...r,...t}),editHyperlinkText:r=>we({newText:r,...t}),editHyperlinkHref:r=>we({newURL:r,...t})}}function at(){return{openCreateHyperlinkPopover:e=>({editor:t,dispatch:r})=>r?le(t,e??{}):!0}}function lt(e){let t=Ve({markName:e.markName,urls:e.urls});return{...it(t),...st({markName:e.markName,urls:e.urls,validate:e.options.validate}),...at()}}var S=require("@tiptap/core"),Ae=require("@tiptap/pm/state");var hr=/\s$/,kr=15,vr=e=>e.split(/\s+/).filter(t=>t!=="");function pt(e){let{urls:t,type:r}=e;return new Ae.Plugin({key:new Ae.PluginKey("hyperlinkAutolink"),appendTransaction:(n,o,i)=>{let s=n.some(f=>f.docChanged)&&!o.doc.eq(i.doc),a=n.some(f=>f.getMeta(se));if(!s||a)return;let{tr:l}=i,c=(0,S.combineTransactionSteps)(o.doc,[...n]),{mapping:p}=c,m=(0,S.getChangedRanges)(c),v=i.schema.marks.code??null;for(let{oldRange:f,newRange:H}of m){for(let y of(0,S.getMarksBetween)(f.from,f.to,o.doc).filter(w=>w.mark.type===r)){let w=p.map(y.from),u=p.map(y.to),T=(0,S.getMarksBetween)(w,u,i.doc).filter(re=>re.mark.type===r);if(!T.length)continue;let U=T[0],ee=o.doc.textBetween(y.from,y.to,void 0," "),me=i.doc.textBetween(U.from,U.to,void 0," "),de=t.detect(ee),te=t.detect(me);de&&!te&&l.removeMark(U.from,U.to,r)}let O=(0,S.findChildrenInRange)(i.doc,H,y=>y.isTextblock),L,C;if(O.length>1?(L=O[0],C=i.doc.textBetween(L.pos,L.pos+L.node.nodeSize,void 0," ")):O.length&&hr.test(i.doc.textBetween(H.from,H.to," "," "))&&(L=O[0],C=i.doc.textBetween(L.pos,H.to,void 0," ")),!L||!C)continue;let P=vr(C);if(!P.length)continue;let h=P[P.length-1],k=L.pos+C.lastIndexOf(h);t.forWrite({kind:"text",text:h}).map(y=>({href:y.href,from:k+y.start+1,to:k+y.end+1})).filter(({from:y})=>{let w=Math.max(0,y-kr),u=i.doc.textBetween(w,y," "," ");return!(u.includes("![")&&u.endsWith("]("))}).filter(({from:y})=>v?!i.doc.nodeAt(y)?.marks.some(u=>u.type===v):!0).forEach(({from:y,to:w,href:u})=>{l.addMark(y,w,r.create({href:u}))})}if(l.steps.length)return l}})}var We=require("@tiptap/core"),Ce=require("@tiptap/pm/state");function pe(e,t,r){if(t.isConnected)return t;if(typeof r=="number")try{let{node:s}=e.view.domAtPos(r),l=("closest"in s?s:s.parentElement)?.closest("a");if(l&&e.view.dom.contains(l))return l}catch{}let n=t.getAttribute("href"),o=t.textContent;return Array.from(e.view.dom.querySelectorAll("a")).find(s=>s.getAttribute("href")===n&&s.textContent===o)??null}function F({editor:e,link:t,nodePos:r,validate:n,isAllowedUri:o,markName:i=M}){let s=e.view,a=pe(e,t,r)??t,l=r??-1,c=null;try{l=s.posAtDOM(a,0),l>=0&&(c=s.state.doc.nodeAt(l))}catch{c=null}let m=c?.marks.find(v=>v.type.name===i)?.attrs??{href:a.getAttribute("href"),target:null,rel:null,class:null,title:null,image:null};return{editor:e,link:a,nodePos:l,attrs:m,validate:n,isAllowedUri:o}}function J(e){let{editor:t,link:r,validate:n}=e,o=d("form",{className:"hyperlink-edit-popover"}),i=d("div",{className:"inputs-wrapper"}),s=d("div",{className:"buttons-wrapper"}),a=d("div",{className:"text-wrapper"}),l=d("div",{className:"search-icon",innerHTML:Je({size:24})}),c=d("input",{type:"text",value:r.innerText||"",placeholder:"Enter link text"}),p=d("div",{className:"error-message",textContent:"Please enter link text"}),m=d("div",{className:"href-wrapper"}),v=d("div",{className:"search-icon",innerHTML:Ee({size:24})}),f=d("input",{type:"text",inputMode:"url",value:r.getAttribute("href")??"",placeholder:"Enter URL",autocomplete:"new-password",spellcheck:!1}),H=d("div",{className:"error-message",textContent:"Please enter a valid URL"}),O=d("button",{type:"button",textContent:"Back",className:"back-button"}),L=d("button",{type:"submit",textContent:"Apply",className:"apply-button"}),C=(h,k)=>{h.classList.add("error"),k.classList.add("show")},P=(h,k)=>{h.classList.remove("error"),k.classList.remove("show")};return c.addEventListener("input",()=>P(a,p)),f.addEventListener("input",()=>P(m,H)),o.addEventListener("keydown",h=>{h.key==="Escape"&&(h.preventDefault(),g().close(),t.commands.focus())}),O.addEventListener("click",()=>{if(e.onBack){e.onBack();return}V(F({editor:t,link:r,validate:n,isAllowedUri:e.isAllowedUri,nodePos:e.nodePos,markName:e.markName}))}),o.addEventListener("submit",h=>{h.preventDefault();let k=c.value.trim(),y=f.value.trim(),w=!1;if(k||(C(a,p),w=!0),I(y,{customValidator:n})||(C(m,H),w=!0),w)return;let u=e.markName??M;if(!t.chain().focus().extendMarkRange(u).editHyperlink({newURL:y,newText:k}).run()){if(!t.isActive(u)){g().close();return}C(m,H);return}g().close()}),a.append(l,c,p),m.append(v,f,H),i.append(a,m),s.append(O,L),o.append(i,s),queueMicrotask(()=>c.focus()),o}function ce(e){let{editor:t}=e,{popovers:r}=Y(t,"openEditHyperlink"),o=(r.editHyperlink??J)(e);if(!o)return;let i=pe(t,e.link,e.nodePos),s=!1,a=_({coordinates:{getBoundingClientRect:()=>{if(i=i?pe(t,i,e.nodePos):null,!i)return s||(s=!0,queueMicrotask(()=>a.hide())),{x:-9999,y:-9999,width:0,height:0};let l=i.getBoundingClientRect();return{x:l.left,y:l.top,width:l.width,height:l.height}},contextElement:t.view.dom},content:o,placement:"bottom",showArrow:!0,role:"dialog",ariaLabel:"Edit link",onHide:x});g().adopt(a,"edit",{element:a.element,referenceElement:null}),j(t,a),a.show()}var Fe=(e,t,r)=>{let n=d("button",{type:"button",className:e,innerHTML:r});return n.setAttribute("aria-label",t),ge(n,t),n};function Q(e){let{link:t,editor:r}=e,n=e.attrs.href??"",o=b(n)?n:"",i=e.isAllowedUri??b,s=d("div",{className:"hyperlink-preview-popover"}),a=Fe("remove","Remove link",ve()),l=Fe("copy","Copy link",ke()),c=Fe("edit","Edit link",Le()),p=d("a",{target:"_blank",rel:"noopener noreferrer",href:o,innerText:n});return p.addEventListener("click",m=>{m.preventDefault(),o&&i(o)&&window.open(o,"_blank",B)}),a.addEventListener("click",()=>{g().close(),r.chain().focus().unsetHyperlink().run()}),c.addEventListener("click",()=>{ce({editor:r,link:t,nodePos:e.nodePos,validate:e.validate,isAllowedUri:e.isAllowedUri})}),l.addEventListener("click",()=>{he(n,m=>{m&&g().close()})}),s.append(p,l,c,a),s}function V(e){let{editor:t}=e,{popovers:r}=Y(t,"openPreviewHyperlink"),o=(r.previewHyperlink??Q)(e);if(!o)return!1;let i=_({referenceElement:e.link,content:o,placement:"bottom",showArrow:!0,role:"toolbar",onHide:x});return g().adopt(i,"preview",{element:i.element,referenceElement:e.link}),j(t,i),i.show(),!0}function ue(e,t){let r=e.target;if(!r)return null;let n=r.closest("a");return!n||!t.contains(n)?null:n}function ut(e,t){return t.urls.forRead(e).navigable}function ct(e,t,r,n){let o=F({editor:r.editor,link:t,validate:r.validate,isAllowedUri:l=>r.urls.forRead(l).navigable}),i=o.attrs.href??t.getAttribute("href"),s=t.target||o.attrs.target||"_blank";if(!r.previewPopover)return!e.editable&&ut(i,r)&&window.open(i,s,B),!e.editable;if(!i)return g().close(),!0;if(!V(o))return!0;if(n!==void 0){let{from:l,to:c}=e.state.selection;if(r.options.enableClickSelection&&e.editable&&l===c){let p=(0,We.getMarkRange)(e.state.doc.resolve(n),r.type);p?r.editor.chain().focus(n).setTextSelection(p).run():r.editor.chain().focus(n===0?"start":n).run()}else{let p=(0,We.getMarkRange)(e.state.doc.resolve(n),r.type),m=!!p&&l<p.to&&c>p.from,v=l===c||!m?n:{from:l,to:c};r.editor.chain().focus(n===0?"start":n).setTextSelection(v).run()}}return!0}function mt(e){return new Ce.Plugin({key:new Ce.PluginKey("hyperlinkClickHandler"),view(t){let r=i=>{i.button!==0||!ue(i,t.dom)||(i.preventDefault(),i.stopPropagation())},n=i=>{if(i.button!==0)return;ue(i,t.dom)&&i.preventDefault()},o=i=>{if(i.button!==1)return;let s=ue(i,t.dom);if(!s)return;i.preventDefault(),i.stopPropagation();let{attrs:a}=F({editor:e.editor,link:s}),l=a.href??s.getAttribute("href");ut(l,e)&&window.open(l,"_blank",B)};return t.dom.addEventListener("mousedown",r,!0),t.dom.addEventListener("click",n,!0),t.dom.addEventListener("auxclick",o,!0),{destroy(){t.dom.removeEventListener("mousedown",r,!0),t.dom.removeEventListener("click",n,!0),t.dom.removeEventListener("auxclick",o,!0)}}},props:{handleDOMEvents:{touchend:(t,r)=>{let n=ue(r,t.dom);if(!n)return!1;r.preventDefault();let{clientX:o,clientY:i}=r.changedTouches[0],s=t.posAtCoords({left:o,top:i});return ct(t,n,e,s?.pos)},click:(t,r)=>{if(r.button!==0)return!1;let n=ue(r,t.dom);if(!n)return!1;r.preventDefault();let o=t.posAtCoords({left:r.clientX,top:r.clientY});return ct(t,n,e,o?.pos)}}}})}var dt=require("@tiptap/core"),Er=/(\[([^\]]+)\]\(([^)]+)\))$/;function ft(e){return new dt.InputRule({find:Er,handler:({state:t,range:r,match:n})=>{let[,,o,i]=n,{tr:s}=t,a=r.from,l=r.to,[c]=e.urls.forWrite({kind:"href",href:i});if(!c)return;let p=t.doc.nodeAt(a)?.marks.filter(m=>m.type!==e.type)??[];s.replaceWith(a,l,t.schema.text(o,p)),s.addMark(a,a+o.length,e.type.create({href:c.href}))}})}var Pe=require("@tiptap/pm/state"),yt=require("linkifyjs");function gt(e){return new Pe.Plugin({key:new Pe.PluginKey("hyperlinkPasteHandler"),props:{handlePaste:(t,r,n)=>{let{selection:o}=t.state;if(o.empty)return!1;let i="";n.content.forEach(l=>{i+=l.textContent});let s=(0,yt.find)(i).find(l=>l.isLink&&l.value===i);if(!i||!s)return!1;let[a]=e.urls.forWrite({kind:"match",match:s});return a?e.editor.chain().setHyperlink({href:a.href}).run():!1}}})}var ht=require("@tiptap/core"),kt=require("linkifyjs");function vt(e){return(0,ht.markPasteRule)({find:t=>(0,kt.find)(t).filter(r=>r.isLink).flatMap(r=>{let[n]=e.urls.forWrite({kind:"match",match:r});return n?[{text:r.value,index:r.start,data:{href:n.href}}]:[]}),type:e.type,getAttributes:t=>({href:t.data.href})})}function Lr(e){return be({defaultProtocol:e.defaultProtocol,gate:ot({isAllowedUri:e.isAllowedUri,protocols:e.protocols,defaultProtocol:e.defaultProtocol}),validate:e.validate,shouldAutoLink:e.shouldAutoLink})}function Be({editor:e,type:t,options:r}){return{type:t,editor:e,urls:Lr(r),options:r,validate:r.validate,previewPopover:r.popovers.previewHyperlink??null}}function Te(e){let t=[];return e.options.autolink&&t.push(pt(e)),e.options.openOnClick&&t.push(mt(e)),e.options.linkOnPaste&&t.push(gt(e)),{inputRules:[ft(e)],pasteRules:[vt(e)],plugins:t}}var Et=new Set;function Lt(e,t){Et.has(e)||(Et.add(e),(0,xt.registerCustomProtocol)(e,t))}var $e=Me.Mark.create({name:M,priority:1e3,keepOnSplit:!1,markdownTokenName:"link",parseMarkdown:(e,t)=>{let r=z(e.href||"");return t.applyMark(M,t.parseInline(e.tokens??[]),{href:b(r)?r:""})},renderMarkdown:(e,t,r)=>{let n=t.renderChildren(e),o=e.attrs?.href||"",i=(b(o)?o:"").replace(/\)/g,"%29").replace(/\s/g,"%20");return`[${n}](${i})`},addStorage(){return{context:null}},onCreate(){this.options.protocols.forEach(e=>{typeof e=="string"?Lt(e):Lt(e.scheme,e.optionalSlashes)})},onDestroy(){tt(this.editor)},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,editHyperlink:null,createHyperlink:null},validate:void 0,defaultProtocol:K,isAllowedUri:void 0,shouldAutoLink:void 0,enableClickSelection:!1,exitable:!1}},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,rendered:!1}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{if(typeof e=="string")return!1;let t=e.getAttribute("href")??"";return b(t)?null:!1}}]},renderHTML({HTMLAttributes:e}){let t=b(e.href)?e:{...e,href:""};return["a",(0,Me.mergeAttributes)(this.options.HTMLAttributes,t),0]},addCommands(){return lt({markName:this.name,options:this.options,urls:Re(this).urls})},addKeyboardShortcuts(){let e={"Mod-k":()=>this.editor.commands.openCreateHyperlinkPopover()};return this.options.exitable&&(e.ArrowRight=()=>xr(this.editor,this.type)),e},addInputRules(){return Te(Re(this)).inputRules},addPasteRules(){return Te(Re(this)).pasteRules},addProseMirrorPlugins(){return Te(Re(this)).plugins}});function Re(e){if(e.storage.context)return e.storage.context;let t=Be({editor:e.editor,type:e.type,options:e.options});return e.storage.context=t,t}function xr(e,t){let{state:r}=e,{selection:n,tr:o}=r;if(!n.empty)return!1;let i=n.$from,s=i.nodeAfter;return(i.nodeBefore?.marks.some(p=>p.type===t)??!1)&&(!s||!s.marks.some(p=>p.type===t))&&(o.setStoredMarks((r.storedMarks??i.marks()).filter(p=>p.type!==t)),e.view.dispatch(o)),!1}var Ht=require("linkifyjs"),Hr=$e;0&&(module.exports={Copy,DANGEROUS_SCHEME_RE,DEFAULT_OFFSET,Hyperlink,LinkOff,Pencil,SAFE_WINDOW_FEATURES,attachTooltip,buildPreviewOptionsFromAnchor,copyToClipboard,createHTMLElement,createHyperlinkPopover,createPopover,editHyperlinkPopover,getDefaultController,getSpecialUrlInfo,hideTooltip,isSafeHref,normalizeHref,openCreateHyperlink,openEditHyperlink,openPreviewHyperlink,previewHyperlinkPopover,registerCustomProtocol,validateURL});
22
+ //# sourceMappingURL=index.cjs.map