@progress/kendo-vue-editor
Version:
99 lines (98 loc) • 2.65 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import { defineComponent as h, h as g, createVNode as p } from "vue";
import { Button as l } from "@progress/kendo-vue-buttons";
import { guid as f } from "@progress/kendo-vue-common";
import { InsertTablePopup as m } from "./popup.mjs";
import { provideLocalizationService as T } from "@progress/kendo-vue-intl";
import { messages as c } from "../../messages/main.mjs";
import { createTable as P, insertNode as v, canInsert as w } from "@progress/kendo-editor-common";
const z = /* @__PURE__ */ h({
name: "KendoInsertTable",
props: {
view: Object,
settings: {
type: Object,
default: function() {
return {
messages: {}
};
}
},
dir: String,
...l.props
},
inject: {
kendoLocalizationService: {
default: null
}
},
created() {
this.buttonRef = f();
},
data() {
return {
openedPopup: !1
};
},
render() {
const {
view: e,
settings: n,
...t
} = this.$props, o = e && e.state, s = T(this), {
createTable: r,
createTableHint: a
} = n.messages, i = s.toLanguageString(r, c[r]), u = s.toLanguageString(a, c[a]), d = {
...t,
disabled: !o || !w(o, o.schema.nodes.table),
key: "InsertTable",
title: i,
...n.props
}, b = [g(l, {
ref: this.buttonRef,
onClick: this.togglePopup,
onMousedown: this.preventDefault,
onPointerdown: this.preventDefault,
...d
}), e && p(m, {
key: "insertTablePopup",
createTableMessage: i,
createTableHintMessage: u,
dir: this.dir,
anchor: this.buttonRef,
show: this.openedPopup,
onClose: this.closePopup,
onTableinsert: this.onTableInsert
}, null) || null];
return p("span", null, [b]);
},
methods: {
togglePopup() {
this.openedPopup = !this.openedPopup;
},
closePopup() {
this.openedPopup && this.togglePopup();
},
onTableInsert(e, n) {
const {
view: t
} = this.$props;
if (!t)
return;
const o = P(t.state.schema.nodes, e, n);
o && v(o, !0)(t.state, t.dispatch), t.focus(), this.closePopup();
},
preventDefault(e) {
e.preventDefault();
}
}
});
export {
z as InsertTable
};