| 334 | }) |
| 335 | |
| 336 | const buildDecorations = (doc) => { |
| 337 | const decorations = [] |
| 338 | const regex = /\{\{?[a-zA-Z0-9_.-]+\}\}?/g |
| 339 | |
| 340 | doc.descendants((node, pos) => { |
| 341 | if (!node.isText) return |
| 342 | |
| 343 | let match |
| 344 | |
| 345 | while ((match = regex.exec(node.text)) !== null) { |
| 346 | decorations.push( |
| 347 | Decoration.inline(pos + match.index, pos + match.index + match[0].length, { |
| 348 | class: 'variable-highlight' |
| 349 | }) |
| 350 | ) |
| 351 | } |
| 352 | }) |
| 353 | |
| 354 | return DecorationSet.create(doc, decorations) |
| 355 | } |
| 356 | |
| 357 | const VariableHighlight = Extension.create({ |
| 358 | name: 'variableHighlight', |