prosemirror-state
Advanced tools
Comparing version 1.4.0-beta.1 to 1.4.0-beta.2
@@ -139,3 +139,3 @@ import { Schema, Node, Mark, MarkType, Slice, ResolvedPos } from 'prosemirror-model'; | ||
*/ | ||
interface PluginSpec { | ||
interface PluginSpec<PluginState> { | ||
/** | ||
@@ -151,3 +151,3 @@ The [view props](https://prosemirror.net/docs/ref/#view.EditorProps) added by this plugin. Props | ||
*/ | ||
state?: StateField<any>; | ||
state?: StateField<PluginState>; | ||
/** | ||
@@ -182,2 +182,7 @@ Can be used to make this a keyed plugin. You can have only one | ||
appendTransaction?: (transactions: readonly Transaction[], oldState: EditorState, newState: EditorState) => Transaction | null | undefined; | ||
/** | ||
Additional properties are allowed on plugin specs, which can be | ||
read via [`Plugin.spec`](https://prosemirror.net/docs/ref/#state.Plugin.spec). | ||
*/ | ||
[key: string]: any; | ||
} | ||
@@ -204,7 +209,7 @@ /** | ||
*/ | ||
declare class Plugin { | ||
declare class Plugin<PluginState = any> { | ||
/** | ||
The plugin's [spec object](https://prosemirror.net/docs/ref/#state.PluginSpec). | ||
*/ | ||
readonly spec: PluginSpec; | ||
readonly spec: PluginSpec<PluginState>; | ||
/** | ||
@@ -217,3 +222,3 @@ Create a plugin. | ||
*/ | ||
spec: PluginSpec); | ||
spec: PluginSpec<PluginState>); | ||
/** | ||
@@ -226,3 +231,3 @@ The [props](https://prosemirror.net/docs/ref/#view.EditorProps) exported by this plugin. | ||
*/ | ||
getState(state: EditorState): any; | ||
getState(state: EditorState): PluginState | undefined; | ||
} | ||
@@ -267,3 +272,3 @@ /** | ||
*/ | ||
declare class PluginKey { | ||
declare class PluginKey<PluginState = any> { | ||
/** | ||
@@ -277,7 +282,7 @@ Create a plugin key. | ||
*/ | ||
get(state: EditorState): Plugin | undefined; | ||
get(state: EditorState): Plugin<PluginState> | undefined; | ||
/** | ||
Get the plugin's state from an editor state. | ||
*/ | ||
getState(state: EditorState): any; | ||
getState(state: EditorState): PluginState | undefined; | ||
} | ||
@@ -284,0 +289,0 @@ |
{ | ||
"name": "prosemirror-state", | ||
"version": "1.4.0-beta.1", | ||
"version": "1.4.0-beta.2", | ||
"description": "ProseMirror editor state", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -7,3 +7,3 @@ import {type EditorView, type EditorProps} from "prosemirror-view" | ||
/// constructor. It provides a definition for a plugin. | ||
export interface PluginSpec { | ||
export interface PluginSpec<PluginState> { | ||
/// The [view props](#view.EditorProps) added by this plugin. Props | ||
@@ -16,3 +16,3 @@ /// that are functions will be bound to have the plugin instance as | ||
/// extra slot in the state object in which it can keep its own data. | ||
state?: StateField<any> | ||
state?: StateField<PluginState> | ||
@@ -43,2 +43,6 @@ /// Can be used to make this a keyed plugin. You can have only one | ||
appendTransaction?: (transactions: readonly Transaction[], oldState: EditorState, newState: EditorState) => Transaction | null | undefined | ||
/// Additional properties are allowed on plugin specs, which can be | ||
/// read via [`Plugin.spec`](#state.Plugin.spec). | ||
[key: string]: any | ||
} | ||
@@ -70,7 +74,7 @@ | ||
/// may influence that state and the view that contains it. | ||
export class Plugin { | ||
export class Plugin<PluginState = any> { | ||
/// Create a plugin. | ||
constructor( | ||
/// The plugin's [spec object](#state.PluginSpec). | ||
readonly spec: PluginSpec | ||
readonly spec: PluginSpec<PluginState> | ||
) { | ||
@@ -88,3 +92,3 @@ if (spec.props) bindProps(spec.props, this, this.props) | ||
/// Extract the plugin's state field from an editor state. | ||
getState(state: EditorState) { return (state as any)[this.key] } | ||
getState(state: EditorState): PluginState | undefined { return (state as any)[this.key] } | ||
} | ||
@@ -130,3 +134,3 @@ | ||
/// active in a state. | ||
export class PluginKey { | ||
export class PluginKey<PluginState = any> { | ||
/// @internal | ||
@@ -140,6 +144,6 @@ key: string | ||
/// state. | ||
get(state: EditorState): Plugin | undefined { return state.config.pluginsByKey[this.key] } | ||
get(state: EditorState): Plugin<PluginState> | undefined { return state.config.pluginsByKey[this.key] } | ||
/// Get the plugin's state from an editor state. | ||
getState(state: EditorState): any { return (state as any)[this.key] } | ||
getState(state: EditorState): PluginState | undefined { return (state as any)[this.key] } | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
157518
3519
0