prosemirror-trailing-node
Advanced tools
Comparing version 0.0.0-pr2169.2 to 0.0.0-pr2223.1
@@ -1,2 +0,36 @@ | ||
export { TrailingNodePluginOptions } from './_tsup-dts-rollup'; | ||
export { trailingNode } from './_tsup-dts-rollup'; | ||
import { Plugin } from 'prosemirror-state'; | ||
interface TrailingNodePluginOptions { | ||
/** | ||
* The node to create at the end of the document. | ||
* | ||
* **Note**: the nodeName will always be added to the `ignoredNodes` lists to | ||
* prevent an infinite loop. | ||
* | ||
* @defaultValue 'paragraph' | ||
*/ | ||
nodeName?: string; | ||
/** | ||
* The nodes for which this rule should not apply. | ||
*/ | ||
ignoredNodes?: string[]; | ||
} | ||
/** | ||
* This creates the plugin for trailing node. | ||
* | ||
* ```ts | ||
* import { schema } from 'prosemirror-schema-basic'; | ||
* import { trailingNode } from 'prosemirror-trailing-node'; | ||
* | ||
* // Include the plugin in the created editor state. | ||
* const state = EditorState.create({ | ||
* schema, | ||
* plugins: [trailingNode({ ignoredNodes: [], nodeName: 'paragraph' })], | ||
* }); | ||
* ``` | ||
* | ||
* @param options - the options that can be provided to this plugin. | ||
*/ | ||
declare function trailingNode(options?: TrailingNodePluginOptions): Plugin<boolean>; | ||
export { type TrailingNodePluginOptions, trailingNode }; |
@@ -1,2 +0,2 @@ | ||
// src/trailing-node-plugin.ts | ||
// packages/prosemirror-trailing-node/src/trailing-node-plugin.ts | ||
import { Plugin, PluginKey } from "prosemirror-state"; | ||
@@ -6,6 +6,3 @@ import { includes, uniqueArray } from "@remirror/core-helpers"; | ||
function trailingNode(options) { | ||
const { | ||
ignoredNodes = [], | ||
nodeName = "paragraph" | ||
} = options ?? {}; | ||
const { ignoredNodes = [], nodeName = "paragraph" } = options ?? {}; | ||
const ignoredNodeNames = uniqueArray([...ignoredNodes, nodeName]); | ||
@@ -17,6 +14,3 @@ let type; | ||
appendTransaction(_, __, state) { | ||
const { | ||
doc, | ||
tr | ||
} = state; | ||
const { doc, tr } = state; | ||
const shouldInsertNodeAtEnd = trailingNodePluginKey.getState(state); | ||
@@ -30,6 +24,3 @@ const endPosition = doc.content.size; | ||
state: { | ||
init: (_, { | ||
doc, | ||
schema | ||
}) => { | ||
init: (_, { doc, schema }) => { | ||
const nodeType = schema.nodes[nodeName]; | ||
@@ -40,3 +31,3 @@ if (!nodeType) { | ||
type = nodeType; | ||
types = Object.values(schema.nodes).map(node => node).filter(node => !ignoredNodeNames.includes(node.name)); | ||
types = Object.values(schema.nodes).map((node) => node).filter((node) => !ignoredNodeNames.includes(node.name)); | ||
return includes(types, doc.lastChild?.type); | ||
@@ -53,2 +44,4 @@ }, | ||
} | ||
export { trailingNode }; | ||
export { | ||
trailingNode | ||
}; |
{ | ||
"name": "prosemirror-trailing-node", | ||
"version": "0.0.0-pr2169.2", | ||
"version": "0.0.0-pr2223.1", | ||
"description": "A trailing node plugin for the prosemirror editor.", | ||
@@ -33,11 +33,10 @@ "homepage": "https://github.com/remirror/remirror/tree/HEAD/packages/prosemirror-trailing-node", | ||
"dependencies": { | ||
"@remirror/core-constants": "0.0.0-pr2169.2", | ||
"@remirror/core-helpers": "0.0.0-pr2169.2", | ||
"@remirror/core-constants": "0.0.0-pr2223.1", | ||
"@remirror/core-helpers": "0.0.0-pr2223.1", | ||
"escape-string-regexp": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@remirror/cli": "0.0.0-pr2169.2", | ||
"prosemirror-model": "^1.19.3", | ||
"prosemirror-state": "^1.4.3", | ||
"prosemirror-view": "^1.32.3" | ||
"prosemirror-view": "^1.31.7" | ||
}, | ||
@@ -47,3 +46,3 @@ "peerDependencies": { | ||
"prosemirror-state": "^1.4.2", | ||
"prosemirror-view": "^1.32.3" | ||
"prosemirror-view": "^1.31.2" | ||
}, | ||
@@ -56,6 +55,3 @@ "peerDependenciesMeta": {}, | ||
"sizeLimit": "10 KB" | ||
}, | ||
"scripts": { | ||
"build": "remirror-cli build" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
3
50724
11
245
+ Added@remirror/core-constants@0.0.0-pr2223.1(transitive)
+ Added@remirror/core-helpers@0.0.0-pr2223.1(transitive)
+ Added@remirror/types@0.0.0-pr2223.1(transitive)
- Removed@remirror/core-constants@0.0.0-pr2169.2(transitive)
- Removed@remirror/core-helpers@0.0.0-pr2169.2(transitive)
- Removed@remirror/types@0.0.0-pr2169.2(transitive)