UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

59 lines (58 loc) 2.25 kB
/** * DevExtreme (esm/__internal/ui/diagram/ui.diagram.dialog_manager.js) * Version: 25.2.3 * Build date: Fri Dec 12 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import messageLocalization from "../../../common/core/localization/message"; import $ from "../../../core/renderer"; import { getWindow } from "../../../core/utils/window"; import FileUploader from "../../../ui/file_uploader"; import { getDiagram } from "../../ui/diagram/diagram.importer"; const DiagramDialogManager = { getConfigurations() { const { DiagramCommand: DiagramCommand } = getDiagram(); return this.dialogList || (this.dialogList = [{ command: DiagramCommand.InsertShapeImage, title: messageLocalization.format("dxDiagram-dialogInsertShapeImageTitle"), onGetContent: this.getChangeImageDialogContent }, { command: DiagramCommand.EditShapeImage, title: messageLocalization.format("dxDiagram-dialogEditShapeImageTitle"), onGetContent: this.getChangeImageDialogContent }]) }, getChangeImageDialogContent(args) { const $uploader = $("<div>"); args.component._createComponent($uploader, FileUploader, { selectButtonText: messageLocalization.format("dxDiagram-dialogEditShapeImageSelectButton"), accept: "image/*", uploadMode: "useForm", onValueChanged(e) { const window = getWindow(); const reader = new window.FileReader; reader.onload = () => { args.component._commandParameter = e.target.result }; reader.readAsDataURL(e.value[0]) } }); return $uploader }, getDialogParameters(command) { const commandIndex = this.getConfigurations().map((c => c.command)).indexOf(command); if (commandIndex >= 0) { return this.getConfigurations()[commandIndex] } return null } }; export default DiagramDialogManager;