Skip to content

Commit

Permalink
feat: app新增插件方法
Browse files Browse the repository at this point in the history
  • Loading branch information
JessYan0913 committed Jul 27, 2023
1 parent 2358d24 commit 0576e6e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main/src/view/canvas/index.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { App, ellipseTool, polylineTool, rectTool, selectTool, triangleTool } from '@pictode/core';
import { History } from '@pictode/plugin-history';
const containerRef = ref<HTMLDivElement>();
const app = new App();
app.use(new History());
onMounted(() => {
if (containerRef.value) {
app.mount(containerRef.value);
Expand Down
32 changes: 32 additions & 0 deletions packages/plugin-history/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,35 @@ App.prototype.undo = function (step: number = 1): App {
}
return this;
};

App.prototype.redo = function (step: number = 1): App {
const history = this.getPlugin('history') as History;
if (history) {
history.redo(step);
}
return this;
};

App.prototype.canUndo = function (): boolean {
const history = this.getPlugin('history') as History;
if (history) {
return history.canUndo();
}
return false;
};

App.prototype.canRedo = function (): boolean {
const history = this.getPlugin('history') as History;
if (history) {
return history.canRedo();
}
return false;
};

App.prototype.jump = function (id: number): App {
const history = this.getPlugin('history') as History;
if (history) {
history.jump(id);
}
return this;
};

0 comments on commit 0576e6e

Please sign in to comment.