Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

prosemirror-trailing-node

Package Overview
Dependencies
Maintainers
1
Versions
208
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-trailing-node - npm Package Compare versions

Comparing version
3.0.0-beta.3
to
3.0.0-beta.4
+24
-55
./dist/prosemirror-trailing-node.cjs
"use strict";
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
var __defProp = Object.defineProperty;

@@ -11,33 +7,14 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;

var __export = (target, all) => {
for (var name in all) __defProp(target, name, {
get: all[name],
enumerable: true
});
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
var _iterator = _createForOfIteratorHelper(__getOwnPropNames(from)),
_step;
try {
var _loop = function _loop() {
var key = _step.value;
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: () => from[key],
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
};
for (_iterator.s(); !(_step = _iterator.n()).done;) {
_loop();
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
value: true
}), mod);
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -47,3 +24,3 @@ // src/index.ts

__export(src_exports, {
trailingNode: () => _trailingNode
trailingNode: () => trailingNode
});

@@ -54,20 +31,14 @@ module.exports = __toCommonJS(src_exports);

var import_prosemirror_state = require("prosemirror-state");
var import_core_helpers = require("@remirror/core-helpers");
var trailingNodePluginKey = new import_prosemirror_state.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 = (0, import_core_helpers.uniqueArray)([...ignoredNodes, nodeName]);
var type;
var types;
function trailingNode(options) {
const { ignoredNodes = [], nodeName = "paragraph" } = options != null ? options : {};
const ignoredNodeNames = /* @__PURE__ */ new Set([...ignoredNodes, nodeName]);
let type;
let types;
return new import_prosemirror_state.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) {

@@ -79,7 +50,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) {

@@ -89,11 +58,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 (0, import_core_helpers.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 (0, import_core_helpers.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);
}

@@ -105,3 +74,3 @@ }

0 && (module.exports = {
trailingNode: _trailingNode
});
trailingNode
});
"use strict";
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
var __defProp = Object.defineProperty;

@@ -11,33 +7,14 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;

var __export = (target, all) => {
for (var name in all) __defProp(target, name, {
get: all[name],
enumerable: true
});
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
var _iterator = _createForOfIteratorHelper(__getOwnPropNames(from)),
_step;
try {
var _loop = function _loop() {
var key = _step.value;
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: () => from[key],
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
};
for (_iterator.s(); !(_step = _iterator.n()).done;) {
_loop();
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
value: true
}), mod);
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -47,3 +24,3 @@ // src/index.ts

__export(src_exports, {
trailingNode: () => _trailingNode
trailingNode: () => trailingNode
});

@@ -54,20 +31,14 @@ module.exports = __toCommonJS(src_exports);

var import_prosemirror_state = require("prosemirror-state");
var import_core_helpers = require("@remirror/core-helpers");
var trailingNodePluginKey = new import_prosemirror_state.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 = (0, import_core_helpers.uniqueArray)([...ignoredNodes, nodeName]);
var type;
var types;
function trailingNode(options) {
const { ignoredNodes = [], nodeName = "paragraph" } = options != null ? options : {};
const ignoredNodeNames = /* @__PURE__ */ new Set([...ignoredNodes, nodeName]);
let type;
let types;
return new import_prosemirror_state.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) {

@@ -79,7 +50,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) {

@@ -89,11 +58,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 (0, import_core_helpers.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 (0, import_core_helpers.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);
}

@@ -105,3 +74,3 @@ }

0 && (module.exports = {
trailingNode: _trailingNode
});
trailingNode
});
// 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