Skip to content

Commit

Permalink
Update anchor behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
m4n1ok authored and ifox committed Mar 2, 2020
1 parent e8b450d commit cf25ee8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
10 changes: 7 additions & 3 deletions frontend/js/components/Wysiwyg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@
},
anchorHandler (value) {
if (value === true) {
value = prompt('Enter Id:')
value = prompt('Enter anchor:')
} else {
let range = this.quill.getSelection()
const id = this.quill.getFormat(range).anchor || ''
value = prompt('Edit anchor:', id)
}
this.quill.format('anchor', value)
},
Expand Down Expand Up @@ -438,8 +442,8 @@
color: $color__link;
}
.ql-anchor {
text-underline: $color__link;
.ql-editor .ql-anchor {
text-decoration: underline $color__link;
}
.ql-snow.ql-toolbar {
Expand Down
11 changes: 2 additions & 9 deletions frontend/js/libs/Quill/QuillConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ class Anchor extends Inline {
static create (value) {
let node = super.create(value)
value = this.sanitize(value)
console.log(value)
node.setAttribute('id', value)
node.className = 'ql-anchor'
return node
}

static sanitize (id) {
return sanitizeAnchor(id) ? id : ''
return id.replace(/\s+/g, '-').toLowerCase()
}

static formats (domNode) {
Expand All @@ -93,13 +93,6 @@ class Anchor extends Inline {
}
}

function sanitizeAnchor (id) {
let anchor = document.createElement('span')
anchor.className = 'ql-anchor'
anchor.id = id.replace(/\s+/g, '-').toLowerCase()
return true
}

Anchor.blotName = anchor.blotName
Anchor.tagName = anchor.tagName

Expand Down

0 comments on commit cf25ee8

Please sign in to comment.