mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-14 18:49:02 +08:00
Merge pull request #860 from Priestch/main
fix missing username when copy paragraph contains mentions
This commit is contained in:
commit
30db1c9210
@ -1,5 +1,6 @@
|
|||||||
import { Node } from 'tiptap'
|
import { Node } from 'tiptap'
|
||||||
import { replaceText } from 'tiptap-commands'
|
import { replaceText } from 'tiptap-commands'
|
||||||
|
import { Fragment } from 'prosemirror-model'
|
||||||
import SuggestionsPlugin from '../plugins/Suggestions'
|
import SuggestionsPlugin from '../plugins/Suggestions'
|
||||||
|
|
||||||
export default class Mention extends Node {
|
export default class Mention extends Node {
|
||||||
@ -20,6 +21,10 @@ export default class Mention extends Node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLabel(dom) {
|
||||||
|
return dom.innerText.split(this.options.matcher.char).join('')
|
||||||
|
}
|
||||||
|
|
||||||
get schema() {
|
get schema() {
|
||||||
return {
|
return {
|
||||||
attrs: {
|
attrs: {
|
||||||
@ -28,6 +33,7 @@ export default class Mention extends Node {
|
|||||||
},
|
},
|
||||||
group: 'inline',
|
group: 'inline',
|
||||||
inline: true,
|
inline: true,
|
||||||
|
content: 'inline*',
|
||||||
selectable: false,
|
selectable: false,
|
||||||
atom: true,
|
atom: true,
|
||||||
toDOM: node => [
|
toDOM: node => [
|
||||||
@ -43,9 +49,16 @@ export default class Mention extends Node {
|
|||||||
tag: 'span[data-mention-id]',
|
tag: 'span[data-mention-id]',
|
||||||
getAttrs: dom => {
|
getAttrs: dom => {
|
||||||
const id = dom.getAttribute('data-mention-id')
|
const id = dom.getAttribute('data-mention-id')
|
||||||
const label = dom.innerText.split(this.options.matcher.char).join('')
|
const label = this.getLabel(dom)
|
||||||
return { id, label }
|
return { id, label }
|
||||||
},
|
},
|
||||||
|
getContent: (dom, schema) => {
|
||||||
|
const label = this.getLabel(dom)
|
||||||
|
return Fragment.fromJSON(schema, [{
|
||||||
|
type: 'text',
|
||||||
|
text: `${this.options.matcher.char}${label}`,
|
||||||
|
}])
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user