Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #47 from cultureamp/comp-237/list-is-active
Browse files Browse the repository at this point in the history
feat: Add listIsActive method
  • Loading branch information
anirudhbs authored Aug 11, 2022
2 parents 7104d7e + 3ec199d commit 3130ac3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-fishes-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cultureamp/rich-text-toolkit": minor
---

Add listIsActive method
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"prosemirror-schema-basic": "^1.1.2",
"prosemirror-schema-list": "^1.1.6",
"prosemirror-state": "^1.3.4",
"prosemirror-utils": "^1.0.0-0",
"prosemirror-view": "^1.23.7"
}
}
1 change: 1 addition & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from "./addMark"
export * from "./getMarkAttrs"
export * from "./getMarkRange"
export * from "./listIsActive"
export * from "./markContainsSelection"
export * from "./markIsActive"
export * from "./removeMark"
Expand Down
10 changes: 10 additions & 0 deletions src/commands/listIsActive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { EditorState } from "prosemirror-state"
import { NodeType, Schema } from "prosemirror-model"
import { hasParentNodeOfType } from "prosemirror-utils"

export function listIsActive(
state: EditorState,
type: NodeType<Schema<any, any>>
) {
return hasParentNodeOfType(state.schema.nodes[type.name])(state.selection)
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4148,6 +4148,11 @@ prosemirror-transform@^1.0.0, prosemirror-transform@^1.1.0:
dependencies:
prosemirror-model "^1.0.0"

prosemirror-utils@^1.0.0-0:
version "1.0.0-0"
resolved "https://registry.yarnpkg.com/prosemirror-utils/-/prosemirror-utils-1.0.0-0.tgz#7dfd112abf69001508a76200f9c8660fda7fa85f"
integrity sha512-11hTMG4Qwqlux6Vwp/4m16mLDg6IwWb0/odsWXGtWvvRJo61SfG0RGYlA8H72vExmbnWpiXa7PNenZ6t12Rkqw==

prosemirror-view@^1.23.7:
version "1.23.7"
resolved "https://registry.yarnpkg.com/prosemirror-view/-/prosemirror-view-1.23.7.tgz#f003af94445ef456e397c18cf4bb995e7072097f"
Expand Down

0 comments on commit 3130ac3

Please sign in to comment.