键盘调整位置时,快捷按钮没跟着一起;编辑文本框时,图形快捷键被激活;键盘调整位置时,快捷按钮没跟着一起;

This commit is contained in:
猴赛雷 2024-11-04 12:42:34 +08:00
parent 3dc28d1284
commit 8c7b83031a
9 changed files with 754 additions and 544 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "ddei-editor", "name": "ddei-editor",
"version": "1.2.41-5", "version": "1.2.42-6",
"private": false, "private": false,
"type": "module", "type": "module",
"author": "hoslay <3697355039@qq.com>", "author": "hoslay <3697355039@qq.com>",

View File

@ -57,10 +57,25 @@ 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) { if (ddInstance && ddInstance.stage) {
//必须是canvas的子控件
if (this.isActive(document.activeElement)) {
let models = [] let models = []
if (ddInstance.stage.selectedModels?.size > 0) { if (ddInstance.stage.selectedModels?.size > 0) {
models = Array.from(ddInstance.stage.selectedModels?.values()); models = Array.from(ddInstance.stage.selectedModels?.values());
@ -87,9 +102,14 @@ class DDeiKeyActionAllSelect extends DDeiKeyAction {
ddInstance?.bus?.push(DDeiEnumBusCommandType.RefreshShape, null, evt); ddInstance?.bus?.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
ddInstance?.bus?.executeAll(); ddInstance?.bus?.executeAll();
return true;
} }
} }
return false
}
} }

View File

@ -56,9 +56,24 @@ class DDeiKeyActionBrushData extends DDeiKeyAction {
return DDeiKeyActionBrushData; 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) { if (ddInstance && ddInstance.stage) {
//必须是canvas的子控件
if (this.isActive(document.activeElement)) {
let stage = ddInstance.stage let stage = ddInstance.stage
let editor = DDeiEditor.ACTIVE_INSTANCE; let editor = DDeiEditor.ACTIVE_INSTANCE;
let models = Array.from(ddInstance.stage.selectedModels?.values()); let models = Array.from(ddInstance.stage.selectedModels?.values());
@ -113,12 +128,16 @@ class DDeiKeyActionBrushData extends DDeiKeyAction {
editor.bus?.push(DDeiEnumBusCommandType.ChangeCursor, { image: 'cursor-brush' }) editor.bus?.push(DDeiEnumBusCommandType.ChangeCursor, { image: 'cursor-brush' })
editor.bus?.executeAll(); editor.bus?.executeAll();
} }
return true;
} }
} }
}
} }
return false
} }
} }

View File

@ -1,10 +1,10 @@
import {DDeiEditor} from "ddei-framework"; import { DDeiEditor, DDeiEditorUtil } from "ddei-framework";
import {DDei} from "ddei-framework"; import {DDei} from "ddei-framework";
import {DDeiKeyAction} from "ddei-framework"; import {DDeiKeyAction} from "ddei-framework";
import {DDeiEnumBusCommandType} from "ddei-framework"; import {DDeiEnumBusCommandType} from "ddei-framework";
import {DDeiAbstractShape} from "ddei-framework"; import {DDeiAbstractShape} from "ddei-framework";
import {DDeiEnumControlState} 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) { getHotKeys(editor) {
return [this]; return [this];
} }
@ -61,9 +63,25 @@ class DDeiKeyActionMoveModels extends DDeiKeyAction {
return DDeiKeyActionMoveModels; 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) { if (ddInstance && ddInstance.stage) {
//必须是canvas的子控件
if (this.isActive(document.activeElement)) {
let selectedModels = ddInstance.stage.selectedModels; let selectedModels = ddInstance.stage.selectedModels;
let models = Array.from(selectedModels.values()); let models = Array.from(selectedModels.values());
if (models.length == 1 && models[0].baseModelType == 'DDeiTable' && models[0].curRow != -1 && models[0].curCol != -1) { if (models.length == 1 && models[0].baseModelType == 'DDeiTable' && models[0].curRow != -1 && models[0].curCol != -1) {
@ -141,7 +159,7 @@ class DDeiKeyActionMoveModels extends DDeiKeyAction {
else if (evt.keyCode == 40) { else if (evt.keyCode == 40) {
let mod = 0; let mod = 0;
if (!isShift) { if (!isShift) {
mod = outRect.y % moveSize; mod = Math.round(outRect.y) % moveSize;
} }
deltaY = moveSize - mod deltaY = moveSize - mod
} }
@ -160,7 +178,7 @@ class DDeiKeyActionMoveModels extends DDeiKeyAction {
else if (evt.keyCode == 39) { else if (evt.keyCode == 39) {
let mod = 0; let mod = 0;
if (!isShift) { if (!isShift) {
mod = outRect.x % moveSize; mod = Math.round(outRect.x) % moveSize;
} }
deltaX = moveSize - mod deltaX = moveSize - mod
} }
@ -182,13 +200,16 @@ class DDeiKeyActionMoveModels extends DDeiKeyAction {
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt); ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
ddInstance.bus.executeAll(); ddInstance.bus.executeAll();
DDeiEditorUtil.invokeCallbackFunc("EVENT_CONTROL_DRAG_AFTER", DDeiEnumOperateType.DRAG, { models: models }, ddInstance, evt)
return true
}
} }
} }
return false
} }
} }

View File

@ -60,9 +60,24 @@ class DDeiKeyActionPushModels extends DDeiKeyAction {
return DDeiKeyActionPushModels; 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) { if (ddInstance && ddInstance.stage) {
//必须是canvas的子控件
if (this.isActive(document.activeElement)) {
let stageRender = ddInstance.stage.render; let stageRender = ddInstance.stage.render;
let optContainer = stageRender.currentOperateContainer; let optContainer = stageRender.currentOperateContainer;
if (optContainer) { if (optContainer) {
@ -95,9 +110,14 @@ class DDeiKeyActionPushModels extends DDeiKeyAction {
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt); ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
ddInstance.bus.executeAll(); ddInstance.bus.executeAll();
return true;
} }
} }
return false;
}
} }

View File

@ -61,8 +61,23 @@ class DDeiKeyActionReRevoke extends DDeiKeyAction {
return DDeiKeyActionReRevoke; 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 editor = DDeiEditor.ACTIVE_INSTANCE;
//必须是canvas的子控件
if (this.isActive(document.activeElement)) {
let histype = DDeiEditorUtil.getConfigValue("HISTROY_LEVEL", editor); let histype = DDeiEditorUtil.getConfigValue("HISTROY_LEVEL", editor);
if (histype == 'file') { if (histype == 'file') {
if (editor?.files.length > 0 && (editor.currentFileIndex == 0 || editor.currentFileIndex)) { if (editor?.files.length > 0 && (editor.currentFileIndex == 0 || editor.currentFileIndex)) {
@ -98,6 +113,8 @@ class DDeiKeyActionReRevoke extends DDeiKeyAction {
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape); ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape);
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts) ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
ddInstance.bus.executeAll(); ddInstance.bus.executeAll();
return true;
} }
} }
} }
@ -125,6 +142,8 @@ class DDeiKeyActionReRevoke extends DDeiKeyAction {
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt); ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts) ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
ddInstance.bus.executeAll(); ddInstance.bus.executeAll();
return true;
} }
} }
@ -132,6 +151,9 @@ class DDeiKeyActionReRevoke extends DDeiKeyAction {
} }
} }
return false;
}
} }

View File

@ -61,8 +61,23 @@ class DDeiKeyActionRevoke extends DDeiKeyAction {
return DDeiKeyActionRevoke; 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 editor = DDeiEditor.ACTIVE_INSTANCE;
//必须是canvas的子控件
if (this.isActive(document.activeElement)) {
let histype = DDeiEditorUtil.getConfigValue("HISTROY_LEVEL", editor); let histype = DDeiEditorUtil.getConfigValue("HISTROY_LEVEL", editor);
if (histype == 'file') { if (histype == 'file') {
let editor = DDeiEditor.ACTIVE_INSTANCE; let editor = DDeiEditor.ACTIVE_INSTANCE;
@ -101,6 +116,8 @@ class DDeiKeyActionRevoke extends DDeiKeyAction {
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape); ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape);
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts) ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
ddInstance.bus.executeAll(); ddInstance.bus.executeAll();
return true;
} }
} }
} }
@ -129,12 +146,15 @@ class DDeiKeyActionRevoke extends DDeiKeyAction {
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt); ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts) ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
ddInstance.bus.executeAll(); ddInstance.bus.executeAll();
return true;
} }
} }
} }
} }
}
return false;
} }
} }

View File

@ -60,8 +60,25 @@ class DDeiKeyActionStartQuickEdit extends DDeiKeyAction {
return DDeiKeyActionStartQuickEdit; 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 && ddInstance.stage) {
//必须是canvas的子控件
if (this.isActive(document.activeElement)) {
if (ddInstance.stage?.selectedModels?.size == 1) { if (ddInstance.stage?.selectedModels?.size == 1) {
let model = Array.from(ddInstance.stage?.selectedModels.values())[0] let model = Array.from(ddInstance.stage?.selectedModels.values())[0]
let editor = DDeiEditor.ACTIVE_INSTANCE; let editor = DDeiEditor.ACTIVE_INSTANCE;
@ -257,6 +274,8 @@ class DDeiKeyActionStartQuickEdit extends DDeiKeyAction {
editor.bus.push(DDeiEnumBusCommandType.TextEditorChangeSelectPos); editor.bus.push(DDeiEnumBusCommandType.TextEditorChangeSelectPos);
editor.bus.push(DDeiEditorEnumBusCommandType.ClearTemplateUI); editor.bus.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
editor.bus.executeAll(); editor.bus.executeAll();
return true;
} }
} }
} }
@ -264,6 +283,9 @@ class DDeiKeyActionStartQuickEdit extends DDeiKeyAction {
} }
} }
} }
}
return false
}
} }

View File

@ -9,9 +9,14 @@ class DDeiExtSearchLifeCycle extends DDeiLifeCycle {
*/ */
static defaultIns: DDeiExtSearchLifeCycle = new DDeiExtSearchLifeCycle(null); 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_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_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); 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)
}
}
}
/** /**
* *
*/ */
@ -92,7 +121,6 @@ class DDeiExtSearchLifeCycle extends DDeiLifeCycle {
let editorDomPos = DDeiUtil.getDomAbsPosition(editorEle); let editorDomPos = DDeiUtil.getDomAbsPosition(editorEle);
let modelPos = DDeiUtil.getModelsDomAbsPosition([data.model]) let modelPos = DDeiUtil.getModelsDomAbsPosition([data.model])
let stageRatio = ddInstance.stage.getStageRatio()
let width = 50 let width = 50
let height = 50 let height = 50
let left = modelPos.left - editorDomPos.left - width / 2 let left = modelPos.left - editorDomPos.left - width / 2
@ -118,6 +146,44 @@ class DDeiExtSearchLifeCycle extends DDeiLifeCycle {
} }
} }
/**
*
*/
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)
}
}
/** /**
* *
*/ */