@progress/kendo-vue-editor
Version:
165 lines (164 loc) • 5.12 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 w, createVNode as e, isVNode as y } from "vue";
import { Window as V, DialogActionsBar as L } from "@progress/kendo-vue-dialogs";
import { Button as p } from "@progress/kendo-vue-buttons";
import { getMark as S, applyLink as I } from "@progress/kendo-editor-common";
import { provideLocalizationService as z } from "@progress/kendo-vue-intl";
import { messages as r } from "../messages/main.mjs";
import { getRef as s, setRef as a } from "@progress/kendo-vue-common";
import { Form as H, FormElement as $, FieldWrapper as u } from "@progress/kendo-vue-form";
import { Input as k, Checkbox as j } from "@progress/kendo-vue-inputs";
function C(t) {
return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !y(t);
}
const M = /* @__PURE__ */ w({
name: "KendoInsertLinkDialog",
emits: {
close: null
},
props: {
view: Object,
settings: Object,
dir: String
},
data() {
const {
view: t,
settings: l
} = this.$props, i = t ? S(t.state, t.state.schema.marks[l.mark]) : !1;
return {
hrefValue: i && i.attrs.href || void 0,
titleValue: i && i.attrs.title || void 0,
targetValue: i && !!i.attrs.target || void 0
};
},
inject: {
kendoLocalizationService: {
default: null
}
},
mounted() {
this.href = s(this, "href"), this.title = s(this, "title"), this.target = s(this, "target"), this.href && this.href.focus();
},
render() {
let t, l;
const {
settings: i,
dir: o
} = this.$props, n = z(this), {
insertHyperlinkDialogTitle: h,
insertHyperlinkAddress: d,
insertHyperlinkTitle: f,
insertHyperlinkNewWindow: g,
insertHyperlinkCancel: c,
insertHyperlinkInsert: m
} = i.messages, b = n.toLanguageString(g, r[g]), v = e(H, null, {
default: () => [e($, {
horizontal: !0
}, {
default: () => [e(u, null, {
default: () => [e("label", {
for: "k-editor-link-url",
class: "k-form-label"
}, [n.toLanguageString(d, r[d])]), e("div", {
class: "k-form-field-wrap"
}, [e(k, {
id: "k-editor-link-url",
ref: a(this, "href"),
onInput: this.hrefChange,
value: this.hrefValue
}, null)])]
}), e(u, null, {
default: () => [e("label", {
for: "k-editor-link-text",
class: "k-form-label"
}, [n.toLanguageString(f, r[f])]), e("div", {
class: "k-form-field-wrap"
}, [e(k, {
id: "k-editor-link-text",
ref: a(this, "title"),
onInput: this.titleChange,
value: this.titleValue
}, null)])]
}), i.linkTarget !== !1 && e(u, null, {
default: () => [e("div", {
class: "k-form-label"
}, null), e("div", {
class: "k-form-field-wrap"
}, [e(j, {
id: "k-editor-link-target",
ref: a(this, "target"),
label: b,
onChange: this.targetChange,
checked: this.targetValue
}, null)])]
})]
})]
});
return e(V, {
initialWidth: 450,
initialHeight: 250,
windowClass: "k-editor-window",
title: n.toLanguageString(h, r[h]),
onClose: this.onClose,
dir: o,
modal: !0,
minimizeButton: () => null,
maximizeButton: () => null,
resizable: !1
}, {
default: () => [v, e(L, null, {
default: () => [e(p, {
type: "button",
onClick: this.onClose,
dir: o,
key: "cancel"
}, C(t = n.toLanguageString(c, r[c])) ? t : {
default: () => [t]
}), e(p, {
type: "button",
onClick: this.onInsert,
themeColor: "primary",
dir: o,
key: "insert"
}, C(l = n.toLanguageString(m, r[m])) ? l : {
default: () => [l]
})]
})]
});
},
methods: {
hrefChange(t) {
this.hrefValue = t.value;
},
titleChange(t) {
this.titleValue = t.value;
},
targetChange(t) {
this.targetValue = t.value;
},
onClose() {
this.$props.view.focus(), this.$emit("close");
},
onInsert() {
const t = this.$props.view, l = this.$props.settings.mark, i = {
href: this.href ? this.hrefValue : void 0,
title: this.title ? this.titleValue : void 0,
target: this.target && this.targetValue ? "_blank" : void 0
};
I({
mark: l,
attrs: i
}, this.$props.settings.commandName)(t.state, t.dispatch), this.onClose();
}
}
});
export {
M as InsertLinkDialog
};