script.js 544 B

1234567891011121314151617181920212223
  1. import Inline from '../blots/inline';
  2. class Script extends Inline {
  3. static create(value) {
  4. if (value === 'super') {
  5. return document.createElement('sup');
  6. } else if (value === 'sub') {
  7. return document.createElement('sub');
  8. } else {
  9. return super.create(value);
  10. }
  11. }
  12. static formats(domNode) {
  13. if (domNode.tagName === 'SUB') return 'sub';
  14. if (domNode.tagName === 'SUP') return 'super';
  15. return undefined;
  16. }
  17. }
  18. Script.blotName = 'script';
  19. Script.tagName = ['SUB', 'SUP'];
  20. export default Script;