mirror of
https://gitee.com/hoslay/ddei-editor.git
synced 2025-12-07 01:28:28 +08:00
键盘调整位置时,快捷按钮没跟着一起;编辑文本框时,图形快捷键被激活;键盘调整位置时,快捷按钮没跟着一起;
This commit is contained in:
parent
3dc28d1284
commit
8c7b83031a
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ddei-editor",
|
||||
"version": "1.2.41-5",
|
||||
"version": "1.2.42-6",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
"author": "hoslay <3697355039@qq.com>",
|
||||
|
||||
@ -57,37 +57,57 @@ class DDeiKeyActionAllSelect extends DDeiKeyAction {
|
||||
}
|
||||
|
||||
// ============================ 方法 ===============================
|
||||
action(evt: Event, ddInstance: DDei): void {
|
||||
|
||||
|
||||
isActive(element: object): boolean {
|
||||
if (!element) {
|
||||
return true
|
||||
}
|
||||
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
action(evt: Event, ddInstance: DDei): boolean {
|
||||
//修改当前操作控件坐标
|
||||
if (ddInstance && ddInstance.stage) {
|
||||
|
||||
let models = []
|
||||
if (ddInstance.stage.selectedModels?.size > 0) {
|
||||
models = Array.from(ddInstance.stage.selectedModels?.values());
|
||||
}
|
||||
if (models?.length == 1 && models[0].baseModelType == 'DDeiTable' && models[0].curRow != -1 && models[0].curCol != -1) {
|
||||
//选中当前表格所有单元格
|
||||
for (let i = 0; i < models[0].rows.length; i++) {
|
||||
let rowObj = models[0].rows[i];
|
||||
for (let j = 0; j < rowObj.length; j++) {
|
||||
rowObj[j].setState(DDeiEnumControlState.SELECTED)
|
||||
//必须是canvas的子控件
|
||||
if (this.isActive(document.activeElement)) {
|
||||
let models = []
|
||||
if (ddInstance.stage.selectedModels?.size > 0) {
|
||||
models = Array.from(ddInstance.stage.selectedModels?.values());
|
||||
}
|
||||
if (models?.length == 1 && models[0].baseModelType == 'DDeiTable' && models[0].curRow != -1 && models[0].curCol != -1) {
|
||||
//选中当前表格所有单元格
|
||||
for (let i = 0; i < models[0].rows.length; i++) {
|
||||
let rowObj = models[0].rows[i];
|
||||
for (let j = 0; j < rowObj.length; j++) {
|
||||
rowObj[j].setState(DDeiEnumControlState.SELECTED)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//当前激活的图层
|
||||
let layer = ddInstance.stage.layers[ddInstance.stage.layerIndex]
|
||||
//加载事件的配置
|
||||
let rsState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_SELECT_BEFORE", DDeiEnumOperateType.SELECT, { models: Array.from(layer.models.values()) }, ddInstance, evt)
|
||||
if (rsState == 0 || rsState == 1) {
|
||||
ddInstance?.bus?.push(DDeiEnumBusCommandType.ModelChangeSelect, { models: layer.models, value: DDeiEnumControlState.SELECTED }, evt);
|
||||
ddInstance?.bus?.push(DDeiEnumBusCommandType.StageChangeSelectModels, {}, evt);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//当前激活的图层
|
||||
let layer = ddInstance.stage.layers[ddInstance.stage.layerIndex]
|
||||
//加载事件的配置
|
||||
let rsState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_SELECT_BEFORE", DDeiEnumOperateType.SELECT, { models: Array.from(layer.models.values()) }, ddInstance, evt)
|
||||
if (rsState == 0 || rsState == 1) {
|
||||
ddInstance?.bus?.push(DDeiEnumBusCommandType.ModelChangeSelect, { models: layer.models, value: DDeiEnumControlState.SELECTED }, evt);
|
||||
ddInstance?.bus?.push(DDeiEnumBusCommandType.StageChangeSelectModels, {}, evt);
|
||||
}
|
||||
}
|
||||
//渲染图形
|
||||
ddInstance?.bus?.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||
//渲染图形
|
||||
ddInstance?.bus?.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||
|
||||
ddInstance?.bus?.executeAll();
|
||||
ddInstance?.bus?.executeAll();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -56,69 +56,88 @@ class DDeiKeyActionBrushData extends DDeiKeyAction {
|
||||
return DDeiKeyActionBrushData;
|
||||
}
|
||||
// ============================ 方法 ===============================
|
||||
action(evt: Event, ddInstance: DDei): void {
|
||||
|
||||
isActive(element: object): boolean {
|
||||
if (!element) {
|
||||
return true
|
||||
}
|
||||
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
action(evt: Event, ddInstance: DDei): boolean {
|
||||
//记录当前格式信息,修改状态为刷子状态
|
||||
if (ddInstance && ddInstance.stage) {
|
||||
let stage = ddInstance.stage
|
||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||
let models = Array.from(ddInstance.stage.selectedModels?.values());
|
||||
stage.brushData = null
|
||||
if (models?.length == 1) {
|
||||
if (models[0].baseModelType == 'DDeiTable') {
|
||||
let table = models[0]
|
||||
let selectedCells = table.getSelectedCells();
|
||||
let minMaxColRow = table.getMinMaxRowAndCol(selectedCells);
|
||||
stage.brushData = []
|
||||
for (let i = minMaxColRow.minRow; i <= minMaxColRow.maxRow; i++) {
|
||||
let rowObj = table.rows[i];
|
||||
let rowData = []
|
||||
//必须是canvas的子控件
|
||||
if (this.isActive(document.activeElement)) {
|
||||
let stage = ddInstance.stage
|
||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||
let models = Array.from(ddInstance.stage.selectedModels?.values());
|
||||
stage.brushData = null
|
||||
if (models?.length == 1) {
|
||||
if (models[0].baseModelType == 'DDeiTable') {
|
||||
let table = models[0]
|
||||
let selectedCells = table.getSelectedCells();
|
||||
let minMaxColRow = table.getMinMaxRowAndCol(selectedCells);
|
||||
stage.brushData = []
|
||||
for (let i = minMaxColRow.minRow; i <= minMaxColRow.maxRow; i++) {
|
||||
let rowObj = table.rows[i];
|
||||
let rowData = []
|
||||
|
||||
for (let j = minMaxColRow.minCol; j <= minMaxColRow.maxCol; j++) {
|
||||
let cellObj = rowObj[j];
|
||||
rowData.push(cellObj);
|
||||
}
|
||||
stage.brushData.push(rowData);
|
||||
}
|
||||
if (stage.brushData.length > 0) {
|
||||
editor.changeState(DDeiEditorState.DESIGNING)
|
||||
editor.bus.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
|
||||
editor.bus.executeAll();
|
||||
}
|
||||
} else {
|
||||
|
||||
if (editor.state == DDeiEditorState.QUICK_EDITING) {
|
||||
let shadowControl = editor.ddInstance.stage.render.editorShadowControl
|
||||
if (shadowControl?.render.isEditoring) {
|
||||
let editorText = DDeiUtil.getEditorText();
|
||||
//开始光标与结束光标
|
||||
let curSIdx = -1
|
||||
let curEIdx = -1
|
||||
if (editorText) {
|
||||
curSIdx = editorText.selectionStart
|
||||
curEIdx = editorText.selectionEnd
|
||||
for (let j = minMaxColRow.minCol; j <= minMaxColRow.maxCol; j++) {
|
||||
let cellObj = rowObj[j];
|
||||
rowData.push(cellObj);
|
||||
}
|
||||
stage.brushDataText = cloneDeep(shadowControl.getSptAllStyles(curSIdx, curEIdx))
|
||||
stage.brushData.push(rowData);
|
||||
}
|
||||
if (stage.brushData.length > 0) {
|
||||
editor.changeState(DDeiEditorState.DESIGNING)
|
||||
editor.bus.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
|
||||
editor.bus.executeAll();
|
||||
}
|
||||
|
||||
|
||||
delete stage.brushData
|
||||
editor.bus?.push(DDeiEnumBusCommandType.ChangeCursor, { image: 'cursor-brush' })
|
||||
editor.bus?.executeAll();
|
||||
} else {
|
||||
let model = models[0]
|
||||
stage.brushData = [model]
|
||||
delete stage.brushDataText
|
||||
editor.changeState(DDeiEditorState.DESIGNING)
|
||||
editor.bus?.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
|
||||
editor.bus?.push(DDeiEnumBusCommandType.ChangeCursor, { image: 'cursor-brush' })
|
||||
editor.bus?.executeAll();
|
||||
|
||||
if (editor.state == DDeiEditorState.QUICK_EDITING) {
|
||||
let shadowControl = editor.ddInstance.stage.render.editorShadowControl
|
||||
if (shadowControl?.render.isEditoring) {
|
||||
let editorText = DDeiUtil.getEditorText();
|
||||
//开始光标与结束光标
|
||||
let curSIdx = -1
|
||||
let curEIdx = -1
|
||||
if (editorText) {
|
||||
curSIdx = editorText.selectionStart
|
||||
curEIdx = editorText.selectionEnd
|
||||
}
|
||||
stage.brushDataText = cloneDeep(shadowControl.getSptAllStyles(curSIdx, curEIdx))
|
||||
}
|
||||
|
||||
|
||||
delete stage.brushData
|
||||
editor.bus?.push(DDeiEnumBusCommandType.ChangeCursor, { image: 'cursor-brush' })
|
||||
editor.bus?.executeAll();
|
||||
} else {
|
||||
let model = models[0]
|
||||
stage.brushData = [model]
|
||||
delete stage.brushDataText
|
||||
editor.changeState(DDeiEditorState.DESIGNING)
|
||||
editor.bus?.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
|
||||
editor.bus?.push(DDeiEnumBusCommandType.ChangeCursor, { image: 'cursor-brush' })
|
||||
editor.bus?.executeAll();
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import {DDeiEditor} from "ddei-framework";
|
||||
import { DDeiEditor, DDeiEditorUtil } from "ddei-framework";
|
||||
import {DDei} from "ddei-framework";
|
||||
import {DDeiKeyAction} from "ddei-framework";
|
||||
import {DDeiEnumBusCommandType} from "ddei-framework";
|
||||
import {DDeiAbstractShape} from "ddei-framework";
|
||||
import {DDeiEnumControlState} from "ddei-framework";
|
||||
import {DDeiEditorState} from "ddei-framework";
|
||||
import { DDeiEditorState, DDeiEnumOperateType } from "ddei-framework";
|
||||
|
||||
/**
|
||||
* 键行为:移动模型
|
||||
@ -33,6 +33,8 @@ class DDeiKeyActionMoveModels extends DDeiKeyAction {
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
getHotKeys(editor) {
|
||||
return [this];
|
||||
}
|
||||
@ -61,134 +63,153 @@ class DDeiKeyActionMoveModels extends DDeiKeyAction {
|
||||
return DDeiKeyActionMoveModels;
|
||||
}
|
||||
// ============================ 方法 ===============================
|
||||
action(evt: Event, ddInstance: DDei,editor:DDeiEditor): void {
|
||||
|
||||
|
||||
isActive(element: object): boolean {
|
||||
if (!element) {
|
||||
return true
|
||||
}
|
||||
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
action(evt: Event, ddInstance: DDei,editor:DDeiEditor): boolean {
|
||||
//修改当前操作控件坐标
|
||||
if (ddInstance && ddInstance.stage) {
|
||||
let selectedModels = ddInstance.stage.selectedModels;
|
||||
let models = Array.from(selectedModels.values());
|
||||
if (models.length == 1 && models[0].baseModelType == 'DDeiTable' && models[0].curRow != -1 && models[0].curCol != -1) {
|
||||
//必须是canvas的子控件
|
||||
if (this.isActive(document.activeElement)) {
|
||||
let selectedModels = ddInstance.stage.selectedModels;
|
||||
let models = Array.from(selectedModels.values());
|
||||
if (models.length == 1 && models[0].baseModelType == 'DDeiTable' && models[0].curRow != -1 && models[0].curCol != -1) {
|
||||
|
||||
//上
|
||||
if (evt.keyCode == 38) {
|
||||
if (models[0].curRow > 0) {
|
||||
if (models[0].tempDragCell) {
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
||||
//上
|
||||
if (evt.keyCode == 38) {
|
||||
if (models[0].curRow > 0) {
|
||||
if (models[0].tempDragCell) {
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
||||
}
|
||||
models[0].curRow--;
|
||||
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
||||
}
|
||||
models[0].curRow--;
|
||||
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
||||
}
|
||||
}//下
|
||||
else if (evt.keyCode == 40) {
|
||||
if (models[0].curRow < models[0].rows.length - 1) {
|
||||
if (models[0].tempDragCell) {
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
||||
}//下
|
||||
else if (evt.keyCode == 40) {
|
||||
if (models[0].curRow < models[0].rows.length - 1) {
|
||||
if (models[0].tempDragCell) {
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
||||
}
|
||||
models[0].curRow++;
|
||||
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
||||
}
|
||||
models[0].curRow++;
|
||||
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
||||
}
|
||||
}//左
|
||||
else if (evt.keyCode == 37) {
|
||||
if (models[0].curCol > 0) {
|
||||
if (models[0].tempDragCell) {
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
||||
}//左
|
||||
else if (evt.keyCode == 37) {
|
||||
if (models[0].curCol > 0) {
|
||||
if (models[0].tempDragCell) {
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
||||
}
|
||||
models[0].curCol--;
|
||||
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
||||
}
|
||||
models[0].curCol--;
|
||||
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
||||
}
|
||||
}//右
|
||||
else if (evt.keyCode == 39) {
|
||||
if (models[0].curCol < models[0].cols.length - 1) {
|
||||
if (models[0].tempDragCell) {
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
||||
}//右
|
||||
else if (evt.keyCode == 39) {
|
||||
if (models[0].curCol < models[0].cols.length - 1) {
|
||||
if (models[0].tempDragCell) {
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
||||
}
|
||||
models[0].curCol++;
|
||||
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
||||
}
|
||||
models[0].curCol++;
|
||||
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
||||
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
||||
}
|
||||
}
|
||||
} else if (editor.GLOBAL_KEYBOARD_ALIGN_ENABLE){
|
||||
let moveSize = 1;
|
||||
} else if (editor.GLOBAL_KEYBOARD_ALIGN_ENABLE){
|
||||
let moveSize = 1;
|
||||
|
||||
let isShift = DDei.KEY_DOWN_STATE.get("shift");
|
||||
if (!isShift) {
|
||||
|
||||
//辅助对齐线宽度
|
||||
moveSize = 10;
|
||||
}
|
||||
let moveOriginLines = []
|
||||
models.forEach(md => {
|
||||
if (md.baseModelType == 'DDeiLine') {
|
||||
moveOriginLines.push(md.id)
|
||||
}
|
||||
});
|
||||
let outRect = DDeiAbstractShape.getOutRectByPV(models);
|
||||
let deltaX, deltaY
|
||||
//上
|
||||
if (evt.keyCode == 38) {
|
||||
let mod = 0;
|
||||
//如果开启辅助对齐线,则跳回到对齐线上
|
||||
let isShift = DDei.KEY_DOWN_STATE.get("shift");
|
||||
if (!isShift) {
|
||||
if (outRect.y % moveSize > 0) {
|
||||
mod = moveSize - (outRect.y % moveSize);
|
||||
|
||||
//辅助对齐线宽度
|
||||
moveSize = 10;
|
||||
}
|
||||
let moveOriginLines = []
|
||||
models.forEach(md => {
|
||||
if (md.baseModelType == 'DDeiLine') {
|
||||
moveOriginLines.push(md.id)
|
||||
}
|
||||
}
|
||||
deltaY = - moveSize + mod
|
||||
}
|
||||
//下
|
||||
else if (evt.keyCode == 40) {
|
||||
let mod = 0;
|
||||
if (!isShift) {
|
||||
mod = outRect.y % moveSize;
|
||||
}
|
||||
deltaY = moveSize - mod
|
||||
}
|
||||
//左
|
||||
else if (evt.keyCode == 37) {
|
||||
let mod = 0;
|
||||
//如果开启辅助对齐线,则跳回到对齐线上
|
||||
if (!isShift) {
|
||||
if (outRect.x % moveSize > 0) {
|
||||
mod = moveSize - (outRect.x % moveSize);
|
||||
});
|
||||
let outRect = DDeiAbstractShape.getOutRectByPV(models);
|
||||
let deltaX, deltaY
|
||||
//上
|
||||
if (evt.keyCode == 38) {
|
||||
let mod = 0;
|
||||
//如果开启辅助对齐线,则跳回到对齐线上
|
||||
if (!isShift) {
|
||||
if (outRect.y % moveSize > 0) {
|
||||
mod = moveSize - (outRect.y% moveSize);
|
||||
}
|
||||
}
|
||||
deltaY = - moveSize + mod
|
||||
}
|
||||
deltaX = - moveSize + mod
|
||||
}
|
||||
//右
|
||||
else if (evt.keyCode == 39) {
|
||||
let mod = 0;
|
||||
if (!isShift) {
|
||||
mod = outRect.x % moveSize;
|
||||
//下
|
||||
else if (evt.keyCode == 40) {
|
||||
let mod = 0;
|
||||
if (!isShift) {
|
||||
mod = Math.round(outRect.y) % moveSize;
|
||||
}
|
||||
deltaY = moveSize - mod
|
||||
}
|
||||
deltaX = moveSize - mod
|
||||
//左
|
||||
else if (evt.keyCode == 37) {
|
||||
let mod = 0;
|
||||
//如果开启辅助对齐线,则跳回到对齐线上
|
||||
if (!isShift) {
|
||||
if (outRect.x % moveSize > 0) {
|
||||
mod = moveSize - (outRect.x % moveSize);
|
||||
}
|
||||
}
|
||||
deltaX = - moveSize + mod
|
||||
}
|
||||
//右
|
||||
else if (evt.keyCode == 39) {
|
||||
let mod = 0;
|
||||
if (!isShift) {
|
||||
mod = Math.round(outRect.x) % moveSize;
|
||||
}
|
||||
deltaX = moveSize - mod
|
||||
}
|
||||
let stage = ddInstance.stage
|
||||
|
||||
DDeiAbstractShape.moveModels(models, deltaX, deltaY, moveOriginLines);
|
||||
|
||||
stage.layers[stage.layerIndex].opPoints = []
|
||||
if (stage.layers[stage.layerIndex].opLine?.render) {
|
||||
stage.layers[stage.layerIndex].opLine.render.enableRefreshShape()
|
||||
}
|
||||
delete stage.layers[stage.layerIndex].opLine;
|
||||
stage.render.refreshJumpLine = false
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.UpdateSelectorBounds);
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.NodifyChange);
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.AddHistroy, null, evt);
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.ClearTemplateVars);
|
||||
//渲染图形
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||
|
||||
ddInstance.bus.executeAll();
|
||||
DDeiEditorUtil.invokeCallbackFunc("EVENT_CONTROL_DRAG_AFTER", DDeiEnumOperateType.DRAG, { models: models }, ddInstance, evt)
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
let stage = ddInstance.stage
|
||||
|
||||
DDeiAbstractShape.moveModels(models, deltaX, deltaY, moveOriginLines);
|
||||
|
||||
stage.layers[stage.layerIndex].opPoints = []
|
||||
if (stage.layers[stage.layerIndex].opLine?.render) {
|
||||
stage.layers[stage.layerIndex].opLine.render.enableRefreshShape()
|
||||
}
|
||||
delete stage.layers[stage.layerIndex].opLine;
|
||||
stage.render.refreshJumpLine = false
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.UpdateSelectorBounds);
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.NodifyChange);
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.AddHistroy, null, evt);
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.ClearTemplateVars);
|
||||
//渲染图形
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||
|
||||
ddInstance.bus.executeAll();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -60,42 +60,62 @@ class DDeiKeyActionPushModels extends DDeiKeyAction {
|
||||
return DDeiKeyActionPushModels;
|
||||
}
|
||||
// ============================ 方法 ===============================
|
||||
action(evt: Event, ddInstance: DDei): void {
|
||||
|
||||
isActive(element: object): boolean {
|
||||
if (!element) {
|
||||
return true
|
||||
}
|
||||
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
action(evt: Event, ddInstance: DDei): boolean {
|
||||
//修改当前操作控件坐标
|
||||
if (ddInstance && ddInstance.stage) {
|
||||
let stageRender = ddInstance.stage.render;
|
||||
let optContainer = stageRender.currentOperateContainer;
|
||||
if (optContainer) {
|
||||
let isCtrl = DDei.KEY_DOWN_STATE.get("ctrl");
|
||||
let isShift = DDei.KEY_DOWN_STATE.get("shift");
|
||||
//同时按下ctrl和shift
|
||||
if (isCtrl && isShift) {
|
||||
//上
|
||||
if (evt.keyCode == 38) {
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "top" }, evt);
|
||||
//必须是canvas的子控件
|
||||
if (this.isActive(document.activeElement)) {
|
||||
let stageRender = ddInstance.stage.render;
|
||||
let optContainer = stageRender.currentOperateContainer;
|
||||
if (optContainer) {
|
||||
let isCtrl = DDei.KEY_DOWN_STATE.get("ctrl");
|
||||
let isShift = DDei.KEY_DOWN_STATE.get("shift");
|
||||
//同时按下ctrl和shift
|
||||
if (isCtrl && isShift) {
|
||||
//上
|
||||
if (evt.keyCode == 38) {
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "top" }, evt);
|
||||
}
|
||||
//下
|
||||
else if (evt.keyCode == 40) {
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "bottom" }, evt);
|
||||
}
|
||||
}
|
||||
//下
|
||||
else if (evt.keyCode == 40) {
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "bottom" }, evt);
|
||||
//只按下了ctrl
|
||||
else if (isCtrl) {
|
||||
//上
|
||||
if (evt.keyCode == 38) {
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "up" }, evt);
|
||||
}
|
||||
//下
|
||||
else if (evt.keyCode == 40) {
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "down" }, evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
//只按下了ctrl
|
||||
else if (isCtrl) {
|
||||
//上
|
||||
if (evt.keyCode == 38) {
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "up" }, evt);
|
||||
}
|
||||
//下
|
||||
else if (evt.keyCode == 40) {
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "down" }, evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
//渲染图形
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||
//渲染图形
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||
|
||||
ddInstance.bus.executeAll();
|
||||
ddInstance.bus.executeAll();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -61,75 +61,97 @@ class DDeiKeyActionReRevoke extends DDeiKeyAction {
|
||||
return DDeiKeyActionReRevoke;
|
||||
}
|
||||
// ============================ 方法 ===============================
|
||||
action(evt: Event, ddInstance: DDei): void {
|
||||
|
||||
isActive(element: object): boolean {
|
||||
if (!element) {
|
||||
return true
|
||||
}
|
||||
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
action(evt: Event, ddInstance: DDei): boolean {
|
||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||
let histype = DDeiEditorUtil.getConfigValue("HISTROY_LEVEL", editor);
|
||||
if (histype == 'file') {
|
||||
if (editor?.files.length > 0 && (editor.currentFileIndex == 0 || editor.currentFileIndex)) {
|
||||
let file = editor?.files[editor.currentFileIndex]
|
||||
//从历史恢复文件
|
||||
if (file?.active == DDeiActiveType.ACTIVE) {
|
||||
let hisData = file.reRevokeHistroyData();
|
||||
if (hisData?.data) {
|
||||
let jsonData = JSON.parse(hisData?.data)
|
||||
if (jsonData) {
|
||||
let ddInstance = editor?.ddInstance;
|
||||
ddInstance.stage.destroyRender()
|
||||
let hisFile = DDeiFile.loadFromJSON(jsonData, {
|
||||
currentDdInstance: ddInstance,
|
||||
});
|
||||
if (hisData.isNew == true) {
|
||||
file.state = DDeiFileState.NONE;
|
||||
} else {
|
||||
file.state = DDeiFileState.MODIFY
|
||||
}
|
||||
file.name = hisFile?.name;
|
||||
file.desc = hisFile?.desc;
|
||||
file.lastUpdateTime = hisFile?.lastUpdateTime;
|
||||
file.sheets = hisFile?.sheets;
|
||||
if (file && file.sheets && ddInstance) {
|
||||
file.changeSheet(hisFile.currentSheetIndex);
|
||||
let stage = file.sheets[file.currentSheetIndex].stage;
|
||||
stage.ddInstance = ddInstance;
|
||||
//刷新页面
|
||||
ddInstance.stage = stage;
|
||||
//加载场景渲染器
|
||||
stage.initRender();
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape);
|
||||
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
||||
ddInstance.bus.executeAll();
|
||||
//必须是canvas的子控件
|
||||
if (this.isActive(document.activeElement)) {
|
||||
let histype = DDeiEditorUtil.getConfigValue("HISTROY_LEVEL", editor);
|
||||
if (histype == 'file') {
|
||||
if (editor?.files.length > 0 && (editor.currentFileIndex == 0 || editor.currentFileIndex)) {
|
||||
let file = editor?.files[editor.currentFileIndex]
|
||||
//从历史恢复文件
|
||||
if (file?.active == DDeiActiveType.ACTIVE) {
|
||||
let hisData = file.reRevokeHistroyData();
|
||||
if (hisData?.data) {
|
||||
let jsonData = JSON.parse(hisData?.data)
|
||||
if (jsonData) {
|
||||
let ddInstance = editor?.ddInstance;
|
||||
ddInstance.stage.destroyRender()
|
||||
let hisFile = DDeiFile.loadFromJSON(jsonData, {
|
||||
currentDdInstance: ddInstance,
|
||||
});
|
||||
if (hisData.isNew == true) {
|
||||
file.state = DDeiFileState.NONE;
|
||||
} else {
|
||||
file.state = DDeiFileState.MODIFY
|
||||
}
|
||||
file.name = hisFile?.name;
|
||||
file.desc = hisFile?.desc;
|
||||
file.lastUpdateTime = hisFile?.lastUpdateTime;
|
||||
file.sheets = hisFile?.sheets;
|
||||
if (file && file.sheets && ddInstance) {
|
||||
file.changeSheet(hisFile.currentSheetIndex);
|
||||
let stage = file.sheets[file.currentSheetIndex].stage;
|
||||
stage.ddInstance = ddInstance;
|
||||
//刷新页面
|
||||
ddInstance.stage = stage;
|
||||
//加载场景渲染器
|
||||
stage.initRender();
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape);
|
||||
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
||||
ddInstance.bus.executeAll();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (histype == 'stage') {
|
||||
//修改当前操作控件坐标
|
||||
if (ddInstance && ddInstance.stage) {
|
||||
let hisData = ddInstance.stage.reRevokeHistroyData();
|
||||
if (hisData?.data) {
|
||||
let jsonData = JSON.parse(hisData?.data)
|
||||
if (jsonData) {
|
||||
ddInstance.stage.destroyRender()
|
||||
let tempData = { "currentDdInstance": ddInstance, "currentStage": ddInstance.stage }
|
||||
tempData[ddInstance.stage.id] = ddInstance.stage
|
||||
let layers = [];
|
||||
jsonData.layers.forEach(layer => {
|
||||
let model = DDeiLayer.loadFromJSON(layer, tempData);
|
||||
layers.push(model);
|
||||
})
|
||||
ddInstance.stage.idIdx = jsonData.idIdx;
|
||||
ddInstance.stage.layers = layers
|
||||
ddInstance.stage.initRender();
|
||||
//渲染图形
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
||||
ddInstance.bus.executeAll();
|
||||
}
|
||||
}
|
||||
} else if (histype == 'stage') {
|
||||
//修改当前操作控件坐标
|
||||
if (ddInstance && ddInstance.stage) {
|
||||
let hisData = ddInstance.stage.reRevokeHistroyData();
|
||||
if (hisData?.data) {
|
||||
let jsonData = JSON.parse(hisData?.data)
|
||||
if (jsonData) {
|
||||
ddInstance.stage.destroyRender()
|
||||
let tempData = { "currentDdInstance": ddInstance, "currentStage": ddInstance.stage }
|
||||
tempData[ddInstance.stage.id] = ddInstance.stage
|
||||
let layers = [];
|
||||
jsonData.layers.forEach(layer => {
|
||||
let model = DDeiLayer.loadFromJSON(layer, tempData);
|
||||
layers.push(model);
|
||||
})
|
||||
ddInstance.stage.idIdx = jsonData.idIdx;
|
||||
ddInstance.stage.layers = layers
|
||||
ddInstance.stage.initRender();
|
||||
//渲染图形
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
||||
ddInstance.bus.executeAll();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -61,80 +61,100 @@ class DDeiKeyActionRevoke extends DDeiKeyAction {
|
||||
return DDeiKeyActionRevoke;
|
||||
}
|
||||
// ============================ 方法 ===============================
|
||||
action(evt: Event, ddInstance: DDei): void {
|
||||
|
||||
isActive(element: object): boolean {
|
||||
if (!element) {
|
||||
return true
|
||||
}
|
||||
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
action(evt: Event, ddInstance: DDei): boolean {
|
||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||
let histype = DDeiEditorUtil.getConfigValue("HISTROY_LEVEL", editor);
|
||||
if (histype == 'file') {
|
||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||
if (editor?.files.length > 0 && (editor.currentFileIndex == 0 || editor.currentFileIndex)) {
|
||||
let file = editor?.files[editor.currentFileIndex]
|
||||
//从历史恢复文件
|
||||
if (file?.active == DDeiActiveType.ACTIVE) {
|
||||
let hisData = file.revokeHistroyData();
|
||||
if (hisData?.data) {
|
||||
let jsonData = JSON.parse(hisData?.data)
|
||||
if (jsonData) {
|
||||
let ddInstance = editor?.ddInstance;
|
||||
ddInstance.stage.destroyRender()
|
||||
let hisFile = DDeiFile.loadFromJSON(jsonData, {
|
||||
currentDdInstance: ddInstance,
|
||||
});
|
||||
//必须是canvas的子控件
|
||||
if (this.isActive(document.activeElement)) {
|
||||
let histype = DDeiEditorUtil.getConfigValue("HISTROY_LEVEL", editor);
|
||||
if (histype == 'file') {
|
||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||
if (editor?.files.length > 0 && (editor.currentFileIndex == 0 || editor.currentFileIndex)) {
|
||||
let file = editor?.files[editor.currentFileIndex]
|
||||
//从历史恢复文件
|
||||
if (file?.active == DDeiActiveType.ACTIVE) {
|
||||
let hisData = file.revokeHistroyData();
|
||||
if (hisData?.data) {
|
||||
let jsonData = JSON.parse(hisData?.data)
|
||||
if (jsonData) {
|
||||
let ddInstance = editor?.ddInstance;
|
||||
ddInstance.stage.destroyRender()
|
||||
let hisFile = DDeiFile.loadFromJSON(jsonData, {
|
||||
currentDdInstance: ddInstance,
|
||||
});
|
||||
|
||||
if (hisData.isNew == true) {
|
||||
file.state = DDeiFileState.NONE;
|
||||
} else {
|
||||
file.state = DDeiFileState.MODIFY
|
||||
}
|
||||
file.name = hisFile?.name;
|
||||
file.desc = hisFile?.desc;
|
||||
file.lastUpdateTime = hisFile?.lastUpdateTime;
|
||||
file.sheets = hisFile?.sheets;
|
||||
if (file && file.sheets && ddInstance) {
|
||||
file.changeSheet(hisFile.currentSheetIndex);
|
||||
let stage = file.sheets[file.currentSheetIndex].stage;
|
||||
stage.ddInstance = ddInstance;
|
||||
//刷新页面
|
||||
ddInstance.stage = stage;
|
||||
//加载场景渲染器
|
||||
stage.initRender();
|
||||
if (hisData.isNew == true) {
|
||||
file.state = DDeiFileState.NONE;
|
||||
} else {
|
||||
file.state = DDeiFileState.MODIFY
|
||||
}
|
||||
file.name = hisFile?.name;
|
||||
file.desc = hisFile?.desc;
|
||||
file.lastUpdateTime = hisFile?.lastUpdateTime;
|
||||
file.sheets = hisFile?.sheets;
|
||||
if (file && file.sheets && ddInstance) {
|
||||
file.changeSheet(hisFile.currentSheetIndex);
|
||||
let stage = file.sheets[file.currentSheetIndex].stage;
|
||||
stage.ddInstance = ddInstance;
|
||||
//刷新页面
|
||||
ddInstance.stage = stage;
|
||||
//加载场景渲染器
|
||||
stage.initRender();
|
||||
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape);
|
||||
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
||||
ddInstance.bus.executeAll();
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape);
|
||||
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
||||
ddInstance.bus.executeAll();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (histype == 'stage') {
|
||||
//修改当前操作控件坐标
|
||||
if (ddInstance && ddInstance.stage) {
|
||||
} else if (histype == 'stage') {
|
||||
//修改当前操作控件坐标
|
||||
if (ddInstance && ddInstance.stage) {
|
||||
|
||||
let hisData = ddInstance.stage.revokeHistroyData();
|
||||
if (hisData?.data) {
|
||||
let jsonData = JSON.parse(hisData?.data)
|
||||
if (jsonData) {
|
||||
ddInstance.stage.destroyRender()
|
||||
let tempData = { "currentDdInstance": ddInstance, "currentStage": ddInstance.stage }
|
||||
tempData[ddInstance.stage.id] = ddInstance.stage
|
||||
let layers = [];
|
||||
jsonData.layers.forEach(layer => {
|
||||
let model = DDeiLayer.loadFromJSON(layer, tempData);
|
||||
layers.push(model);
|
||||
})
|
||||
ddInstance.stage.idIdx = jsonData.idIdx;
|
||||
ddInstance.stage.layers = layers
|
||||
ddInstance.stage.initRender();
|
||||
//渲染图形
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
||||
ddInstance.bus.executeAll();
|
||||
let hisData = ddInstance.stage.revokeHistroyData();
|
||||
if (hisData?.data) {
|
||||
let jsonData = JSON.parse(hisData?.data)
|
||||
if (jsonData) {
|
||||
ddInstance.stage.destroyRender()
|
||||
let tempData = { "currentDdInstance": ddInstance, "currentStage": ddInstance.stage }
|
||||
tempData[ddInstance.stage.id] = ddInstance.stage
|
||||
let layers = [];
|
||||
jsonData.layers.forEach(layer => {
|
||||
let model = DDeiLayer.loadFromJSON(layer, tempData);
|
||||
layers.push(model);
|
||||
})
|
||||
ddInstance.stage.idIdx = jsonData.idIdx;
|
||||
ddInstance.stage.layers = layers
|
||||
ddInstance.stage.initRender();
|
||||
//渲染图形
|
||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
||||
ddInstance.bus.executeAll();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -60,209 +60,231 @@ class DDeiKeyActionStartQuickEdit extends DDeiKeyAction {
|
||||
return DDeiKeyActionStartQuickEdit;
|
||||
}
|
||||
// ============================ 方法 ===============================
|
||||
action(evt: Event, ddInstance: DDei): void {
|
||||
|
||||
isActive(element: object): boolean {
|
||||
if (!element) {
|
||||
return true
|
||||
}
|
||||
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
action(evt: Event, ddInstance: DDei): boolean {
|
||||
//获取当前编辑控件
|
||||
if (ddInstance.stage?.selectedModels?.size == 1) {
|
||||
let model = Array.from(ddInstance.stage?.selectedModels.values())[0]
|
||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||
if(editor.state == DDeiEditorState.DESIGNING){
|
||||
let rsState1 = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_VIEW", DDeiEnumOperateType.VIEW, { models: [model] }, ddInstance, null)
|
||||
if (rsState1 == 0 || rsState1 == 1) {
|
||||
//修改当前操作控件坐标
|
||||
if (ddInstance && ddInstance.stage) {
|
||||
//必须是canvas的子控件
|
||||
if (this.isActive(document.activeElement)) {
|
||||
if (ddInstance.stage?.selectedModels?.size == 1) {
|
||||
let model = Array.from(ddInstance.stage?.selectedModels.values())[0]
|
||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||
if(editor.state == DDeiEditorState.DESIGNING){
|
||||
let rsState1 = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_VIEW", DDeiEnumOperateType.VIEW, { models: [model] }, ddInstance, null)
|
||||
if (rsState1 == 0 || rsState1 == 1) {
|
||||
|
||||
let editState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_EDIT_BEFORE", DDeiEnumOperateType.EDIT, { models: [model] }, ddInstance, null)
|
||||
if (editState == 0 || editState== 1){
|
||||
let stage = ddInstance.stage;
|
||||
let stageRatio = stage.getStageRatio()
|
||||
if (model?.render) {
|
||||
let ex = -1;
|
||||
let ey = -1;
|
||||
if (evt.offsetX || evt.offsetY) {
|
||||
ex = evt.offsetX
|
||||
ey = evt.offsetY
|
||||
ex /= window.remRatio
|
||||
ey /= window.remRatio
|
||||
ex -= stage.wpv.x;
|
||||
ey -= stage.wpv.y;
|
||||
ex = ex / stageRatio
|
||||
ey = ey / stageRatio
|
||||
let editState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_EDIT_BEFORE", DDeiEnumOperateType.EDIT, { models: [model] }, ddInstance, null)
|
||||
if (editState == 0 || editState== 1){
|
||||
let stage = ddInstance.stage;
|
||||
let stageRatio = stage.getStageRatio()
|
||||
if (model?.render) {
|
||||
let ex = -1;
|
||||
let ey = -1;
|
||||
if (evt.offsetX || evt.offsetY) {
|
||||
ex = evt.offsetX
|
||||
ey = evt.offsetY
|
||||
ex /= window.remRatio
|
||||
ey /= window.remRatio
|
||||
ex -= stage.wpv.x;
|
||||
ey -= stage.wpv.y;
|
||||
ex = ex / stageRatio
|
||||
ey = ey / stageRatio
|
||||
|
||||
}
|
||||
if (model.baseModelType == 'DDeiTable') {
|
||||
let selectCells = model.getSelectedCells();
|
||||
if (selectCells?.length == 1) {
|
||||
model = selectCells[0];
|
||||
editor.quickEditorModel = model;
|
||||
} else {
|
||||
editor.quickEditorModel = null;
|
||||
return;
|
||||
}
|
||||
} else if (model.baseModelType == 'DDeiLine') {
|
||||
//计算事件发生在线的哪个位置,键盘为中间,鼠标则需要判断位置
|
||||
let type = 3;
|
||||
let linePoint = null;
|
||||
//鼠标事件
|
||||
if (evt.offsetX || evt.offsetY) {
|
||||
let cdist = DDeiUtil.getPointDistance(model.pvs[0].x, model.pvs[1].y, model.pvs[model.pvs.length - 1].x, model.pvs[model.pvs.length - 1].y);
|
||||
let sdist = DDeiUtil.getPointDistance(ex, ey, model.pvs[0].x, model.pvs[0].y);
|
||||
let edist = DDeiUtil.getPointDistance(ex, ey, model.pvs[model.pvs.length - 1].x, model.pvs[model.pvs.length - 1].y);
|
||||
//开始
|
||||
if (sdist < cdist / 5) {
|
||||
type = 1;
|
||||
}
|
||||
//结束
|
||||
else if (edist < cdist / 5) {
|
||||
type = 2;
|
||||
}
|
||||
}
|
||||
if (type == 1) {
|
||||
linePoint = model.startPoint;
|
||||
}
|
||||
else if (type == 2) {
|
||||
linePoint = model.endPoint;
|
||||
}
|
||||
else if (type == 3) {
|
||||
//奇数,取正中间
|
||||
let pi = Math.floor(model.pvs.length / 2)
|
||||
if (model.pvs.length % 3 == 0) {
|
||||
linePoint = model.pvs[pi];
|
||||
}
|
||||
//偶数,取两边的中间点
|
||||
else {
|
||||
linePoint = {
|
||||
x: (model.pvs[pi - 1].x + model.pvs[pi].x) / 2,
|
||||
y: (model.pvs[pi - 1].y + model.pvs[pi].y) / 2
|
||||
if (model.baseModelType == 'DDeiTable') {
|
||||
let selectCells = model.getSelectedCells();
|
||||
if (selectCells?.length == 1) {
|
||||
model = selectCells[0];
|
||||
editor.quickEditorModel = model;
|
||||
} else {
|
||||
editor.quickEditorModel = null;
|
||||
return;
|
||||
}
|
||||
} else if (model.baseModelType == 'DDeiLine') {
|
||||
//计算事件发生在线的哪个位置,键盘为中间,鼠标则需要判断位置
|
||||
let type = 3;
|
||||
let linePoint = null;
|
||||
//鼠标事件
|
||||
if (evt.offsetX || evt.offsetY) {
|
||||
let cdist = DDeiUtil.getPointDistance(model.pvs[0].x, model.pvs[1].y, model.pvs[model.pvs.length - 1].x, model.pvs[model.pvs.length - 1].y);
|
||||
let sdist = DDeiUtil.getPointDistance(ex, ey, model.pvs[0].x, model.pvs[0].y);
|
||||
let edist = DDeiUtil.getPointDistance(ex, ey, model.pvs[model.pvs.length - 1].x, model.pvs[model.pvs.length - 1].y);
|
||||
//开始
|
||||
if (sdist < cdist / 5) {
|
||||
type = 1;
|
||||
}
|
||||
//结束
|
||||
else if (edist < cdist / 5) {
|
||||
type = 2;
|
||||
}
|
||||
}
|
||||
if (type == 1) {
|
||||
linePoint = model.startPoint;
|
||||
}
|
||||
else if (type == 2) {
|
||||
linePoint = model.endPoint;
|
||||
}
|
||||
else if (type == 3) {
|
||||
//奇数,取正中间
|
||||
let pi = Math.floor(model.pvs.length / 2)
|
||||
if (model.pvs.length % 3 == 0) {
|
||||
linePoint = model.pvs[pi];
|
||||
}
|
||||
//偶数,取两边的中间点
|
||||
else {
|
||||
linePoint = {
|
||||
x: (model.pvs[pi - 1].x + model.pvs[pi].x) / 2,
|
||||
y: (model.pvs[pi - 1].y + model.pvs[pi].y) / 2
|
||||
}
|
||||
}
|
||||
}
|
||||
let realModel = null;
|
||||
|
||||
model.linkModels.forEach(lm => {
|
||||
if (lm.type == type) {
|
||||
realModel = lm.dm;
|
||||
}
|
||||
});
|
||||
|
||||
//如果控件不存在,则创建控件并创建链接
|
||||
if (!realModel) {
|
||||
|
||||
//根据control的定义,初始化临时控件,并推送至上层Editor
|
||||
let dataJson = {
|
||||
|
||||
modelCode: "100200",
|
||||
|
||||
};
|
||||
let controlDefine = DDeiUtil.getControlDefine(dataJson)
|
||||
for (let i in controlDefine?.define) {
|
||||
dataJson[i] = controlDefine.define[i];
|
||||
}
|
||||
dataJson["id"] = "lsm_" + (stage.idIdx++)
|
||||
dataJson["width"] = 80
|
||||
dataJson["height"] = 25
|
||||
dataJson["font"] = { size: 12 }
|
||||
realModel = ddInstance.controlModelClasses["DDeiPolygon"].initByJSON(
|
||||
dataJson,
|
||||
{ currentStage: stage, currentDdInstance: ddInstance, currentContainer: model.pModel }
|
||||
);
|
||||
let move1Matrix = new Matrix3(
|
||||
1, 0, linePoint.x,
|
||||
0, 1, linePoint.y,
|
||||
0, 0, 1);
|
||||
realModel.transVectors(move1Matrix)
|
||||
model.layer.addModel(realModel);
|
||||
|
||||
realModel.initRender()
|
||||
let lineLink = new DDeiLineLink({
|
||||
line: model,
|
||||
type: type,
|
||||
dm: realModel,
|
||||
dx: 0,
|
||||
dy: 0
|
||||
})
|
||||
model.linkModels.set(realModel.id, lineLink);
|
||||
}
|
||||
model = realModel;
|
||||
editor.quickEditorModel = model;
|
||||
}
|
||||
|
||||
//获取控件所占区域
|
||||
//判断控件是否有composes,如果被composes拦截了,则启用componses的编辑
|
||||
model = DDeiAbstractShape.findBottomComponseByArea(model, ex, ey);
|
||||
|
||||
let fillArea = model.textArea
|
||||
|
||||
if (fillArea?.length > 0) {
|
||||
editor.quickEditorModel = model;
|
||||
let canvasPos = DDeiUtil.getDomAbsPosition(ddInstance.render.canvas);
|
||||
//创建大文本框
|
||||
let inputEle = DDeiUtil.getEditorText();
|
||||
let rotate = model.rotate
|
||||
let stageRatio = ddInstance.stage.getStageRatio();
|
||||
let pos = new Vector3(model.pvs[0].x, model.pvs[0].y, 1)
|
||||
if (rotate != 0) {
|
||||
let pvc = new Vector3(model.cpv.x, model.cpv.y, 1);
|
||||
let angle = (rotate * DDeiConfig.ROTATE_UNIT).toFixed(4);
|
||||
//计算input的正确打开位置,由节点0
|
||||
let move1Matrix = new Matrix3(
|
||||
1, 0, -pvc.x,
|
||||
0, 1, -pvc.y,
|
||||
0, 0, 1);
|
||||
let rotateMatrix = new Matrix3(
|
||||
Math.cos(angle), Math.sin(angle), 0,
|
||||
-Math.sin(angle), Math.cos(angle), 0,
|
||||
0, 0, 1);
|
||||
let move2Matrix = new Matrix3(
|
||||
1, 0, pvc.x,
|
||||
0, 1, pvc.y,
|
||||
0, 0, 1);
|
||||
let m1 = new Matrix3().premultiply(move1Matrix).premultiply(rotateMatrix).premultiply(move2Matrix);
|
||||
pos.applyMatrix3(m1)
|
||||
}
|
||||
|
||||
inputEle.value = model.text ? model.text : ''
|
||||
inputEle.style.fontSize = (model.render.getCachedValue("font.size") * stageRatio) + "px"
|
||||
inputEle.style.color = DDeiUtil.getColor(model.render.getCachedValue("font.color"))
|
||||
inputEle.style.width = (fillArea.width) * stageRatio + "px";
|
||||
inputEle.style.height = (fillArea.height) * stageRatio + "px";
|
||||
|
||||
|
||||
inputEle.style.left = canvasPos.left + pos.x + ddInstance.stage.wpv.x + 1 + "px";
|
||||
inputEle.style.top = canvasPos.top + pos.y + ddInstance.stage.wpv.y + 10 + "px";
|
||||
// inputEle.style.transform = "rotate(" + rotate + "deg)";
|
||||
// inputEle.style.backgroundColor = "grey"
|
||||
inputEle.style.display = "block";
|
||||
|
||||
let textAreaRect = DDeiAbstractShape.pvsToOutRect(model.textArea);
|
||||
inputEle.style.width = textAreaRect.width + "px"
|
||||
inputEle.style.height = textAreaRect.height + "px"
|
||||
//创建编辑影子元素
|
||||
ddInstance.stage.render.editorShadowControl = DDeiUtil.getShadowControl(model);
|
||||
//清空当前opPoints
|
||||
model.layer.opPoints = [];
|
||||
if (model.layer.opLine?.render) {
|
||||
model.layer.opLine.render.enableRefreshShape()
|
||||
}
|
||||
delete model.layer.opLine;
|
||||
ddInstance.stage.render.editorShadowControl.render.isEditoring = true
|
||||
inputEle.focus()
|
||||
|
||||
inputEle.selectionStart = 0 // 选中开始位置
|
||||
inputEle.selectionEnd = inputEle.value.length // 获取输入框里的长度。
|
||||
//修改编辑器状态为快捷编辑中
|
||||
editor.changeState(DDeiEditorState.QUICK_EDITING);
|
||||
delete ddInstance.stage.brushData
|
||||
delete ddInstance.stage.brushDataText
|
||||
ddInstance.stage.render.operateState = DDeiEnumOperateState.QUICK_EDITING
|
||||
//发出通知,选中的焦点发生变化
|
||||
editor.bus.push(DDeiEnumBusCommandType.StageChangeSelectModels);
|
||||
editor.bus.push(DDeiEnumBusCommandType.TextEditorChangeSelectPos);
|
||||
editor.bus.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
|
||||
editor.bus.executeAll();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
let realModel = null;
|
||||
|
||||
model.linkModels.forEach(lm => {
|
||||
if (lm.type == type) {
|
||||
realModel = lm.dm;
|
||||
}
|
||||
});
|
||||
|
||||
//如果控件不存在,则创建控件并创建链接
|
||||
if (!realModel) {
|
||||
|
||||
//根据control的定义,初始化临时控件,并推送至上层Editor
|
||||
let dataJson = {
|
||||
|
||||
modelCode: "100200",
|
||||
|
||||
};
|
||||
let controlDefine = DDeiUtil.getControlDefine(dataJson)
|
||||
for (let i in controlDefine?.define) {
|
||||
dataJson[i] = controlDefine.define[i];
|
||||
}
|
||||
dataJson["id"] = "lsm_" + (stage.idIdx++)
|
||||
dataJson["width"] = 80
|
||||
dataJson["height"] = 25
|
||||
dataJson["font"] = { size: 12 }
|
||||
realModel = ddInstance.controlModelClasses["DDeiPolygon"].initByJSON(
|
||||
dataJson,
|
||||
{ currentStage: stage, currentDdInstance: ddInstance, currentContainer: model.pModel }
|
||||
);
|
||||
let move1Matrix = new Matrix3(
|
||||
1, 0, linePoint.x,
|
||||
0, 1, linePoint.y,
|
||||
0, 0, 1);
|
||||
realModel.transVectors(move1Matrix)
|
||||
model.layer.addModel(realModel);
|
||||
|
||||
realModel.initRender()
|
||||
let lineLink = new DDeiLineLink({
|
||||
line: model,
|
||||
type: type,
|
||||
dm: realModel,
|
||||
dx: 0,
|
||||
dy: 0
|
||||
})
|
||||
model.linkModels.set(realModel.id, lineLink);
|
||||
}
|
||||
model = realModel;
|
||||
editor.quickEditorModel = model;
|
||||
}
|
||||
|
||||
//获取控件所占区域
|
||||
//判断控件是否有composes,如果被composes拦截了,则启用componses的编辑
|
||||
model = DDeiAbstractShape.findBottomComponseByArea(model, ex, ey);
|
||||
|
||||
let fillArea = model.textArea
|
||||
|
||||
if (fillArea?.length > 0) {
|
||||
editor.quickEditorModel = model;
|
||||
let canvasPos = DDeiUtil.getDomAbsPosition(ddInstance.render.canvas);
|
||||
//创建大文本框
|
||||
let inputEle = DDeiUtil.getEditorText();
|
||||
let rotate = model.rotate
|
||||
let stageRatio = ddInstance.stage.getStageRatio();
|
||||
let pos = new Vector3(model.pvs[0].x, model.pvs[0].y, 1)
|
||||
if (rotate != 0) {
|
||||
let pvc = new Vector3(model.cpv.x, model.cpv.y, 1);
|
||||
let angle = (rotate * DDeiConfig.ROTATE_UNIT).toFixed(4);
|
||||
//计算input的正确打开位置,由节点0
|
||||
let move1Matrix = new Matrix3(
|
||||
1, 0, -pvc.x,
|
||||
0, 1, -pvc.y,
|
||||
0, 0, 1);
|
||||
let rotateMatrix = new Matrix3(
|
||||
Math.cos(angle), Math.sin(angle), 0,
|
||||
-Math.sin(angle), Math.cos(angle), 0,
|
||||
0, 0, 1);
|
||||
let move2Matrix = new Matrix3(
|
||||
1, 0, pvc.x,
|
||||
0, 1, pvc.y,
|
||||
0, 0, 1);
|
||||
let m1 = new Matrix3().premultiply(move1Matrix).premultiply(rotateMatrix).premultiply(move2Matrix);
|
||||
pos.applyMatrix3(m1)
|
||||
}
|
||||
|
||||
inputEle.value = model.text ? model.text : ''
|
||||
inputEle.style.fontSize = (model.render.getCachedValue("font.size") * stageRatio) + "px"
|
||||
inputEle.style.color = DDeiUtil.getColor(model.render.getCachedValue("font.color"))
|
||||
inputEle.style.width = (fillArea.width) * stageRatio + "px";
|
||||
inputEle.style.height = (fillArea.height) * stageRatio + "px";
|
||||
|
||||
|
||||
inputEle.style.left = canvasPos.left + pos.x + ddInstance.stage.wpv.x + 1 + "px";
|
||||
inputEle.style.top = canvasPos.top + pos.y + ddInstance.stage.wpv.y + 10 + "px";
|
||||
// inputEle.style.transform = "rotate(" + rotate + "deg)";
|
||||
// inputEle.style.backgroundColor = "grey"
|
||||
inputEle.style.display = "block";
|
||||
|
||||
let textAreaRect = DDeiAbstractShape.pvsToOutRect(model.textArea);
|
||||
inputEle.style.width = textAreaRect.width + "px"
|
||||
inputEle.style.height = textAreaRect.height + "px"
|
||||
//创建编辑影子元素
|
||||
ddInstance.stage.render.editorShadowControl = DDeiUtil.getShadowControl(model);
|
||||
//清空当前opPoints
|
||||
model.layer.opPoints = [];
|
||||
if (model.layer.opLine?.render) {
|
||||
model.layer.opLine.render.enableRefreshShape()
|
||||
}
|
||||
delete model.layer.opLine;
|
||||
ddInstance.stage.render.editorShadowControl.render.isEditoring = true
|
||||
inputEle.focus()
|
||||
|
||||
inputEle.selectionStart = 0 // 选中开始位置
|
||||
inputEle.selectionEnd = inputEle.value.length // 获取输入框里的长度。
|
||||
//修改编辑器状态为快捷编辑中
|
||||
editor.changeState(DDeiEditorState.QUICK_EDITING);
|
||||
delete ddInstance.stage.brushData
|
||||
delete ddInstance.stage.brushDataText
|
||||
ddInstance.stage.render.operateState = DDeiEnumOperateState.QUICK_EDITING
|
||||
//发出通知,选中的焦点发生变化
|
||||
editor.bus.push(DDeiEnumBusCommandType.StageChangeSelectModels);
|
||||
editor.bus.push(DDeiEnumBusCommandType.TextEditorChangeSelectPos);
|
||||
editor.bus.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
|
||||
editor.bus.executeAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,9 +9,14 @@ class DDeiExtSearchLifeCycle extends DDeiLifeCycle {
|
||||
*/
|
||||
static defaultIns: DDeiExtSearchLifeCycle = new DDeiExtSearchLifeCycle(null);
|
||||
|
||||
// static{
|
||||
// DDeiExtSearchLifeCycle.changeQuickControlDialogPos = debounce(DDeiExtSearchLifeCycle.changeQuickControlDialogPos,200)
|
||||
// }
|
||||
|
||||
EVENT_MOUSE_MOVE_IN_CONTROL: DDeiFuncData | null = new DDeiFuncData("quickcontrol-ext-show", 1, this.moveInControl);
|
||||
|
||||
EVENT_CONTROL_DRAG_AFTER: DDeiFuncData | null = new DDeiFuncData("quickcontrol-ext-changepos", 1, this.changeQuickControlDialogPos);
|
||||
|
||||
EVENT_MOUSE_MOVE_IN_LAYER: DDeiFuncData | null = new DDeiFuncData("quickcontrol-ext-close", 1, this.closeQuickControlDialog);
|
||||
|
||||
EVENT_CONTROL_SELECT_AFTER: DDeiFuncData | null = new DDeiFuncData("quickcontrol-ext-show", 1, this.closeAndShowQuickControlDialog);
|
||||
@ -43,6 +48,30 @@ class DDeiExtSearchLifeCycle extends DDeiLifeCycle {
|
||||
}
|
||||
}
|
||||
|
||||
changeQuickControlDialogPos(operateType, data, ddInstance, evt) {
|
||||
if (ddInstance && ddInstance["AC_DESIGN_EDIT"] && data?.models?.length > 0) {
|
||||
|
||||
let editor = DDeiEditorUtil.getEditorInsByDDei(ddInstance);
|
||||
if (editor.state == 'designing') {
|
||||
let model = data.models[0]
|
||||
|
||||
//如果存在选中控件,则重新定位到选中控件
|
||||
if (editor.ddInstance.stage.selectedModels?.size > 0) {
|
||||
if (!editor.ddInstance.stage.selectedModels.has(model.id)) {
|
||||
if (editor.ddInstance.stage.selectedModels?.size == 1) {
|
||||
model = Array.from(editor.ddInstance.stage.selectedModels.values())[0]
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
data.model = model
|
||||
DDeiExtSearchLifeCycle.changeQuickControlDialogPos(operateType, data, ddInstance, evt)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 正在进行鼠标操作
|
||||
*/
|
||||
@ -83,7 +112,7 @@ class DDeiExtSearchLifeCycle extends DDeiLifeCycle {
|
||||
static showQuickControlDialog(operateType, data, ddInstance, evt): DDeiFuncCallResult {
|
||||
if (ddInstance && ddInstance["AC_DESIGN_EDIT"] && data?.model) {
|
||||
let editor = DDeiEditorUtil.getEditorInsByDDei(ddInstance);
|
||||
if (!data.model?.rotate && data.model?.baseModelType != 'DDeiLine' && (!editor.tempPopData || !editor.tempPopData['ddei-ext-dialog-quickcontrol'] || editor.tempPopData['ddei-ext-dialog-quickcontrol'].model != data.model)){
|
||||
if (!data.model?.rotate && data.model?.baseModelType != 'DDeiLine' && (!editor.tempPopData || !editor.tempPopData['ddei-ext-dialog-quickcontrol'] || editor.tempPopData['ddei-ext-dialog-quickcontrol'].model != data.model)) {
|
||||
//隐藏弹出框
|
||||
DDeiEditorUtil.closeDialog(editor, 'ddei-ext-dialog-quickcontrol', true)
|
||||
DDeiEditorUtil.closeDialog(editor, 'ddei-ext-dialog-quickchoosecontrol', true)
|
||||
@ -92,32 +121,69 @@ class DDeiExtSearchLifeCycle extends DDeiLifeCycle {
|
||||
let editorDomPos = DDeiUtil.getDomAbsPosition(editorEle);
|
||||
let modelPos = DDeiUtil.getModelsDomAbsPosition([data.model])
|
||||
|
||||
let stageRatio = ddInstance.stage.getStageRatio()
|
||||
let width = 50
|
||||
let height = 50
|
||||
let left = modelPos.left - editorDomPos.left - width/2
|
||||
let top = modelPos.top - editorDomPos.top - height/2
|
||||
let left = modelPos.left - editorDomPos.left - width / 2
|
||||
let top = modelPos.top - editorDomPos.top - height / 2
|
||||
|
||||
let offset = null
|
||||
if (data.model.state == DDeiEnumControlState.SELECTED) {
|
||||
height = 70
|
||||
top-=20
|
||||
offset = {
|
||||
top -= 20
|
||||
offset = {
|
||||
'left': "margin-top:20px",
|
||||
'right': "margin-top:20px"
|
||||
}
|
||||
}
|
||||
DDeiEditorUtil.showDialog(editor, 'ddei-ext-dialog-quickcontrol', {
|
||||
group: "canvas-pop-quickcontrol",
|
||||
model:data.model,
|
||||
model: data.model,
|
||||
width: width,
|
||||
height: height,
|
||||
offset:offset
|
||||
}, { type: 99, left: left, top: top, ignoreOutSide:1, hiddenMask: true }, null, true, true)
|
||||
offset: offset
|
||||
}, { type: 99, left: left, top: top, ignoreOutSide: 1, hiddenMask: true }, null, true, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改坐标
|
||||
*/
|
||||
static changeQuickControlDialogPos(operateType, data, ddInstance, evt): DDeiFuncCallResult {
|
||||
if (ddInstance && ddInstance["AC_DESIGN_EDIT"] && data?.model) {
|
||||
let editor = DDeiEditorUtil.getEditorInsByDDei(ddInstance);
|
||||
|
||||
//显示弹出框
|
||||
let editorEle = document.getElementById(editor.id);
|
||||
let editorDomPos = DDeiUtil.getDomAbsPosition(editorEle);
|
||||
let modelPos = DDeiUtil.getModelsDomAbsPosition([data.model])
|
||||
|
||||
let width = 50
|
||||
let height = 50
|
||||
let left = modelPos.left - editorDomPos.left - width / 2
|
||||
let top = modelPos.top - editorDomPos.top - height / 2
|
||||
|
||||
let offset = null
|
||||
if (data.model.state == DDeiEnumControlState.SELECTED) {
|
||||
height = 70
|
||||
top -= 20
|
||||
offset = {
|
||||
'left': "margin-top:20px",
|
||||
'right': "margin-top:20px"
|
||||
}
|
||||
}
|
||||
DDeiEditorUtil.displayDialog(editor, 'ddei-ext-dialog-quickcontrol', {
|
||||
group: "canvas-pop-quickcontrol",
|
||||
model: data.model,
|
||||
width: width,
|
||||
height: height,
|
||||
offset: offset
|
||||
}, { type: 99, left: left, top: top, ignoreOutSide: 1, hiddenMask: true }, null, true, true)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 鼠标进入画布
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user