Skip to content

Commit

Permalink
Regenerate readme from TypeScript types
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed May 20, 2022
1 parent 2dd15a2 commit b54c18e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,23 @@ to communication around the project.

## Documentation

**`dropCursor`**`(options: ?Object) → Plugin`

Create a plugin that, when added to a ProseMirror instance, causes a
decoration to show up at the drop position when something is dragged
over the editor.

- **`options`**`: ?Object`
- **`color`**`: ?string (default: black)`
- **`width`**`: ?number (default: 1)`
- **`class`**`: ?string`\
Adds a class to the cursor.\
*Layout overrides such as `width` are not recommended*
* **`dropCursor`**`(options?: interface = {}) → Plugin`\
Create a plugin that, when added to a ProseMirror instance,
causes a decoration to show up at the drop position when something
is dragged over the editor.

Nodes may add a `disableDropCursor` property to their spec to
control the showing of a drop cursor inside them. This may be a
boolean or a function, which will be called with a view and a
position, and should return a boolean.

* **`options`**

* **`color`**`?: string`\
The color of the cursor. Defaults to `black`.

* **`width`**`?: number`\
The precise width of the cursor in pixels. Defaults to 1.

* **`class`**`?: string`\
A CSS class name to add to the cursor element.
2 changes: 1 addition & 1 deletion src/dropcursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class DropCursorView {
let pos = this.editorView.posAtCoords({left: event.clientX, top: event.clientY})

let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside)
let disableDropCursor = node && (node.type.spec as any).disableDropCursor
let disableDropCursor = node && node.type.spec.disableDropCursor
let disabled = typeof disableDropCursor == "function" ? disableDropCursor(this.editorView, pos) : disableDropCursor

if (pos && !disabled) {
Expand Down

0 comments on commit b54c18e

Please sign in to comment.