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.5.0 to 0.5.1

37

dist/index.js

@@ -266,4 +266,2 @@ 'use strict';

var canReplace = function canReplace($pos, content) {
var index = $pos.index($pos.depth);
var indexAfter = $pos.indexAfter($pos.depth);
var node = $pos.node($pos.depth);

@@ -683,3 +681,3 @@ return node && node.type.validContent(content instanceof prosemirrorModel.Fragment ? content : prosemirrorModel.Fragment.from(content));

// :: (selection: Selection) → ?{pos: number, node: ProseMirrorNode}
// :: (selection: Selection) → ?{pos: number, start: number, node: ProseMirrorNode}
// Iterates over parent nodes, returning the closest table node.

@@ -768,3 +766,3 @@ //

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

@@ -787,5 +785,6 @@ //

});
return cells.map(function (pos) {
var node = table.node.nodeAt(pos);
return { pos: pos + table.pos + 1, node: node };
return cells.map(function (nodePos) {
var node = table.node.nodeAt(nodePos);
var pos = nodePos + table.start;
return { pos: pos, start: pos + 1, node: node };
});

@@ -797,3 +796,3 @@ }

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

@@ -816,5 +815,6 @@ //

});
return cells.map(function (pos) {
var node = table.node.nodeAt(pos);
return { pos: pos + table.pos + 1, node: node };
return cells.map(function (nodePos) {
var node = table.node.nodeAt(nodePos);
var pos = nodePos + table.start;
return { pos: pos, start: pos + 1, node: node };
});

@@ -826,3 +826,3 @@ }

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

@@ -843,5 +843,6 @@ //

});
return cells.map(function (pos) {
var node = table.node.nodeAt(pos);
return { pos: pos + table.pos + 1, node: node };
return cells.map(function (nodePos) {
var node = table.node.nodeAt(nodePos);
var pos = nodePos + table.start;
return { pos: pos, start: pos + 1, node: node };
});

@@ -1151,3 +1152,3 @@ }

// :: (columnIndex: number, cellTransform: (cell: { pos: number, node: ProseMirrorNode }) → (tr: Transaction)), setCursorToLastCell: ?boolean) → (tr: Transaction) → Transaction
// :: (columnIndex: number, cellTransform: (cell: {pos: number, start: number, node: ProseMirrorNode}) → (tr: Transaction)), setCursorToLastCell: ?boolean) → (tr: Transaction) → Transaction
// Returns a new transaction that maps a given `cellTransform` function to each cell in a column at a given `columnIndex`.

@@ -1178,3 +1179,3 @@ // It will set the selection into the last cell of the column if `setCursorToLastCell` param is set to `true`.

// :: (rowIndex: number, cellTransform: (cell: { pos: number, node: ProseMirrorNode }) → (tr: Transaction)), setCursorToLastCell: ?boolean) → (tr: Transaction) → Transaction
// :: (rowIndex: number, cellTransform: (cell: {pos: number, start: number, node: ProseMirrorNode}) → (tr: Transaction)), setCursorToLastCell: ?boolean) → (tr: Transaction) → Transaction
// Returns a new transaction that maps a given `cellTransform` function to each cell in a row at a given `rowIndex`.

@@ -1204,3 +1205,3 @@ // It will set the selection into the last cell of the row if `setCursorToLastCell` param is set to `true`.

// :: (cell: { pos: number, node: ProseMirrorNode }, attrs: Object) → (tr: Transaction) → Transaction
// :: (cell: {pos: number, start: number, node: ProseMirrorNode}, attrs: Object) → (tr: Transaction) → Transaction
// Returns a new transaction that sets given `attrs` to a given `cell`.

@@ -1207,0 +1208,0 @@ //

{
"name": "prosemirror-utils",
"version": "0.5.0",
"version": "0.5.1",
"description": "Utils library for ProseMirror",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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

* **`findTable`**`(selection: Selection) → ?{pos: number, node: ProseMirrorNode}`\
* **`findTable`**`(selection: Selection) → ?{pos: number, start: number, node: ProseMirrorNode}`\
Iterates over parent nodes, returning the closest table node.

@@ -257,3 +257,3 @@

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

@@ -266,3 +266,3 @@

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

@@ -275,3 +275,3 @@

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

@@ -423,3 +423,3 @@

* **`forEachCellInColumn`**`(columnIndex: number, cellTransform: fn(cell: {pos: number, node: ProseMirrorNode}) → fn(tr: Transaction))`\
* **`forEachCellInColumn`**`(columnIndex: number, cellTransform: fn(cell: {pos: number, start: number, node: ProseMirrorNode}) → fn(tr: Transaction))`\
, setCursorToLastCell: ?boolean) → (tr: Transaction) → Transaction

@@ -436,3 +436,3 @@ Returns a new transaction that maps a given `cellTransform` function to each cell in a column at a given `columnIndex`.

* **`forEachCellInRow`**`(rowIndex: number, cellTransform: fn(cell: {pos: number, node: ProseMirrorNode}) → fn(tr: Transaction))`\
* **`forEachCellInRow`**`(rowIndex: number, cellTransform: fn(cell: {pos: number, start: number, node: ProseMirrorNode}) → fn(tr: Transaction))`\
, setCursorToLastCell: ?boolean) → (tr: Transaction) → Transaction

@@ -449,3 +449,3 @@ Returns a new transaction that maps a given `cellTransform` function to each cell in a row at a given `rowIndex`.

* **`setCellAttrs`**`(cell: {pos: number, node: ProseMirrorNode}, attrs: Object) → fn(tr: Transaction) → Transaction`\
* **`setCellAttrs`**`(cell: {pos: number, start: number, node: ProseMirrorNode}, attrs: Object) → fn(tr: Transaction) → Transaction`\
Returns a new transaction that sets given `attrs` to a given `cell`.

@@ -452,0 +452,0 @@

@@ -8,9 +8,12 @@ import { Node as ProsemirrorNode, Schema, NodeType, Mark, MarkType, ResolvedPos, Fragment } from 'prosemirror-model';

export type CellTransform = (cell: {pos: number, node: ProsemirrorNode}) => (tr: Transaction) => Transaction;
export type ContentNodeWithPos = {pos: number, start: number, node: ProsemirrorNode};
export type NodeWithPos = {pos: number, node: ProsemirrorNode};
export type CellTransform = (cell: NodeWithPos) => (tr: Transaction) => Transaction;
// Selection
export function findParentNode(predicate: Predicate): (selection: Selection) => {pos: number, node: ProsemirrorNode} | undefined;
export function findParentNode(predicate: Predicate): (selection: Selection) => ContentNodeWithPos | undefined;
export function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): {pos: number, node: ProsemirrorNode} | undefined;
export function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): ContentNodeWithPos | undefined;

@@ -21,5 +24,5 @@ export function findParentDomRef(predicate: Predicate, domAtPos: DomAtPos): (selection: Selection) => Node | undefined;

export function findParentNodeOfType(nodeType: NodeType | NodeType[]): (selection: Selection) => {pos: number, node: ProsemirrorNode} | undefined;
export function findParentNodeOfType(nodeType: NodeType | NodeType[]): (selection: Selection) => ContentNodeWithPos | undefined;
export function findParentNodeOfTypeClosestToPos($pos: ResolvedPos, nodeType: NodeType | NodeType[]): {pos: number, node: ProsemirrorNode} | undefined;
export function findParentNodeOfTypeClosestToPos($pos: ResolvedPos, nodeType: NodeType | NodeType[]): ContentNodeWithPos | undefined;

@@ -30,3 +33,3 @@ export function hasParentNodeOfType(nodeType: NodeType | NodeType[]): (selection: Selection) => boolean;

export function findSelectedNodeOfType(nodeType: NodeType | NodeType[]): (selection: Selection) => {pos: number, node: ProsemirrorNode} | undefined;
export function findSelectedNodeOfType(nodeType: NodeType | NodeType[]): (selection: Selection) => ContentNodeWithPos | undefined;

@@ -40,17 +43,17 @@ export function isNodeSelection(selection: Selection): boolean;

// Node
export function flatten(node: ProsemirrorNode, descend?: boolean): {pos: number, node: ProsemirrorNode}[];
export function flatten(node: ProsemirrorNode, descend?: boolean): NodeWithPos[];
export function findChildren(node: ProsemirrorNode, predicate: Predicate, descend?: boolean): {pos: number, node: ProsemirrorNode}[];
export function findChildren(node: ProsemirrorNode, predicate: Predicate, descend?: boolean): NodeWithPos[];
export function findTextNodes(node: ProsemirrorNode, descend?: boolean): {pos: number, node: ProsemirrorNode}[];
export function findTextNodes(node: ProsemirrorNode, descend?: boolean): NodeWithPos[];
export function findInlineNodes(node: ProsemirrorNode, descend?: boolean): {pos: number, node: ProsemirrorNode}[];
export function findInlineNodes(node: ProsemirrorNode, descend?: boolean): NodeWithPos[];
export function findBlockNodes(node: ProsemirrorNode, descend?: boolean): {pos: number, node: ProsemirrorNode}[];
export function findBlockNodes(node: ProsemirrorNode, descend?: boolean): NodeWithPos[];
export function findChildrenByAttr(node: ProsemirrorNode, predicate: Predicate, descend?: boolean): {pos: number, node: ProsemirrorNode}[];
export function findChildrenByAttr(node: ProsemirrorNode, predicate: Predicate, descend?: boolean): NodeWithPos[];
export function findChildrenByType(node: ProsemirrorNode, nodeType: NodeType, descend?: boolean): {pos: number, node: ProsemirrorNode}[];
export function findChildrenByType(node: ProsemirrorNode, nodeType: NodeType, descend?: boolean): NodeWithPos[];
export function findChildrenByMark(node: ProsemirrorNode, markType: MarkType, descend?: boolean): {pos: number, node: ProsemirrorNode}[];
export function findChildrenByMark(node: ProsemirrorNode, markType: MarkType, descend?: boolean): NodeWithPos[];

@@ -60,3 +63,3 @@ export function contains(node: ProsemirrorNode, nodeType: NodeType): boolean;

// Table
export function findTable(selection: Selection): {pos: number, node: ProsemirrorNode} | undefined;
export function findTable(selection: Selection): ContentNodeWithPos | undefined;

@@ -71,7 +74,7 @@ export function isCellSelection(selection: Selection): boolean;

export function getCellsInColumn(columnIndex: number): (selection: Selection) => {pos: number, node: ProsemirrorNode}[] | undefined;
export function getCellsInColumn(columnIndex: number): (selection: Selection) => ContentNodeWithPos[] | undefined;
export function getCellsInRow(rowIndex: number): (selection: Selection) => {pos: number, node: ProsemirrorNode}[] | undefined;
export function getCellsInRow(rowIndex: number): (selection: Selection) => ContentNodeWithPos[] | undefined;
export function getCellsInTable(selection: Selection): {pos: number, node: ProsemirrorNode}[] | undefined;
export function getCellsInTable(selection: Selection): ContentNodeWithPos[] | undefined;

@@ -84,3 +87,3 @@ export function selectColumn(columnIndex: number): (tr: Transaction) => Transaction;

export function emptyCell(cell: {pos: number, node: ProsemirrorNode}, schema: Schema): (tr: Transaction) => Transaction;
export function emptyCell(cell: ContentNodeWithPos, schema: Schema): (tr: Transaction) => Transaction;

@@ -109,5 +112,5 @@ export function addColumnAt(columnIndex: number): (tr: Transaction) => Transaction;

export function setCellAttrs(cell: {pos: number, node: ProsemirrorNode}, attrs: Object): (tr: Transaction) => Transaction;
export function setCellAttrs(cell: ContentNodeWithPos, attrs: Object): (tr: Transaction) => Transaction;
export function findCellClosestToPos($pos: ResolvedPos): {pos: number, node: ProsemirrorNode} | undefined;
export function findCellClosestToPos($pos: ResolvedPos): ContentNodeWithPos | undefined;

@@ -114,0 +117,0 @@ export function createTable(schema: Schema, rowsCount?: number, colsCount?: number, withHeaderRow?: boolean): ProsemirrorNode;

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