Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
move deletion of figures to plugins
- Loading branch information
Showing
11 changed files
with
108 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import DeleteFigure from './lib/DeleteFigure'; | ||
|
||
const KEY_CODES = { 'bspace': 8 }; | ||
|
||
class FigureBspaceKey { | ||
constructor(content, selection) { | ||
this.content = content; | ||
this.selection = selection; | ||
} | ||
|
||
static getName() { | ||
return 'bspace'; | ||
} | ||
|
||
// return or ctrl+m | ||
matches(event) { | ||
return event.keyCode === KEY_CODES.bspace; | ||
} | ||
|
||
down(callback) { | ||
const guids = this.selection.guids(); | ||
const offsets = this.selection.offsets(); | ||
|
||
if (this.selection.isFigure() && !this.selection.isCaption()) { | ||
const command = new DeleteFigure(this.content); | ||
const results = command.execute(guids); | ||
callback({ | ||
content: results.content, | ||
position: results.position, | ||
stopPropagation: !!results, | ||
preventDefault: !!results, | ||
emit: true | ||
}); | ||
} else { | ||
callback({ content: this.content }); | ||
} | ||
} | ||
|
||
up(callback) { | ||
callback({ content: this.content }); | ||
} | ||
|
||
_deleteFigure() { | ||
return new DeleteFigure(this.content); | ||
} | ||
} | ||
|
||
export default FigureBspaceKey; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import DeleteFigure from './lib/DeleteFigure'; | ||
|
||
const KEY_CODES = { 'delete': 46 }; | ||
|
||
class FigureDeleteKey { | ||
constructor(content, selection) { | ||
this.content = content; | ||
this.selection = selection; | ||
} | ||
|
||
static getName() { | ||
return 'figure-delete'; | ||
} | ||
|
||
matches(event) { | ||
return event.keyCode === KEY_CODES.delete; | ||
} | ||
|
||
down(callback) { | ||
const guids = this.selection.guids(); | ||
const offsets = this.selection.offsets(); | ||
|
||
if (this.selection.isFigure() && !this.selection.isCaption()) { | ||
const command = new DeleteFigure(this.content); | ||
const results = command.execute(guids); | ||
callback({ | ||
content: results.content, | ||
position: results.position, | ||
stopPropagation: !!results, | ||
preventDefault: !!results, | ||
emit: true | ||
}); | ||
} else { | ||
callback({ content: this.content }); | ||
} | ||
} | ||
|
||
up(callback) { | ||
callback({ content: this.content }); | ||
} | ||
} | ||
|
||
export default FigureDeleteKey; |
Empty file.
Empty file.
4 changes: 2 additions & 2 deletions
4
modules/helpers/Manipulation/DeleteFigure.js → modules/plugins/shared/lib/DeleteFigure.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters