-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3b297f
commit 36dad2b
Showing
4 changed files
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# setMeta | ||
Store a metadata property in the current transaction. | ||
|
||
## Parameters | ||
`key: string` | ||
|
||
The name of your metadata. You can get its value at any time with [getMeta](https://prosemirror.net/docs/ref/#state.Transaction.getMeta). | ||
|
||
`value: any` | ||
|
||
Store any value within your metadata. | ||
|
||
## Usage | ||
```js | ||
// Prevent the update event from being triggered | ||
editor.commands.setMeta('preventUpdate', true) | ||
|
||
// Store any value in the current transaction. | ||
// You can get this value at any time with tr.getMeta('foo'). | ||
editor.commands.setMeta('foo', 'bar') | ||
``` |
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,18 @@ | ||
import { Command, RawCommands } from '../types' | ||
|
||
declare module '@tiptap/core' { | ||
interface Commands { | ||
setMeta: { | ||
/** | ||
* Store a metadata property in the current transaction. | ||
*/ | ||
setMeta: (key: string, value: any) => Command, | ||
} | ||
} | ||
} | ||
|
||
export const setMeta: RawCommands['setMeta'] = (key, value) => ({ tr }) => { | ||
tr.setMeta(key, value) | ||
|
||
return true | ||
} |
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