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

@milkdown/plugin-table

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@milkdown/plugin-table - npm Package Compare versions

Comparing version 4.5.3 to 4.6.0

11

CHANGELOG.md
# @milkdown/plugin-table
## 4.6.0
### Minor Changes
- e1fbf79: Refactor the plugin system to functional plugin for better extension ability.
### Patch Changes
- Updated dependencies [e1fbf79]
- @milkdown/utils@4.6.0
## 4.5.3

@@ -4,0 +15,0 @@

8

lib/index.d.ts

@@ -1,7 +0,7 @@

export declare const remarkGFMPlugin: import("@milkdown/core").Atom<import("@milkdown/core").LoadState, import("@milkdown/core").AnyRecord, import("@milkdown/core").IdleContext | import("@milkdown/core").SchemaReadyContext | import("@milkdown/core").LoadPluginContext | import("@milkdown/core").CompleteContext, import("@milkdown/core").IdleContext | import("@milkdown/core").SchemaReadyContext | import("@milkdown/core").LoadPluginContext | import("@milkdown/core").CompleteContext>;
export declare const tableEditPlugin: import("@milkdown/core").Atom<import("@milkdown/core").LoadState, import("@milkdown/core").AnyRecord, import("@milkdown/core").IdleContext | import("@milkdown/core").SchemaReadyContext | import("@milkdown/core").LoadPluginContext | import("@milkdown/core").CompleteContext, import("@milkdown/core").IdleContext | import("@milkdown/core").SchemaReadyContext | import("@milkdown/core").LoadPluginContext | import("@milkdown/core").CompleteContext>;
export declare const tablePlugin: import("@milkdown/core").Atom<import("@milkdown/core").LoadState, import("@milkdown/core").AnyRecord, import("@milkdown/core").IdleContext | import("@milkdown/core").SchemaReadyContext | import("@milkdown/core").LoadPluginContext | import("@milkdown/core").CompleteContext, import("@milkdown/core").IdleContext | import("@milkdown/core").SchemaReadyContext | import("@milkdown/core").LoadPluginContext | import("@milkdown/core").CompleteContext>[];
export declare const table: import("@milkdown/core").Atom<import("@milkdown/core").LoadState, import("@milkdown/core").AnyRecord, import("@milkdown/core").IdleContext | import("@milkdown/core").SchemaReadyContext | import("@milkdown/core").LoadPluginContext | import("@milkdown/core").CompleteContext, import("@milkdown/core").IdleContext | import("@milkdown/core").SchemaReadyContext | import("@milkdown/core").LoadPluginContext | import("@milkdown/core").CompleteContext>[];
export declare const remarkGFMPlugin: import("@milkdown/core").MilkdownPlugin;
export declare const tableEditPlugin: import("@milkdown/core").MilkdownPlugin;
export declare const tablePlugins: import("@milkdown/core").MilkdownPlugin[];
export declare const table: import("@milkdown/core").MilkdownPlugin[];
export * from './nodes';
export * from './utils';
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

import { createProsemirrorPlugin, createRemarkPlugin } from '@milkdown/core';
import { prosePluginFactory, remarkPluginFactory } from '@milkdown/core';
import { columnResizing, tableEditing } from 'prosemirror-tables';

@@ -6,12 +6,8 @@ import gfm from 'remark-gfm';

import { tableOperatorPlugin } from './table-operator-plugin';
export const remarkGFMPlugin = createRemarkPlugin('remark-table-markdown', () => [gfm]);
export const tableEditPlugin = createProsemirrorPlugin('prosemirror-table-edit', () => [
columnResizing({}),
tableOperatorPlugin(),
tableEditing(),
]);
export const tablePlugin = [remarkGFMPlugin, tableEditPlugin];
export const table = [...tablePlugin, ...tableNodes];
export const remarkGFMPlugin = remarkPluginFactory(gfm);
export const tableEditPlugin = prosePluginFactory([columnResizing({}), tableOperatorPlugin(), tableEditing()]);
export const tablePlugins = [remarkGFMPlugin, tableEditPlugin];
export const table = [...tablePlugins, ...tableNodes];
export * from './nodes';
export * from './utils';
//# sourceMappingURL=index.js.map

@@ -1,44 +0,15 @@

import { Atom, Node, NodeParserSpec, NodeSerializerSpec } from '@milkdown/core';
import { NodeSpec, NodeType, Schema } from 'prosemirror-model';
import { InputRule } from 'prosemirror-inputrules';
import { BaseNode } from './base-node';
export declare enum SupportedKeys {
NextCell = "NextCell",
PrevCell = "PrevCell",
ExitTable = "ExitTable"
}
declare type Keys = SupportedKeys.NextCell | SupportedKeys.PrevCell | SupportedKeys.ExitTable;
export declare class Table extends BaseNode<Keys> {
readonly id = "table";
readonly schema: NodeSpec;
readonly parser: NodeParserSpec;
readonly serializer: NodeSerializerSpec;
inputRules: (nodeType: NodeType, schema: Schema) => InputRule[];
readonly commands: BaseNode<Keys>['commands'];
}
export declare class TableRow extends Node {
id: string;
schema: NodeSpec;
parser: NodeParserSpec;
serializer: NodeSerializerSpec;
}
export declare class TableCell extends Node {
id: string;
schema: NodeSpec;
parser: NodeParserSpec;
serializer: NodeSerializerSpec;
}
export declare class TableHeader extends Node {
id: string;
schema: NodeSpec;
parser: NodeParserSpec;
serializer: NodeSerializerSpec;
}
declare type ConstructorOf<T> = T extends InstanceType<infer U> ? U : T;
declare class NodeList<T extends Atom = Atom> extends Array<T> {
configure<U extends ConstructorOf<T>>(Target: U, config: ConstructorParameters<U>[0]): this;
static create<T extends Atom = Atom>(from: T[]): NodeList;
}
export declare const tableNodes: NodeList<Atom<import("@milkdown/core").LoadState, import("@milkdown/core").AnyRecord, import("@milkdown/core").IdleContext | import("@milkdown/core").SchemaReadyContext | import("@milkdown/core").LoadPluginContext | import("@milkdown/core").CompleteContext, import("@milkdown/core").IdleContext | import("@milkdown/core").SchemaReadyContext | import("@milkdown/core").LoadPluginContext | import("@milkdown/core").CompleteContext>>;
export {};
import { AtomList } from '@milkdown/utils';
export declare const SupportedKeys: {
readonly NextCell: "NextCell";
readonly PrevCell: "PrevCell";
readonly ExitTable: "ExitTable";
};
export declare type SupportedKeys = typeof SupportedKeys;
export declare const table: import("@milkdown/utils/lib/atom/types").Origin<"Node", "NextCell" | "PrevCell" | "ExitTable", import("@milkdown/utils/lib/type-utility").UnknownRecord>;
export declare const tableRow: import("@milkdown/utils/lib/atom/types").Origin<"Node", string, import("@milkdown/utils/lib/type-utility").UnknownRecord>;
export declare const tableCell: import("@milkdown/utils/lib/atom/types").Origin<"Node", string, import("@milkdown/utils/lib/type-utility").UnknownRecord>;
export declare const tableHeader: import("@milkdown/utils/lib/atom/types").Origin<"Node", string, import("@milkdown/utils/lib/type-utility").UnknownRecord>;
export declare const tableNodes: AtomList<import("@milkdown/core").MilkdownPlugin & {
origin: import("@milkdown/utils/lib/atom/types").Origin<"Node" | "Mark", string, import("@milkdown/utils/lib/type-utility").UnknownRecord>;
}>;
//# sourceMappingURL=nodes.d.ts.map

@@ -1,8 +0,7 @@

import { Node } from '@milkdown/core';
import { tableNodes as tableNodesSpecCreator, goToNextCell } from 'prosemirror-tables';
import { AtomList, createNode } from '@milkdown/utils';
import { InputRule } from 'prosemirror-inputrules';
import { TextSelection } from 'prosemirror-state';
import { goToNextCell, tableNodes as tableNodesSpecCreator } from 'prosemirror-tables';
import { exitTable } from './command';
import { createTable } from './utils';
import { BaseNode } from './base-node';
import { exitTable } from './command';
const tableNodesSpec = tableNodesSpecCreator({

@@ -21,14 +20,13 @@ tableGroup: 'block',

});
export var SupportedKeys;
(function (SupportedKeys) {
SupportedKeys["NextCell"] = "NextCell";
SupportedKeys["PrevCell"] = "PrevCell";
SupportedKeys["ExitTable"] = "ExitTable";
})(SupportedKeys || (SupportedKeys = {}));
export class Table extends BaseNode {
constructor() {
super(...arguments);
this.id = 'table';
this.schema = tableNodesSpec.table;
this.parser = {
export const SupportedKeys = {
NextCell: 'NextCell',
PrevCell: 'PrevCell',
ExitTable: 'ExitTable',
};
export const table = createNode(() => {
const id = 'table';
return {
id,
schema: tableNodesSpec.table,
parser: {
match: (node) => node.type === 'table',

@@ -42,5 +40,5 @@ runner: (state, node, type) => {

},
};
this.serializer = {
match: (node) => node.type.name === this.id,
},
serializer: {
match: (node) => node.type.name === id,
runner: (state, node) => {

@@ -59,4 +57,4 @@ var _a;

},
};
this.inputRules = (nodeType, schema) => [
},
inputRules: (nodeType, schema) => [
new InputRule(/^\|\|\s$/, (state, _match, start, end) => {

@@ -70,4 +68,4 @@ const $start = state.doc.resolve(start);

}),
];
this.commands = (_, schema) => ({
],
commands: (_, schema) => ({
[SupportedKeys.NextCell]: {

@@ -85,11 +83,11 @@ defaultKey: 'Mod-]',

},
});
}
}
export class TableRow extends Node {
constructor() {
super(...arguments);
this.id = 'table_row';
this.schema = tableNodesSpec.table_row;
this.parser = {
}),
};
});
export const tableRow = createNode(() => {
const id = 'table_row';
return {
id,
schema: tableNodesSpec.table_row,
parser: {
match: (node) => node.type === 'tableRow',

@@ -103,5 +101,5 @@ runner: (state, node, type) => {

},
};
this.serializer = {
match: (node) => node.type.name === this.id,
},
serializer: {
match: (node) => node.type.name === id,
runner: (state, node) => {

@@ -112,11 +110,11 @@ state.openNode('tableRow');

},
};
}
}
export class TableCell extends Node {
constructor() {
super(...arguments);
this.id = 'table_cell';
this.schema = tableNodesSpec.table_cell;
this.parser = {
},
};
});
export const tableCell = createNode(() => {
const id = 'table_cell';
return {
id,
schema: tableNodesSpec.table_cell,
parser: {
match: (node) => node.type === 'tableCell' && !node.isHeader,

@@ -132,17 +130,17 @@ runner: (state, node, type) => {

},
};
this.serializer = {
match: (node) => node.type.name === this.id,
},
serializer: {
match: (node) => node.type.name === id,
runner: (state, node) => {
state.openNode('tableCell').next(node.content).closeNode();
},
};
}
}
export class TableHeader extends Node {
constructor() {
super(...arguments);
this.id = 'table_header';
this.schema = tableNodesSpec.table_header;
this.parser = {
},
};
});
export const tableHeader = createNode(() => {
const id = 'table_header';
return {
id,
schema: tableNodesSpec.table_header,
parser: {
match: (node) => node.type === 'tableCell' && !!node.isHeader,

@@ -157,5 +155,5 @@ runner: (state, node, type) => {

},
};
this.serializer = {
match: (node) => node.type.name === this.id,
},
serializer: {
match: (node) => node.type.name === id,
runner: (state, node) => {

@@ -166,18 +164,6 @@ state.openNode('tableCell');

},
};
}
}
class NodeList extends Array {
configure(Target, config) {
const index = this.findIndex((x) => x.constructor === Target);
if (index < 0)
return this;
this.splice(index, 1, new Target(config));
return this;
}
static create(from) {
return new NodeList(...from);
}
}
export const tableNodes = NodeList.create([new Table(), new TableRow(), new TableCell(), new TableHeader()]);
},
};
});
export const tableNodes = AtomList.create([table(), tableRow(), tableCell(), tableHeader()]);
//# sourceMappingURL=nodes.js.map
{
"name": "@milkdown/plugin-table",
"version": "4.5.3",
"version": "4.6.0",
"main": "lib/index.js",

@@ -11,18 +11,6 @@ "module": "lib/index.js",

"peerDependencies": {
"@milkdown/core": "*",
"@types/prosemirror-commands": "*",
"@types/prosemirror-inputrules": "*",
"@types/prosemirror-keymap": "*",
"@types/prosemirror-model": "*",
"@types/prosemirror-state": "*",
"@types/prosemirror-view": "*",
"prosemirror-commands": "*",
"prosemirror-inputrules": "*",
"prosemirror-keymap": "*",
"prosemirror-model": "*",
"prosemirror-state": "*",
"prosemirror-view": "*"
"@milkdown/core": "*"
},
"dependencies": {
"@milkdown/utils": "4.5.3",
"@milkdown/utils": "4.6.0",
"prosemirror-tables": "*",

@@ -33,3 +21,2 @@ "remark-gfm": "^1.0.0",

"devDependencies": {
"@milkdown/core": "4.5.3",
"concurrently": "^6.0.2"

@@ -40,6 +27,8 @@ },

"watch": "concurrently -n ts,css \"tsc -w\" \"postcss style/style.css --watch --verbose -o lib/style.css\"",
"watch:css": "postcss style/style.css --watch --verbose -o lib/style.css",
"test": "jest",
"tsc": "tsc --noEmit",
"build": "tsc && postcss style/style.css --verbose -o lib/style.css"
"build": "tsc && postcss style/style.css --verbose -o lib/style.css",
"build:css": "postcss style/style.css --verbose -o lib/style.css"
}
}

@@ -20,4 +20,3 @@ # @milkdown/plugin-table

const root = document.body;
new Editor({ root }).use(commonmark).use(table).create();
new Editor().use(commonmark).use(table).create();
```

@@ -28,11 +27,10 @@

```typescript
import { tableNodes, tablePlugin, SupportedKeys, Table } from '@milkdown/plugin-table';
import { tableNodes, tablePlugin, SupportedKeys, table } from '@milkdown/plugin-table';
// import style
import '@milkdown/plugin-table/lib/style.css';
const root = document.body;
new Editor({ root })
new Editor()
.use(commonmark)
.use(
tableNodes.configure(Table, {
tableNodes.configure(table, {
keymap: {

@@ -39,0 +37,0 @@ [SupportedKeys.NextCell]: 'Enter',

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