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.6 to 4.6.7

6

CHANGELOG.md
# @milkdown/core
## 4.6.7
### Patch Changes
- c0a50be: Bug fix for CRA.
## 4.6.6

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

20

lib/context/ctx.spec.js
import { createCtx } from './ctx';
test('createCtx', () => {
test('primitive ctx', () => {
const factory = createCtx(0);

@@ -7,3 +7,21 @@ const map = new Map();

expect(ctx.get()).toBe(0);
ctx.set(20);
expect(ctx.get()).toBe(20);
ctx.update((x) => x + 1);
expect(ctx.get()).toBe(21);
});
test('structure ctx', () => {
const factory = createCtx([]);
const map1 = new Map();
const ctx1 = factory(map1);
const map2 = new Map();
const ctx2 = factory(map2);
expect(ctx1.get()).toEqual([]);
ctx1.set([1]);
expect(ctx1.get()).toEqual([1]);
expect(ctx2.get()).toEqual([]);
ctx1.update((x) => x.concat(3));
expect(ctx1.get()).toEqual([1, 3]);
expect(ctx2.get()).toEqual([]);
});
//# sourceMappingURL=ctx.spec.js.map

4

lib/editor/editor.d.ts
import { Meta } from '../context';
import { Timer } from '../timing';
import { Configure, Ctx, MilkdownPlugin, Pre } from '../utility';

@@ -6,7 +7,8 @@ export declare class Editor {

inject: <T>(meta: Meta<T>, resetValue?: T | undefined) => Pre;
record: (timingMeta: Timer) => Pre;
use: (plugins: MilkdownPlugin | MilkdownPlugin[]) => this;
create: () => Promise<this>;
config: (configure: Configure) => this;
create: () => Promise<this>;
action: <T>(action: (ctx: Ctx) => T) => T;
}
//# sourceMappingURL=editor.d.ts.map

@@ -1,8 +0,10 @@

var _Editor_container, _Editor_ctx, _Editor_plugins, _Editor_configureList, _Editor_pre, _Editor_loadInternal;
var _Editor_container, _Editor_clock, _Editor_ctx, _Editor_plugins, _Editor_pre, _Editor_loadInternal, _Editor_configureList;
import { __awaiter, __classPrivateFieldGet } from "tslib";
import { createContainer } from '../context';
import { parser, schema, serializer, editorView, init, keymap, inputRules, config, nodeView, editorState, } from '../internal-plugin';
import { createClock } from '../timing';
export class Editor {
constructor() {
_Editor_container.set(this, createContainer());
_Editor_clock.set(this, createClock());
_Editor_ctx.set(this, {

@@ -13,5 +15,6 @@ use: __classPrivateFieldGet(this, _Editor_container, "f").getCtx,

update: (meta, updater) => __classPrivateFieldGet(this, _Editor_container, "f").getCtx(meta).update(updater),
wait: (timer) => __classPrivateFieldGet(this, _Editor_clock, "f").get(timer)(),
done: (timer) => __classPrivateFieldGet(this, _Editor_clock, "f").get(timer).done(),
});
_Editor_plugins.set(this, new Set());
_Editor_configureList.set(this, []);
this.inject = (meta, resetValue) => {

@@ -21,5 +24,16 @@ meta(__classPrivateFieldGet(this, _Editor_container, "f").contextMap, resetValue);

};
this.record = (timingMeta) => {
timingMeta(__classPrivateFieldGet(this, _Editor_clock, "f").store);
return __classPrivateFieldGet(this, _Editor_pre, "f");
};
_Editor_pre.set(this, {
inject: this.inject,
record: this.record,
});
this.use = (plugins) => {
[plugins].flat().forEach((plugin) => {
__classPrivateFieldGet(this, _Editor_plugins, "f").add(plugin(__classPrivateFieldGet(this, _Editor_pre, "f")));
});
return this;
};
_Editor_loadInternal.set(this, () => {

@@ -32,12 +46,2 @@ const internalPlugins = [schema, parser, serializer, nodeView, keymap, inputRules, editorState, editorView];

});
this.use = (plugins) => {
[plugins].flat().forEach((plugin) => {
__classPrivateFieldGet(this, _Editor_plugins, "f").add(plugin(__classPrivateFieldGet(this, _Editor_pre, "f")));
});
return this;
};
this.config = (configure) => {
__classPrivateFieldGet(this, _Editor_configureList, "f").push(configure);
return this;
};
this.create = () => __awaiter(this, void 0, void 0, function* () {

@@ -50,6 +54,11 @@ __classPrivateFieldGet(this, _Editor_loadInternal, "f").call(this);

});
_Editor_configureList.set(this, []);
this.config = (configure) => {
__classPrivateFieldGet(this, _Editor_configureList, "f").push(configure);
return this;
};
this.action = (action) => action(__classPrivateFieldGet(this, _Editor_ctx, "f"));
}
}
_Editor_container = new WeakMap(), _Editor_ctx = new WeakMap(), _Editor_plugins = new WeakMap(), _Editor_configureList = new WeakMap(), _Editor_pre = new WeakMap(), _Editor_loadInternal = new WeakMap();
_Editor_container = new WeakMap(), _Editor_clock = new WeakMap(), _Editor_ctx = new WeakMap(), _Editor_plugins = new WeakMap(), _Editor_pre = new WeakMap(), _Editor_loadInternal = new WeakMap(), _Editor_configureList = new WeakMap();
//# sourceMappingURL=editor.js.map
import { Configure, MilkdownPlugin } from '../utility';
export declare const Config: {
(): Promise<unknown>;
done(): void;
};
export declare const Config: import("../timing").Timer;
export declare const config: (configure: Configure) => MilkdownPlugin;
//# sourceMappingURL=config.d.ts.map
import { __awaiter } from "tslib";
import { createTiming } from '../timing';
export const Config = createTiming('Config');
export const config = (configure) => () => (ctx) => __awaiter(void 0, void 0, void 0, function* () {
yield configure(ctx);
Config.done();
});
import { createTimer } from '../timing';
export const Config = createTimer('Config');
export const config = (configure) => (pre) => {
pre.record(Config);
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
yield configure(ctx);
ctx.done(Config);
});
};
//# sourceMappingURL=config.js.map
import { Node, Schema } from 'prosemirror-model';
import { EditorState } from 'prosemirror-state';
import { Timer } from '../timing';
import { AnyRecord, MilkdownPlugin } from '../utility';

@@ -11,5 +12,5 @@ declare type DefaultValue = string | {

};
export declare const defaultValueCtx: import("..").Meta<DefaultValue>;
export declare const editorStateCtx: import("..").Meta<EditorState<any>>;
export declare const editorStateOptionsCtx: import("..").Meta<{
export declare const defaultValueCtx: import("../context").Meta<DefaultValue>;
export declare const editorStateCtx: import("../context").Meta<EditorState<any>>;
export declare const editorStateOptionsCtx: import("../context").Meta<{
schema?: Schema<any, any> | null | undefined;

@@ -21,8 +22,6 @@ doc?: Node<Schema<any, any>> | null | undefined;

}>;
export declare const StateReady: {
(): Promise<unknown>;
done(): void;
};
export declare const editorStateTimerCtx: import("../context").Meta<Timer[]>;
export declare const StateReady: Timer;
export declare const editorState: MilkdownPlugin;
export {};
//# sourceMappingURL=editor-state.d.ts.map

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

import { keymap as createKeymap } from 'prosemirror-keymap';
import { Node, DOMParser } from 'prosemirror-model';
import { DOMParser, Node } from 'prosemirror-model';
import { EditorState } from 'prosemirror-state';
import { createCtx, inputRulesCtx } from '..';
import { createTiming } from '../timing';
import { InputRulesReady } from './input-rules';
import { createCtx } from '../context';
import { createTimer } from '../timing';
import { inputRulesCtx, InputRulesReady } from './input-rules';
import { keymapCtx, KeymapReady } from './keymap';

@@ -19,3 +19,4 @@ import { parserCtx, ParserReady } from './parser';

export const editorStateOptionsCtx = createCtx({});
export const StateReady = createTiming('StateReady');
export const editorStateTimerCtx = createCtx([]);
export const StateReady = createTimer('StateReady');
const getDoc = (defaultValue, parser, schema) => {

@@ -34,5 +35,9 @@ if (typeof defaultValue === 'string') {

export const editorState = (pre) => {
pre.inject(defaultValueCtx).inject(editorStateCtx).inject(editorStateOptionsCtx);
pre.inject(defaultValueCtx)
.inject(editorStateCtx)
.inject(editorStateOptionsCtx)
.inject(editorStateTimerCtx, [KeymapReady, InputRulesReady, ParserReady, SerializerReady])
.record(StateReady);
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
yield Promise.all([KeymapReady(), InputRulesReady(), ParserReady(), SerializerReady()]);
yield Promise.all(ctx.get(editorStateTimerCtx).map((x) => ctx.wait(x)));
const schema = ctx.get(schemaCtx);

@@ -47,5 +52,5 @@ const parser = ctx.get(parserCtx);

ctx.set(editorStateCtx, state);
StateReady.done();
ctx.done(StateReady);
});
};
//# sourceMappingURL=editor-state.js.map
import { EditorView } from 'prosemirror-view';
import { Timer } from '../timing';
import { MilkdownPlugin } from '../utility';
declare type EditorOptions = Omit<ConstructorParameters<typeof EditorView>[1], 'state'>;
export declare const editorViewCtx: import("..").Meta<EditorView<any>>;
export declare const editorViewOptionsCtx: import("..").Meta<EditorOptions>;
export declare const rootCtx: import("..").Meta<Node>;
export declare const Complete: {
(): Promise<unknown>;
done(): void;
};
export declare const editorViewCtx: import("../context").Meta<EditorView<any>>;
export declare const editorViewOptionsCtx: import("../context").Meta<EditorOptions>;
export declare const rootCtx: import("../context").Meta<Node>;
export declare const editorViewTimerCtx: import("../context").Meta<Timer[]>;
export declare const Complete: Timer;
export declare const editorView: MilkdownPlugin;
export {};
//# sourceMappingURL=editor-view.d.ts.map
import { __awaiter } from "tslib";
import { EditorView } from 'prosemirror-view';
import { createCtx } from '..';
import { createTiming } from '../timing';
import { createCtx } from '../context';
import { createTimer } from '../timing';
import { editorStateCtx, StateReady } from './editor-state';

@@ -10,3 +10,4 @@ import { nodeViewCtx, NodeViewReady } from './node-view';

export const rootCtx = createCtx(document.body);
export const Complete = createTiming('complete');
export const editorViewTimerCtx = createCtx([]);
export const Complete = createTimer('complete');
const createViewContainer = (root) => {

@@ -23,5 +24,9 @@ const container = document.createElement('div');

export const editorView = (pre) => {
pre.inject(rootCtx, document.body).inject(editorViewCtx).inject(editorViewOptionsCtx);
pre.inject(rootCtx, document.body)
.inject(editorViewCtx)
.inject(editorViewOptionsCtx)
.inject(editorViewTimerCtx, [StateReady, NodeViewReady])
.record(Complete);
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
yield Promise.all([StateReady(), NodeViewReady()]);
yield Promise.all(ctx.get(editorViewTimerCtx).map((x) => ctx.wait(x)));
const state = ctx.get(editorStateCtx);

@@ -35,5 +40,5 @@ const options = ctx.get(editorViewOptionsCtx);

ctx.set(editorViewCtx, view);
Complete.done();
ctx.done(Complete);
});
};
//# sourceMappingURL=editor-view.js.map
import type { MilkdownPlugin } from '../utility';
import type { Editor } from '..';
export declare const Initialize: {
(): Promise<unknown>;
done(): void;
};
export declare const editorCtx: import("..").Meta<Editor>;
import { Timer } from '../timing';
import type { Editor } from '../editor';
export declare const Initialize: Timer;
export declare const initTimerCtx: import("../context").Meta<Timer[]>;
export declare const editorCtx: import("../context").Meta<Editor>;
export declare const init: (editor: Editor) => MilkdownPlugin;
//# sourceMappingURL=init.d.ts.map
import { __awaiter } from "tslib";
import { createTiming } from '../timing';
import { SchemaReady } from '.';
import { createTimer } from '../timing';
import { Config } from './config';
import { Complete } from './editor-view';
import { createCtx } from '..';
import { createCtx } from '../context';
import { prosePluginsCtx } from './prose-plugin-factory';
import { remarkPluginsCtx } from './remark-plugin-factory';
export const Initialize = createTiming('Initialize');
export const Initialize = createTimer('Initialize');
export const initTimerCtx = createCtx([]);
export const editorCtx = createCtx({});
export const init = (editor) => (pre) => {
pre.inject(editorCtx, editor).inject(prosePluginsCtx).inject(remarkPluginsCtx);
return () => __awaiter(void 0, void 0, void 0, function* () {
yield Config();
Initialize.done();
yield SchemaReady();
yield Complete();
pre.inject(editorCtx, editor)
.inject(prosePluginsCtx)
.inject(remarkPluginsCtx)
.inject(initTimerCtx, [Config])
.record(Initialize);
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
yield Promise.all(ctx.get(initTimerCtx).map((x) => ctx.wait(x)));
ctx.done(Initialize);
});
};
//# sourceMappingURL=init.js.map
import type { InputRule } from 'prosemirror-inputrules';
import { Timer } from '../timing';
import { MilkdownPlugin } from '../utility';
export declare const inputRulesCtx: import("../context").Meta<InputRule<any>[]>;
export declare const InputRulesReady: {
(): Promise<unknown>;
done(): void;
};
export declare const inputRulesTimerCtx: import("../context").Meta<Timer[]>;
export declare const InputRulesReady: Timer;
export declare const inputRules: MilkdownPlugin;
//# sourceMappingURL=input-rules.d.ts.map
import { __awaiter } from "tslib";
import { createCtx } from '../context';
import { marksCtx, nodesCtx, schemaCtx, SchemaReady } from '../internal-plugin';
import { createTiming } from '../timing';
import { createTimer } from '../timing';
import { getAtom } from '../utility';
export const inputRulesCtx = createCtx([]);
export const InputRulesReady = createTiming('InputRulesReady');
export const inputRulesTimerCtx = createCtx([]);
export const InputRulesReady = createTimer('InputRulesReady');
export const inputRules = (pre) => {
pre.inject(inputRulesCtx);
pre.inject(inputRulesCtx).inject(inputRulesTimerCtx, [SchemaReady]).record(InputRulesReady);
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
yield SchemaReady();
yield Promise.all(ctx.get(inputRulesTimerCtx).map((x) => ctx.wait(x)));
const nodes = ctx.get(nodesCtx);

@@ -21,5 +22,5 @@ const marks = ctx.get(marksCtx);

ctx.set(inputRulesCtx, inputRules);
InputRulesReady.done();
ctx.done(InputRulesReady);
});
};
//# sourceMappingURL=input-rules.js.map
import type { Plugin as ProsePlugin } from 'prosemirror-state';
import { Timer } from '../timing';
import { MilkdownPlugin } from '../utility';
export declare const keymapCtx: import("../context").Meta<ProsePlugin<any, any>[]>;
export declare const KeymapReady: {
(): Promise<unknown>;
done(): void;
};
export declare const keymapTimerCtx: import("../context").Meta<Timer[]>;
export declare const KeymapReady: Timer;
export declare const keymap: MilkdownPlugin;
//# sourceMappingURL=keymap.d.ts.map

@@ -5,10 +5,11 @@ import { __awaiter } from "tslib";

import { marksCtx, nodesCtx, schemaCtx, SchemaReady } from '../internal-plugin';
import { createTiming } from '../timing';
import { createTimer } from '../timing';
import { getAtom } from '../utility';
export const keymapCtx = createCtx([]);
export const KeymapReady = createTiming('KeymapReady');
export const keymapTimerCtx = createCtx([]);
export const KeymapReady = createTimer('KeymapReady');
export const keymap = (pre) => {
pre.inject(keymapCtx);
pre.inject(keymapCtx).inject(keymapTimerCtx, [SchemaReady]).record(KeymapReady);
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
yield SchemaReady();
yield Promise.all(ctx.get(keymapTimerCtx).map((x) => ctx.wait(x)));
const nodes = ctx.get(nodesCtx);

@@ -26,5 +27,5 @@ const marks = ctx.get(marksCtx);

ctx.set(keymapCtx, keymapList);
KeymapReady.done();
ctx.done(KeymapReady);
});
};
//# sourceMappingURL=keymap.js.map

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

import { Timer } from '../timing';
import { MilkdownPlugin, ProseView } from '../utility';
export declare const nodeViewCtx: import("..").Meta<Record<string, ProseView>>;
export declare const NodeViewReady: {
(): Promise<unknown>;
done(): void;
};
export declare const nodeViewCtx: import("../context").Meta<Record<string, ProseView>>;
export declare const nodeViewTimerCtx: import("../context").Meta<Timer[]>;
export declare const NodeViewReady: Timer;
export declare const nodeView: MilkdownPlugin;
//# sourceMappingURL=node-view.d.ts.map
import { __awaiter } from "tslib";
import { fromPairs } from 'lodash-es';
import { createCtx } from '..';
import { createTiming } from '../timing';
import { createCtx } from '../context';
import { createTimer } from '../timing';
import { getAtom } from '../utility';

@@ -9,7 +9,8 @@ import { editorCtx } from './init';

export const nodeViewCtx = createCtx({});
export const NodeViewReady = createTiming('NodeViewReady');
export const nodeViewTimerCtx = createCtx([]);
export const NodeViewReady = createTimer('NodeViewReady');
export const nodeView = (pre) => {
pre.inject(nodeViewCtx);
pre.inject(nodeViewCtx).inject(nodeViewTimerCtx, [SchemaReady]).record(NodeViewReady);
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
yield SchemaReady();
yield Promise.all(ctx.get(nodeViewTimerCtx).map((x) => ctx.wait(x)));
const nodes = ctx.get(nodesCtx);

@@ -20,3 +21,3 @@ const marks = ctx.get(marksCtx);

const getViewMap = (atoms, isNode) => atoms
.map((x) => [getAtom(x.id, schema, isNode), { view: x.view, id: x.id }])
.map(({ id, view }) => [getAtom(id, schema, isNode), { view: view, id }])
.map(([atom, { id, view }]) => atom && view

@@ -30,5 +31,5 @@ ? [id, ((...args) => view(editor, atom, ...args))]

ctx.set(nodeViewCtx, nodeView);
NodeViewReady.done();
ctx.done(NodeViewReady);
});
};
//# sourceMappingURL=node-view.js.map
import type { Node as ProsemirrorNode } from 'prosemirror-model';
import re from 'remark';
import { Meta } from '../context';
import { Timer } from '../timing';
import { MilkdownPlugin } from '../utility';

@@ -9,7 +10,5 @@ export declare type Parser = (text: string) => ProsemirrorNode | null;

export declare const remarkCtx: Meta<RemarkParser>;
export declare const ParserReady: {
(): Promise<unknown>;
done(): void;
};
export declare const parserTimerCtx: Meta<Timer[]>;
export declare const ParserReady: Timer;
export declare const parser: MilkdownPlugin;
//# sourceMappingURL=parser.d.ts.map

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

import { createParser } from '../parser';
import { createTiming } from '../timing';
import { createTimer } from '../timing';
import { remarkPluginsCtx } from './remark-plugin-factory';

@@ -12,7 +12,8 @@ import { marksCtx, nodesCtx, schemaCtx, SchemaReady } from './schema';

export const remarkCtx = createCtx(re());
export const ParserReady = createTiming('ParserReady');
export const parserTimerCtx = createCtx([]);
export const ParserReady = createTimer('ParserReady');
export const parser = (pre) => {
pre.inject(parserCtx).inject(remarkCtx, re());
pre.inject(parserCtx).inject(remarkCtx, re()).inject(parserTimerCtx, [SchemaReady]).record(ParserReady);
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
yield SchemaReady();
yield Promise.all(ctx.get(parserTimerCtx).map((x) => ctx.wait(x)));
const nodes = ctx.get(nodesCtx);

@@ -30,5 +31,5 @@ const marks = ctx.get(marksCtx);

ctx.set(parserCtx, createParser(schema, spec, processor));
ParserReady.done();
ctx.done(ParserReady);
});
};
//# sourceMappingURL=parser.js.map
import type { Plugin as ProsemirrorPlugin } from 'prosemirror-state';
import { MilkdownPlugin } from '..';
export declare const prosePluginsCtx: import("..").Meta<ProsemirrorPlugin<any, any>[]>;
import type { MilkdownPlugin } from '../utility';
export declare const prosePluginsCtx: import("../context").Meta<ProsemirrorPlugin<any, any>[]>;
export declare const prosePluginFactory: (plugin: ProsemirrorPlugin | ProsemirrorPlugin[]) => MilkdownPlugin;
//# sourceMappingURL=prose-plugin-factory.d.ts.map

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

import { createCtx } from '..';
import { createCtx } from '../context';
export const prosePluginsCtx = createCtx([]);

@@ -3,0 +3,0 @@ export const prosePluginFactory = (plugin) => () => (ctx) => {

import type { Plugin } from 'unified';
import { MilkdownPlugin } from '..';
export declare const remarkPluginsCtx: import("..").Meta<Plugin<never, never>[]>;
import type { MilkdownPlugin } from '../utility';
export declare const remarkPluginsCtx: import("../context").Meta<Plugin<never, never>[]>;
export declare const remarkPluginFactory: (plugin: Plugin | Plugin[]) => MilkdownPlugin;
//# sourceMappingURL=remark-plugin-factory.d.ts.map

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

import { createCtx } from '..';
import { createCtx } from '../context';
export const remarkPluginsCtx = createCtx([]);

@@ -3,0 +3,0 @@ export const remarkPluginFactory = (plugin) => () => (ctx) => {

import { Schema } from 'prosemirror-model';
import { MilkdownPlugin } from '../utility';
import { Mark, Node } from '../internal-plugin';
export declare const SchemaReady: {
(): Promise<unknown>;
done(): void;
};
import { Timer } from '../timing';
export declare const SchemaReady: Timer;
export declare const schemaCtx: import("../context").Meta<Schema<any, any>>;
export declare const nodesCtx: import("../context").Meta<Node[]>;
export declare const marksCtx: import("../context").Meta<Mark[]>;
export declare const schemaTimerCtx: import("../context").Meta<Timer[]>;
export declare const schema: MilkdownPlugin;
//# sourceMappingURL=schema.d.ts.map

@@ -6,11 +6,12 @@ import { __awaiter } from "tslib";

import { Initialize } from '../internal-plugin';
import { createTiming } from '../timing';
export const SchemaReady = createTiming('schemaReady');
import { createTimer } from '../timing';
export const SchemaReady = createTimer('schemaReady');
export const schemaCtx = createCtx({});
export const nodesCtx = createCtx([]);
export const marksCtx = createCtx([]);
export const schemaTimerCtx = createCtx([]);
export const schema = (pre) => {
pre.inject(schemaCtx).inject(nodesCtx).inject(marksCtx);
pre.inject(schemaCtx).inject(nodesCtx).inject(marksCtx).inject(schemaTimerCtx, [Initialize]).record(SchemaReady);
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
yield Initialize();
yield Promise.all(ctx.get(schemaTimerCtx).map((x) => ctx.wait(x)));
const getAtom = (x) => fromPairs(x.map(({ id, schema }) => [id, schema]));

@@ -23,5 +24,5 @@ const nodes = getAtom(ctx.get(nodesCtx));

}));
SchemaReady.done();
ctx.done(SchemaReady);
});
};
//# sourceMappingURL=schema.js.map
import type { Node as ProsemirrorNode } from 'prosemirror-model';
import { Timer } from '../timing';
import { MilkdownPlugin } from '../utility';
export declare const serializerCtx: import("..").Meta<(node: ProsemirrorNode) => string>;
export declare const SerializerReady: {
(): Promise<unknown>;
done(): void;
};
export declare const serializerCtx: import("../context").Meta<(node: ProsemirrorNode) => string>;
export declare const serializerTimerCtx: import("../context").Meta<Timer[]>;
export declare const SerializerReady: Timer;
export declare const serializer: MilkdownPlugin;
//# sourceMappingURL=serializer.d.ts.map
import { __awaiter } from "tslib";
import { fromPairs } from 'lodash-es';
import { marksCtx, nodesCtx, remarkCtx, schemaCtx, SchemaReady } from '..';
import { marksCtx, nodesCtx, remarkCtx, schemaCtx, SchemaReady } from '.';
import { createCtx } from '../context';
import { createSerializer } from '../serializer';
import { createTiming } from '../timing';
import { createTimer } from '../timing';
export const serializerCtx = createCtx(() => '');
export const SerializerReady = createTiming('SerializerReady');
export const serializerTimerCtx = createCtx([]);
export const SerializerReady = createTimer('SerializerReady');
export const serializer = (pre) => {
pre.inject(serializerCtx);
pre.inject(serializerCtx).inject(serializerTimerCtx, [SchemaReady]).record(SerializerReady);
return (ctx) => __awaiter(void 0, void 0, void 0, function* () {
yield SchemaReady();
yield Promise.all(ctx.get(serializerTimerCtx).map((x) => ctx.wait(x)));
const nodes = ctx.get(nodesCtx);

@@ -20,5 +21,5 @@ const marks = ctx.get(marksCtx);

ctx.set(serializerCtx, createSerializer(schema, spec, remark));
SerializerReady.done();
ctx.done(SerializerReady);
});
};
//# sourceMappingURL=serializer.js.map
import { Mark } from 'prosemirror-model';
import { StackElement } from './stack-element';
import { AnyRecord } from '../utility';
import { MarkdownNode } from '..';
import type { MarkdownNode } from '..';
export declare const createStack: () => {

@@ -6,0 +6,0 @@ build: () => MarkdownNode;

@@ -1,5 +0,16 @@

export declare const createTiming: (name: string, timeout?: number) => {
(): Promise<unknown>;
done(): void;
export declare type Timing = {
(): Promise<void>;
done: () => void;
};
export declare type ClockMap = Map<symbol, Timing>;
export declare type Timer = {
(store: ClockMap): Timing;
id: symbol;
};
export declare type Clock = {
store: ClockMap;
get: (timer: Timer) => Timing;
};
export declare const createClock: () => Clock;
export declare const createTimer: (name: string, timeout?: number) => Timer;
//# sourceMappingURL=create-timing.d.ts.map

@@ -1,16 +0,41 @@

export const createTiming = (name, timeout = 3000) => {
const event = new Event(name);
const timing = () => new Promise((resolve, reject) => {
setTimeout(() => {
reject(`Timing ${name} timeout.`);
}, timeout);
addEventListener(name, () => {
resolve(undefined);
export const createClock = () => {
const store = new Map();
const get = (timer) => {
const meta = store.get(timer.id);
if (!meta)
throw new Error();
return meta;
};
return {
store,
get,
};
};
export const createTimer = (name, timeout = 3000) => {
const id = Symbol('Timer');
const timer = (store) => {
const data = Symbol(name);
const timing = () => new Promise((resolve, reject) => {
setTimeout(() => {
reject(`Timing ${name} timeout.`);
}, timeout);
addEventListener(name, (e) => {
if (!(e instanceof CustomEvent)) {
return;
}
if (e.detail.id === data) {
resolve(undefined);
}
});
});
});
timing.done = () => {
dispatchEvent(event);
timing.done = () => {
const event = new CustomEvent(name, { detail: { id: data } });
dispatchEvent(event);
};
store.set(id, timing);
return timing;
};
return timing;
timer.id = id;
return timer;
};
//# sourceMappingURL=create-timing.js.map
import type { Context, Meta } from '../context';
import type { Mark, Node } from '../internal-plugin';
import { Timer } from '../timing';
export declare type AnyRecord = Record<string, any>;

@@ -9,5 +10,8 @@ export declare type Ctx = {

update: <T>(meta: Meta<T>, updater: (prev: T) => T) => void;
wait: (timer: Timer) => Promise<void> | void;
done: (timer: Timer) => void;
};
export declare type Pre = {
inject: <T>(meta: Meta<T>, resetValue?: T) => Pre;
record: (record: Timer) => Pre;
};

@@ -14,0 +18,0 @@ export declare type CtxHandler = (ctx: Ctx) => void | Promise<void>;

{
"name": "@milkdown/core",
"version": "4.6.6",
"version": "4.6.7",
"main": "lib/index.js",

@@ -16,2 +16,11 @@ "module": "lib/index.js",

],
"keywords": [
"milkdown",
"prosemirror",
"remark",
"markdown",
"wysiwyg",
"text editor",
"markdown editor"
],
"dependencies": {

@@ -18,0 +27,0 @@ "@types/lodash-es": "^4.17.4",

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

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