UNPKG

@syncfusion/ej2-vue-documenteditor

Version:

Feature-rich document editor control with built-in support for context menu, options pane and dialogs. for Vue

378 lines (374 loc) 16.8 kB
import { DocumentEditor, DocumentEditorContainer } from '@syncfusion/ej2-documenteditor'; export * from '@syncfusion/ej2-documenteditor'; import { getProps, vueDefineComponent, ComponentBase, isExecute, gh } from '@syncfusion/ej2-vue-base'; import { isNullOrUndefined } from '@syncfusion/ej2-base'; const properties = ['isLazyUpdate', 'plugins', 'acceptTab', 'autoResizeOnVisibilityChange', 'currentUser', 'defaultPasteOption', 'documentEditorSettings', 'documentName', 'documentSettings', 'enableAutoFocus', 'enableBookmarkDialog', 'enableBordersAndShadingDialog', 'enableCollaborativeEditing', 'enableColumnsDialog', 'enableComment', 'enableContextMenu', 'enableCursorOnReadOnly', 'enableEditor', 'enableEditorHistory', 'enableFontDialog', 'enableFootnoteAndEndnoteDialog', 'enableFormField', 'enableHyperlinkDialog', 'enableImageResizer', 'enableLayout', 'enableListDialog', 'enableLocalPaste', 'enableLockAndEdit', 'enableOptionsPane', 'enablePageSetupDialog', 'enableParagraphDialog', 'enablePersistence', 'enablePrint', 'enableRtl', 'enableSearch', 'enableSelection', 'enableSfdtExport', 'enableSpellCheck', 'enableStyleDialog', 'enableTableDialog', 'enableTableOfContentsDialog', 'enableTableOptionsDialog', 'enableTablePropertiesDialog', 'enableTextExport', 'enableTrackChanges', 'enableWordExport', 'headers', 'height', 'isReadOnly', 'layoutType', 'locale', 'pageGap', 'pageOutline', 'serverActionSettings', 'serviceUrl', 'showComments', 'showRevisions', 'useCtrlClickToFollowHyperlink', 'userColor', 'width', 'zIndex', 'zoomFactor', 'actionComplete', 'afterFormFieldFill', 'beforeAcceptRejectChanges', 'beforeCommentAction', 'beforeFileOpen', 'beforeFormFieldFill', 'beforePaneSwitch', 'beforePaste', 'commentBegin', 'commentDelete', 'commentEnd', 'contentChange', 'contentControl', 'created', 'customContextMenuBeforeOpen', 'customContextMenuSelect', 'destroyed', 'documentChange', 'keyDown', 'requestNavigate', 'searchResultsChange', 'selectionChange', 'serviceFailure', 'trackChange', 'viewChange', 'zoomFactorChange', 'beforeXmlHttpRequestSend', 'documentLoadFailed']; const modelProps = []; const testProp = getProps({ props: properties }); const props = testProp[0], watch = testProp[1], emitProbs = Object.keys(watch); emitProbs.push('modelchanged', 'update:modelValue'); for (let props of modelProps) { emitProbs.push('update:' + props); } /** * Represents the Essential JS 2 VueJS Document Editor Component * ```html * <ejs-documenteditor id='container'></ejs-documenteditor> * ``` */ let DocumentEditorComponent = vueDefineComponent({ name: 'DocumentEditorComponent', mixins: [ComponentBase], props: props, watch: watch, emits: emitProbs, provide() { return { custom: this.custom }; }, data() { return { ej2Instance: new DocumentEditor({}), propKeys: properties, models: modelProps, hasChildDirective: false, hasInjectedModules: true, tagMapper: {}, tagNameMapper: {}, isVue3: !isExecute, templateCollection: {}, }; }, created() { this.bindProperties(); this.ej2Instances._setProperties = this.ej2Instances.setProperties; this.ej2Instances.setProperties = this.setProperties; this.ej2Instances.clearTemplate = this.clearTemplate; this.updated = this.updated; }, render(createElement) { let h = !isExecute ? gh : createElement; let slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', slots); }, methods: { clearTemplate(templateNames) { if (!templateNames) { templateNames = Object.keys(this.templateCollection || {}); } if (templateNames.length && this.templateCollection) { for (let tempName of templateNames) { let elementCollection = this.templateCollection[tempName]; if (elementCollection && elementCollection.length) { for (let ele of elementCollection) { this.destroyPortals(ele); } delete this.templateCollection[tempName]; } } } }, setProperties(prop, muteOnChange) { if (this.isVue3) { this.models = !this.models ? this.ej2Instances.referModels : this.models; } if (this.ej2Instances && this.ej2Instances._setProperties) { this.ej2Instances._setProperties(prop, muteOnChange); } if (prop && this.models && this.models.length) { Object.keys(prop).map((key) => { this.models.map((model) => { if ((key === model) && !(/datasource/i.test(key))) { if (this.isVue3) { this.ej2Instances.vueInstance.$emit('update:' + key, prop[key]); } else { this.$emit('update:' + key, prop[key]); this.$emit('modelchanged', prop[key]); } } }); }); } }, custom() { this.updated(); }, destroy() { return this.ej2Instances.destroy(); }, enableAllModules() { return this.ej2Instances.enableAllModules(); }, exportAsImage(pageNumber, format) { return this.ej2Instances.exportAsImage(pageNumber, format); }, exportContentControlData(isExportRichTextData) { return this.ej2Instances.exportContentControlData(isExportRichTextData); }, exportFormData() { return this.ej2Instances.exportFormData(); }, fitPage(pageFitType) { return this.ej2Instances.fitPage(pageFitType); }, focusIn() { return this.ej2Instances.focusIn(); }, getBookmarks() { return this.ej2Instances.getBookmarks(); }, getComments() { return this.ej2Instances.getComments(); }, getDefaultCharacterFormat() { return this.ej2Instances.getDefaultCharacterFormat(); }, getDefaultParagraphFormat() { return this.ej2Instances.getDefaultParagraphFormat(); }, getDefaultSectionFormat() { return this.ej2Instances.getDefaultSectionFormat(); }, getDocumentCharacterFormat() { return this.ej2Instances.getDocumentCharacterFormat(); }, getDocumentParagraphFormat() { return this.ej2Instances.getDocumentParagraphFormat(); }, getFormFieldInfo(name) { return this.ej2Instances.getFormFieldInfo(name); }, getFormFieldNames() { return this.ej2Instances.getFormFieldNames(); }, getStyleNames(styleType) { return this.ej2Instances.getStyleNames(styleType); }, getStyles(styleType) { return this.ej2Instances.getStyles(styleType); }, importContentControlData(contentControlInfo) { return this.ej2Instances.importContentControlData(contentControlInfo); }, importFormData(formData) { return this.ej2Instances.importFormData(formData); }, open(inputData) { return this.ej2Instances.open(inputData); }, openAsync(inputData) { return this.ej2Instances.openAsync(inputData); }, openBlank() { return this.ej2Instances.openBlank(); }, print(printWindow) { return this.ej2Instances.print(printWindow); }, resetContentControlData(contentControInfo) { return this.ej2Instances.resetContentControlData(contentControInfo); }, resetFormFields(name) { return this.ej2Instances.resetFormFields(name); }, resize(width, height) { return this.ej2Instances.resize(width, height); }, save(fileName, formatType) { return this.ej2Instances.save(fileName, formatType); }, saveAsBlob(formatType) { return this.ej2Instances.saveAsBlob(formatType); }, scrollToPage(pageNumber) { return this.ej2Instances.scrollToPage(pageNumber); }, serialize() { return this.ej2Instances.serialize(); }, setCustomFonts(fonts) { return this.ej2Instances.setCustomFonts(fonts); }, setDefaultCharacterFormat(characterFormat) { return this.ej2Instances.setDefaultCharacterFormat(characterFormat); }, setDefaultParagraphFormat(paragraphFormat) { return this.ej2Instances.setDefaultParagraphFormat(paragraphFormat); }, setDefaultSectionFormat(sectionFormat) { return this.ej2Instances.setDefaultSectionFormat(sectionFormat); }, setDocumentCharacterFormat(characterFormat) { return this.ej2Instances.setDocumentCharacterFormat(characterFormat); }, setDocumentParagraphFormat(paragraphFormat) { return this.ej2Instances.setDocumentParagraphFormat(paragraphFormat); }, setFormFieldInfo(name, formFieldInfo) { return this.ej2Instances.setFormFieldInfo(name, formFieldInfo); }, showDialog(dialogType) { return this.ej2Instances.showDialog(dialogType); }, showOptionsPane() { return this.ej2Instances.showOptionsPane(); }, showRestrictEditingPane(show) { return this.ej2Instances.showRestrictEditingPane(show); }, showXmlPane() { return this.ej2Instances.showXmlPane(); }, updateFields() { return this.ej2Instances.updateFields(); }, verbalizeFromCursorLocation() { return this.ej2Instances.verbalizeFromCursorLocation(); }, } }); const DocumentEditorPlugin = { name: 'ejs-documenteditor', install(Vue) { Vue.component(DocumentEditorPlugin.name, DocumentEditorComponent); } }; const properties$1 = ['isLazyUpdate', 'plugins', 'autoResizeOnVisibilityChange', 'backstageMenu', 'currentUser', 'documentEditorSettings', 'documentSettings', 'enableAutoFocus', 'enableComment', 'enableCsp', 'enableLocalPaste', 'enableLockAndEdit', 'enablePersistence', 'enableRtl', 'enableSpellCheck', 'enableToolbar', 'enableTrackChanges', 'fileMenuItems', 'headers', 'height', 'layoutType', 'locale', 'restrictEditing', 'ribbonLayout', 'serverActionSettings', 'serviceUrl', 'showPropertiesPane', 'toolbarItems', 'toolbarMode', 'userColor', 'width', 'zIndex', 'beforeAcceptRejectChanges', 'beforeCommentAction', 'beforePaneSwitch', 'beforePaste', 'commentDelete', 'contentChange', 'contentControl', 'created', 'customContextMenuBeforeOpen', 'customContextMenuSelect', 'destroyed', 'documentChange', 'fileMenuItemClick', 'selectionChange', 'serviceFailure', 'toolbarClick', 'trackChange', 'beforeXmlHttpRequestSend']; const modelProps$1 = []; const testProp$1 = getProps({ props: properties$1 }); const props$1 = testProp$1[0], watch$1 = testProp$1[1], emitProbs$1 = Object.keys(watch$1); emitProbs$1.push('modelchanged', 'update:modelValue'); for (let props of modelProps$1) { emitProbs$1.push('update:' + props); } /** * Represents the Essential JS 2 VueJS Document Editor Container * ```html * <ejs-documenteditor-container id='container'></ejs-documenteditor-container> * ``` */ let DocumentEditorContainerComponent = vueDefineComponent({ name: 'DocumentEditorContainerComponent', mixins: [ComponentBase], props: props$1, watch: watch$1, emits: emitProbs$1, provide() { return { custom: this.custom }; }, data() { return { ej2Instance: new DocumentEditorContainer({}), propKeys: properties$1, models: modelProps$1, hasChildDirective: false, hasInjectedModules: true, tagMapper: {}, tagNameMapper: {}, isVue3: !isExecute, templateCollection: {}, }; }, created() { this.bindProperties(); this.ej2Instances._setProperties = this.ej2Instances.setProperties; this.ej2Instances.setProperties = this.setProperties; this.ej2Instances.clearTemplate = this.clearTemplate; this.updated = this.updated; }, render(createElement) { let h = !isExecute ? gh : createElement; let slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', slots); }, methods: { clearTemplate(templateNames) { if (!templateNames) { templateNames = Object.keys(this.templateCollection || {}); } if (templateNames.length && this.templateCollection) { for (let tempName of templateNames) { let elementCollection = this.templateCollection[tempName]; if (elementCollection && elementCollection.length) { for (let ele of elementCollection) { this.destroyPortals(ele); } delete this.templateCollection[tempName]; } } } }, setProperties(prop, muteOnChange) { if (this.isVue3) { this.models = !this.models ? this.ej2Instances.referModels : this.models; } if (this.ej2Instances && this.ej2Instances._setProperties) { this.ej2Instances._setProperties(prop, muteOnChange); } if (prop && this.models && this.models.length) { Object.keys(prop).map((key) => { this.models.map((model) => { if ((key === model) && !(/datasource/i.test(key))) { if (this.isVue3) { this.ej2Instances.vueInstance.$emit('update:' + key, prop[key]); } else { this.$emit('update:' + key, prop[key]); this.$emit('modelchanged', prop[key]); } } }); }); } }, custom() { this.updated(); }, destroy() { return this.ej2Instances.destroy(); }, getDefaultCharacterFormat() { return this.ej2Instances.getDefaultCharacterFormat(); }, getDefaultParagraphFormat() { return this.ej2Instances.getDefaultParagraphFormat(); }, getDefaultSectionFormat() { return this.ej2Instances.getDefaultSectionFormat(); }, getDocumentCharacterFormat() { return this.ej2Instances.getDocumentCharacterFormat(); }, getDocumentParagraphFormat() { return this.ej2Instances.getDocumentParagraphFormat(); }, resize(width, height) { return this.ej2Instances.resize(width, height); }, setDefaultCharacterFormat(characterFormat) { return this.ej2Instances.setDefaultCharacterFormat(characterFormat); }, setDefaultParagraphFormat(paragraphFormat) { return this.ej2Instances.setDefaultParagraphFormat(paragraphFormat); }, setDefaultSectionFormat(sectionFormat) { return this.ej2Instances.setDefaultSectionFormat(sectionFormat); }, setDocumentCharacterFormat(characterFormat) { return this.ej2Instances.setDocumentCharacterFormat(characterFormat); }, setDocumentParagraphFormat(paragraphFormat) { return this.ej2Instances.setDocumentParagraphFormat(paragraphFormat); }, } }); const DocumentEditorContainerPlugin = { name: 'ejs-documenteditorcontainer', install(Vue) { Vue.component(DocumentEditorContainerPlugin.name, DocumentEditorContainerComponent); } }; export { DocumentEditorComponent, DocumentEditorContainerComponent, DocumentEditorContainerPlugin, DocumentEditorPlugin }; //# sourceMappingURL=ej2-vue-documenteditor.es2015.js.map