mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 08:38:06 +02:00
parent
308ca2a16f
commit
4acc086292
5 changed files with 91 additions and 21 deletions
|
@ -820,14 +820,14 @@ class AnnotationEditorLayer {
|
|||
this.#currentEditorType.startDrawing(this, this.#uiManager, false, event);
|
||||
}
|
||||
|
||||
endDrawingSession() {
|
||||
endDrawingSession(isAborted = false) {
|
||||
if (!this.#drawingAC) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
this.#drawingAC.abort();
|
||||
this.#drawingAC = null;
|
||||
this.#uiManager.disableUserSelect(false);
|
||||
this.#currentEditorType.endDrawing();
|
||||
return this.#currentEditorType.endDrawing(isAborted);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -739,13 +739,13 @@ class DrawingEditor extends AnnotationEditor {
|
|||
return;
|
||||
}
|
||||
|
||||
this.endDrawing();
|
||||
this.endDrawing(/* isAborted = */ false);
|
||||
}
|
||||
|
||||
static endDrawing() {
|
||||
static endDrawing(isAborted) {
|
||||
const parent = this._currentParent;
|
||||
if (!parent) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
parent.toggleDrawing(true);
|
||||
parent.cleanUndoStack(AnnotationEditorParamsType.DRAW_STEP);
|
||||
|
@ -756,20 +756,31 @@ class DrawingEditor extends AnnotationEditor {
|
|||
scale,
|
||||
} = parent;
|
||||
|
||||
parent.createAndAddNewEditor({ offsetX: 0, offsetY: 0 }, false, {
|
||||
drawId: this._currentDrawId,
|
||||
drawOutlines: this._currentDraw.getOutlines(
|
||||
pageWidth * scale,
|
||||
pageHeight * scale,
|
||||
scale,
|
||||
this._INNER_MARGIN
|
||||
),
|
||||
drawingOptions: this._currentDrawingOptions,
|
||||
mustBeCommitted: true,
|
||||
});
|
||||
} else {
|
||||
parent.drawLayer.remove(this._currentDrawId);
|
||||
const editor = parent.createAndAddNewEditor(
|
||||
{ offsetX: 0, offsetY: 0 },
|
||||
false,
|
||||
{
|
||||
drawId: this._currentDrawId,
|
||||
drawOutlines: this._currentDraw.getOutlines(
|
||||
pageWidth * scale,
|
||||
pageHeight * scale,
|
||||
scale,
|
||||
this._INNER_MARGIN
|
||||
),
|
||||
drawingOptions: this._currentDrawingOptions,
|
||||
mustBeCommitted: !isAborted,
|
||||
}
|
||||
);
|
||||
this._cleanup();
|
||||
return editor;
|
||||
}
|
||||
|
||||
parent.drawLayer.remove(this._currentDrawId);
|
||||
this._cleanup();
|
||||
return null;
|
||||
}
|
||||
|
||||
static _cleanup() {
|
||||
this._currentDrawId = -1;
|
||||
this._currentDraw = null;
|
||||
this._currentDrawingOptions = null;
|
||||
|
|
|
@ -2088,11 +2088,16 @@ class AnnotationEditorUIManager {
|
|||
*/
|
||||
delete() {
|
||||
this.commitOrRemove();
|
||||
if (!this.hasSelection) {
|
||||
const drawingEditor = this.currentLayer?.endDrawingSession(
|
||||
/* isAborted = */ true
|
||||
);
|
||||
if (!this.hasSelection && !drawingEditor) {
|
||||
return;
|
||||
}
|
||||
|
||||
const editors = [...this.#selectedEditors];
|
||||
const editors = drawingEditor
|
||||
? [drawingEditor]
|
||||
: [...this.#selectedEditors];
|
||||
const cmd = () => {
|
||||
for (const editor of editors) {
|
||||
editor.remove();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue