Adds setter for history
This commit is contained in:
parent
e6eb277f49
commit
04b6353e41
5 changed files with 28 additions and 3 deletions
|
@ -23,7 +23,7 @@
|
|||
"start": "node scripts/dev & yarn types:dev",
|
||||
"build": "node scripts/build && yarn types:build",
|
||||
"types:pre": "tsc",
|
||||
"types:dev": "tsc --watch ",
|
||||
"types:dev": "tsc --watch",
|
||||
"types:build": "tsc --project tsconfig.build.json",
|
||||
"lint": "eslint src/ --ext .ts,.tsx",
|
||||
"clean": "rm -rf dist",
|
||||
|
|
|
@ -67,6 +67,6 @@
|
|||
"@tldraw/core": "^0.0.79",
|
||||
"perfect-freehand": "^0.5.3",
|
||||
"react-hotkeys-hook": "^3.4.0",
|
||||
"rko": "^0.5.22"
|
||||
"rko": "^0.5.23"
|
||||
}
|
||||
}
|
|
@ -370,5 +370,14 @@ describe('TLDrawState', () => {
|
|||
|
||||
expect(tlstate.history).toBeDefined()
|
||||
expect(tlstate.history).toMatchSnapshot('history')
|
||||
|
||||
tlstate.history = []
|
||||
expect(tlstate.history).toEqual([])
|
||||
|
||||
const before = tlstate.state
|
||||
tlstate.undo()
|
||||
const after = tlstate.state
|
||||
|
||||
expect(before).toBe(after)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -37,6 +37,7 @@ import {
|
|||
TLDrawPage,
|
||||
TLDrawBinding,
|
||||
GroupShape,
|
||||
TLDrawCommand,
|
||||
} from '~types'
|
||||
import { TLDR } from './tldr'
|
||||
import { defaultStyle } from '~shape'
|
||||
|
@ -653,6 +654,13 @@ export class TLDrawState extends StateManager<Data> {
|
|||
return this.stack
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the current history stack.
|
||||
*/
|
||||
set history(commands: TLDrawCommand[]) {
|
||||
this.replaceHistory(commands)
|
||||
}
|
||||
|
||||
/**
|
||||
* The current document.
|
||||
*/
|
||||
|
|
10
yarn.lock
10
yarn.lock
|
@ -11557,7 +11557,7 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
|
|||
hash-base "^3.0.0"
|
||||
inherits "^2.0.1"
|
||||
|
||||
rko@^0.5.19, rko@^0.5.20, rko@^0.5.22:
|
||||
rko@^0.5.19, rko@^0.5.20:
|
||||
version "0.5.22"
|
||||
resolved "https://registry.yarnpkg.com/rko/-/rko-0.5.22.tgz#d5a563beefd97a9cfdda3c29c1fbe119d782b576"
|
||||
integrity sha512-aNXCHTLshLgq6XuWZzb3XKgy5RyS5YY6/YzCnrBa+tn7NTPC2HysbNhJwyt6bow3u8whiD36GajhUYR6oIbJWw==
|
||||
|
@ -11565,6 +11565,14 @@ rko@^0.5.19, rko@^0.5.20, rko@^0.5.22:
|
|||
idb-keyval "^5.1.3"
|
||||
zustand "^3.5.9"
|
||||
|
||||
rko@^0.5.23:
|
||||
version "0.5.23"
|
||||
resolved "https://registry.yarnpkg.com/rko/-/rko-0.5.23.tgz#2613c05d518df71b08215bb031aa4680ede51302"
|
||||
integrity sha512-u4c2n/99zE+j23WE7FoO5GA4ussYhvhZ5/fh/xJ9ctXyV6Vy+445r2jM2M2xegrCRkIw67RtPI5BmpCXZHnRxA==
|
||||
dependencies:
|
||||
idb-keyval "^5.1.3"
|
||||
zustand "^3.5.9"
|
||||
|
||||
rollup-plugin-terser@^7.0.0:
|
||||
version "7.0.2"
|
||||
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d"
|
||||
|
|
Loading…
Reference in a new issue