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