@docs.plus/extension-hyperlink 1.5.0 → 1.5.1
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 +110 -4
- 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.
|
|
@@ -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,108 @@ function setHyperlinkModal(options) {
|
|
|
228
227
|
|
|
229
228
|
</details>
|
|
230
229
|
|
|
230
|
+
|
|
231
|
+
<details>
|
|
232
|
+
<summary>The Hyperlink styles.scss</summary>
|
|
233
|
+
|
|
234
|
+
```scss
|
|
235
|
+
.tippy-box {
|
|
236
|
+
.hyperlink-preview-modal,
|
|
237
|
+
.hyperlink-set-modal,
|
|
238
|
+
.hyperlink-edit-modal {
|
|
239
|
+
background-color: #fff;
|
|
240
|
+
border-radius: 10px;
|
|
241
|
+
border: 1px solid #dadce0;
|
|
242
|
+
display: flex;
|
|
243
|
+
align-items: center;
|
|
244
|
+
justify-content: space-between;
|
|
245
|
+
padding: 6px 6px;
|
|
246
|
+
box-shadow: 0 1px 3px 1px rgba(60, 64, 67, 0.15);
|
|
247
|
+
margin-top: -6px;
|
|
248
|
+
|
|
249
|
+
&__metadata {
|
|
250
|
+
width: 200px;
|
|
251
|
+
display: flex;
|
|
252
|
+
align-items: center;
|
|
253
|
+
justify-content: flex-end;
|
|
254
|
+
flex-direction: row-reverse;
|
|
255
|
+
a {
|
|
256
|
+
font-size: 0.9rem;
|
|
257
|
+
margin-right: 6px;
|
|
258
|
+
white-space: nowrap;
|
|
259
|
+
overflow: hidden;
|
|
260
|
+
text-overflow: ellipsis;
|
|
261
|
+
}
|
|
262
|
+
img {
|
|
263
|
+
width: 18px;
|
|
264
|
+
height: 18px;
|
|
265
|
+
border-radius: 50%;
|
|
266
|
+
margin-right: 8px;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
&__remove-button,
|
|
271
|
+
&__edit-button,
|
|
272
|
+
&__copy-button,
|
|
273
|
+
&__apply-button {
|
|
274
|
+
width: 30px;
|
|
275
|
+
height: 30px;
|
|
276
|
+
border-radius: 50%;
|
|
277
|
+
margin: 0 0.25rem;
|
|
278
|
+
display: flex;
|
|
279
|
+
align-items: center;
|
|
280
|
+
justify-content: center;
|
|
281
|
+
transition: background-color 0.1s ease-in-out;
|
|
282
|
+
&:hover {
|
|
283
|
+
background-color: #eee;
|
|
284
|
+
}
|
|
285
|
+
> svg {
|
|
286
|
+
width: 16px;
|
|
287
|
+
height: 16px;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
form {
|
|
292
|
+
display: flex;
|
|
293
|
+
align-items: flex-end;
|
|
294
|
+
width: 100%;
|
|
295
|
+
input {
|
|
296
|
+
border: 1px solid #dadce0;
|
|
297
|
+
border-radius: 6px;
|
|
298
|
+
padding: 0.4rem 0.8rem;
|
|
299
|
+
margin-bottom: 0.2rem;
|
|
300
|
+
width: 100%;
|
|
301
|
+
&:last-of-type {
|
|
302
|
+
margin-bottom: 0;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
.hyperlink-set-modal__buttons-wrapper,
|
|
306
|
+
.hyperlink-edit-modal__buttons-wrapper {
|
|
307
|
+
margin-left: 8px;
|
|
308
|
+
button {
|
|
309
|
+
border-radius: 6px;
|
|
310
|
+
padding: 4px 14px;
|
|
311
|
+
width: 70px;
|
|
312
|
+
margin-bottom: 0.2rem;
|
|
313
|
+
color: #1a73e8;
|
|
314
|
+
&:hover {
|
|
315
|
+
background: rgba(26, 115, 232, 0.04);
|
|
316
|
+
color: #174ea6;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.tippy-svg-arrow {
|
|
324
|
+
top: -6px !important;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
</details>
|
|
330
|
+
|
|
331
|
+
|
|
231
332
|
````ts
|
|
232
333
|
import {
|
|
233
334
|
Hyperlink,
|
|
@@ -246,8 +347,12 @@ Hyperlink.configure({
|
|
|
246
347
|
},
|
|
247
348
|
})
|
|
248
349
|
````
|
|
350
|
+
|
|
249
351
|
> 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
352
|
|
|
353
|
+
<Su>
|
|
354
|
+
|
|
355
|
+
|
|
251
356
|
|
|
252
357
|
### Removing and overriding existing html attributes
|
|
253
358
|
|
|
@@ -345,6 +450,7 @@ this.editor.getAttributes('link').href
|
|
|
345
450
|
|
|
346
451
|
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
452
|
|
|
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.
|
|
453
|
+
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.
|
|
454
|
+
> Please note: We're not affiliated with Tiptap, but we believe in recognizing foundational work.
|
|
349
455
|
|
|
350
456
|
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. Wish to converse? Connect with us [here](https://github.com/docs-plus/docs.plus#-connect-with-us).
|
package/package.json
CHANGED