Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/assets/js/formats/script.js
2018-10-16 18:28:42 +02:00

24 lines
544 B
JavaScript

import Inline from '../blots/inline';
class Script extends Inline {
static create(value) {
if (value === 'super') {
return document.createElement('sup');
} else if (value === 'sub') {
return document.createElement('sub');
} else {
return super.create(value);
}
}
static formats(domNode) {
if (domNode.tagName === 'SUB') return 'sub';
if (domNode.tagName === 'SUP') return 'super';
return undefined;
}
}
Script.blotName = 'script';
Script.tagName = ['SUB', 'SUP'];
export default Script;