embed.ts 837 B

1234567891011121314151617181920212223242526272829
  1. import { Formattable } from './abstract/blot';
  2. import LeafBlot from './abstract/leaf';
  3. class EmbedBlot extends LeafBlot implements Formattable {
  4. static formats(domNode: HTMLElement): any {
  5. return undefined;
  6. }
  7. format(name: string, value: any): void {
  8. // super.formatAt wraps, which is what we want in general,
  9. // but this allows subclasses to overwrite for formats
  10. // that just apply to particular embeds
  11. super.formatAt(0, this.length(), name, value);
  12. }
  13. formatAt(index: number, length: number, name: string, value: any): void {
  14. if (index === 0 && length === this.length()) {
  15. this.format(name, value);
  16. } else {
  17. super.formatAt(index, length, name, value);
  18. }
  19. }
  20. formats(): { [index: string]: any } {
  21. return this.statics.formats(this.domNode);
  22. }
  23. }
  24. export default EmbedBlot;