同步框架代码
This commit is contained in:
parent
4427c51410
commit
de6b1a70cc
@ -456,13 +456,13 @@ export class JlDrawApp extends GraphicApp {
|
|||||||
* 删除选中图形对象
|
* 删除选中图形对象
|
||||||
*/
|
*/
|
||||||
deleteSelectedGraphics() {
|
deleteSelectedGraphics() {
|
||||||
const deletes = this.selectedGraphics.slice(
|
const deletes = this.deleteGraphics(...this.selectedGraphics);
|
||||||
0,
|
if (deletes.length > 0) {
|
||||||
this.selectedGraphics.length
|
// 删除图形对象操作记录
|
||||||
);
|
this.opRecord.record(new GraphicDeleteOperation(this, deletes));
|
||||||
this.deleteGraphics(...this.selectedGraphics);
|
} else {
|
||||||
// 删除图形对象操作记录
|
console.debug('没有删除元素,不记录');
|
||||||
this.opRecord.record(new GraphicDeleteOperation(this, deletes));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCanvasAndRecord(data: ICanvasProperties) {
|
updateCanvasAndRecord(data: ICanvasProperties) {
|
||||||
|
@ -320,6 +320,11 @@ export interface IGraphicAppConfig {
|
|||||||
* 超出屏幕显示范围是否剪裁,默认true
|
* 超出屏幕显示范围是否剪裁,默认true
|
||||||
*/
|
*/
|
||||||
cullable?: boolean;
|
cullable?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否支持删除操作
|
||||||
|
*/
|
||||||
|
isSupportDeletion?: (g: JlGraphic) => boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -729,8 +734,19 @@ export class GraphicApp extends EventEmitter<GraphicAppEvents> {
|
|||||||
* 删除图形
|
* 删除图形
|
||||||
* @param graphics 图形对象
|
* @param graphics 图形对象
|
||||||
*/
|
*/
|
||||||
deleteGraphics(...graphics: JlGraphic[]) {
|
deleteGraphics(...graphics: JlGraphic[]): JlGraphic[] {
|
||||||
graphics.forEach((g) => this.doDeleteGraphics(g));
|
const dels = graphics.filter((g) => {
|
||||||
|
if (
|
||||||
|
this._options?.isSupportDeletion &&
|
||||||
|
this._options.isSupportDeletion(g)
|
||||||
|
) {
|
||||||
|
this.doDeleteGraphics(g);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
console.debug(`type=${g.type},id=${g.id}的图形不支持删除`);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
return dels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user