From 2a0bb473793cbecfc643b318430c7d7f9c063f59 Mon Sep 17 00:00:00 2001 From: Sunny Hirai Date: Thu, 18 Apr 2019 15:10:10 -0700 Subject: [PATCH] Fix syntax highlighting (#2698) * Add support with warning for decorations without paths * Fix linting * Fix syntax highlighting crash in examples * Fix order of imports * Grab text.js from upstream instead of origin which was outdated --- examples/code-highlighting/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/code-highlighting/index.js b/examples/code-highlighting/index.js index 0cc059376..877a834c5 100644 --- a/examples/code-highlighting/index.js +++ b/examples/code-highlighting/index.js @@ -3,6 +3,7 @@ import { Value } from 'slate' import Prism from 'prismjs' import React from 'react' + import initialValueAsJson from './value.json' /** @@ -183,6 +184,7 @@ class CodeHighlighting extends React.Component { const others = next() || [] if (node.type !== 'code') return others + const { document } = editor.value const language = node.data.get('language') const texts = node.getTexts().toArray() const string = texts.map(t => t.text).join('\n') @@ -217,13 +219,18 @@ class CodeHighlighting extends React.Component { } if (typeof token !== 'string') { + const startPath = document.assertPath(startText.key) + const endPath = document.assertPath(endText.key) + const dec = { anchor: { key: startText.key, + path: startPath, offset: startOffset, }, focus: { key: endText.key, + path: endPath, offset: endOffset, }, mark: {