mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Fix polygons closing when clicking existing masks while editing IO (#3990)
* fix polygons closing when clicking existing masks while editing io * disallow selecting new polygons * update CONTRIBUTORS * preserve ids when pushing canvas state to undo stack * rehandle tool changes after undoing/redoing the polygon tool makes all objects unselectable, which isn't preserved when restoring the canvas state after an undo/redo
This commit is contained in:
parent
573f59fab1
commit
c33974f6ab
8 changed files with 11 additions and 2 deletions
|
@ -299,7 +299,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
? 'left-border-radius'
|
? 'left-border-radius'
|
||||||
: 'right-border-radius'}"
|
: 'right-border-radius'}"
|
||||||
{iconSize}
|
{iconSize}
|
||||||
on:click={tool.action}
|
on:click={() => {
|
||||||
|
tool.action();
|
||||||
|
handleToolChanges(activeTool);
|
||||||
|
}}
|
||||||
tooltip="{tool.tooltip()} ({getPlatformString(tool.shortcut)})"
|
tooltip="{tool.tooltip()} ({getPlatformString(tool.shortcut)})"
|
||||||
disabled={tool.name === "undo"
|
disabled={tool.name === "undo"
|
||||||
? !$undoStack.undoable
|
? !$undoStack.undoable
|
||||||
|
|
|
@ -26,6 +26,7 @@ export class Shape {
|
||||||
occludeInactive?: boolean;
|
occludeInactive?: boolean;
|
||||||
/* Cloze ordinal */
|
/* Cloze ordinal */
|
||||||
ordinal: number | undefined;
|
ordinal: number | undefined;
|
||||||
|
id: string | undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{ left = 0, top = 0, angle = 0, fill = SHAPE_MASK_COLOR, occludeInactive, ordinal = undefined }:
|
{ left = 0, top = 0, angle = 0, fill = SHAPE_MASK_COLOR, occludeInactive, ordinal = undefined }:
|
||||||
|
|
|
@ -17,6 +17,7 @@ export class Ellipse extends Shape {
|
||||||
super(rest);
|
super(rest);
|
||||||
this.rx = rx;
|
this.rx = rx;
|
||||||
this.ry = ry;
|
this.ry = ry;
|
||||||
|
this.id = "ellipse-" + new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
toDataForCloze(): EllipseDataForCloze {
|
toDataForCloze(): EllipseDataForCloze {
|
||||||
|
|
|
@ -15,6 +15,7 @@ export class Polygon extends Shape {
|
||||||
constructor({ points = [], ...rest }: ConstructorParams<Polygon> = {}) {
|
constructor({ points = [], ...rest }: ConstructorParams<Polygon> = {}) {
|
||||||
super(rest);
|
super(rest);
|
||||||
this.points = points;
|
this.points = points;
|
||||||
|
this.id = "polygon-" + new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
toDataForCloze(): PolygonDataForCloze {
|
toDataForCloze(): PolygonDataForCloze {
|
||||||
|
|
|
@ -17,6 +17,7 @@ export class Rectangle extends Shape {
|
||||||
super(rest);
|
super(rest);
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
this.id = "rect-" + new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
toDataForCloze(): RectangleDataForCloze {
|
toDataForCloze(): RectangleDataForCloze {
|
||||||
|
|
|
@ -28,6 +28,7 @@ export class Text extends Shape {
|
||||||
this.scaleX = scaleX;
|
this.scaleX = scaleX;
|
||||||
this.scaleY = scaleY;
|
this.scaleY = scaleY;
|
||||||
this.fontSize = fontSize;
|
this.fontSize = fontSize;
|
||||||
|
this.id = "text-" + new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
toDataForCloze(): TextDataForCloze {
|
toDataForCloze(): TextDataForCloze {
|
||||||
|
|
|
@ -197,6 +197,7 @@ const generatePolygon = (canvas: fabric.Canvas, pointsList): void => {
|
||||||
strokeWidth: 1,
|
strokeWidth: 1,
|
||||||
strokeUniform: true,
|
strokeUniform: true,
|
||||||
noScaleCache: false,
|
noScaleCache: false,
|
||||||
|
selectable: false,
|
||||||
opacity: get(opacityStateStore) ? 0.4 : 1,
|
opacity: get(opacityStateStore) ? 0.4 : 1,
|
||||||
});
|
});
|
||||||
polygon["id"] = "polygon-" + new Date().getTime();
|
polygon["id"] = "polygon-" + new Date().getTime();
|
||||||
|
|
|
@ -116,7 +116,7 @@ class UndoStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
private push(): void {
|
private push(): void {
|
||||||
const entry = JSON.stringify(this.canvas);
|
const entry = JSON.stringify(this.canvas?.toJSON(["id"]));
|
||||||
if (entry === this.stack[this.stack.length - 1]) {
|
if (entry === this.stack[this.stack.length - 1]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue