Files
Flowise/packages/ui/src/utils/customMention.js
T
Debottam Mandal da32fc7167 Fixed: Variable syntax highlighting lost after copy-paste from external editor in Agentflow V2 (#5513)
* 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>
2025-11-26 00:33:54 +00:00

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 }
})
}
}
})
]
}
})