UNPKG

@mui/x-internal-exceljs-fork

Version:

Excel Workbook Manager - Read and Write xlsx and csv Files.

108 lines (104 loc) 3.55 kB
"use strict"; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } const RichTextXform = require('../strings/rich-text-xform'); const utils = require('../../../utils/utils'); const BaseXform = require('../base-xform'); /** <comment ref="B1" authorId="0"> <text> <r> <rPr> <b/> <sz val="9"/> <rFont val="宋体"/> <charset val="134"/> </rPr> <t>51422:</t> </r> <r> <rPr> <sz val="9"/> <rFont val="宋体"/> <charset val="134"/> </rPr> <t xml:space="preserve">&#10;test</t> </r> </text> </comment> */ const CommentXform = module.exports = function (model) { this.model = model; }; utils.inherits(CommentXform, BaseXform, { get tag() { return 'r'; }, get richTextXform() { if (!this._richTextXform) { this._richTextXform = new RichTextXform(); } return this._richTextXform; }, render(xmlStream, model) { model = model || this.model; xmlStream.openNode('comment', { ref: model.ref, authorId: 0 }); xmlStream.openNode('text'); if (model && model.note && model.note.texts) { model.note.texts.forEach(text => { this.richTextXform.render(xmlStream, text); }); } xmlStream.closeNode(); xmlStream.closeNode(); }, parseOpen(node) { if (this.parser) { this.parser.parseOpen(node); return true; } switch (node.name) { case 'comment': this.model = _objectSpread({ type: 'note', note: { texts: [] } }, node.attributes); return true; case 'r': this.parser = this.richTextXform; this.parser.parseOpen(node); return true; default: return false; } }, parseText(text) { if (this.parser) { this.parser.parseText(text); } }, parseClose(name) { switch (name) { case 'comment': return false; case 'r': this.model.note.texts.push(this.parser.model); this.parser = undefined; return true; default: if (this.parser) { this.parser.parseClose(name); } return true; } } }); //# sourceMappingURL=comment-xform.js.map