mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-22 07:01:07 +03:00
da32fc7167
* Fixed: Variable syntax highlighting lost after copy-paste from external editor in Agentflow V2 * Fixed: Variable syntax highlighting lost after copy paste * Rename CustomMention.js to customMention.js * Update ExpandRichInputDialog.jsx * Update RichInput.jsx * Update customMention.js * Update ExpandRichInputDialog.jsx * Update RichInput.jsx * lint fix --------- Co-authored-by: Henry Heng <henryheng@flowiseai.com>
27 lines
837 B
JavaScript
27 lines
837 B
JavaScript
import Mention from '@tiptap/extension-mention'
|
|
import { PasteRule } from '@tiptap/core'
|
|
|
|
export const CustomMention = Mention.extend({
|
|
renderText({ node }) {
|
|
return `{{${node.attrs.label ?? node.attrs.id}}}`
|
|
},
|
|
addPasteRules() {
|
|
return [
|
|
new PasteRule({
|
|
find: /\{\{([^{}]+)\}\}/g,
|
|
handler: ({ match, chain, range }) => {
|
|
const label = match[1].trim()
|
|
if (label) {
|
|
chain()
|
|
.deleteRange(range)
|
|
.insertContentAt(range.from, {
|
|
type: this.name,
|
|
attrs: { id: label, label: label }
|
|
})
|
|
}
|
|
}
|
|
})
|
|
]
|
|
}
|
|
})
|