UNPKG

@syncfusion/ej2-vue-documenteditor

Version:

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

144 lines (143 loc) 6.96 kB
import { ComponentBase, gh, getProps, isExecute, vueDefineComponent } from '@syncfusion/ej2-vue-base'; import { isNullOrUndefined } from '@syncfusion/ej2-base'; import { DocumentEditorContainer } from '@syncfusion/ej2-documenteditor'; export var properties = ['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', 'unsupportedBorderStyleClick', 'beforeXmlHttpRequestSend']; export var modelProps = []; export var testProp = getProps({ props: properties }); export var props = testProp[0], watch = testProp[1], emitProbs = Object.keys(watch); emitProbs.push('modelchanged', 'update:modelValue'); for (var _i = 0, modelProps_1 = modelProps; _i < modelProps_1.length; _i++) { var props_1 = modelProps_1[_i]; emitProbs.push('update:' + props_1); } /** * Represents the Essential JS 2 VueJS Document Editor Container * ```html * <ejs-documenteditor-container id='container'></ejs-documenteditor-container> * ``` */ export var DocumentEditorContainerComponent = vueDefineComponent({ name: 'DocumentEditorContainerComponent', mixins: [ComponentBase], props: props, watch: watch, emits: emitProbs, provide: function () { return { custom: this.custom }; }, data: function () { return { ej2Instance: new DocumentEditorContainer({}), propKeys: properties, models: modelProps, hasChildDirective: false, hasInjectedModules: true, tagMapper: {}, tagNameMapper: {}, isVue3: !isExecute, templateCollection: {}, }; }, created: function () { this.bindProperties(); this.ej2Instances._setProperties = this.ej2Instances.setProperties; this.ej2Instances.setProperties = this.setProperties; this.ej2Instances.clearTemplate = this.clearTemplate; this.updated = this.updated; }, render: function (createElement) { var h = !isExecute ? gh : createElement; var slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', slots); }, methods: { clearTemplate: function (templateNames) { if (!templateNames) { templateNames = Object.keys(this.templateCollection || {}); } if (templateNames.length && this.templateCollection) { for (var _i = 0, templateNames_1 = templateNames; _i < templateNames_1.length; _i++) { var tempName = templateNames_1[_i]; var elementCollection = this.templateCollection[tempName]; if (elementCollection && elementCollection.length) { for (var _a = 0, elementCollection_1 = elementCollection; _a < elementCollection_1.length; _a++) { var ele = elementCollection_1[_a]; this.destroyPortals(ele); } delete this.templateCollection[tempName]; } } } }, setProperties: function (prop, muteOnChange) { var _this = this; 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(function (key) { _this.models.map(function (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: function () { this.updated(); }, destroy: function () { return this.ej2Instances.destroy(); }, getDefaultCharacterFormat: function () { return this.ej2Instances.getDefaultCharacterFormat(); }, getDefaultParagraphFormat: function () { return this.ej2Instances.getDefaultParagraphFormat(); }, getDefaultSectionFormat: function () { return this.ej2Instances.getDefaultSectionFormat(); }, getDocumentCharacterFormat: function () { return this.ej2Instances.getDocumentCharacterFormat(); }, getDocumentParagraphFormat: function () { return this.ej2Instances.getDocumentParagraphFormat(); }, resize: function (width, height) { return this.ej2Instances.resize(width, height); }, setDefaultCharacterFormat: function (characterFormat) { return this.ej2Instances.setDefaultCharacterFormat(characterFormat); }, setDefaultParagraphFormat: function (paragraphFormat) { return this.ej2Instances.setDefaultParagraphFormat(paragraphFormat); }, setDefaultSectionFormat: function (sectionFormat) { return this.ej2Instances.setDefaultSectionFormat(sectionFormat); }, setDocumentCharacterFormat: function (characterFormat) { return this.ej2Instances.setDocumentCharacterFormat(characterFormat); }, setDocumentParagraphFormat: function (paragraphFormat) { return this.ej2Instances.setDocumentParagraphFormat(paragraphFormat); }, } }); export var DocumentEditorContainerPlugin = { name: 'ejs-documenteditorcontainer', install: function (Vue) { Vue.component(DocumentEditorContainerPlugin.name, DocumentEditorContainerComponent); } };