prosemirror-trailing-node
Advanced tools
Comparing version 0.0.0-pr2128.4 to 0.0.0-pr2156.1
@@ -1,36 +0,1 @@ | ||
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 { TrailingNodePluginOptions, trailingNode }; | ||
export {}; |
@@ -6,3 +6,6 @@ // packages/prosemirror-trailing-node/src/trailing-node-plugin.ts | ||
function trailingNode(options) { | ||
const { ignoredNodes = [], nodeName = "paragraph" } = options ?? {}; | ||
const { | ||
ignoredNodes = [], | ||
nodeName = "paragraph" | ||
} = options ?? {}; | ||
const ignoredNodeNames = uniqueArray([...ignoredNodes, nodeName]); | ||
@@ -14,3 +17,6 @@ let type; | ||
appendTransaction(_, __, state) { | ||
const { doc, tr } = state; | ||
const { | ||
doc, | ||
tr | ||
} = state; | ||
const shouldInsertNodeAtEnd = trailingNodePluginKey.getState(state); | ||
@@ -24,4 +30,6 @@ const endPosition = doc.content.size; | ||
state: { | ||
init: (_, { doc, schema }) => { | ||
var _a; | ||
init: (_, { | ||
doc, | ||
schema | ||
}) => { | ||
const nodeType = schema.nodes[nodeName]; | ||
@@ -32,11 +40,10 @@ if (!nodeType) { | ||
type = nodeType; | ||
types = Object.values(schema.nodes).map((node) => node).filter((node) => !ignoredNodeNames.includes(node.name)); | ||
return includes(types, (_a = doc.lastChild) == null ? void 0 : _a.type); | ||
types = Object.values(schema.nodes).map(node => node).filter(node => !ignoredNodeNames.includes(node.name)); | ||
return includes(types, doc.lastChild?.type); | ||
}, | ||
apply: (tr, value) => { | ||
var _a; | ||
if (!tr.docChanged) { | ||
return value; | ||
} | ||
return includes(types, (_a = tr.doc.lastChild) == null ? void 0 : _a.type); | ||
return includes(types, tr.doc.lastChild?.type); | ||
} | ||
@@ -46,4 +53,2 @@ } | ||
} | ||
export { | ||
trailingNode | ||
}; | ||
export { trailingNode }; |
{ | ||
"name": "prosemirror-trailing-node", | ||
"version": "0.0.0-pr2128.4", | ||
"version": "0.0.0-pr2156.1", | ||
"description": "A trailing node plugin for the prosemirror editor.", | ||
@@ -33,4 +33,4 @@ "homepage": "https://github.com/remirror/remirror/tree/HEAD/packages/prosemirror-trailing-node", | ||
"dependencies": { | ||
"@remirror/core-constants": "0.0.0-pr2128.4", | ||
"@remirror/core-helpers": "0.0.0-pr2128.4", | ||
"@remirror/core-constants": "0.0.0-pr2156.1", | ||
"@remirror/core-helpers": "0.0.0-pr2156.1", | ||
"escape-string-regexp": "^4.0.0" | ||
@@ -37,0 +37,0 @@ }, |
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
13
48838
243
+ Added@remirror/core-constants@0.0.0-pr2156.1(transitive)
+ Added@remirror/core-helpers@0.0.0-pr2156.1(transitive)
+ Added@remirror/types@0.0.0-pr2156.1(transitive)
+ Addedprosemirror-view@1.36.0(transitive)
- Removed@ampproject/remapping@2.3.0(transitive)
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/compat-data@7.26.2(transitive)
- Removed@babel/core@7.26.0(transitive)
- Removed@babel/generator@7.26.2(transitive)
- Removed@babel/helper-compilation-targets@7.25.9(transitive)
- Removed@babel/helper-module-imports@7.25.9(transitive)
- Removed@babel/helper-module-transforms@7.26.0(transitive)
- Removed@babel/helper-plugin-utils@7.25.9(transitive)
- Removed@babel/helper-simple-access@7.25.9(transitive)
- Removed@babel/helper-string-parser@7.25.9(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@babel/helper-validator-option@7.25.9(transitive)
- Removed@babel/helpers@7.26.0(transitive)
- Removed@babel/parser@7.26.2(transitive)
- Removed@babel/plugin-proposal-export-namespace-from@7.18.9(transitive)
- Removed@babel/plugin-syntax-dynamic-import@7.8.3(transitive)
- Removed@babel/plugin-syntax-export-namespace-from@7.8.3(transitive)
- Removed@babel/plugin-transform-modules-commonjs@7.25.9(transitive)
- Removed@babel/template@7.25.9(transitive)
- Removed@babel/traverse@7.25.9(transitive)
- Removed@babel/types@7.26.0(transitive)
- Removed@jridgewell/gen-mapping@0.3.5(transitive)
- Removed@jridgewell/resolve-uri@3.1.2(transitive)
- Removed@jridgewell/set-array@1.2.1(transitive)
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@jridgewell/trace-mapping@0.3.25(transitive)
- Removed@linaria/core@4.2.10(transitive)
- Removed@linaria/logger@4.5.0(transitive)
- Removed@linaria/utils@4.5.3(transitive)
- Removed@remirror/core-constants@0.0.0-pr2128.4(transitive)
- Removed@remirror/core-helpers@0.0.0-pr2128.4(transitive)
- Removed@remirror/types@0.0.0-pr2128.4(transitive)
- Removedbabel-merge@3.0.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@2.0.1(transitive)
- Removedbrowserslist@4.24.2(transitive)
- Removedcaniuse-lite@1.0.30001684(transitive)
- Removedconvert-source-map@2.0.0(transitive)
- Removeddebug@4.3.7(transitive)
- Removeddeepmerge@2.2.1(transitive)
- Removedelectron-to-chromium@1.5.65(transitive)
- Removedescalade@3.2.0(transitive)
- Removedfind-up@5.0.0(transitive)
- Removedgensync@1.0.0-beta.2(transitive)
- Removedglobals@11.12.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjsesc@3.0.2(transitive)
- Removedjson5@2.2.3(transitive)
- Removedlocate-path@6.0.0(transitive)
- Removedlru-cache@5.1.1(transitive)
- Removedminimatch@9.0.5(transitive)
- Removedms@2.1.3(transitive)
- Removednode-releases@2.0.18(transitive)
- Removedp-limit@3.1.0(transitive)
- Removedp-locate@5.0.0(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedprosemirror-view@1.37.0(transitive)
- Removedsemver@6.3.1(transitive)
- Removedupdate-browserslist-db@1.1.1(transitive)
- Removedyallist@3.1.1(transitive)
- Removedyocto-queue@0.1.0(transitive)