@docs.plus/extension-hyperlink 1.3.12 → 1.5.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/README.md +81 -55
- package/dist/helpers/clickHandler.d.ts +1 -3
- package/dist/helpers/tippyHelper.d.ts +1 -2
- package/dist/hyperlink.d.ts +6 -4
- package/dist/index.cjs +42 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +41 -40
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +42 -41
- package/dist/index.umd.js.map +1 -1
- package/dist/{dialogBoxs → modals}/editeHyperlink.d.ts +2 -4
- package/dist/{dialogBoxs → modals}/previewHyperlink.d.ts +2 -5
- package/dist/modals/setHyperlink.d.ts +14 -0
- package/package.json +1 -1
- package/src/helpers/clickHandler.ts +8 -9
- package/src/helpers/tippyHelper.ts +3 -4
- package/src/hyperlink.ts +14 -9
- package/src/index.ts +5 -5
- package/src/{dialogBoxs → modals}/editeHyperlink.ts +8 -10
- package/src/{dialogBoxs → modals}/previewHyperlink.ts +12 -16
- package/src/{dialogBoxs → modals}/setHyperlink.ts +14 -13
- package/dist/dialogBoxs/setHyperlink.d.ts +0 -9
- /package/dist/{dialogBoxs → modals}/icons.d.ts +0 -0
- /package/src/{dialogBoxs → modals}/icons.ts +0 -0
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
import { Editor } from "@tiptap/core";
|
|
2
|
-
import {
|
|
3
|
-
import { editeHyperlinkHandler } from "./editeHyperlink";
|
|
2
|
+
import { editHyperlinkHandler } from "./editeHyperlink";
|
|
4
3
|
import { Copy, LinkSlash, Pencil } from "./icons";
|
|
5
4
|
import Tooltip from "../helpers/tippyHelper";
|
|
6
5
|
|
|
7
|
-
type
|
|
6
|
+
export type THyperlinkPreviewModalOptions = {
|
|
8
7
|
editor: Editor;
|
|
9
8
|
validate?: (url: string) => boolean;
|
|
10
|
-
view: EditorView;
|
|
11
9
|
link: HTMLAnchorElement;
|
|
12
10
|
node?: any;
|
|
13
11
|
nodePos: number;
|
|
14
12
|
tippy: Tooltip;
|
|
15
13
|
};
|
|
16
14
|
|
|
17
|
-
export function
|
|
15
|
+
export function previewHyperlinkModal(options: THyperlinkPreviewModalOptions): HTMLElement {
|
|
18
16
|
const href = options.link.href;
|
|
19
17
|
|
|
20
|
-
const
|
|
18
|
+
const hyperlinkModal = document.createElement("div");
|
|
21
19
|
const removeButton = document.createElement("button");
|
|
22
20
|
const copyButton = document.createElement("button");
|
|
23
21
|
const editButton = document.createElement("button");
|
|
24
22
|
|
|
25
23
|
const newBubble = document.createElement("div");
|
|
26
|
-
newBubble.classList.add("
|
|
24
|
+
newBubble.classList.add("hyperlink-preview-modal__metadata");
|
|
27
25
|
|
|
28
26
|
const hrefTitle = document.createElement("a");
|
|
29
27
|
hrefTitle.setAttribute("target", "_blank");
|
|
@@ -58,15 +56,15 @@ export function previewHyperlink(options: HyperlinkModalOptions): HTMLElement {
|
|
|
58
56
|
console.error("Error fetching metadata:", error);
|
|
59
57
|
});
|
|
60
58
|
|
|
61
|
-
|
|
59
|
+
hyperlinkModal.classList.add("hyperlink-preview-modal");
|
|
62
60
|
|
|
63
|
-
removeButton.classList.add("
|
|
61
|
+
removeButton.classList.add("hyperlink-preview-modal__remove-button");
|
|
64
62
|
removeButton.innerHTML = LinkSlash();
|
|
65
63
|
|
|
66
|
-
editButton.classList.add("
|
|
64
|
+
editButton.classList.add("hyperlink-preview-modal__edit-button");
|
|
67
65
|
editButton.innerHTML = Pencil();
|
|
68
66
|
|
|
69
|
-
copyButton.classList.add("
|
|
67
|
+
copyButton.classList.add("hyperlink-preview-modal__copy-button");
|
|
70
68
|
copyButton.innerHTML = Copy();
|
|
71
69
|
|
|
72
70
|
removeButton.addEventListener("click", () => {
|
|
@@ -74,16 +72,14 @@ export function previewHyperlink(options: HyperlinkModalOptions): HTMLElement {
|
|
|
74
72
|
return options.editor.chain().focus().unsetHyperlink().run();
|
|
75
73
|
});
|
|
76
74
|
|
|
77
|
-
editButton.addEventListener("click", () =>
|
|
78
|
-
editeHyperlinkHandler({ ...options, hyperlinkLinkModal })
|
|
79
|
-
);
|
|
75
|
+
editButton.addEventListener("click", () => editHyperlinkHandler({ ...options, hyperlinkModal }));
|
|
80
76
|
|
|
81
77
|
copyButton.addEventListener("click", () => {
|
|
82
78
|
options.tippy.hide();
|
|
83
79
|
navigator.clipboard.writeText(href);
|
|
84
80
|
});
|
|
85
81
|
|
|
86
|
-
|
|
82
|
+
hyperlinkModal.append(newBubble, copyButton, editButton, removeButton);
|
|
87
83
|
|
|
88
|
-
return
|
|
84
|
+
return hyperlinkModal;
|
|
89
85
|
}
|
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { Editor } from "@tiptap/core";
|
|
2
|
-
import Tooltip from "../helpers/tippyHelper";
|
|
2
|
+
import Tooltip, { TippyInitOptions } from "../helpers/tippyHelper";
|
|
3
3
|
import { find } from "linkifyjs";
|
|
4
|
-
import { roundArrow } from "tippy.js";
|
|
5
4
|
|
|
6
|
-
type
|
|
5
|
+
export type TSetHyperlinkModalOptions = {
|
|
7
6
|
editor: Editor;
|
|
8
7
|
validate?: (url: string) => boolean;
|
|
9
8
|
extentionName: string;
|
|
10
|
-
attributes:
|
|
9
|
+
attributes?: { href: string; target?: string | null };
|
|
10
|
+
Tooltip: new (options: TippyInitOptions) => Tooltip;
|
|
11
|
+
roundArrow: string;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
let tooltip: Tooltip | undefined = undefined;
|
|
14
15
|
|
|
15
|
-
export function
|
|
16
|
+
export function setHyperlinkModal(options: TSetHyperlinkModalOptions): void {
|
|
16
17
|
// Create the tooltip instance
|
|
17
|
-
if (!tooltip) tooltip = new Tooltip(
|
|
18
|
+
if (!tooltip) tooltip = new options.Tooltip(options);
|
|
18
19
|
|
|
19
20
|
// Initialize the tooltip
|
|
20
21
|
let { tippyModal } = tooltip.init();
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
+
const hyperlinkModal = document.createElement("div");
|
|
23
24
|
const buttonsWrapper = document.createElement("div");
|
|
24
25
|
const inputsWrapper = document.createElement("div");
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
hyperlinkModal.classList.add("hyperlink-set-modal");
|
|
27
28
|
|
|
28
|
-
buttonsWrapper.classList.add("
|
|
29
|
-
inputsWrapper.classList.add("
|
|
29
|
+
buttonsWrapper.classList.add("hyperlink-set-modal__buttons-wrapper");
|
|
30
|
+
inputsWrapper.classList.add("hyperlink-set-modal__inputs-wrapper");
|
|
30
31
|
|
|
31
32
|
// create a form that contain url input and a button for submit
|
|
32
33
|
const form = document.createElement("form");
|
|
@@ -42,12 +43,12 @@ export function setHyperlink(options: setHyperlinkModalOptions): void {
|
|
|
42
43
|
buttonsWrapper.append(button);
|
|
43
44
|
form.append(inputsWrapper, buttonsWrapper);
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
hyperlinkModal.append(form);
|
|
46
47
|
|
|
47
48
|
tippyModal.innerHTML = "";
|
|
48
|
-
tippyModal.append(
|
|
49
|
+
tippyModal.append(hyperlinkModal);
|
|
49
50
|
tooltip.update(options.editor.view, {
|
|
50
|
-
arrow: roundArrow,
|
|
51
|
+
arrow: options.roundArrow,
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
// make sure
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Editor } from "@tiptap/core";
|
|
2
|
-
type setHyperlinkModalOptions = {
|
|
3
|
-
editor: Editor;
|
|
4
|
-
validate?: (url: string) => boolean;
|
|
5
|
-
extentionName: string;
|
|
6
|
-
attributes: Record<string, any>;
|
|
7
|
-
};
|
|
8
|
-
export declare function setHyperlink(options: setHyperlinkModalOptions): void;
|
|
9
|
-
export {};
|
|
File without changes
|
|
File without changes
|