blip-xform.js 833 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const BaseXform = require('../base-xform');
  2. class BlipXform extends BaseXform {
  3. get tag() {
  4. return 'a:blip';
  5. }
  6. render(xmlStream, model) {
  7. xmlStream.leafNode(this.tag, {
  8. 'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
  9. 'r:embed': model.rId,
  10. cstate: 'print',
  11. });
  12. // TODO: handle children (e.g. a:extLst=>a:ext=>a14:useLocalDpi
  13. }
  14. parseOpen(node) {
  15. switch (node.name) {
  16. case this.tag:
  17. this.model = {
  18. rId: node.attributes['r:embed'],
  19. };
  20. return true;
  21. default:
  22. return true;
  23. }
  24. }
  25. parseText() {}
  26. parseClose(name) {
  27. switch (name) {
  28. case this.tag:
  29. return false;
  30. default:
  31. // unprocessed internal nodes
  32. return true;
  33. }
  34. }
  35. }
  36. module.exports = BlipXform;