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

@milkdown/core

Package Overview
Dependencies
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@milkdown/core - npm Package Compare versions

Comparing version 4.6.4 to 4.6.5

lib/context/ctx.spec.d.ts

6

CHANGELOG.md
# @milkdown/core
## 4.6.5
### Patch Changes
- 58158e3: Add cursor package and fix config bug.
## 4.6.4

@@ -4,0 +10,0 @@

6

lib/context/index.js

@@ -1,9 +0,3 @@

// import type { Plugin as ProsemirrorPlugin } from 'prosemirror-state';
// import type { NodeView } from 'prosemirror-view';
// import type { Editor } from '../editor';
// import type { MarkViewParams, NodeViewParams } from '../utility';
// import { createCtx } from './container';
// export const prosePluginsCtx = createCtx<ProsemirrorPlugin[]>([]);
export * from './container';
export * from './ctx';
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

var _Editor_container, _Editor_ctx, _Editor_plugins, _Editor_configure, _Editor_pre, _Editor_loadInternal;
import { __awaiter, __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
var _Editor_container, _Editor_ctx, _Editor_plugins, _Editor_configureList, _Editor_pre, _Editor_loadInternal;
import { __awaiter, __classPrivateFieldGet } from "tslib";
import { createContainer } from '../context';

@@ -15,3 +15,3 @@ import { parser, schema, serializer, editorView, init, keymap, inputRules, config, nodeView, editorState, } from '../internal-plugin';

_Editor_plugins.set(this, new Set());
_Editor_configure.set(this, () => undefined);
_Editor_configureList.set(this, []);
this.inject = (meta, resetValue) => {

@@ -26,3 +26,6 @@ meta(__classPrivateFieldGet(this, _Editor_container, "f").contextMap, resetValue);

const internalPlugins = [schema, parser, serializer, nodeView, keymap, inputRules, editorState, editorView];
this.use(internalPlugins.concat(init(this)).concat(config(__classPrivateFieldGet(this, _Editor_configure, "f"))));
const configPlugin = config((x) => __awaiter(this, void 0, void 0, function* () {
yield Promise.all(__classPrivateFieldGet(this, _Editor_configureList, "f").map((fn) => fn(x)));
}));
this.use(internalPlugins.concat(init(this)).concat(configPlugin));
});

@@ -36,3 +39,3 @@ this.use = (plugins) => {

this.config = (configure) => {
__classPrivateFieldSet(this, _Editor_configure, configure, "f");
__classPrivateFieldGet(this, _Editor_configureList, "f").push(configure);
return this;

@@ -50,3 +53,3 @@ };

}
_Editor_container = new WeakMap(), _Editor_ctx = new WeakMap(), _Editor_plugins = new WeakMap(), _Editor_configure = new WeakMap(), _Editor_pre = new WeakMap(), _Editor_loadInternal = new WeakMap();
_Editor_container = new WeakMap(), _Editor_ctx = new WeakMap(), _Editor_plugins = new WeakMap(), _Editor_configureList = new WeakMap(), _Editor_pre = new WeakMap(), _Editor_loadInternal = new WeakMap();
//# sourceMappingURL=editor.js.map

2

lib/internal-plugin/input-rules.d.ts
import type { InputRule } from 'prosemirror-inputrules';
import type { MilkdownPlugin } from '../utility';
import { MilkdownPlugin } from '../utility';
export declare const inputRulesCtx: import("../context").Meta<InputRule<any>[]>;

@@ -4,0 +4,0 @@ export declare const InputRulesReady: {

@@ -5,2 +5,3 @@ import { __awaiter } from "tslib";

import { createTiming } from '../timing';
import { getAtom } from '../utility';
export const inputRulesCtx = createCtx([]);

@@ -15,15 +16,7 @@ export const InputRulesReady = createTiming('InputRulesReady');

const schema = ctx.get(schemaCtx);
const nodesInputRules = nodes.reduce((acc, cur) => {
const node = schema.nodes[cur.id];
if (!node || !cur.inputRules)
return acc;
return [...acc, ...cur.inputRules(node, schema)];
}, []);
const marksInputRules = marks.reduce((acc, cur) => {
const mark = schema.marks[cur.id];
if (!mark || !cur.inputRules)
return acc;
return [...acc, ...cur.inputRules(mark, schema)];
}, []);
const inputRules = [...nodesInputRules, ...marksInputRules];
const getInputRules = (atoms, isNode) => atoms
.map((x) => [getAtom(x.id, schema, isNode), x.inputRules])
.flatMap(([atom, inputRules]) => atom && (inputRules === null || inputRules === void 0 ? void 0 : inputRules(atom, schema)))
.filter((x) => !!x);
const inputRules = [...getInputRules(nodes, true), ...getInputRules(marks, false)];
ctx.set(inputRulesCtx, inputRules);

@@ -30,0 +23,0 @@ InputRulesReady.done();

@@ -1,4 +0,4 @@

import type { Plugin as ProsemirrorPlugin } from 'prosemirror-state';
import type { MilkdownPlugin } from '../utility';
export declare const keymapCtx: import("../context").Meta<ProsemirrorPlugin<any, any>[]>;
import type { Plugin as ProsePlugin } from 'prosemirror-state';
import { MilkdownPlugin } from '../utility';
export declare const keymapCtx: import("../context").Meta<ProsePlugin<any, any>[]>;
export declare const KeymapReady: {

@@ -5,0 +5,0 @@ (): Promise<unknown>;

@@ -6,2 +6,3 @@ import { __awaiter } from "tslib";

import { createTiming } from '../timing';
import { getAtom } from '../utility';
export const keymapCtx = createCtx([]);

@@ -16,19 +17,10 @@ export const KeymapReady = createTiming('KeymapReady');

const schema = ctx.get(schemaCtx);
const nodesKeymap = nodes.map((cur) => {
var _a;
const node = schema.nodes[cur.id];
if (!node)
throw new Error();
return (_a = cur.keymap) === null || _a === void 0 ? void 0 : _a.call(cur, node, schema);
});
const marksKeymap = marks.map((cur) => {
var _a;
const mark = schema.marks[cur.id];
if (!mark)
throw new Error();
return (_a = cur.keymap) === null || _a === void 0 ? void 0 : _a.call(cur, mark, schema);
});
const keymapList = [...nodesKeymap, ...marksKeymap]
.filter((keys) => Boolean(keys))
.map((keys) => proseKeymap(keys));
const getKeymap = (atoms, isNode) => atoms
.map((x) => [getAtom(x.id, schema, isNode), x.keymap])
.map(([atom, keymap]) => atom && (keymap === null || keymap === void 0 ? void 0 : keymap(atom, schema)))
.filter((x) => !!x)
.map(proseKeymap);
const nodesKeymap = getKeymap(nodes, true);
const marksKeymap = getKeymap(marks, false);
const keymapList = [...nodesKeymap, ...marksKeymap];
ctx.set(keymapCtx, keymapList);

@@ -35,0 +27,0 @@ KeymapReady.done();

@@ -1,5 +0,3 @@

import type { NodeView } from 'prosemirror-view';
import { MarkViewParams, NodeViewParams } from '..';
import { MilkdownPlugin } from '../utility';
export declare const nodeViewCtx: import("..").Meta<Record<string, (...args: NodeViewParams | MarkViewParams) => NodeView>>;
import { MilkdownPlugin, ProseView } from '../utility';
export declare const nodeViewCtx: import("..").Meta<Record<string, ProseView>>;
export declare const NodeViewReady: {

@@ -6,0 +4,0 @@ (): Promise<unknown>;

import { __awaiter } from "tslib";
import { fromPairs } from 'lodash-es';
import { createCtx } from '..';
import { createTiming } from '../timing';
import { getAtom } from '../utility';
import { editorCtx } from './init';

@@ -16,21 +18,11 @@ import { marksCtx, nodesCtx, schemaCtx, SchemaReady } from './schema';

const editor = ctx.get(editorCtx);
const nodeViewMap = nodes
.filter((node) => Boolean(node.view))
.reduce((acc, cur) => {
const { view } = cur;
const node = schema.nodes[cur.id];
if (!node || !view)
return acc;
return Object.assign(Object.assign({}, acc), { [cur.id]: (...args) => view(editor, node, ...args) });
}, {});
const markViewMap = marks
.filter((mark) => Boolean(mark.view))
.reduce((acc, cur) => {
const { view } = cur;
const mark = schema.marks[cur.id];
if (!mark || !view)
return acc;
return Object.assign(Object.assign({}, acc), { [cur.id]: (...args) => view(editor, mark, ...args) });
}, {});
const nodeView = Object.assign(Object.assign({}, nodeViewMap), markViewMap);
const getViewMap = (atoms, isNode) => atoms
.map((x) => [getAtom(x.id, schema, isNode), { view: x.view, id: x.id }])
.map(([atom, { id, view }]) => atom && view
? [id, ((...args) => view(editor, atom, ...args))]
: undefined)
.filter((x) => !!x);
const nodeViewMap = getViewMap(nodes, true);
const markViewMap = getViewMap(marks, false);
const nodeView = fromPairs([...nodeViewMap, ...markViewMap]);
ctx.set(nodeViewCtx, nodeView);

@@ -37,0 +29,0 @@ NodeViewReady.done();

import { __awaiter } from "tslib";
import { fromPairs } from 'lodash-es';
import re from 'remark';

@@ -6,3 +7,2 @@ import { createCtx } from '../context';

import { createTiming } from '../timing';
import { buildObject } from '../utility';
import { remarkPluginsCtx } from './remark-plugin-factory';

@@ -27,6 +27,3 @@ import { marksCtx, nodesCtx, schemaCtx, SchemaReady } from './schema';

];
const spec = buildObject(children, (child) => [
child.id,
Object.assign(Object.assign({}, child.parser), { is: child.is, key: child.id }),
]);
const spec = fromPairs(children.map(({ id, parser, is }) => [id, Object.assign(Object.assign({}, parser), { is, key: id })]));
ctx.set(parserCtx, createParser(schema, spec, processor));

@@ -33,0 +30,0 @@ ParserReady.done();

import { createCtx } from '..';
export const prosePluginsCtx = createCtx([]);
export const prosePluginFactory = (plugin) => () => (ctx) => {
const plugins = [plugin].flat();
ctx.update(prosePluginsCtx, (prev) => prev.concat(plugins));
ctx.update(prosePluginsCtx, (prev) => prev.concat([plugin].flat()));
};
//# sourceMappingURL=prose-plugin-factory.js.map
import { createCtx } from '..';
export const remarkPluginsCtx = createCtx([]);
export const remarkPluginFactory = (plugin) => () => (ctx) => {
const plugins = [plugin].flat();
ctx.update(remarkPluginsCtx, (prev) => prev.concat(plugins));
ctx.update(remarkPluginsCtx, (prev) => prev.concat([plugin].flat()));
};
//# sourceMappingURL=remark-plugin-factory.js.map
import { __awaiter } from "tslib";
import { fromPairs } from 'lodash-es';
import { marksCtx, nodesCtx, remarkCtx, schemaCtx, SchemaReady } from '..';

@@ -6,3 +7,2 @@ import { createCtx } from '../context';

import { createTiming } from '../timing';
import { buildObject } from '../utility';
export const serializerCtx = createCtx(() => '');

@@ -19,3 +19,3 @@ export const SerializerReady = createTiming('SerializerReady');

const children = [...nodes, ...marks];
const spec = buildObject(children, (child) => [child.id, child.serializer]);
const spec = fromPairs(children.map((child) => [child.id, child.serializer]));
ctx.set(serializerCtx, createSerializer(schema, spec, remark));

@@ -22,0 +22,0 @@ SerializerReady.done();

import { Mark } from 'prosemirror-model';
import { maybeMerge } from '../utility/prosemirror';
import { maybeMerge, getStackUtil } from '../utility';
import { createElement } from './stack-element';
const size = (ctx) => ctx.elements.length;
const top = (ctx) => ctx.elements[size(ctx) - 1];
const push = (ctx) => (node) => { var _a; return (_a = top(ctx)) === null || _a === void 0 ? void 0 : _a.push(node); };
const openNode = (ctx) => (nodeType, attrs) => ctx.elements.push(createElement(nodeType, [], attrs));
const { size, push, top, open, close } = getStackUtil();
const openNode = (ctx) => (nodeType, attrs) => open(ctx)(createElement(nodeType, [], attrs));
const addNode = (ctx) => (nodeType, attrs, content) => {

@@ -17,5 +15,3 @@ const node = nodeType.createAndFill(attrs, content, ctx.marks);

ctx.marks = Mark.none;
const element = ctx.elements.pop();
if (!element)
throw new Error();
const element = close(ctx);
return addNode(ctx)(element.type, element.attrs, element.content);

@@ -22,0 +18,0 @@ };

import { createElement } from './stack-element';
import { getStackUtil } from '../utility';
const { size, push, top, open, close } = getStackUtil();
const createMarkdownNode = (element) => {

@@ -12,6 +14,3 @@ const node = Object.assign(Object.assign({}, element.props), { type: element.type });

};
const size = (ctx) => ctx.elements.length;
const top = (ctx) => ctx.elements[size(ctx) - 1];
const push = (ctx) => (node) => { var _a; return (_a = top(ctx)) === null || _a === void 0 ? void 0 : _a.push(node); };
const openNode = (ctx) => (type, value, props) => ctx.elements.push(createElement(type, [], value, props));
const openNode = (ctx) => (type, value, props) => open(ctx)(createElement(type, [], value, props));
const addNode = (ctx) => (type, children, value, props) => {

@@ -24,5 +23,3 @@ const element = createElement(type, children, value, props);

const closeNode = (ctx) => () => {
const element = ctx.elements.pop();
if (!element)
throw new Error();
const element = close(ctx);
return addNode(ctx)(element.type, element.children, element.value, element.props);

@@ -29,0 +26,0 @@ };

@@ -1,4 +0,4 @@

export * from './build-object';
export * from './prosemirror';
export * from './types';
export * from './stack';
//# sourceMappingURL=index.d.ts.map

@@ -1,4 +0,4 @@

export * from './build-object';
export * from './prosemirror';
export * from './types';
export * from './stack';
//# sourceMappingURL=index.js.map

@@ -13,4 +13,13 @@ import type { Editor } from '../editor';

export declare type MarkViewParams = [mark: Mark, view: EditorView, getPos: boolean, decorations: Decoration[]];
export declare type ViewParams = [
atom: Node | Mark,
view: EditorView,
getPos: () => number | boolean,
decorations: Decoration[]
];
export declare type NodeViewFactory = (editor: Editor, nodeType: NodeType, ...params: NodeViewParams) => NodeView;
export declare type MarkViewFactory = (editor: Editor, markType: MarkType, ...params: MarkViewParams) => NodeView;
export declare type ViewFactory = (editor: Editor, atomType: NodeType | MarkType, ...params: ViewParams) => NodeView;
export declare type ProseView = (...args: NodeViewParams | MarkViewParams) => NodeView;
export declare const getAtom: (id: string, schema: Schema, isNode: boolean) => (NodeType<any> & MarkType<any>) | undefined;
//# sourceMappingURL=prosemirror.d.ts.map

@@ -9,2 +9,3 @@ import { Mark } from 'prosemirror-model';

};
export const getAtom = (id, schema, isNode) => schema[isNode ? 'nodes' : 'marks'][id];
//# sourceMappingURL=prosemirror.js.map
{
"name": "@milkdown/core",
"version": "4.6.4",
"version": "4.6.5",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "module": "lib/index.js",

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

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

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

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

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

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

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