Skip to content

Commit

Permalink
Prevent code-token attribute in deltas (slab#2259)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgreensp authored and jhchen committed Aug 21, 2018
1 parent 54fd8be commit a5894ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
4 changes: 3 additions & 1 deletion blots/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,12 @@ function bubbleFormats(blot, formats = {}) {
if (blot == null) return formats;
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 ||
blot.parent.blotName === 'scroll' ||
blot.parent.statics.blotName === 'scroll' ||
blot.parent.statics.scope !== blot.statics.scope
) {
return formats;
Expand Down
12 changes: 0 additions & 12 deletions modules/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a5894ab

Please sign in to comment.