@docs.plus/extension-hyperlink 1.5.0 → 1.5.2
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 +111 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
[](https://npmcharts.com/compare/@docs.plus/extension-hyperlink)
|
|
5
5
|
[](https://www.npmjs.com/package/@docs.plus/extension-hyperlink)
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
The Link extension adds support for `<a>` tags to the editor. The extension is headless, there is no actual <u>**UI**</u> to add, <u>modify</u> or <u>delete</u> links. The usage example below uses the native JavaScript prompt to show you how that could work.
|
|
9
8
|
|
|
10
9
|
In a real world application, you would probably add a more sophisticated user interface.
|
|
@@ -12,7 +11,7 @@ In a real world application, you would probably add a more sophisticated user in
|
|
|
12
11
|
## Installation
|
|
13
12
|
|
|
14
13
|
````sh
|
|
15
|
-
npm install @
|
|
14
|
+
npm install @docs.plus/extension-hyperlink
|
|
16
15
|
````
|
|
17
16
|
|
|
18
17
|
## Settings
|
|
@@ -93,6 +92,7 @@ Hyperlink.configure({
|
|
|
93
92
|
### Modals
|
|
94
93
|
|
|
95
94
|
The Modals configuration option lets you incorporate an interactive user interface similar to Google Docs for **setting** and **previewing** hyperlinks. This provides users with a more intuitive and interactive experience;
|
|
95
|
+
|
|
96
96
|
- [Dive into the code](https://github.com/HMarzban/extension-hyperlink/blob/4f37ffa18237f10d76c316844b1c2ab20b751fe9/packages/nextjs/src/components/Tiptap.tsx#L21-L28)
|
|
97
97
|
- [Demo](https://github.com/HMarzban/extension-hyperlink#test-drive-with-our-demo-)
|
|
98
98
|
|
|
@@ -150,11 +150,10 @@ function previewHyperlinkModal(options) {
|
|
|
150
150
|
|
|
151
151
|
```ts
|
|
152
152
|
import { Editor } from "@tiptap/core";
|
|
153
|
-
import Tooltip, { TippyInitOptions } from "../helpers/tippyHelper";
|
|
154
153
|
import { find } from "linkifyjs";
|
|
155
154
|
|
|
155
|
+
let tooltip = undefined;
|
|
156
156
|
|
|
157
|
-
let tooltip: Tooltip | undefined = undefined;
|
|
158
157
|
function setHyperlinkModal(options) {
|
|
159
158
|
// Create the tooltip instance
|
|
160
159
|
if (!tooltip) tooltip = new options.Tooltip(options);
|
|
@@ -228,6 +227,106 @@ function setHyperlinkModal(options) {
|
|
|
228
227
|
|
|
229
228
|
</details>
|
|
230
229
|
|
|
230
|
+
<details>
|
|
231
|
+
<summary>The Hyperlink styles.scss</summary>
|
|
232
|
+
|
|
233
|
+
```scss
|
|
234
|
+
.tippy-box {
|
|
235
|
+
.hyperlink-preview-modal,
|
|
236
|
+
.hyperlink-set-modal,
|
|
237
|
+
.hyperlink-edit-modal {
|
|
238
|
+
background-color: #fff;
|
|
239
|
+
border-radius: 10px;
|
|
240
|
+
border: 1px solid #dadce0;
|
|
241
|
+
display: flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
justify-content: space-between;
|
|
244
|
+
padding: 6px 6px;
|
|
245
|
+
box-shadow: 0 1px 3px 1px rgba(60, 64, 67, 0.15);
|
|
246
|
+
margin-top: -6px;
|
|
247
|
+
|
|
248
|
+
&__metadata {
|
|
249
|
+
width: 200px;
|
|
250
|
+
display: flex;
|
|
251
|
+
align-items: center;
|
|
252
|
+
justify-content: flex-end;
|
|
253
|
+
flex-direction: row-reverse;
|
|
254
|
+
a {
|
|
255
|
+
font-size: 0.9rem;
|
|
256
|
+
margin-right: 6px;
|
|
257
|
+
white-space: nowrap;
|
|
258
|
+
overflow: hidden;
|
|
259
|
+
text-overflow: ellipsis;
|
|
260
|
+
}
|
|
261
|
+
img {
|
|
262
|
+
width: 18px;
|
|
263
|
+
height: 18px;
|
|
264
|
+
border-radius: 50%;
|
|
265
|
+
margin-right: 8px;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
&__remove-button,
|
|
270
|
+
&__edit-button,
|
|
271
|
+
&__copy-button,
|
|
272
|
+
&__apply-button {
|
|
273
|
+
width: 30px;
|
|
274
|
+
height: 30px;
|
|
275
|
+
border-radius: 50%;
|
|
276
|
+
margin: 0 0.25rem;
|
|
277
|
+
display: flex;
|
|
278
|
+
align-items: center;
|
|
279
|
+
justify-content: center;
|
|
280
|
+
transition: background-color 0.1s ease-in-out;
|
|
281
|
+
&:hover {
|
|
282
|
+
background-color: #eee;
|
|
283
|
+
}
|
|
284
|
+
> svg {
|
|
285
|
+
width: 16px;
|
|
286
|
+
height: 16px;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
form {
|
|
291
|
+
display: flex;
|
|
292
|
+
align-items: flex-end;
|
|
293
|
+
width: 100%;
|
|
294
|
+
input {
|
|
295
|
+
border: 1px solid #dadce0;
|
|
296
|
+
border-radius: 6px;
|
|
297
|
+
padding: 0.4rem 0.8rem;
|
|
298
|
+
margin-bottom: 0.2rem;
|
|
299
|
+
width: 100%;
|
|
300
|
+
&:last-of-type {
|
|
301
|
+
margin-bottom: 0;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
.hyperlink-set-modal__buttons-wrapper,
|
|
305
|
+
.hyperlink-edit-modal__buttons-wrapper {
|
|
306
|
+
margin-left: 8px;
|
|
307
|
+
button {
|
|
308
|
+
border-radius: 6px;
|
|
309
|
+
padding: 4px 14px;
|
|
310
|
+
width: 70px;
|
|
311
|
+
margin-bottom: 0.2rem;
|
|
312
|
+
color: #1a73e8;
|
|
313
|
+
&:hover {
|
|
314
|
+
background: rgba(26, 115, 232, 0.04);
|
|
315
|
+
color: #174ea6;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.tippy-svg-arrow {
|
|
323
|
+
top: -6px !important;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
</details>
|
|
329
|
+
|
|
231
330
|
````ts
|
|
232
331
|
import {
|
|
233
332
|
Hyperlink,
|
|
@@ -246,8 +345,10 @@ Hyperlink.configure({
|
|
|
246
345
|
},
|
|
247
346
|
})
|
|
248
347
|
````
|
|
348
|
+
|
|
249
349
|
> Note: The `previewHyperlinkModal` and `setHyperlinkModal` modals are prebuilt modal boxes. You can use them or create your own modal boxes. To learn how to create your own modal boxes, please check the [source code](https://github.com/HMarzban/extension-hyperlink/tree/main/packages/extension-hyperlink/src/modals)
|
|
250
350
|
|
|
351
|
+
<Su>
|
|
251
352
|
|
|
252
353
|
### Removing and overriding existing html attributes
|
|
253
354
|
|
|
@@ -336,7 +437,7 @@ this.editor.getAttributes('link').href
|
|
|
336
437
|
## Sorce code and Example
|
|
337
438
|
|
|
338
439
|
- Demo:
|
|
339
|
-
[
|
|
440
|
+
[extension-hyperlink](https://github.com/HMarzban/extension-hyperlink#test-drive-with-our-demo-)
|
|
340
441
|
- Extension:
|
|
341
442
|
[packages/extension-hyperlink](https://github.com/HMarzban/extension-hyperlink/tree/main/packages/extension-hyperlink)
|
|
342
443
|
- Usage: [packages/nextjs/src/components/Tiptap.tsx](https://github.com/HMarzban/extension-hyperlink/blob/59f45eba1886202f4840eb2112c34574c16fe68a/packages/nextjs/src/components/Tiptap.tsx#L19-L29)
|
|
@@ -345,6 +446,9 @@ this.editor.getAttributes('link').href
|
|
|
345
446
|
|
|
346
447
|
Thank you for exploring our Hyperlink extension from docs.plus! We aim to make collaboration and knowledge sharing not just easy, but also enjoyable.
|
|
347
448
|
|
|
348
|
-
Our extension is inspired by Tiptap's [extension-link](https://github.com/ueberdosis/tiptap/tree/main/packages/extension-link). While we've incorporated our own enhancements, we'd like to tip our hats to Tiptap for pioneering the "headless" approach that we admire greatly.
|
|
449
|
+
Our extension is inspired by Tiptap's [extension-link](https://github.com/ueberdosis/tiptap/tree/main/packages/extension-link). While we've incorporated our own enhancements, we'd like to tip our hats to Tiptap for pioneering the "headless" approach that we admire greatly.
|
|
450
|
+
> Please note: We're not affiliated with Tiptap, but we believe in recognizing foundational work.
|
|
451
|
+
|
|
452
|
+
Your feedback and interest in docs.plus are invaluable to us. Share your thoughts, suggestions, or dive deeper into our mission at the [docs.plus](https://github.com/docs-plus/docs.plus) repository.
|
|
349
453
|
|
|
350
|
-
|
|
454
|
+
Wish to converse? Connect with us [here](https://github.com/docs-plus/docs.plus#-connect-with-us).
|
package/package.json
CHANGED