prosemirror-trailing-node
Advanced tools
Comparing version 3.0.0-beta.3 to 3.0.0-beta.4
// 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) { | ||
var _ref = options !== null && options !== void 0 ? options : {}, | ||
_ref$ignoredNodes = _ref.ignoredNodes, | ||
ignoredNodes = _ref$ignoredNodes === void 0 ? [] : _ref$ignoredNodes, | ||
_ref$nodeName = _ref.nodeName, | ||
nodeName = _ref$nodeName === void 0 ? "paragraph" : _ref$nodeName; | ||
var ignoredNodeNames = uniqueArray([...ignoredNodes, nodeName]); | ||
var type; | ||
var types; | ||
const { ignoredNodes = [], nodeName = "paragraph" } = options != null ? options : {}; | ||
const ignoredNodeNames = /* @__PURE__ */ new Set([...ignoredNodes, nodeName]); | ||
let type; | ||
let types; | ||
return new Plugin({ | ||
key: trailingNodePluginKey, | ||
appendTransaction(_, __, state) { | ||
var doc = state.doc, | ||
tr = state.tr; | ||
var shouldInsertNodeAtEnd = trailingNodePluginKey.getState(state); | ||
var endPosition = doc.content.size; | ||
const { doc, tr } = state; | ||
const shouldInsertNodeAtEnd = trailingNodePluginKey.getState(state); | ||
const endPosition = doc.content.size; | ||
if (!shouldInsertNodeAtEnd) { | ||
@@ -27,7 +21,5 @@ return; | ||
state: { | ||
init: (_, _ref2) => { | ||
var _doc$lastChild; | ||
var doc = _ref2.doc, | ||
schema = _ref2.schema; | ||
var nodeType = schema.nodes[nodeName]; | ||
init: (_, { doc, schema }) => { | ||
var _a; | ||
const nodeType = schema.nodes[nodeName]; | ||
if (!nodeType) { | ||
@@ -37,11 +29,11 @@ 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 = doc.lastChild) === null || _doc$lastChild === void 0 ? void 0 : _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 _tr$doc$lastChild; | ||
var _a; | ||
if (!tr.docChanged) { | ||
return value; | ||
} | ||
return includes(types, (_tr$doc$lastChild = tr.doc.lastChild) === null || _tr$doc$lastChild === void 0 ? void 0 : _tr$doc$lastChild.type); | ||
return types.includes((_a = tr.doc.lastChild) == null ? void 0 : _a.type); | ||
} | ||
@@ -51,2 +43,4 @@ } | ||
} | ||
export { trailingNode }; | ||
export { | ||
trailingNode | ||
}; |
{ | ||
"name": "prosemirror-trailing-node", | ||
"version": "3.0.0-beta.3", | ||
"version": "3.0.0-beta.4", | ||
"description": "A trailing node plugin for the prosemirror editor.", | ||
@@ -33,16 +33,15 @@ "homepage": "https://github.com/remirror/remirror/tree/HEAD/packages/prosemirror-trailing-node", | ||
"dependencies": { | ||
"@remirror/core-constants": "3.0.0-beta.2", | ||
"@remirror/core-helpers": "4.0.0-beta.2", | ||
"@remirror/core-constants": "3.0.0-beta.3", | ||
"escape-string-regexp": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@remirror/cli": "1.0.1", | ||
"prosemirror-model": "^1.19.3", | ||
"@remirror/cli": "1.1.0-beta.0", | ||
"prosemirror-model": "^1.22.1", | ||
"prosemirror-state": "^1.4.3", | ||
"prosemirror-view": "^1.32.3" | ||
"prosemirror-view": "^1.33.8" | ||
}, | ||
"peerDependencies": { | ||
"prosemirror-model": "^1.19.0", | ||
"prosemirror-model": "^1.22.1", | ||
"prosemirror-state": "^1.4.2", | ||
"prosemirror-view": "^1.32.3" | ||
"prosemirror-view": "^1.33.8" | ||
}, | ||
@@ -49,0 +48,0 @@ "peerDependenciesMeta": {}, |
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
28884
254
+ Added@remirror/core-constants@3.0.0-beta.3(transitive)
- Removed@remirror/core-helpers@4.0.0-beta.2
- Removed@remirror/core-constants@3.0.0-beta.2(transitive)
- Removed@remirror/core-helpers@4.0.0-beta.2(transitive)
- Removed@remirror/types@2.0.0-beta.2(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)