UNPKG

devexpress-richedit

Version:

DevExpress Rich Text Editor is an advanced word-processing tool designed for working with rich text documents.

41 lines (40 loc) 2.27 kB
import { NoteType } from "../../../../../../common/model/footnotes/footnote"; import { SubDocument } from "../../../../../../common/model/sub-document"; import { MapCreator } from "../../../../../../common/utils/map-creator"; import { TranslationTables } from "../../../translation-table/translation-tables"; import { BodyDestinationBase } from "../document/body-destination-base"; import { ParagraphDestination } from "../paragraph/paragraph-destination"; import { HeaderFooterDestination } from "../section/header-footer/header-footer-destination"; import { TableDestination } from "../table/table/table-destination"; export class NoteDestination extends BodyDestinationBase { static { this.handlerTable = new MapCreator() .add('p', (data) => new ParagraphDestination(data)) .add('tbl', (data) => new TableDestination(data)) .add('bookmarkStart', BodyDestinationBase.onBookmarkStart) .add('bookmarkEnd', BodyDestinationBase.onBookmarkEnd) .add('permStart', BodyDestinationBase.onRangePermissionStart) .add('permEnd', BodyDestinationBase.onRangePermissionEnd) .add('sdt', BodyDestinationBase.onStructuredDocument) .add('customXml', BodyDestinationBase.onCustomXml) .get(); } get elementHandlerTable() { return HeaderFooterDestination.handlerTable; } async processElementOpen(reader) { this.type = this.data.readerHelper.getWpEnumValue(reader, "type", TranslationTables.noteTypeTable.importMap, NoteType.Normal); const note = this.createSubDocument(this.SubDocumentType); note.info.noteType = this.type; this.data.pushCurrentSubDocument(note); this.id = reader.getAttributeNS("id", this.data.constants.wordProcessingNamespaceConst); } async processElementClose(_reader) { this.data.fixLastParagraph(); const subDoc = this.data.popCurrentSubDocument(); this.subDocId = subDoc.id; if (!this.addNote(this.id, this.subDocId, this.type)) this.data.documentModel.subDocumentsCollection.delete(this.subDocId); } createSubDocument(type) { return this.documentModel.createSubDocument(type, SubDocument.MAIN_SUBDOCUMENT_ID, true); } }