@progress/kendo-react-editor
Version:
React Editor enables users to create rich text content through a WYSIWYG interface. KendoReact Editor package
114 lines (113 loc) • 4.67 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 * as e from "react";
import { Window as C, WindowActionsBar as w } from "@progress/kendo-react-dialogs";
import { Button as v } from "@progress/kendo-react-buttons";
import { Input as y, Checkbox as L } from "@progress/kendo-react-inputs";
import { Form as b, FormElement as x, FieldWrapper as s } from "@progress/kendo-react-form";
import { applyLink as F, getMark as N } from "@progress/kendo-editor-common";
import { registerForLocalization as z, provideLocalizationService as H } from "@progress/kendo-react-intl";
import { messages as n } from "../messages/index.mjs";
let I = class extends e.Component {
constructor() {
super(...arguments), this.href = null, this.title = null, this.target = null, this.onClose = () => {
this.props.view.focus(), this.props.onClose();
}, this.onInsert = () => {
const r = this.props.view, a = this.props.settings.mark, o = {
href: this.href ? this.href.value : void 0,
title: this.title ? this.title.value : void 0,
target: this.target && this.target.element && this.target.element.checked ? "_blank" : void 0
};
F({ mark: a, attrs: o }, this.props.settings.commandName)(r.state, r.dispatch), this.onClose();
};
}
/**
* @hidden
*/
render() {
const { view: r, settings: a, dir: o, render: m } = this.props, i = H(this), {
insertHyperlinkDialogTitle: c,
insertHyperlinkAddress: h,
insertHyperlinkTitle: k,
insertHyperlinkNewWindow: d,
insertHyperlinkCancel: g,
insertHyperlinkInsert: p
} = a.messages, l = r ? N(r.state, r.state.schema.marks[a.mark]) : !1, u = /* @__PURE__ */ e.createElement(
b,
{
render: () => /* @__PURE__ */ e.createElement(x, { horizontal: !0 }, /* @__PURE__ */ e.createElement(s, null, /* @__PURE__ */ e.createElement("label", { htmlFor: "k-editor-link-url", className: "k-form-label" }, i.toLanguageString(
h,
n[h]
)), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
y,
{
type: "text",
id: "k-editor-link-url",
ref: (t) => {
this.href = t && t.element;
},
defaultValue: l && l.attrs.href || void 0,
autoFocus: !0
}
))), /* @__PURE__ */ e.createElement(s, null, /* @__PURE__ */ e.createElement("label", { htmlFor: "k-editor-link-text", className: "k-form-label" }, i.toLanguageString(
k,
n[k]
)), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
y,
{
type: "text",
id: "k-editor-link-text",
ref: (t) => {
this.title = t && t.element;
},
defaultValue: l && l.attrs.title || void 0
}
))), a.linkTarget !== !1 && /* @__PURE__ */ e.createElement(s, null, /* @__PURE__ */ e.createElement("label", { htmlFor: "k-editor-link-target", className: "k-checkbox-label" }, /* @__PURE__ */ e.createElement(
L,
{
id: "k-editor-link-target",
ref: (t) => {
this.target = t;
},
defaultChecked: l && !!l.attrs.target || void 0
}
), i.toLanguageString(
d,
n[d]
))))
}
), f = [
/* @__PURE__ */ e.createElement(v, { onClick: this.onClose, dir: o, key: "cancel" }, i.toLanguageString(g, n[g])),
/* @__PURE__ */ e.createElement(v, { onClick: this.onInsert, themeColor: "primary", dir: o, key: "insert" }, i.toLanguageString(p, n[p]))
], E = /* @__PURE__ */ e.createElement(
C,
{
initialWidth: 450,
initialHeight: 250,
className: "k-editor-window",
title: i.toLanguageString(
c,
n[c]
),
onClose: this.onClose,
style: o === "rtl" ? { textAlign: "right" } : void 0,
modal: !0,
minimizeButton: () => null,
maximizeButton: () => null,
resizable: !1
},
u,
/* @__PURE__ */ e.createElement(w, null, ...f)
);
return m ? m(E, { content: u, actionButtons: f }) : E;
}
};
z(I);
export {
I as InsertLinkDialog
};