New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prosemirror-utils

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-utils - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

typings.d.ts

47

dist/index.js

@@ -25,3 +25,3 @@ 'use strict';

// :: (predicate: (node: ProseMirrorNode) → boolean, domAtPos: (pos: number) → {node: HTMLElement, offset: number}) → (selection: Selection) → ?HTMLElement
// :: (predicate: (node: ProseMirrorNode) → boolean, domAtPos: (pos: number) → {node: dom.Node, offset: number}) → (selection: Selection) → ?dom.Node
// Iterates over parent nodes, returning DOM reference of the first node `predicate` returns truthy for.

@@ -65,3 +65,3 @@ var findParentDomRef = function findParentDomRef(predicate, domAtPos) {

// :: (nodeType: NodeType, domAtPos: (pos: number) → {node: HTMLElement, offset: number}) → (selection: Selection) → ?HTMLElement
// :: (nodeType: NodeType, domAtPos: (pos: number) → {node: dom.Node, offset: number}) → (selection: Selection) → ?dom.Node
// Iterates over parent nodes, returning DOM reference of the first node of the given `nodeType`.

@@ -166,3 +166,3 @@ var findParentDomRefOfType = function findParentDomRefOfType(nodeType, domAtPos) {

return findParentNode(function (node) {
return node.type.spec.tableRole && node.type.spec.tableRole === 'table';
return node.type.spec.tableRole && node.type.spec.tableRole === "table";
})(selection);

@@ -225,3 +225,3 @@ };

// :: (columnIndex: number) → (selection: Selection) → [{ pos: number, node: ProseMirrorNode }]
// :: (columnIndex: number) → (selection: Selection) → ?[{ pos: number, node: ProseMirrorNode }]
// Returns an array of cells in a column at index `columnIndex`.

@@ -233,3 +233,8 @@ var getCellsInColumn = function getCellsInColumn(columnIndex) {

var map = prosemirrorTables.TableMap.get(table.node);
var cells = map.cellsInRect({ left: columnIndex, right: columnIndex + 1, top: 0, bottom: map.height });
var cells = map.cellsInRect({
left: columnIndex,
right: columnIndex + 1,
top: 0,
bottom: map.height
});
return cells.map(function (pos) {

@@ -243,3 +248,3 @@ var node = table.node.nodeAt(pos);

// :: (rowIndex: number) → (selection: Selection) → [{ pos: number, node: ProseMirrorNode }]
// :: (rowIndex: number) → (selection: Selection) → ?[{ pos: number, node: ProseMirrorNode }]
// Returns an array of cells in a row at index `rowIndex`.

@@ -251,3 +256,8 @@ var getCellsInRow = function getCellsInRow(rowIndex) {

var map = prosemirrorTables.TableMap.get(table.node);
var cells = map.cellsInRect({ left: 0, right: map.width, top: rowIndex, bottom: rowIndex + 1 });
var cells = map.cellsInRect({
left: 0,
right: map.width,
top: rowIndex,
bottom: rowIndex + 1
});
return cells.map(function (pos) {

@@ -261,3 +271,3 @@ var node = table.node.nodeAt(pos);

// :: (selection: Selection) → [{ pos: number, node: ProseMirrorNode }]
// :: (selection: Selection) → ?[{ pos: number, node: ProseMirrorNode }]
// Returns an array of all cells in a table.

@@ -268,3 +278,8 @@ var getCellsInTable = function getCellsInTable(selection) {

var map = prosemirrorTables.TableMap.get(table.node);
var cells = map.cellsInRect({ left: 0, right: map.width, top: 0, bottom: map.height });
var cells = map.cellsInRect({
left: 0,
right: map.width,
top: 0,
bottom: map.height
});
return cells.map(function (pos) {

@@ -336,3 +351,3 @@ var node = table.node.nodeAt(pos);

// Returns an `insert` transaction that inserts a given `node` at the current cursor position if it is allowed by schema. If schema restricts such nesting, it will try to find the appropriate place for the given `node` in the document, looping through parent nodes up until the root document node.
var safeInsert = function safeInsert(content) {
var safeInsert = function safeInsert(node) {
return function (tr) {

@@ -343,8 +358,8 @@ var $from = tr.curSelection.$from;

// given content is allowed at the current cursor position
if ($from.parent.canReplaceWith(index, index, content.type)) {
return tr.insert($from.pos, content);
// given node is allowed at the current cursor position
if ($from.parent.canReplaceWith(index, index, node.type)) {
return tr.insert($from.pos, node);
}
// looking for a place in the doc where the content is allowed
// looking for a place in the doc where the node is allowed
for (var i = $from.depth; i > 0; i--) {

@@ -354,4 +369,4 @@ var pos = $from.after(i);

var _index = $pos.index();
if ($pos.parent.canReplaceWith(_index, _index, content.type)) {
return tr.insert(pos, content);
if ($pos.parent.canReplaceWith(_index, _index, node.type)) {
return tr.insert(pos, node);
}

@@ -358,0 +373,0 @@ }

{
"name": "prosemirror-utils",
"version": "0.0.3",
"version": "0.0.4",
"description": "Utils library for ProseMirror",

@@ -23,3 +23,3 @@ "main": "dist/index.js",

},
"files": ["dist"],
"files": ["dist", "typings.d.ts"],
"scripts": {

@@ -26,0 +26,0 @@ "build": "NODE_ENV=production rollup -c",

@@ -18,3 +18,3 @@ # Utils library for ProseMirror

- **`findParentDomRef`**`(predicate: fn(node: ProseMirrorNode) → boolean, domAtPos: fn(pos: number) → {node: HTMLElement, offset: number}) → fn(selection: Selection) → ?HTMLElement`\
- **`findParentDomRef`**`(predicate: fn(node: ProseMirrorNode) → boolean, domAtPos: fn(pos: number) → {node: dom.Node, offset: number}) → fn(selection: Selection) → ?dom.Node`\
Iterates over parent nodes, returning DOM reference of the first node `predicate` returns truthy for.

@@ -31,3 +31,3 @@

- **`findParentDomRefOfType`**`(nodeType: NodeType, domAtPos: fn(pos: number) → {node: HTMLElement, offset: number}) → fn(selection: Selection) → ?HTMLElement`\
- **`findParentDomRefOfType`**`(nodeType: NodeType, domAtPos: fn(pos: number) → {node: dom.Node, offset: number}) → fn(selection: Selection) → ?dom.Node`\
Iterates over parent nodes, returning DOM reference of the first node of the given `nodeType`.

@@ -82,9 +82,9 @@

- **`getCellsInColumn`**`(columnIndex: number) → fn(selection: Selection) → [{pos: number, node: ProseMirrorNode}]`\
- **`getCellsInColumn`**`(columnIndex: number) → fn(selection: Selection) → ?[{pos: number, node: ProseMirrorNode}]`\
Returns an array of cells in a column at index `columnIndex`.
* **`getCellsInRow`**`(rowIndex: number) → fn(selection: Selection) → [{pos: number, node: ProseMirrorNode}]`\
* **`getCellsInRow`**`(rowIndex: number) → fn(selection: Selection) → ?[{pos: number, node: ProseMirrorNode}]`\
Returns an array of cells in a row at index `rowIndex`.
- **`getCellsInTable`**`(selection: Selection) → [{pos: number, node: ProseMirrorNode}]`\
- **`getCellsInTable`**`(selection: Selection) → ?[{pos: number, node: ProseMirrorNode}]`\
Returns an array of all cells in a table.

@@ -91,0 +91,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc