| 529 | const variableHighlightKey = new PluginKey('variableHighlight') |
| 530 | |
| 531 | function buildDecorations (doc) { |
| 532 | const decorations = [] |
| 533 | const regex = /\[\[[^\]]*\]\]/g |
| 534 | |
| 535 | doc.descendants((node, pos) => { |
| 536 | if (!node.isText) return |
| 537 | |
| 538 | let match |
| 539 | |
| 540 | while ((match = regex.exec(node.text)) !== null) { |
| 541 | const from = pos + match.index |
| 542 | const to = from + match[0].length |
| 543 | |
| 544 | decorations.push(Decoration.inline(from, to, { nodeName: 'dynamic-variable' })) |
| 545 | } |
| 546 | }) |
| 547 | |
| 548 | return DecorationSet.create(doc, decorations) |
| 549 | } |
| 550 | |
| 551 | const VariableHighlight = Extension.create({ |
| 552 | name: 'variableHighlight', |