From 4ea01e410c944b3c347b49886321d924f92af765 Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Mon, 20 Aug 2018 15:53:35 -0700 Subject: [PATCH 1/2] Prevent code-token attribute in deltas --- blots/block.js | 7 +++++-- modules/syntax.js | 12 ------------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/blots/block.js b/blots/block.js index c065f2b19c..b6932e7a2d 100644 --- a/blots/block.js +++ b/blots/block.js @@ -178,12 +178,15 @@ function blockDelta(blot) { function bubbleFormats(blot, formats = {}) { if (blot == null) return formats; - if (typeof blot.formats === 'function') { + if ( + typeof blot.formats === 'function' && + blot.statics.blotName !== 'code-token' + ) { formats = extend(formats, blot.formats()); } if ( blot.parent == null || - blot.parent.blotName === 'scroll' || + blot.parent.statics.blotName === 'scroll' || blot.parent.statics.scope !== blot.statics.scope ) { return formats; diff --git a/modules/syntax.js b/modules/syntax.js index 0720ef6e64..b9dbddc377 100644 --- a/modules/syntax.js +++ b/modules/syntax.js @@ -65,18 +65,6 @@ class SyntaxCodeBlock extends CodeBlock { static register() {} // Syntax module will register - delta() { - if (this.cache.delta == null) { - const delta = super.delta(); - this.cache.delta = delta.compose( - new Delta().retain(delta.length(), { - [CodeToken.blotName]: null, - }), - ); - } - return this.cache.delta; - } - format(name, value) { if (name === this.statics.blotName && value) { this.domNode.setAttribute('data-language', value); From db9cbcea31da4e0a7a60b19c2c2197c07363bb7f Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Mon, 20 Aug 2018 16:19:14 -0700 Subject: [PATCH 2/2] exclude code-token format specifically --- blots/block.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/blots/block.js b/blots/block.js index b6932e7a2d..fbb6975c7d 100644 --- a/blots/block.js +++ b/blots/block.js @@ -178,11 +178,10 @@ function blockDelta(blot) { function bubbleFormats(blot, formats = {}) { if (blot == null) return formats; - if ( - typeof blot.formats === 'function' && - blot.statics.blotName !== 'code-token' - ) { + if (typeof blot.formats === 'function') { formats = extend(formats, blot.formats()); + // exclude syntax highlighting from deltas and getFormat() + delete formats['code-token']; } if ( blot.parent == null ||