@milkdown/utils
Advanced tools
Comparing version 7.5.0 to 7.5.8
import type { Ctx, MilkdownPlugin } from '@milkdown/ctx'; | ||
import type { RemarkPluginRaw } from '@milkdown/transformer'; | ||
import type { $Ctx } from '../$ctx'; | ||
export type $Remark<Id extends string, Options> = [optionsCtx: $Ctx<Options, Id>, plugin: MilkdownPlugin] & { | ||
export type $Remark<Id extends string, Options> = [ | ||
optionsCtx: $Ctx<Options, Id>, | ||
plugin: MilkdownPlugin | ||
] & { | ||
id: Id; | ||
@@ -6,0 +9,0 @@ plugin: MilkdownPlugin; |
@@ -11,3 +11,6 @@ import type { Ctx, SliceType } from '@milkdown/ctx'; | ||
export type UserKeymapConfig<Key extends string> = Record<Key, KeymapItem>; | ||
export type $UserKeymap<N extends string, Key extends string> = [$Ctx<KeymapConfig<Key>, `${N}Keymap`>, $Shortcut] & { | ||
export type $UserKeymap<N extends string, Key extends string> = [ | ||
$Ctx<KeymapConfig<Key>, `${N}Keymap`>, | ||
$Shortcut | ||
] & { | ||
key: SliceType<KeymapConfig<Key>, `${N}Keymap`>; | ||
@@ -14,0 +17,0 @@ keymap: Keymap; |
import type { Cleanup, Ctx, MilkdownPlugin, SliceType, TimerType } from '@milkdown/ctx'; | ||
export declare const nanoid: (size?: number | undefined) => string; | ||
export declare const nanoid: (size?: number) => string; | ||
export type WithTimer<T> = T & { | ||
@@ -4,0 +4,0 @@ timer: TimerType; |
@@ -72,3 +72,6 @@ import { createCmdKey as O, commandsTimerCtx as I, CommandsReady as R, commandsCtx as d, editorStateTimerCtx as A, SchemaReady as l, inputRulesCtx as C, schemaCtx as g, schemaTimerCtx as E, marksCtx as w, nodesCtx as k, prosePluginsCtx as p, editorViewTimerCtx as D, nodeViewCtx as v, markViewCtx as $, InitReady as N, remarkPluginsCtx as b, editorViewCtx as f, serializerCtx as H, parserCtx as M, editorStateOptionsCtx as L } from "@milkdown/core"; | ||
const e = o(t); | ||
return t.update(w, (a) => [...a.filter((s) => s[0] !== n), [n, e]]), r.id = n, r.schema = e, () => { | ||
return t.update(w, (a) => [ | ||
...a.filter((s) => s[0] !== n), | ||
[n, e] | ||
]), r.id = n, r.schema = e, () => { | ||
t.update(w, (a) => a.filter(([s]) => s !== n)); | ||
@@ -79,4 +82,3 @@ }; | ||
const e = t.get(g).marks[n]; | ||
if (!e) | ||
throw P(n); | ||
if (!e) throw P(n); | ||
return e; | ||
@@ -89,3 +91,6 @@ }, r; | ||
const i = await o(e); | ||
return e.update(w, (u) => [...u.filter((c) => c[0] !== n), [n, i]]), a.id = n, a.schema = i, s(), () => { | ||
return e.update(w, (u) => [ | ||
...u.filter((c) => c[0] !== n), | ||
[n, i] | ||
]), a.id = n, a.schema = i, s(), () => { | ||
e.update(w, (u) => u.filter(([c]) => c !== n)); | ||
@@ -99,4 +104,3 @@ }; | ||
const a = e.get(g).marks[n]; | ||
if (!a) | ||
throw P(n); | ||
if (!a) throw P(n); | ||
return a; | ||
@@ -108,3 +112,6 @@ }, t; | ||
const e = o(t); | ||
return t.update(k, (a) => [...a.filter((s) => s[0] !== n), [n, e]]), r.id = n, r.schema = e, () => { | ||
return t.update(k, (a) => [ | ||
...a.filter((s) => s[0] !== n), | ||
[n, e] | ||
]), r.id = n, r.schema = e, () => { | ||
t.update(k, (a) => a.filter(([s]) => s !== n)); | ||
@@ -115,4 +122,3 @@ }; | ||
const e = t.get(g).nodes[n]; | ||
if (!e) | ||
throw j(n); | ||
if (!e) throw j(n); | ||
return e; | ||
@@ -125,3 +131,6 @@ }, r; | ||
const i = await o(e); | ||
return e.update(k, (u) => [...u.filter((c) => c[0] !== n), [n, i]]), a.id = n, a.schema = i, s(), () => { | ||
return e.update(k, (u) => [ | ||
...u.filter((c) => c[0] !== n), | ||
[n, i] | ||
]), a.id = n, a.schema = i, s(), () => { | ||
e.update(k, (u) => u.filter(([c]) => c !== n)); | ||
@@ -135,4 +144,3 @@ }; | ||
const a = e.get(g).nodes[n]; | ||
if (!a) | ||
throw j(n); | ||
if (!a) throw j(n); | ||
return a; | ||
@@ -175,3 +183,6 @@ }, t; | ||
return r.update(p, (s) => [...s, a]), t.keymap = e, () => { | ||
r.update(p, (s) => s.filter((i) => i !== a)); | ||
r.update( | ||
p, | ||
(s) => s.filter((i) => i !== a) | ||
); | ||
}; | ||
@@ -187,3 +198,9 @@ }, | ||
const e = o(t); | ||
return n.type(t) instanceof T ? t.update(v, (a) => [...a, [n.id, e]]) : t.update($, (a) => [...a, [n.id, e]]), r.view = e, r.type = n, () => { | ||
return n.type(t) instanceof T ? t.update(v, (a) => [ | ||
...a, | ||
[n.id, e] | ||
]) : t.update($, (a) => [ | ||
...a, | ||
[n.id, e] | ||
]), r.view = e, r.type = n, () => { | ||
n.type(t) instanceof T ? t.update(v, (a) => a.filter((s) => s[0] !== n.id)) : t.update($, (a) => a.filter((s) => s[0] !== n.id)); | ||
@@ -199,3 +216,9 @@ }; | ||
const a = await o(t); | ||
return n.type(t) instanceof T ? t.update(v, (s) => [...s, [n.id, a]]) : t.update($, (s) => [...s, [n.id, a]]), e.view = a, e.type = n, () => { | ||
return n.type(t) instanceof T ? t.update(v, (s) => [ | ||
...s, | ||
[n.id, a] | ||
]) : t.update($, (s) => [ | ||
...s, | ||
[n.id, a] | ||
]), e.view = a, e.type = n, () => { | ||
n.type(t) instanceof T ? t.update(v, (s) => s.filter((i) => i[0] !== n.id)) : t.update($, (s) => s.filter((i) => i[0] !== n.id)); | ||
@@ -218,3 +241,6 @@ }; | ||
const i = s.get(r.key), c = a(i)(s); | ||
s.update(k, (m) => [...m.filter((S) => S[0] !== n), [n, c]]), e.schema = c; | ||
s.update(k, (m) => [ | ||
...m.filter((S) => S[0] !== n), | ||
[n, c] | ||
]), e.schema = c; | ||
}, e; | ||
@@ -226,8 +252,15 @@ } | ||
const i = s.get(r.key), c = a(i)(s); | ||
s.update(w, (m) => [...m.filter((S) => S[0] !== n), [n, c]]), e.schema = c; | ||
s.update(w, (m) => [ | ||
...m.filter((S) => S[0] !== n), | ||
[n, c] | ||
]), e.schema = c; | ||
}, e; | ||
} | ||
function ge(n, o) { | ||
const r = Object.fromEntries(Object.entries(o).map(([s, { shortcuts: i }]) => [s, i])), t = h(r, `${n}Keymap`), e = X((s) => { | ||
const i = s.get(t.key), u = Object.entries(o).flatMap(([c, { command: m }]) => [i[c]].flat().map((V) => [V, m(s)])); | ||
const r = Object.fromEntries( | ||
Object.entries(o).map(([s, { shortcuts: i }]) => [s, i]) | ||
), t = h(r, `${n}Keymap`), e = X((s) => { | ||
const i = s.get(t.key), u = Object.entries(o).flatMap( | ||
([c, { command: m }]) => [i[c]].flat().map((V) => [V, m(s)]) | ||
); | ||
return Object.fromEntries(u); | ||
@@ -262,3 +295,5 @@ }), a = [t, e]; | ||
return (n) => { | ||
const o = document.createElement("div"), r = n.get(g), t = n.get(f), e = B.fromSchema(r).serializeFragment(t.state.doc.content); | ||
const o = document.createElement("div"), r = n.get(g), t = n.get(f), e = B.fromSchema(r).serializeFragment( | ||
t.state.doc.content | ||
); | ||
return o.appendChild(e), o.innerHTML; | ||
@@ -276,7 +311,8 @@ }; | ||
const r = o.get(f), e = o.get(M)(n); | ||
if (!e) | ||
return; | ||
if (!e) return; | ||
const a = r.state.selection.content(); | ||
return r.dispatch( | ||
r.state.tr.replaceSelection(new K(e.content, a.openStart, a.openEnd)).scrollIntoView() | ||
r.state.tr.replaceSelection( | ||
new K(e.content, a.openStart, a.openEnd) | ||
).scrollIntoView() | ||
); | ||
@@ -289,3 +325,7 @@ }; | ||
return o.state.doc.descendants((e) => { | ||
e.type.name === "heading" && e.attrs.level && r.push({ text: e.textContent, level: e.attrs.level, id: e.attrs.id }); | ||
e.type.name === "heading" && e.attrs.level && r.push({ | ||
text: e.textContent, | ||
level: e.attrs.level, | ||
id: e.attrs.id | ||
}); | ||
}), r; | ||
@@ -297,7 +337,12 @@ }; | ||
const t = r.get(f), a = r.get(M)(n); | ||
if (!a) | ||
return; | ||
if (!a) return; | ||
if (!o) { | ||
const { state: m } = t; | ||
return t.dispatch(m.tr.replace(0, m.doc.content.size, new K(a.content, 0, 0))); | ||
return t.dispatch( | ||
m.tr.replace( | ||
0, | ||
m.doc.content.size, | ||
new K(a.content, 0, 0) | ||
) | ||
); | ||
} | ||
@@ -316,4 +361,3 @@ const s = r.get(g), i = r.get(L), u = r.get(p), c = G.create({ | ||
const t = r.get(f), { tr: e } = t.state, a = e.doc.nodeAt(n); | ||
if (!a) | ||
return; | ||
if (!a) return; | ||
const s = o(a.attrs); | ||
@@ -331,4 +375,3 @@ return t.dispatch(e.setNodeMarkup(n, void 0, s)); | ||
let e = 0, a = o ? n[e](...t) : t[0]; | ||
for (; ++e < o; ) | ||
a = n[e](a); | ||
for (; ++e < o; ) a = n[e](a); | ||
return a; | ||
@@ -335,0 +378,0 @@ }; |
{ | ||
"name": "@milkdown/utils", | ||
"type": "module", | ||
"version": "7.5.0", | ||
"version": "7.5.8", | ||
"license": "MIT", | ||
@@ -32,9 +32,9 @@ "repository": { | ||
"tslib": "^2.5.0", | ||
"@milkdown/exception": "7.5.0" | ||
"@milkdown/exception": "7.5.8" | ||
}, | ||
"devDependencies": { | ||
"@milkdown/core": "7.5.0", | ||
"@milkdown/ctx": "7.5.0", | ||
"@milkdown/prose": "7.5.0", | ||
"@milkdown/transformer": "7.5.0" | ||
"@milkdown/ctx": "7.5.8", | ||
"@milkdown/core": "7.5.8", | ||
"@milkdown/prose": "7.5.8", | ||
"@milkdown/transformer": "7.5.8" | ||
}, | ||
@@ -41,0 +41,0 @@ "nx": { |
import type { Cmd, CmdKey } from '@milkdown/core' | ||
import type { Ctx, MilkdownPlugin } from '@milkdown/ctx' | ||
import { CommandsReady, commandsCtx, commandsTimerCtx, createCmdKey } from '@milkdown/core' | ||
import { | ||
CommandsReady, | ||
commandsCtx, | ||
commandsTimerCtx, | ||
createCmdKey, | ||
} from '@milkdown/core' | ||
@@ -39,11 +44,15 @@ import { addTimer } from './utils' | ||
/// ``` | ||
export function $command<T, K extends string>(key: K, cmd: (ctx: Ctx) => Cmd<T>): $Command<T> { | ||
export function $command<T, K extends string>( | ||
key: K, | ||
cmd: (ctx: Ctx) => Cmd<T> | ||
): $Command<T> { | ||
const cmdKey = createCmdKey<T>(key) | ||
const plugin: MilkdownPlugin = ctx => async () => { | ||
(<$Command<T>>plugin).key = cmdKey | ||
const plugin: MilkdownPlugin = (ctx) => async () => { | ||
;(<$Command<T>>plugin).key = cmdKey | ||
await ctx.wait(CommandsReady) | ||
const command = cmd(ctx) | ||
ctx.get(commandsCtx).create(cmdKey, command); | ||
(<$Command<T>>plugin).run = (payload?: T) => ctx.get(commandsCtx).call(key, payload) | ||
ctx.get(commandsCtx).create(cmdKey, command) | ||
;(<$Command<T>>plugin).run = (payload?: T) => | ||
ctx.get(commandsCtx).call(key, payload) | ||
@@ -72,3 +81,7 @@ return () => { | ||
/// - `timer`: The timer which will be resolved when the command is ready. | ||
export function $commandAsync<T, K extends string>(key: K, cmd: (ctx: Ctx) => Promise<Cmd<T>>, timerName?: string) { | ||
export function $commandAsync<T, K extends string>( | ||
key: K, | ||
cmd: (ctx: Ctx) => Promise<Cmd<T>>, | ||
timerName?: string | ||
) { | ||
const cmdKey = createCmdKey<T>(key) | ||
@@ -79,5 +92,6 @@ return addTimer<$Command<T>>( | ||
const command = await cmd(ctx) | ||
ctx.get(commandsCtx).create(cmdKey, command); | ||
(<$Command<T>>plugin).run = (payload?: T) => ctx.get(commandsCtx).call(key, payload); | ||
(<$Command<T>>plugin).key = cmdKey | ||
ctx.get(commandsCtx).create(cmdKey, command) | ||
;(<$Command<T>>plugin).run = (payload?: T) => | ||
ctx.get(commandsCtx).call(key, payload) | ||
;(<$Command<T>>plugin).key = cmdKey | ||
return () => { | ||
@@ -88,4 +102,4 @@ ctx.get(commandsCtx).remove(cmdKey) | ||
commandsTimerCtx, | ||
timerName, | ||
timerName | ||
) | ||
} |
@@ -18,10 +18,10 @@ import type { Ctx, MilkdownPlugin } from '@milkdown/ctx' | ||
export function $inputRule(inputRule: (ctx: Ctx) => InputRule): $InputRule { | ||
const plugin: MilkdownPlugin = ctx => async () => { | ||
const plugin: MilkdownPlugin = (ctx) => async () => { | ||
await ctx.wait(SchemaReady) | ||
const ir = inputRule(ctx) | ||
ctx.update(inputRulesCtx, irs => [...irs, ir]); | ||
(<$InputRule>plugin).inputRule = ir | ||
ctx.update(inputRulesCtx, (irs) => [...irs, ir]) | ||
;(<$InputRule>plugin).inputRule = ir | ||
return () => { | ||
ctx.update(inputRulesCtx, irs => irs.filter(x => x !== ir)) | ||
ctx.update(inputRulesCtx, (irs) => irs.filter((x) => x !== ir)) | ||
} | ||
@@ -38,3 +38,6 @@ } | ||
/// - `timer`: The timer which will be resolved when the input rule is ready. | ||
export function $inputRuleAsync(inputRule: (ctx: Ctx) => Promise<InputRule>, timerName?: string) { | ||
export function $inputRuleAsync( | ||
inputRule: (ctx: Ctx) => Promise<InputRule>, | ||
timerName?: string | ||
) { | ||
return addTimer<$InputRule>( | ||
@@ -44,11 +47,11 @@ async (ctx, plugin) => { | ||
const ir = await inputRule(ctx) | ||
ctx.update(inputRulesCtx, irs => [...irs, ir]) | ||
ctx.update(inputRulesCtx, (irs) => [...irs, ir]) | ||
plugin.inputRule = ir | ||
return () => { | ||
ctx.update(inputRulesCtx, irs => irs.filter(x => x !== ir)) | ||
ctx.update(inputRulesCtx, (irs) => irs.filter((x) => x !== ir)) | ||
} | ||
}, | ||
editorStateTimerCtx, | ||
timerName, | ||
timerName | ||
) | ||
} |
@@ -1,11 +0,4 @@ | ||
import type { | ||
Ctx, | ||
MilkdownPlugin, | ||
} from '@milkdown/ctx' | ||
import type { Ctx, MilkdownPlugin } from '@milkdown/ctx' | ||
import type { MarkSchema } from '@milkdown/transformer' | ||
import { | ||
marksCtx, | ||
schemaCtx, | ||
schemaTimerCtx, | ||
} from '@milkdown/core' | ||
import { marksCtx, schemaCtx, schemaTimerCtx } from '@milkdown/core' | ||
import { missingMarkInSchema } from '@milkdown/exception' | ||
@@ -32,17 +25,18 @@ import type { MarkType } from '@milkdown/prose/model' | ||
export function $mark(id: string, schema: (ctx: Ctx) => MarkSchema): $Mark { | ||
const plugin: MilkdownPlugin = ctx => async () => { | ||
const plugin: MilkdownPlugin = (ctx) => async () => { | ||
const markSchema = schema(ctx) | ||
ctx.update(marksCtx, ns => [...ns.filter(n => n[0] !== id), [id, markSchema] as [string, MarkSchema]]); | ||
ctx.update(marksCtx, (ns) => [ | ||
...ns.filter((n) => n[0] !== id), | ||
[id, markSchema] as [string, MarkSchema], | ||
]) | ||
;(<$Mark>plugin).id = id | ||
;(<$Mark>plugin).schema = markSchema | ||
(<$Mark>plugin).id = id; | ||
(<$Mark>plugin).schema = markSchema | ||
return () => { | ||
ctx.update(marksCtx, ns => ns.filter(([x]) => x !== id)) | ||
ctx.update(marksCtx, (ns) => ns.filter(([x]) => x !== id)) | ||
} | ||
} | ||
(<$Mark>plugin).type = (ctx) => { | ||
;(<$Mark>plugin).type = (ctx) => { | ||
const markType = ctx.get(schemaCtx).marks[id] | ||
if (!markType) | ||
throw missingMarkInSchema(id) | ||
if (!markType) throw missingMarkInSchema(id) | ||
return markType | ||
@@ -61,7 +55,14 @@ } | ||
/// - `timer`: The timer which will be resolved when the mark schema is ready. | ||
export function $markAsync(id: string, schema: (ctx: Ctx) => Promise<MarkSchema>, timerName?: string) { | ||
export function $markAsync( | ||
id: string, | ||
schema: (ctx: Ctx) => Promise<MarkSchema>, | ||
timerName?: string | ||
) { | ||
const plugin = addTimer<$Mark>( | ||
async (ctx, plugin, done) => { | ||
const markSchema = await schema(ctx) | ||
ctx.update(marksCtx, ns => [...ns.filter(n => n[0] !== id), [id, markSchema] as [string, MarkSchema]]) | ||
ctx.update(marksCtx, (ns) => [ | ||
...ns.filter((n) => n[0] !== id), | ||
[id, markSchema] as [string, MarkSchema], | ||
]) | ||
@@ -73,7 +74,7 @@ plugin.id = id | ||
return () => { | ||
ctx.update(marksCtx, ns => ns.filter(([x]) => x !== id)) | ||
ctx.update(marksCtx, (ns) => ns.filter(([x]) => x !== id)) | ||
} | ||
}, | ||
schemaTimerCtx, | ||
timerName, | ||
timerName | ||
) | ||
@@ -83,4 +84,3 @@ | ||
const markType = ctx.get(schemaCtx).marks[id] | ||
if (!markType) | ||
throw missingMarkInSchema(id) | ||
if (!markType) throw missingMarkInSchema(id) | ||
return markType | ||
@@ -87,0 +87,0 @@ } |
@@ -1,10 +0,3 @@ | ||
import type { | ||
Ctx, | ||
MilkdownPlugin, | ||
} from '@milkdown/ctx' | ||
import { | ||
nodesCtx, | ||
schemaCtx, | ||
schemaTimerCtx, | ||
} from '@milkdown/core' | ||
import type { Ctx, MilkdownPlugin } from '@milkdown/ctx' | ||
import { nodesCtx, schemaCtx, schemaTimerCtx } from '@milkdown/core' | ||
import { missingNodeInSchema } from '@milkdown/exception' | ||
@@ -32,18 +25,19 @@ import type { NodeType } from '@milkdown/prose/model' | ||
export function $node(id: string, schema: (ctx: Ctx) => NodeSchema): $Node { | ||
const plugin: MilkdownPlugin = ctx => async () => { | ||
const plugin: MilkdownPlugin = (ctx) => async () => { | ||
const nodeSchema = schema(ctx) | ||
ctx.update(nodesCtx, ns => [...ns.filter(n => n[0] !== id), [id, nodeSchema] as [string, NodeSchema]]); | ||
ctx.update(nodesCtx, (ns) => [ | ||
...ns.filter((n) => n[0] !== id), | ||
[id, nodeSchema] as [string, NodeSchema], | ||
]) | ||
;(<$Node>plugin).id = id | ||
;(<$Node>plugin).schema = nodeSchema | ||
(<$Node>plugin).id = id; | ||
(<$Node>plugin).schema = nodeSchema | ||
return () => { | ||
ctx.update(nodesCtx, ns => ns.filter(([x]) => x !== id)) | ||
ctx.update(nodesCtx, (ns) => ns.filter(([x]) => x !== id)) | ||
} | ||
} | ||
(<$Node>plugin).type = (ctx) => { | ||
;(<$Node>plugin).type = (ctx) => { | ||
const nodeType = ctx.get(schemaCtx).nodes[id] | ||
if (!nodeType) | ||
throw missingNodeInSchema(id) | ||
if (!nodeType) throw missingNodeInSchema(id) | ||
@@ -63,7 +57,14 @@ return nodeType | ||
/// - `timer`: The timer which will be resolved when the node schema is ready. | ||
export function $nodeAsync(id: string, schema: (ctx: Ctx) => Promise<NodeSchema>, timerName?: string) { | ||
export function $nodeAsync( | ||
id: string, | ||
schema: (ctx: Ctx) => Promise<NodeSchema>, | ||
timerName?: string | ||
) { | ||
const plugin = addTimer<$Node>( | ||
async (ctx, plugin, done) => { | ||
const nodeSchema = await schema(ctx) | ||
ctx.update(nodesCtx, ns => [...ns.filter(n => n[0] !== id), [id, nodeSchema] as [string, NodeSchema]]) | ||
ctx.update(nodesCtx, (ns) => [ | ||
...ns.filter((n) => n[0] !== id), | ||
[id, nodeSchema] as [string, NodeSchema], | ||
]) | ||
@@ -75,7 +76,7 @@ plugin.id = id | ||
return () => { | ||
ctx.update(nodesCtx, ns => ns.filter(([x]) => x !== id)) | ||
ctx.update(nodesCtx, (ns) => ns.filter(([x]) => x !== id)) | ||
} | ||
}, | ||
schemaTimerCtx, | ||
timerName, | ||
timerName | ||
) | ||
@@ -85,4 +86,3 @@ | ||
const nodeType = ctx.get(schemaCtx).nodes[id] | ||
if (!nodeType) | ||
throw missingNodeInSchema(id) | ||
if (!nodeType) throw missingNodeInSchema(id) | ||
@@ -89,0 +89,0 @@ return nodeType |
import type { Ctx, MilkdownPlugin } from '@milkdown/ctx' | ||
import { SchemaReady, editorStateTimerCtx, prosePluginsCtx } from '@milkdown/core' | ||
import { | ||
SchemaReady, | ||
editorStateTimerCtx, | ||
prosePluginsCtx, | ||
} from '@milkdown/core' | ||
import type { Plugin, PluginKey } from '@milkdown/prose/state' | ||
@@ -21,13 +25,13 @@ | ||
let prosePlugin: Plugin | undefined | ||
const plugin: MilkdownPlugin = ctx => async () => { | ||
const plugin: MilkdownPlugin = (ctx) => async () => { | ||
await ctx.wait(SchemaReady) | ||
prosePlugin = prose(ctx) | ||
ctx.update(prosePluginsCtx, ps => [...ps, prosePlugin!]) | ||
ctx.update(prosePluginsCtx, (ps) => [...ps, prosePlugin!]) | ||
return () => { | ||
ctx.update(prosePluginsCtx, ps => ps.filter(x => x !== prosePlugin)) | ||
ctx.update(prosePluginsCtx, (ps) => ps.filter((x) => x !== prosePlugin)) | ||
} | ||
} | ||
(<$Prose>plugin).plugin = () => prosePlugin!; | ||
(<$Prose>plugin).key = () => prosePlugin!.spec.key | ||
;(<$Prose>plugin).plugin = () => prosePlugin! | ||
;(<$Prose>plugin).key = () => prosePlugin!.spec.key | ||
@@ -43,3 +47,6 @@ return <$Prose>plugin | ||
/// - `timer`: The timer which will be resolved when the plugin is ready. | ||
export function $proseAsync(prose: (ctx: Ctx) => Promise<Plugin>, timerName?: string) { | ||
export function $proseAsync( | ||
prose: (ctx: Ctx) => Promise<Plugin>, | ||
timerName?: string | ||
) { | ||
let prosePlugin: Plugin | undefined | ||
@@ -50,10 +57,10 @@ const plugin = addTimer<$Prose>( | ||
prosePlugin = await prose(ctx) | ||
ctx.update(prosePluginsCtx, ps => [...ps, prosePlugin!]) | ||
ctx.update(prosePluginsCtx, (ps) => [...ps, prosePlugin!]) | ||
return () => { | ||
ctx.update(prosePluginsCtx, ps => ps.filter(x => x !== prosePlugin)) | ||
ctx.update(prosePluginsCtx, (ps) => ps.filter((x) => x !== prosePlugin)) | ||
} | ||
}, | ||
editorStateTimerCtx, | ||
timerName, | ||
timerName | ||
) | ||
@@ -60,0 +67,0 @@ |
import type { Ctx, MilkdownPlugin } from '@milkdown/ctx' | ||
import { SchemaReady, editorStateTimerCtx, prosePluginsCtx } from '@milkdown/core' | ||
import { | ||
SchemaReady, | ||
editorStateTimerCtx, | ||
prosePluginsCtx, | ||
} from '@milkdown/core' | ||
import { keymap } from '@milkdown/prose/keymap' | ||
@@ -22,11 +26,11 @@ import type { Command } from '@milkdown/prose/state' | ||
export function $shortcut(shortcut: (ctx: Ctx) => Keymap): $Shortcut { | ||
const plugin: MilkdownPlugin = ctx => async () => { | ||
const plugin: MilkdownPlugin = (ctx) => async () => { | ||
await ctx.wait(SchemaReady) | ||
const k = shortcut(ctx) | ||
const keymapPlugin = keymap(k) | ||
ctx.update(prosePluginsCtx, ps => [...ps, keymapPlugin]); | ||
(<$Shortcut>plugin).keymap = k | ||
ctx.update(prosePluginsCtx, (ps) => [...ps, keymapPlugin]) | ||
;(<$Shortcut>plugin).keymap = k | ||
return () => { | ||
ctx.update(prosePluginsCtx, ps => ps.filter(x => x !== keymapPlugin)) | ||
ctx.update(prosePluginsCtx, (ps) => ps.filter((x) => x !== keymapPlugin)) | ||
} | ||
@@ -43,3 +47,6 @@ } | ||
/// - `timer`: The timer which will be resolved when the plugin is ready. | ||
export function $shortcutAsync(shortcut: (ctx: Ctx) => Promise<Keymap>, timerName?: string) { | ||
export function $shortcutAsync( | ||
shortcut: (ctx: Ctx) => Promise<Keymap>, | ||
timerName?: string | ||
) { | ||
return addTimer<$Shortcut>( | ||
@@ -50,12 +57,14 @@ async (ctx, plugin) => { | ||
const keymapPlugin = keymap(k) | ||
ctx.update(prosePluginsCtx, ps => [...ps, keymapPlugin]) | ||
ctx.update(prosePluginsCtx, (ps) => [...ps, keymapPlugin]) | ||
plugin.keymap = k | ||
return () => { | ||
ctx.update(prosePluginsCtx, ps => ps.filter(x => x !== keymapPlugin)) | ||
ctx.update(prosePluginsCtx, (ps) => | ||
ps.filter((x) => x !== keymapPlugin) | ||
) | ||
} | ||
}, | ||
editorStateTimerCtx, | ||
timerName, | ||
timerName | ||
) | ||
} |
import type { Ctx, MilkdownPlugin } from '@milkdown/ctx' | ||
import { SchemaReady, editorViewTimerCtx, markViewCtx, nodeViewCtx } from '@milkdown/core' | ||
import { | ||
SchemaReady, | ||
editorViewTimerCtx, | ||
markViewCtx, | ||
nodeViewCtx, | ||
} from '@milkdown/core' | ||
import { NodeType } from '@milkdown/prose/model' | ||
import type { MarkViewConstructor, NodeViewConstructor } from '@milkdown/prose/view' | ||
import type { | ||
MarkViewConstructor, | ||
NodeViewConstructor, | ||
} from '@milkdown/prose/view' | ||
@@ -10,3 +18,6 @@ import { addTimer } from './utils' | ||
/// @internal | ||
export type $View<T extends $Node | $Mark, V extends NodeViewConstructor | MarkViewConstructor> = MilkdownPlugin & { | ||
export type $View< | ||
T extends $Node | $Mark, | ||
V extends NodeViewConstructor | MarkViewConstructor, | ||
> = MilkdownPlugin & { | ||
view: V | ||
@@ -35,18 +46,22 @@ type: T | ||
>(type: T, view: (ctx: Ctx) => V): $View<T, V> { | ||
const plugin: MilkdownPlugin = ctx => async () => { | ||
const plugin: MilkdownPlugin = (ctx) => async () => { | ||
await ctx.wait(SchemaReady) | ||
const v = view(ctx) | ||
if (type.type(ctx) instanceof NodeType) | ||
ctx.update(nodeViewCtx, ps => [...ps, [type.id, v] as [string, NodeViewConstructor]]) | ||
ctx.update(nodeViewCtx, (ps) => [ | ||
...ps, | ||
[type.id, v] as [string, NodeViewConstructor], | ||
]) | ||
else | ||
ctx.update(markViewCtx, ps => [...ps, [type.id, v] as [string, MarkViewConstructor]]); | ||
ctx.update(markViewCtx, (ps) => [ | ||
...ps, | ||
[type.id, v] as [string, MarkViewConstructor], | ||
]) | ||
;(<$View<T, V>>plugin).view = v | ||
;(<$View<T, V>>plugin).type = type | ||
(<$View<T, V>>plugin).view = v; | ||
(<$View<T, V>>plugin).type = type | ||
return () => { | ||
if (type.type(ctx) instanceof NodeType) | ||
ctx.update(nodeViewCtx, ps => ps.filter(x => x[0] !== type.id)) | ||
else | ||
ctx.update(markViewCtx, ps => ps.filter(x => x[0] !== type.id)) | ||
ctx.update(nodeViewCtx, (ps) => ps.filter((x) => x[0] !== type.id)) | ||
else ctx.update(markViewCtx, (ps) => ps.filter((x) => x[0] !== type.id)) | ||
} | ||
@@ -73,5 +88,11 @@ } | ||
if (type.type(ctx) instanceof NodeType) | ||
ctx.update(nodeViewCtx, ps => [...ps, [type.id, v] as [string, NodeViewConstructor]]) | ||
ctx.update(nodeViewCtx, (ps) => [ | ||
...ps, | ||
[type.id, v] as [string, NodeViewConstructor], | ||
]) | ||
else | ||
ctx.update(markViewCtx, ps => [...ps, [type.id, v] as [string, MarkViewConstructor]]) | ||
ctx.update(markViewCtx, (ps) => [ | ||
...ps, | ||
[type.id, v] as [string, MarkViewConstructor], | ||
]) | ||
@@ -83,10 +104,9 @@ plugin.view = v | ||
if (type.type(ctx) instanceof NodeType) | ||
ctx.update(nodeViewCtx, ps => ps.filter(x => x[0] !== type.id)) | ||
else | ||
ctx.update(markViewCtx, ps => ps.filter(x => x[0] !== type.id)) | ||
ctx.update(nodeViewCtx, (ps) => ps.filter((x) => x[0] !== type.id)) | ||
else ctx.update(markViewCtx, (ps) => ps.filter((x) => x[0] !== type.id)) | ||
} | ||
}, | ||
editorViewTimerCtx, | ||
timerName, | ||
timerName | ||
) | ||
} |
@@ -6,11 +6,23 @@ import type { Mark, Node } from '@milkdown/prose/model' | ||
/// @internal | ||
export type $NodeAttr = $Ctx<(node: Node) => Record<string, any>, `${string}Attr`> | ||
export type $NodeAttr = $Ctx< | ||
(node: Node) => Record<string, any>, | ||
`${string}Attr` | ||
> | ||
/// Create a slice which contains the attributes for node schema. | ||
export const $nodeAttr = (name: string, value: (node: Node) => Record<string, any> = () => ({})): $NodeAttr => $ctx(value, `${name}Attr`) | ||
export const $nodeAttr = ( | ||
name: string, | ||
value: (node: Node) => Record<string, any> = () => ({}) | ||
): $NodeAttr => $ctx(value, `${name}Attr`) | ||
/// @internal | ||
export type $MarkAttr = $Ctx<(node: Mark) => Record<string, any>, `${string}Attr`> | ||
export type $MarkAttr = $Ctx< | ||
(node: Mark) => Record<string, any>, | ||
`${string}Attr` | ||
> | ||
/// Create a slice which contains the attributes for mark schema. | ||
export const $markAttr = (name: string, value: (mark: Mark) => Record<string, any> = () => ({})): $MarkAttr => $ctx(value, `${name}Attr`) | ||
export const $markAttr = ( | ||
name: string, | ||
value: (mark: Mark) => Record<string, any> = () => ({}) | ||
): $MarkAttr => $ctx(value, `${name}Attr`) |
@@ -23,3 +23,5 @@ import type { Ctx, MilkdownPlugin } from '@milkdown/ctx' | ||
key: $Ctx<GetMarkSchema, T>['key'] | ||
extendSchema: (handler: (prev: GetMarkSchema) => GetMarkSchema) => MilkdownPlugin | ||
extendSchema: ( | ||
handler: (prev: GetMarkSchema) => GetMarkSchema | ||
) => MilkdownPlugin | ||
} | ||
@@ -39,3 +41,6 @@ | ||
/// - `extendSchema`: A function witch will return a plugin that can extend the mark schema. | ||
export function $markSchema<T extends string>(id: T, schema: GetMarkSchema): $MarkSchema<T> { | ||
export function $markSchema<T extends string>( | ||
id: T, | ||
schema: GetMarkSchema | ||
): $MarkSchema<T> { | ||
const schemaCtx = $ctx(schema, id) | ||
@@ -56,7 +61,10 @@ | ||
result.extendSchema = (handler): MilkdownPlugin => { | ||
return ctx => () => { | ||
return (ctx) => () => { | ||
const prev = ctx.get(schemaCtx.key) | ||
const next = handler(prev) | ||
const markSchema = next(ctx) | ||
ctx.update(marksCtx, ms => [...ms.filter(m => m[0] !== id), [id, markSchema] as [string, MarkSchema]]) | ||
ctx.update(marksCtx, (ms) => [ | ||
...ms.filter((m) => m[0] !== id), | ||
[id, markSchema] as [string, MarkSchema], | ||
]) | ||
result.schema = markSchema | ||
@@ -63,0 +71,0 @@ } |
@@ -23,3 +23,5 @@ import type { Ctx, MilkdownPlugin } from '@milkdown/ctx' | ||
key: $Ctx<GetNodeSchema, T>['key'] | ||
extendSchema: (handler: (prev: GetNodeSchema) => GetNodeSchema) => MilkdownPlugin | ||
extendSchema: ( | ||
handler: (prev: GetNodeSchema) => GetNodeSchema | ||
) => MilkdownPlugin | ||
} | ||
@@ -39,3 +41,6 @@ | ||
/// - `extendSchema`: A function witch will return a plugin that can extend the node schema. | ||
export function $nodeSchema<T extends string>(id: T, schema: GetNodeSchema): $NodeSchema<T> { | ||
export function $nodeSchema<T extends string>( | ||
id: T, | ||
schema: GetNodeSchema | ||
): $NodeSchema<T> { | ||
const schemaCtx = $ctx(schema, id) | ||
@@ -57,7 +62,10 @@ | ||
result.extendSchema = (handler): MilkdownPlugin => { | ||
return ctx => () => { | ||
return (ctx) => () => { | ||
const prev = ctx.get(schemaCtx.key) | ||
const next = handler(prev) | ||
const nodeSchema = next(ctx) | ||
ctx.update(nodesCtx, ns => [...ns.filter(n => n[0] !== id), [id, nodeSchema] as [string, NodeSchema]]) | ||
ctx.update(nodesCtx, (ns) => [ | ||
...ns.filter((n) => n[0] !== id), | ||
[id, nodeSchema] as [string, NodeSchema], | ||
]) | ||
result.schema = nodeSchema | ||
@@ -64,0 +72,0 @@ } |
@@ -9,3 +9,6 @@ import type { Ctx, MilkdownPlugin } from '@milkdown/ctx' | ||
/// @internal | ||
export type $Remark<Id extends string, Options> = [optionsCtx: $Ctx<Options, Id>, plugin: MilkdownPlugin] & { | ||
export type $Remark<Id extends string, Options> = [ | ||
optionsCtx: $Ctx<Options, Id>, | ||
plugin: MilkdownPlugin, | ||
] & { | ||
id: Id | ||
@@ -23,5 +26,9 @@ plugin: MilkdownPlugin | ||
/// - `options`: The ctx contains the options of the remark plugin. | ||
export function $remark<Id extends string, Options>(id: Id, remark: (ctx: Ctx) => RemarkPluginRaw<Options>, initialOptions?: Options): $Remark<Id, Options> { | ||
const options = $ctx<Options, Id>(initialOptions ?? {} as Options, id) | ||
const plugin: MilkdownPlugin = ctx => async () => { | ||
export function $remark<Id extends string, Options>( | ||
id: Id, | ||
remark: (ctx: Ctx) => RemarkPluginRaw<Options>, | ||
initialOptions?: Options | ||
): $Remark<Id, Options> { | ||
const options = $ctx<Options, Id>(initialOptions ?? ({} as Options), id) | ||
const plugin: MilkdownPlugin = (ctx) => async () => { | ||
await ctx.wait(InitReady) | ||
@@ -33,6 +40,6 @@ const re = remark(ctx) | ||
} | ||
ctx.update(remarkPluginsCtx, rp => [...rp, remarkPlugin as RemarkPlugin]) | ||
ctx.update(remarkPluginsCtx, (rp) => [...rp, remarkPlugin as RemarkPlugin]) | ||
return () => { | ||
ctx.update(remarkPluginsCtx, rp => rp.filter(x => x !== remarkPlugin)) | ||
ctx.update(remarkPluginsCtx, (rp) => rp.filter((x) => x !== remarkPlugin)) | ||
} | ||
@@ -39,0 +46,0 @@ } |
@@ -21,3 +21,6 @@ import type { Ctx, SliceType } from '@milkdown/ctx' | ||
/// @internal | ||
export type $UserKeymap<N extends string, Key extends string> = [$Ctx<KeymapConfig<Key>, `${N}Keymap`>, $Shortcut] & { | ||
export type $UserKeymap<N extends string, Key extends string> = [ | ||
$Ctx<KeymapConfig<Key>, `${N}Keymap`>, | ||
$Shortcut, | ||
] & { | ||
key: SliceType<KeymapConfig<Key>, `${N}Keymap`> | ||
@@ -33,6 +36,11 @@ keymap: Keymap | ||
/// - `userKeymap`: The keymap config which contains the shortcuts and the command. | ||
export function $useKeymap<N extends string, Key extends string>(name: N, userKeymap: UserKeymapConfig<Key>) { | ||
const key = Object.fromEntries(Object.entries<KeymapItem>(userKeymap).map(([key, { shortcuts }]) => { | ||
return [key, shortcuts] | ||
})) as Record<Key, string | string[]> | ||
export function $useKeymap<N extends string, Key extends string>( | ||
name: N, | ||
userKeymap: UserKeymapConfig<Key> | ||
) { | ||
const key = Object.fromEntries( | ||
Object.entries<KeymapItem>(userKeymap).map(([key, { shortcuts }]) => { | ||
return [key, shortcuts] | ||
}) | ||
) as Record<Key, string | string[]> | ||
@@ -44,7 +52,9 @@ const keymapDef = $ctx<KeymapConfig<Key>, `${N}Keymap`>(key, `${name}Keymap`) | ||
const keymapTuple = Object.entries<KeymapItem>(userKeymap).flatMap(([key, { command }]) => { | ||
const targetKeys: string[] = [keys[key as Key]].flat() | ||
const keymapTuple = Object.entries<KeymapItem>(userKeymap).flatMap( | ||
([key, { command }]) => { | ||
const targetKeys: string[] = [keys[key as Key]].flat() | ||
return targetKeys.map(targetKey => [targetKey, command(ctx)] as const) | ||
}) | ||
return targetKeys.map((targetKey) => [targetKey, command(ctx)] as const) | ||
} | ||
) | ||
@@ -51,0 +61,0 @@ return Object.fromEntries(keymapTuple) |
@@ -1,2 +0,8 @@ | ||
import type { Cleanup, Ctx, MilkdownPlugin, SliceType, TimerType } from '@milkdown/ctx' | ||
import type { | ||
Cleanup, | ||
Ctx, | ||
MilkdownPlugin, | ||
SliceType, | ||
TimerType, | ||
} from '@milkdown/ctx' | ||
import { createTimer } from '@milkdown/ctx' | ||
@@ -12,3 +18,14 @@ import { customAlphabet } from 'nanoid' | ||
/// @internal | ||
export function addTimer<T extends MilkdownPlugin, PluginWithTimer extends T = WithTimer<T>>(runner: (ctx: Ctx, plugin: PluginWithTimer, done: () => void) => Promise<void | Cleanup>, injectTo: SliceType<TimerType[], string>, timerName?: string): PluginWithTimer { | ||
export function addTimer< | ||
T extends MilkdownPlugin, | ||
PluginWithTimer extends T = WithTimer<T>, | ||
>( | ||
runner: ( | ||
ctx: Ctx, | ||
plugin: PluginWithTimer, | ||
done: () => void | ||
) => Promise<void | Cleanup>, | ||
injectTo: SliceType<TimerType[], string>, | ||
timerName?: string | ||
): PluginWithTimer { | ||
const timer = createTimer(timerName || nanoid()) | ||
@@ -19,3 +36,3 @@ let doneCalled = false | ||
ctx.record(timer) | ||
ctx.update(injectTo, x => x.concat(timer)) | ||
ctx.update(injectTo, (x) => x.concat(timer)) | ||
@@ -30,7 +47,6 @@ return async () => { | ||
if (!doneCalled) | ||
ctx.done(timer) | ||
if (!doneCalled) ctx.done(timer) | ||
return () => { | ||
ctx.update(injectTo, x => x.filter(y => y !== timer)) | ||
ctx.update(injectTo, (x) => x.filter((y) => y !== timer)) | ||
ctx.clearTimer(timer) | ||
@@ -40,6 +56,6 @@ cleanup?.() | ||
} | ||
}; | ||
(<T & { timer: TimerType }>plugin).timer = timer | ||
} | ||
;(<T & { timer: TimerType }>plugin).timer = timer | ||
return <PluginWithTimer>plugin | ||
} |
@@ -8,6 +8,18 @@ import type { CmdKey } from '@milkdown/core' | ||
/// Call a command. You can pass the command key and the payload to the macro. | ||
export function callCommand<T extends CmdKey<any>>(slice: string, payload?: InferParams<T>): (ctx: Ctx) => boolean | ||
export function callCommand<T>(slice: CmdKey<T>, payload?: T): (ctx: Ctx) => boolean | ||
export function callCommand(slice: string | CmdKey<any>, payload?: any): (ctx: Ctx) => boolean | ||
export function callCommand(slice: string | CmdKey<any>, payload?: any): (ctx: Ctx) => boolean { | ||
export function callCommand<T extends CmdKey<any>>( | ||
slice: string, | ||
payload?: InferParams<T> | ||
): (ctx: Ctx) => boolean | ||
export function callCommand<T>( | ||
slice: CmdKey<T>, | ||
payload?: T | ||
): (ctx: Ctx) => boolean | ||
export function callCommand( | ||
slice: string | CmdKey<any>, | ||
payload?: any | ||
): (ctx: Ctx) => boolean | ||
export function callCommand( | ||
slice: string | CmdKey<any>, | ||
payload?: any | ||
): (ctx: Ctx) => boolean { | ||
return (ctx: Ctx) => { | ||
@@ -14,0 +26,0 @@ return ctx.get(commandsCtx).call(slice, payload) |
@@ -11,3 +11,5 @@ import type { Ctx } from '@milkdown/ctx' | ||
const view = ctx.get(editorViewCtx) | ||
const fragment = DOMSerializer.fromSchema(schema).serializeFragment(view.state.doc.content) | ||
const fragment = DOMSerializer.fromSchema(schema).serializeFragment( | ||
view.state.doc.content | ||
) | ||
@@ -14,0 +16,0 @@ div.appendChild(fragment) |
@@ -11,4 +11,3 @@ import type { Ctx } from '@milkdown/ctx' | ||
const doc = parser(markdown) | ||
if (!doc) | ||
return | ||
if (!doc) return | ||
@@ -18,6 +17,8 @@ const contentSlice = view.state.selection.content() | ||
view.state.tr | ||
.replaceSelection(new Slice(doc.content, contentSlice.openStart, contentSlice.openEnd)) | ||
.scrollIntoView(), | ||
.replaceSelection( | ||
new Slice(doc.content, contentSlice.openStart, contentSlice.openEnd) | ||
) | ||
.scrollIntoView() | ||
) | ||
} | ||
} |
@@ -6,9 +6,13 @@ import type { Ctx } from '@milkdown/ctx' | ||
export function outline() { | ||
return (ctx: Ctx): Array<{ text: string, level: number, id: string }> => { | ||
return (ctx: Ctx): Array<{ text: string; level: number; id: string }> => { | ||
const view = ctx.get(editorViewCtx) | ||
const data: { text: string, level: number, id: string }[] = [] | ||
const data: { text: string; level: number; id: string }[] = [] | ||
const doc = view.state.doc | ||
doc.descendants((node) => { | ||
if (node.type.name === 'heading' && node.attrs.level) | ||
data.push({ text: node.textContent, level: node.attrs.level, id: node.attrs.id }) | ||
data.push({ | ||
text: node.textContent, | ||
level: node.attrs.level, | ||
id: node.attrs.id, | ||
}) | ||
}) | ||
@@ -15,0 +19,0 @@ return data |
@@ -19,8 +19,13 @@ import type { Ctx } from '@milkdown/ctx' | ||
const doc = parser(markdown) | ||
if (!doc) | ||
return | ||
if (!doc) return | ||
if (!flush) { | ||
const { state } = view | ||
return view.dispatch(state.tr.replace(0, state.doc.content.size, new Slice(doc.content, 0, 0))) | ||
return view.dispatch( | ||
state.tr.replace( | ||
0, | ||
state.doc.content.size, | ||
new Slice(doc.content, 0, 0) | ||
) | ||
) | ||
} | ||
@@ -27,0 +32,0 @@ |
@@ -11,4 +11,3 @@ import type { Ctx } from '@milkdown/ctx' | ||
const node = tr.doc.nodeAt(pos) | ||
if (!node) | ||
return | ||
if (!node) return | ||
const nextAttr = update(node.attrs) | ||
@@ -15,0 +14,0 @@ return view.dispatch(tr.setNodeMarkup(pos, undefined, nextAttr)) |
@@ -12,31 +12,45 @@ /// @internal | ||
f6: (a: R5) => R6, | ||
f7: (a: R6) => R7, | ||
) => (...args: A) => R7) & (<A extends any[], R1, R2, R3, R4, R5, R6, R7>( | ||
f1: (...args: A) => R1, | ||
f2: (a: R1) => R2, | ||
f3: (a: R2) => R3, | ||
f4: (a: R3) => R4, | ||
f5: (a: R4) => R5, | ||
f6: (a: R5) => R6, | ||
f7: (a: R6) => R7, | ||
...func: Array<Many<(a: any) => any>> | ||
) => (...args: A) => any) & (<A extends any[], R1, R2, R3, R4, R5, R6>( | ||
f1: (...args: A) => R1, | ||
f2: (a: R1) => R2, | ||
f3: (a: R2) => R3, | ||
f4: (a: R3) => R4, | ||
f5: (a: R4) => R5, | ||
f6: (a: R5) => R6, | ||
) => (...args: A) => R6) & (<A extends any[], R1, R2, R3, R4, R5>( | ||
f1: (...args: A) => R1, | ||
f2: (a: R1) => R2, | ||
f3: (a: R2) => R3, | ||
f4: (a: R3) => R4, | ||
f5: (a: R4) => R5, | ||
) => (...args: A) => R5) & (<A extends any[], R1, R2, R3, R4>( | ||
f1: (...args: A) => R1, | ||
f2: (a: R1) => R2, | ||
f3: (a: R2) => R3, | ||
f4: (a: R3) => R4, | ||
) => (...args: A) => R4) & (<A extends any[], R1, R2, R3>(f1: (...args: A) => R1, f2: (a: R1) => R2, f3: (a: R2) => R3) => (...args: A) => R3) & (<A extends any[], R1, R2>(f1: (...args: A) => R1, f2: (a: R1) => R2) => (...args: A) => R2) & ((...func: Array<Many<(...args: any[]) => any>>) => (...args: any[]) => any) | ||
f7: (a: R6) => R7 | ||
) => (...args: A) => R7) & | ||
(<A extends any[], R1, R2, R3, R4, R5, R6, R7>( | ||
f1: (...args: A) => R1, | ||
f2: (a: R1) => R2, | ||
f3: (a: R2) => R3, | ||
f4: (a: R3) => R4, | ||
f5: (a: R4) => R5, | ||
f6: (a: R5) => R6, | ||
f7: (a: R6) => R7, | ||
...func: Array<Many<(a: any) => any>> | ||
) => (...args: A) => any) & | ||
(<A extends any[], R1, R2, R3, R4, R5, R6>( | ||
f1: (...args: A) => R1, | ||
f2: (a: R1) => R2, | ||
f3: (a: R2) => R3, | ||
f4: (a: R3) => R4, | ||
f5: (a: R4) => R5, | ||
f6: (a: R5) => R6 | ||
) => (...args: A) => R6) & | ||
(<A extends any[], R1, R2, R3, R4, R5>( | ||
f1: (...args: A) => R1, | ||
f2: (a: R1) => R2, | ||
f3: (a: R2) => R3, | ||
f4: (a: R3) => R4, | ||
f5: (a: R4) => R5 | ||
) => (...args: A) => R5) & | ||
(<A extends any[], R1, R2, R3, R4>( | ||
f1: (...args: A) => R1, | ||
f2: (a: R1) => R2, | ||
f3: (a: R2) => R3, | ||
f4: (a: R3) => R4 | ||
) => (...args: A) => R4) & | ||
(<A extends any[], R1, R2, R3>( | ||
f1: (...args: A) => R1, | ||
f2: (a: R1) => R2, | ||
f3: (a: R2) => R3 | ||
) => (...args: A) => R3) & | ||
(<A extends any[], R1, R2>( | ||
f1: (...args: A) => R1, | ||
f2: (a: R1) => R2 | ||
) => (...args: A) => R2) & | ||
((...func: Array<Many<(...args: any[]) => any>>) => (...args: any[]) => any) | ||
} | ||
@@ -55,4 +69,3 @@ | ||
let result = length ? funcs[index](...args) : args[0] | ||
while (++index < length) | ||
result = funcs[index](result) | ||
while (++index < length) result = funcs[index](result) | ||
@@ -59,0 +72,0 @@ return result |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130277
1695
+ Added@milkdown/exception@7.5.8(transitive)
- Removed@milkdown/exception@7.5.0(transitive)
Updated@milkdown/exception@7.5.8