Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@milkdown/preset-gfm

Package Overview
Dependencies
Maintainers
1
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@milkdown/preset-gfm - npm Package Compare versions

Comparing version 7.3.1 to 7.3.2

2

lib/__internal__/with-meta.d.ts
import type { Meta, MilkdownPlugin } from '@milkdown/ctx';
export declare const withMeta: <T extends MilkdownPlugin>(plugin: T, meta: Partial<Meta> & Pick<Meta, 'displayName'>) => T;
export declare function withMeta<T extends MilkdownPlugin>(plugin: T, meta: Partial<Meta> & Pick<Meta, 'displayName'>): T;
//# sourceMappingURL=with-meta.d.ts.map

@@ -11,8 +11,11 @@ import { expectDomTypeError as O } from "@milkdown/exception";

import Ue from "remark-gfm";
const d = (e, t) => (Object.assign(e, {
meta: {
package: "@milkdown/preset-gfm",
...t
}
}), e), F = $e("strike_through");
function d(e, t) {
return Object.assign(e, {
meta: {
package: "@milkdown/preset-gfm",
...t
}
}), e;
}
const F = $e("strike_through");
d(F, {

@@ -71,6 +74,10 @@ displayName: "Attr<strikethrough>",

});
const ae = (e, t = 3, n = 3) => {
function ae(e, t = 3, n = 3) {
const o = Array(n).fill(0).map(() => R.type(e).createAndFill()), l = Array(n).fill(0).map(() => I.type(e).createAndFill()), r = Array(t).fill(0).map((s, c) => S.type(e).create(null, c === 0 ? l : o));
return T.type(e).create(null, r);
}, w = (e) => Ze((t) => t.type.spec.tableRole === "table")(e), b = (e, t) => {
}
function w(e) {
return Ze((t) => t.type.spec.tableRole === "table")(e);
}
function b(e, t) {
const n = w(t);

@@ -92,3 +99,4 @@ if (!n)

}).filter((l) => l != null);
}, C = (e, t) => {
}
function C(e, t) {
const n = w(t);

@@ -110,3 +118,4 @@ if (!n)

}).filter((l) => l != null);
}, Xe = (e) => {
}
function Xe(e) {
const t = w(e);

@@ -125,3 +134,4 @@ if (!t)

});
}, qe = (e) => {
}
function qe(e) {
const t = Xe(e.selection);

@@ -136,3 +146,3 @@ if (t && t[0]) {

return e;
};
}
function se(e, t, { map: n, tableStart: o, table: l }, r) {

@@ -145,17 +155,24 @@ const s = Array(r).fill(0).reduce((i, m, a) => i + l.child(a).nodeSize, o), c = Array(n.width).fill(0).map((i, m) => {

}
const ce = (e) => (t) => (n) => {
const o = w(n.selection), l = e === "row";
if (o) {
const r = h.get(o.node);
if (t >= 0 && t < (l ? r.height : r.width)) {
const s = r.positionAt(
l ? t : r.height - 1,
l ? r.width - 1 : t,
o.node
), c = n.doc.resolve(o.start + s), i = l ? y.rowSelection : y.colSelection, m = r.positionAt(l ? t : 0, l ? 0 : t, o.node), a = n.doc.resolve(o.start + m);
return A(n.setSelection(i(c, a)));
function ce(e) {
return (t) => (n) => {
const o = w(n.selection), l = e === "row";
if (o) {
const r = h.get(o.node);
if (t >= 0 && t < (l ? r.height : r.width)) {
const s = r.positionAt(
l ? t : r.height - 1,
l ? r.width - 1 : t,
o.node
), c = n.doc.resolve(o.start + s), i = l ? y.rowSelection : y.colSelection, m = r.positionAt(l ? t : 0, l ? 0 : t, o.node), a = n.doc.resolve(o.start + m);
return A(n.setSelection(i(c, a)));
}
}
}
return n;
}, Je = ce("row"), Qe = ce("col"), X = (e) => e[0].map((t, n) => e.map((o) => o[n])), ie = (e, t) => {
return n;
};
}
const Je = ce("row"), Qe = ce("col");
function X(e) {
return e[0].map((t, n) => e.map((o) => o[n]));
}
function ie(e, t) {
const n = [], o = h.get(e);

@@ -181,3 +198,4 @@ for (let r = 0; r < o.height; r++) {

);
}, de = (e) => {
}
function de(e) {
const t = h.get(e), n = [];

@@ -197,13 +215,17 @@ for (let o = 0; o < t.height; o++) {

return n;
}, me = (e, t, n, o) => {
}
function me(e, t, n, o) {
const l = t[0] > n[0] ? -1 : 1, r = e.splice(t[0], t.length), s = r.length % 2 === 0 ? 1 : 0;
let c;
return o === -1 && l === 1 ? c = n[0] - 1 : o === 1 && l === -1 ? c = n[n.length - 1] - s + 1 : c = l === -1 ? n[0] : n[n.length - 1] - s, e.splice(c, 0, ...r), e;
}, Ye = (e, t, n, o) => {
}
function Ye(e, t, n, o) {
let l = X(de(e.node));
return l = me(l, t, n, o), l = X(l), ie(e.node, l);
}, et = (e, t, n, o) => {
}
function et(e, t, n, o) {
let l = de(e.node);
return l = me(l, t, n, o), ie(e.node, l);
}, q = (e, t) => {
}
function q(e, t) {
let n = e, o = e;

@@ -248,3 +270,4 @@ for (let a = e; a >= 0; a--) {

return { $anchor: c, $head: m, indexes: l };
}, J = (e, t) => {
}
function J(e, t) {
let n = e, o = e;

@@ -283,3 +306,3 @@ for (let a = e; a >= 0; a--)

return { $anchor: c, $head: m, indexes: l };
};
}
function tt(e, t, n, o = !0) {

@@ -286,0 +309,0 @@ const l = w(e.selection);

@@ -11,7 +11,7 @@ import type { ContentNodeWithPos } from '@milkdown/prose';

}
export declare const createTable: (ctx: Ctx, rowsCount?: number, colsCount?: number) => Node;
export declare const findTable: (selection: Selection) => ContentNodeWithPos | undefined;
export declare const getCellsInCol: (columnIndex: number, selection: Selection) => CellPos[] | undefined;
export declare const getCellsInRow: (rowIndex: number, selection: Selection) => CellPos[] | undefined;
export declare const getAllCellsInTable: (selection: Selection) => {
export declare function createTable(ctx: Ctx, rowsCount?: number, colsCount?: number): Node;
export declare function findTable(selection: Selection): ContentNodeWithPos | undefined;
export declare function getCellsInCol(columnIndex: number, selection: Selection): CellPos[] | undefined;
export declare function getCellsInRow(rowIndex: number, selection: Selection): CellPos[] | undefined;
export declare function getAllCellsInTable(selection: Selection): {
pos: number;

@@ -21,5 +21,5 @@ start: number;

}[] | undefined;
export declare const selectTable: (tr: Transaction) => Transaction;
export declare function selectTable(tr: Transaction): Transaction;
export declare function addRowWithAlignment(ctx: Ctx, tr: Transaction, { map, tableStart, table }: TableRect, row: number): Transaction;
export declare const selectLine: (type: 'row' | 'col') => (index: number) => (tr: Transaction) => Transaction;
export declare function selectLine(type: 'row' | 'col'): (index: number) => (tr: Transaction) => Transaction;
export declare const selectRow: (index: number) => (tr: Transaction) => Transaction;

@@ -26,0 +26,0 @@ export declare const selectCol: (index: number) => (tr: Transaction) => Transaction;

{
"name": "@milkdown/preset-gfm",
"type": "module",
"version": "7.3.1",
"version": "7.3.2",
"license": "MIT",

@@ -34,11 +34,11 @@ "repository": {

"tslib": "^2.5.0",
"@milkdown/exception": "7.3.1",
"@milkdown/utils": "7.3.1"
"@milkdown/exception": "7.3.2",
"@milkdown/utils": "7.3.2"
},
"devDependencies": {
"@milkdown/core": "7.3.1",
"@milkdown/ctx": "7.3.1",
"@milkdown/preset-commonmark": "7.3.1",
"@milkdown/prose": "7.3.1",
"@milkdown/transformer": "7.3.1"
"@milkdown/core": "7.3.2",
"@milkdown/ctx": "7.3.2",
"@milkdown/preset-commonmark": "7.3.2",
"@milkdown/prose": "7.3.2",
"@milkdown/transformer": "7.3.2"
},

@@ -45,0 +45,0 @@ "nx": {

/* Copyright 2021, Milkdown by Mirone. */
import type { Meta, MilkdownPlugin } from '@milkdown/ctx'
export const withMeta = <T extends MilkdownPlugin>(
plugin: T,
meta: Partial<Meta> & Pick<Meta, 'displayName'>,
): T => {
export function withMeta<T extends MilkdownPlugin>(plugin: T, meta: Partial<Meta> & Pick<Meta, 'displayName'>): T {
Object.assign(plugin, {

@@ -9,0 +6,0 @@ meta: {

@@ -19,3 +19,3 @@ /* Copyright 2021, Milkdown by Mirone. */

default: 'left',
getFromDOM: dom => (dom as HTMLElement).style.textAlign || 'left',
getFromDOM: dom => (dom).style.textAlign || 'left',
setDOMAttr: (value, attrs) => {

@@ -180,3 +180,4 @@ attrs.style = `text-align: ${value || 'left'}`

export const insertTableInputRule = $inputRule(ctx => new InputRule(
/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/, (state, match, start, end) => {
/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,
(state, match, start, end) => {
const $start = state.doc.resolve(start)

@@ -242,3 +243,3 @@ if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), tableSchema.type(ctx)))

/// By default, it will insert a 3x3 table.
export const insertTableCommand = $command('InsertTable', ctx => ({ row, col }: { row?: number; col?: number } = {}) => (state, dispatch) => {
export const insertTableCommand = $command('InsertTable', ctx => ({ row, col }: { row?: number, col?: number } = {}) => (state, dispatch) => {
const { selection, tr } = state

@@ -264,3 +265,3 @@ const { from } = selection

/// You should specify the `from` and `to` index.
export const moveRowCommand = $command('MoveRow', () => ({ from, to }: { from?: number; to?: number } = {}) => (state, dispatch) => {
export const moveRowCommand = $command('MoveRow', () => ({ from, to }: { from?: number, to?: number } = {}) => (state, dispatch) => {
const { tr } = state

@@ -279,3 +280,3 @@ const result = dispatch?.(moveRow(tr, from ?? 0, to ?? 0, true))

/// You should specify the `from` and `to` index.
export const moveColCommand = $command('MoveCol', () => ({ from, to }: { from?: number; to?: number } = {}) => (state, dispatch) => {
export const moveColCommand = $command('MoveCol', () => ({ from, to }: { from?: number, to?: number } = {}) => (state, dispatch) => {
const { tr } = state

@@ -282,0 +283,0 @@ const result = dispatch?.(moveCol(tr, from ?? 0, to ?? 0, true))

@@ -21,3 +21,3 @@ /* Copyright 2021, Milkdown by Mirone. */

/// @internal
export const createTable = (ctx: Ctx, rowsCount = 3, colsCount = 3): Node => {
export function createTable(ctx: Ctx, rowsCount = 3, colsCount = 3): Node {
const cells = Array(colsCount)

@@ -39,7 +39,8 @@ .fill(0)

/// Find the table node with position information for current selection.
export const findTable = (selection: Selection) =>
findParentNode(node => node.type.spec.tableRole === 'table')(selection)
export function findTable(selection: Selection) {
return findParentNode(node => node.type.spec.tableRole === 'table')(selection)
}
/// Get cells in a column of a table.
export const getCellsInCol = (columnIndex: number, selection: Selection): CellPos[] | undefined => {
export function getCellsInCol(columnIndex: number, selection: Selection): CellPos[] | undefined {
const table = findTable(selection)

@@ -69,3 +70,3 @@ if (!table)

/// Get cells in a row of a table.
export const getCellsInRow = (rowIndex: number, selection: Selection): CellPos[] | undefined => {
export function getCellsInRow(rowIndex: number, selection: Selection): CellPos[] | undefined {
const table = findTable(selection)

@@ -95,3 +96,3 @@ if (!table)

/// Get all cells in a table.
export const getAllCellsInTable = (selection: Selection) => {
export function getAllCellsInTable(selection: Selection) {
const table = findTable(selection)

@@ -116,3 +117,3 @@ if (!table)

/// Select a possible table in current selection.
export const selectTable = (tr: Transaction) => {
export function selectTable(tr: Transaction) {
const cells = getAllCellsInTable(tr.selection)

@@ -150,25 +151,27 @@ if (cells && cells[0]) {

/// @internal
export const selectLine = (type: 'row' | 'col') => (index: number) => (tr: Transaction) => {
const table = findTable(tr.selection)
const isRowSelection = type === 'row'
if (table) {
const map = TableMap.get(table.node)
export function selectLine(type: 'row' | 'col') {
return (index: number) => (tr: Transaction) => {
const table = findTable(tr.selection)
const isRowSelection = type === 'row'
if (table) {
const map = TableMap.get(table.node)
// Check if the index is valid
if (index >= 0 && index < (isRowSelection ? map.height : map.width)) {
const lastCell = map.positionAt(
isRowSelection ? index : map.height - 1,
isRowSelection ? map.width - 1 : index,
table.node,
)
const $lastCell = tr.doc.resolve(table.start + lastCell)
// Check if the index is valid
if (index >= 0 && index < (isRowSelection ? map.height : map.width)) {
const lastCell = map.positionAt(
isRowSelection ? index : map.height - 1,
isRowSelection ? map.width - 1 : index,
table.node,
)
const $lastCell = tr.doc.resolve(table.start + lastCell)
const createCellSelection = isRowSelection ? CellSelection.rowSelection : CellSelection.colSelection
const createCellSelection = isRowSelection ? CellSelection.rowSelection : CellSelection.colSelection
const firstCell = map.positionAt(isRowSelection ? index : 0, isRowSelection ? 0 : index, table.node)
const $firstCell = tr.doc.resolve(table.start + firstCell)
return cloneTr(tr.setSelection(createCellSelection($lastCell, $firstCell) as unknown as Selection))
const firstCell = map.positionAt(isRowSelection ? index : 0, isRowSelection ? 0 : index, table.node)
const $firstCell = tr.doc.resolve(table.start + firstCell)
return cloneTr(tr.setSelection(createCellSelection($lastCell, $firstCell) as unknown as Selection))
}
}
return tr
}
return tr
}

@@ -184,3 +187,3 @@

const transpose = <T>(array: T[][]) => {
function transpose<T>(array: T[][]) {
return array[0]!.map((_, i) => {

@@ -191,3 +194,3 @@ return array.map(column => column[i])

const convertArrayOfRowsToTableNode = (tableNode: Node, arrayOfNodes: (Node | null)[][]) => {
function convertArrayOfRowsToTableNode(tableNode: Node, arrayOfNodes: (Node | null)[][]) {
const rowsPM = []

@@ -227,3 +230,3 @@ const map = TableMap.get(tableNode)

const convertTableNodeToArrayOfRows = (tableNode: Node) => {
function convertTableNodeToArrayOfRows(tableNode: Node) {
const map = TableMap.get(tableNode)

@@ -254,8 +257,3 @@ const rows: (Node | null)[][] = []

const moveRowInArrayOfRows = (
rows: (Node | null)[][],
indexesOrigin: number[],
indexesTarget: number[],
directionOverride: -1 | 1 | 0,
) => {
function moveRowInArrayOfRows(rows: (Node | null)[][], indexesOrigin: number[], indexesTarget: number[], directionOverride: -1 | 1 | 0) {
const direction = indexesOrigin[0]! > indexesTarget[0]! ? -1 : 1

@@ -284,8 +282,3 @@

const moveTableColumn = (
table: ContentNodeWithPos,
indexesOrigin: number[],
indexesTarget: number[],
direction: -1 | 1 | 0,
) => {
function moveTableColumn(table: ContentNodeWithPos, indexesOrigin: number[], indexesTarget: number[], direction: -1 | 1 | 0) {
let rows = transpose(convertTableNodeToArrayOfRows(table.node))

@@ -299,8 +292,3 @@

const moveTableRow = (
table: ContentNodeWithPos,
indexesOrigin: number[],
indexesTarget: number[],
direction: -1 | 1 | 0,
) => {
function moveTableRow(table: ContentNodeWithPos, indexesOrigin: number[], indexesTarget: number[], direction: -1 | 1 | 0) {
let rows = convertTableNodeToArrayOfRows(table.node)

@@ -313,3 +301,3 @@

const getSelectionRangeInColumn = (columnIndex: number, tr: Transaction) => {
function getSelectionRangeInColumn(columnIndex: number, tr: Transaction) {
let startIndex = columnIndex

@@ -379,3 +367,3 @@ let endIndex = columnIndex

const getSelectionRangeInRow = (rowIndex: number, tr: Transaction) => {
function getSelectionRangeInRow(rowIndex: number, tr: Transaction) {
let startIndex = rowIndex

@@ -382,0 +370,0 @@ let endIndex = rowIndex

@@ -39,6 +39,6 @@ /* Copyright 2021, Milkdown by Mirone. */

browser.safari
&& isInTable(state)
&& selection.empty
&& isParagraph($from.parent)
&& $from.parent.textContent.startsWith('\u2060')
&& isInTable(state)
&& selection.empty
&& isParagraph($from.parent)
&& $from.parent.textContent.startsWith('\u2060')
)

@@ -45,0 +45,0 @@ dispatch(tr.delete($from.start(), $from.start() + 1))

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

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