Skip to content

Commit

Permalink
chore(pm): update all prosemirror package dependencies (#4714)
Browse files Browse the repository at this point in the history
* chore(pm): update all prosemirror package dependencies

* rchore(core): remove filterTransaction from state

* fix(demo): fix typings in vue demo

* feat(core): add missing prosemirror commands for joining textblocks

* adoc: added documentation for missing commands

---------

Co-authored-by: bdbch <dominik@bdbch.com>
  • Loading branch information
bdbch and bdbch authored Jan 2, 2024
1 parent fd8d4c0 commit 894c732
Show file tree
Hide file tree
Showing 9 changed files with 407 additions and 216 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Plugin, PluginKey } from '@tiptap/pm/state'
import { DecorationSet } from 'prosemirror-view'
import * as Y from 'yjs'

import { AnnotationItem } from './AnnotationItem.js'
import { AnnotationState } from './AnnotationState.js'

export const AnnotationPluginKey = new PluginKey('annotation')
Expand All @@ -9,7 +11,7 @@ export interface AnnotationPluginOptions {
HTMLAttributes: {
[key: string]: any
}
onUpdate: (items: [any?]) => {}
onUpdate: (items: AnnotationItem[]) => {}
map: Y.Map<any>
instance: string
}
Expand All @@ -32,16 +34,18 @@ export const AnnotationPlugin = (options: AnnotationPluginOptions) => new Plugin

props: {
decorations(state) {
const { decorations } = this.getState(state)
const decorations = this.getState(state)?.decorations || new DecorationSet()
const { selection } = state

if (!selection.empty) {
return decorations
}

const annotations = this.getState(state).annotationsAt(selection.from)
const annotations = this.getState(state)?.annotationsAt(selection.from)

options.onUpdate(annotations)
if (annotations) {
options.onUpdate(annotations)
}

return decorations
},
Expand Down
8 changes: 8 additions & 0 deletions docs/api/commands/join-textblock-backward.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# joinTextblockBackward
A more limited form of joinBackward that only tries to join the current textblock to the one before it, if the cursor is at the start of a textblock. [See also](https://prosemirror.net/docs/ref/#commands.joinTextblockBackward)

## Usage
```js
editor.commands.joinTextblockBackward()
```

8 changes: 8 additions & 0 deletions docs/api/commands/join-textblock-forward.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# joinTextblockForward
A more limited form of joinForward that only tries to join the current textblock to the one after it, if the cursor is at the end of a textblock. [See also](https://prosemirror.net/docs/ref/#commands.joinTextblockForward)

## Usage
```js
editor.commands.joinTextblockForward()
```

Loading

0 comments on commit 894c732

Please sign in to comment.