prosemirror-trailing-node
Advanced tools
Comparing version 0.0.0-pr2223.1 to 0.0.0-pr2271.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 { type TrailingNodePluginOptions, trailingNode }; | ||
export {}; |
@@ -1,8 +0,7 @@ | ||
// packages/prosemirror-trailing-node/src/trailing-node-plugin.ts | ||
// src/trailing-node-plugin.ts | ||
import { Plugin, PluginKey } from "prosemirror-state"; | ||
import { includes, uniqueArray } from "@remirror/core-helpers"; | ||
var trailingNodePluginKey = new PluginKey("trailingNode"); | ||
function trailingNode(options) { | ||
const { ignoredNodes = [], nodeName = "paragraph" } = options ?? {}; | ||
const ignoredNodeNames = uniqueArray([...ignoredNodes, nodeName]); | ||
const { ignoredNodes = [], nodeName = "paragraph" } = options != null ? options : {}; | ||
const ignoredNodeNames = /* @__PURE__ */ new Set([...ignoredNodes, nodeName]); | ||
let type; | ||
@@ -23,15 +22,17 @@ let types; | ||
init: (_, { doc, schema }) => { | ||
var _a; | ||
const nodeType = schema.nodes[nodeName]; | ||
if (!nodeType) { | ||
throw new Error(`Invalid node being used for trailing node extension: '${nodeName}'`); | ||
throw new Error("Invalid node being used for trailing node extension: '".concat(nodeName, "'")); | ||
} | ||
type = nodeType; | ||
types = Object.values(schema.nodes).map((node) => node).filter((node) => !ignoredNodeNames.includes(node.name)); | ||
return includes(types, doc.lastChild?.type); | ||
types = Object.values(schema.nodes).map((node) => node).filter((node) => !ignoredNodeNames.has(node.name)); | ||
return types.includes((_a = doc.lastChild) == null ? void 0 : _a.type); | ||
}, | ||
apply: (tr, value) => { | ||
var _a; | ||
if (!tr.docChanged) { | ||
return value; | ||
} | ||
return includes(types, tr.doc.lastChild?.type); | ||
return types.includes((_a = tr.doc.lastChild) == null ? void 0 : _a.type); | ||
} | ||
@@ -38,0 +39,0 @@ } |
{ | ||
"name": "prosemirror-trailing-node", | ||
"version": "0.0.0-pr2223.1", | ||
"version": "0.0.0-pr2271.1", | ||
"description": "A trailing node plugin for the prosemirror editor.", | ||
@@ -33,15 +33,15 @@ "homepage": "https://github.com/remirror/remirror/tree/HEAD/packages/prosemirror-trailing-node", | ||
"dependencies": { | ||
"@remirror/core-constants": "0.0.0-pr2223.1", | ||
"@remirror/core-helpers": "0.0.0-pr2223.1", | ||
"@remirror/core-constants": "0.0.0-pr2271.1", | ||
"escape-string-regexp": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"prosemirror-model": "^1.19.3", | ||
"@remirror/cli": "0.0.0-pr2271.1", | ||
"prosemirror-model": "^1.22.1", | ||
"prosemirror-state": "^1.4.3", | ||
"prosemirror-view": "^1.31.7" | ||
"prosemirror-view": "^1.33.8" | ||
}, | ||
"peerDependencies": { | ||
"prosemirror-model": "^1.19.0", | ||
"prosemirror-model": "^1.22.1", | ||
"prosemirror-state": "^1.4.2", | ||
"prosemirror-view": "^1.31.2" | ||
"prosemirror-view": "^1.33.8" | ||
}, | ||
@@ -54,3 +54,6 @@ "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
5
13
253
28682
4
+ Added@remirror/core-constants@0.0.0-pr2271.1(transitive)
- Removed@remirror/core-constants@0.0.0-pr2223.1(transitive)
- Removed@remirror/core-helpers@0.0.0-pr2223.1(transitive)
- Removed@remirror/types@0.0.0-pr2223.1(transitive)
- Removed@types/object.omit@3.0.3(transitive)
- Removed@types/object.pick@1.3.4(transitive)
- Removed@types/throttle-debounce@2.1.0(transitive)
- Removedcase-anything@2.1.13(transitive)
- Removeddash-get@1.0.2(transitive)
- Removeddeepmerge@4.3.1(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedis-extendable@1.0.1(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedisobject@3.0.1(transitive)
- Removedmake-error@1.3.6(transitive)
- Removedobject.omit@3.0.0(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedthrottle-debounce@3.0.1(transitive)
- Removedtype-fest@3.13.1(transitive)