同步框架代码

This commit is contained in:
dong 2023-07-12 10:51:06 +08:00
parent 4427c51410
commit de6b1a70cc
2 changed files with 25 additions and 9 deletions

View File

@ -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) {

View File

@ -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;
} }
/** /**