prosemirror-trailing-node
Advanced tools
Comparing version 2.0.7 to 3.0.0-beta.0
@@ -1,36 +0,2 @@ | ||
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 { TrailingNodePluginOptions } from './_tsup-dts-rollup'; | ||
export { trailingNode } from './_tsup-dts-rollup'; |
@@ -1,2 +0,2 @@ | ||
// packages/prosemirror-trailing-node/src/trailing-node-plugin.ts | ||
// src/trailing-node-plugin.ts | ||
import { Plugin, PluginKey } from "prosemirror-state"; | ||
@@ -6,3 +6,6 @@ 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]); | ||
@@ -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": "2.0.7", | ||
"version": "3.0.0-beta.0", | ||
"description": "A trailing node plugin for the prosemirror editor.", | ||
@@ -33,7 +33,8 @@ "homepage": "https://github.com/remirror/remirror/tree/HEAD/packages/prosemirror-trailing-node", | ||
"dependencies": { | ||
"@remirror/core-constants": "^2.0.2", | ||
"@remirror/core-helpers": "^3.0.0", | ||
"@remirror/core-constants": "3.0.0-beta.0", | ||
"@remirror/core-helpers": "4.0.0-beta.0", | ||
"escape-string-regexp": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@remirror/cli": "1.0.1", | ||
"prosemirror-model": "^1.19.3", | ||
@@ -54,3 +55,6 @@ "prosemirror-state": "^1.4.3", | ||
"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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
51423
13
283
4
1
+ Added@remirror/core-constants@3.0.0-beta.0(transitive)
+ Added@remirror/core-helpers@4.0.0-beta.0(transitive)
+ Added@remirror/types@2.0.0-beta.0(transitive)
+ Addedtype-fest@3.13.1(transitive)
- Removed@remirror/core-constants@2.0.2(transitive)
- Removed@remirror/core-helpers@3.0.0(transitive)
- Removed@remirror/types@1.0.1(transitive)
- Removedtype-fest@2.19.0(transitive)