frappe-ui 0.1.129 → 0.1.130
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/package.json
CHANGED
|
@@ -21,10 +21,20 @@ export const LinkExtension = Link.extend({
|
|
|
21
21
|
const { from, to } = state.selection
|
|
22
22
|
const { doc } = state
|
|
23
23
|
|
|
24
|
+
// If there's no selection but cursor is within a link, extend the selection to the link
|
|
24
25
|
if (from === to) {
|
|
25
|
-
|
|
26
|
+
if (editor.isActive('link')) {
|
|
27
|
+
editor.chain().focus().extendMarkRange('link').run()
|
|
28
|
+
} else {
|
|
29
|
+
// No selection and not within a link
|
|
30
|
+
return false
|
|
31
|
+
}
|
|
26
32
|
}
|
|
27
33
|
|
|
34
|
+
// Get the updated selection and position
|
|
35
|
+
const updatedSelection = editor.state.selection
|
|
36
|
+
const updatedTo = updatedSelection.to
|
|
37
|
+
|
|
28
38
|
const existingHref = editor.getAttributes('link').href || ''
|
|
29
39
|
|
|
30
40
|
openLinkEditor(existingHref, editor.view.dom)
|
|
@@ -39,7 +49,7 @@ export const LinkExtension = Link.extend({
|
|
|
39
49
|
.focus()
|
|
40
50
|
.extendMarkRange('link')
|
|
41
51
|
.unsetLink()
|
|
42
|
-
.setTextSelection(
|
|
52
|
+
.setTextSelection(updatedTo)
|
|
43
53
|
.command(({ tr }) => {
|
|
44
54
|
tr.setStoredMarks([])
|
|
45
55
|
return true
|
|
@@ -53,13 +63,13 @@ export const LinkExtension = Link.extend({
|
|
|
53
63
|
.focus()
|
|
54
64
|
.extendMarkRange('link')
|
|
55
65
|
.setLink({ href })
|
|
56
|
-
.setTextSelection(
|
|
66
|
+
.setTextSelection(updatedTo)
|
|
57
67
|
.command(({ tr }) => {
|
|
58
68
|
tr.setStoredMarks([])
|
|
59
69
|
return true
|
|
60
70
|
})
|
|
61
71
|
|
|
62
|
-
const posAfterLink =
|
|
72
|
+
const posAfterLink = updatedTo
|
|
63
73
|
const charAfter =
|
|
64
74
|
posAfterLink < doc.content.size
|
|
65
75
|
? doc.textBetween(posAfterLink, posAfterLink + 1)
|