@milkdown/plugin-listener
Advanced tools
Comparing version 7.2.0 to 7.2.1
@@ -1,21 +0,10 @@ | ||
var m = Object.defineProperty; | ||
var L = (t, e, s) => e in t ? m(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s; | ||
var n = (t, e, s) => (L(t, typeof e != "symbol" ? e + "" : e, s), s); | ||
import { createSlice as c } from "@milkdown/ctx"; | ||
import { InitReady as w, SerializerReady as y, serializerCtx as b, prosePluginsCtx as g, EditorViewReady as k } from "@milkdown/core"; | ||
import { PluginKey as E, Plugin as M } from "@milkdown/prose/state"; | ||
import U from "lodash.debounce"; | ||
class l { | ||
import { createSlice as f } from "@milkdown/ctx"; | ||
import { InitReady as c, SerializerReady as m, serializerCtx as L, prosePluginsCtx as w, EditorViewReady as y } from "@milkdown/core"; | ||
import { PluginKey as b, Plugin as g } from "@milkdown/prose/state"; | ||
import k from "lodash.debounce"; | ||
class u { | ||
constructor() { | ||
n(this, "beforeMountedListeners", []); | ||
n(this, "mountedListeners", []); | ||
n(this, "updatedListeners", []); | ||
n(this, "markdownUpdatedListeners", []); | ||
n(this, "blurListeners", []); | ||
n(this, "focusListeners", []); | ||
n(this, "destroyListeners", []); | ||
n(this, "beforeMount", (e) => (this.beforeMountedListeners.push(e), this)); | ||
n(this, "mounted", (e) => (this.mountedListeners.push(e), this)); | ||
n(this, "updated", (e) => (this.updatedListeners.push(e), this)); | ||
this.beforeMountedListeners = [], this.mountedListeners = [], this.updatedListeners = [], this.markdownUpdatedListeners = [], this.blurListeners = [], this.focusListeners = [], this.destroyListeners = [], this.beforeMount = (t) => (this.beforeMountedListeners.push(t), this), this.mounted = (t) => (this.mountedListeners.push(t), this), this.updated = (t) => (this.updatedListeners.push(t), this); | ||
} | ||
/// A getter to get all [subscribers](#interface-subscribers). You should not use this method directly. | ||
get listeners() { | ||
@@ -32,26 +21,35 @@ return { | ||
} | ||
markdownUpdated(e) { | ||
return this.markdownUpdatedListeners.push(e), this; | ||
/// Subscribe to the markdownUpdated event. | ||
/// This event will be triggered after the editor state is updated and **the document is changed**. | ||
/// The second parameter is the current markdown and the third parameter is the previous markdown. | ||
markdownUpdated(t) { | ||
return this.markdownUpdatedListeners.push(t), this; | ||
} | ||
blur(e) { | ||
return this.blurListeners.push(e), this; | ||
/// Subscribe to the blur event. | ||
/// This event will be triggered when the editor is blurred. | ||
blur(t) { | ||
return this.blurListeners.push(t), this; | ||
} | ||
focus(e) { | ||
return this.focusListeners.push(e), this; | ||
/// Subscribe to the focus event. | ||
/// This event will be triggered when the editor is focused. | ||
focus(t) { | ||
return this.focusListeners.push(t), this; | ||
} | ||
destroy(e) { | ||
return this.destroyListeners.push(e), this; | ||
/// Subscribe to the destroy event. | ||
/// This event will be triggered before the editor is destroyed. | ||
destroy(t) { | ||
return this.destroyListeners.push(t), this; | ||
} | ||
} | ||
const u = c(new l(), "listener"), v = new E("MILKDOWN_LISTENER"), C = (t) => (t.inject(u, new l()), async () => { | ||
await t.wait(w); | ||
const e = t.get(u), { listeners: s } = e; | ||
s.beforeMount.forEach((r) => r(t)), await t.wait(y); | ||
const h = t.get(b); | ||
let i = null, a = null; | ||
const p = new M({ | ||
key: v, | ||
const a = f(new u(), "listener"), E = new b("MILKDOWN_LISTENER"), M = (e) => (e.inject(a, new u()), async () => { | ||
await e.wait(c); | ||
const t = e.get(a), { listeners: r } = t; | ||
r.beforeMount.forEach((s) => s(e)), await e.wait(m); | ||
const h = e.get(L); | ||
let n = null, d = null; | ||
const l = new g({ | ||
key: E, | ||
view: () => ({ | ||
destroy: () => { | ||
s.destroy.forEach((r) => r(t)); | ||
r.destroy.forEach((s) => s(e)); | ||
} | ||
@@ -61,4 +59,4 @@ }), | ||
handleDOMEvents: { | ||
focus: () => (s.focus.forEach((r) => r(t)), !1), | ||
blur: () => (s.blur.forEach((r) => r(t)), !1) | ||
focus: () => (r.focus.forEach((s) => s(e)), !1), | ||
blur: () => (r.blur.forEach((s) => s(e)), !1) | ||
} | ||
@@ -69,19 +67,19 @@ }, | ||
}, | ||
apply: (r) => !r.docChanged || r.getMeta("addToHistory") === !1 ? void 0 : U(() => { | ||
const { doc: o } = r; | ||
if (s.updated.length > 0 && (i == null || !i.eq(o)) && s.updated.forEach((d) => { | ||
d(t, o, i); | ||
}), s.markdownUpdated.length > 0 && (i == null || !i.eq(o))) { | ||
const d = h(o); | ||
s.markdownUpdated.forEach((f) => { | ||
f(t, d, a); | ||
}), a = d; | ||
apply: (s) => !s.docChanged || s.getMeta("addToHistory") === !1 ? void 0 : k(() => { | ||
const { doc: i } = s; | ||
if (r.updated.length > 0 && (n == null || !n.eq(i)) && r.updated.forEach((o) => { | ||
o(e, i, n); | ||
}), r.markdownUpdated.length > 0 && (n == null || !n.eq(i))) { | ||
const o = h(i); | ||
r.markdownUpdated.forEach((p) => { | ||
p(e, o, d); | ||
}), d = o; | ||
} | ||
i = o; | ||
n = i; | ||
}, 200)() | ||
} | ||
}); | ||
t.update(g, (r) => r.concat(p)), await t.wait(k), s.mounted.forEach((r) => r(t)); | ||
e.update(w, (s) => s.concat(l)), await e.wait(y), r.mounted.forEach((s) => s(e)); | ||
}); | ||
C.meta = { | ||
M.meta = { | ||
package: "@milkdown/plugin-listener", | ||
@@ -91,7 +89,7 @@ displayName: "Listener" | ||
export { | ||
l as ListenerManager, | ||
v as key, | ||
C as listener, | ||
u as listenerCtx | ||
u as ListenerManager, | ||
E as key, | ||
M as listener, | ||
a as listenerCtx | ||
}; | ||
//# sourceMappingURL=index.es.js.map |
@@ -1,21 +0,10 @@ | ||
var m = Object.defineProperty; | ||
var L = (t, e, s) => e in t ? m(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s; | ||
var n = (t, e, s) => (L(t, typeof e != "symbol" ? e + "" : e, s), s); | ||
import { createSlice as c } from "@milkdown/ctx"; | ||
import { InitReady as w, SerializerReady as y, serializerCtx as b, prosePluginsCtx as g, EditorViewReady as k } from "@milkdown/core"; | ||
import { PluginKey as E, Plugin as M } from "@milkdown/prose/state"; | ||
import U from "lodash.debounce"; | ||
class l { | ||
import { createSlice as f } from "@milkdown/ctx"; | ||
import { InitReady as c, SerializerReady as m, serializerCtx as L, prosePluginsCtx as w, EditorViewReady as y } from "@milkdown/core"; | ||
import { PluginKey as b, Plugin as g } from "@milkdown/prose/state"; | ||
import k from "lodash.debounce"; | ||
class u { | ||
constructor() { | ||
n(this, "beforeMountedListeners", []); | ||
n(this, "mountedListeners", []); | ||
n(this, "updatedListeners", []); | ||
n(this, "markdownUpdatedListeners", []); | ||
n(this, "blurListeners", []); | ||
n(this, "focusListeners", []); | ||
n(this, "destroyListeners", []); | ||
n(this, "beforeMount", (e) => (this.beforeMountedListeners.push(e), this)); | ||
n(this, "mounted", (e) => (this.mountedListeners.push(e), this)); | ||
n(this, "updated", (e) => (this.updatedListeners.push(e), this)); | ||
this.beforeMountedListeners = [], this.mountedListeners = [], this.updatedListeners = [], this.markdownUpdatedListeners = [], this.blurListeners = [], this.focusListeners = [], this.destroyListeners = [], this.beforeMount = (t) => (this.beforeMountedListeners.push(t), this), this.mounted = (t) => (this.mountedListeners.push(t), this), this.updated = (t) => (this.updatedListeners.push(t), this); | ||
} | ||
/// A getter to get all [subscribers](#interface-subscribers). You should not use this method directly. | ||
get listeners() { | ||
@@ -32,26 +21,35 @@ return { | ||
} | ||
markdownUpdated(e) { | ||
return this.markdownUpdatedListeners.push(e), this; | ||
/// Subscribe to the markdownUpdated event. | ||
/// This event will be triggered after the editor state is updated and **the document is changed**. | ||
/// The second parameter is the current markdown and the third parameter is the previous markdown. | ||
markdownUpdated(t) { | ||
return this.markdownUpdatedListeners.push(t), this; | ||
} | ||
blur(e) { | ||
return this.blurListeners.push(e), this; | ||
/// Subscribe to the blur event. | ||
/// This event will be triggered when the editor is blurred. | ||
blur(t) { | ||
return this.blurListeners.push(t), this; | ||
} | ||
focus(e) { | ||
return this.focusListeners.push(e), this; | ||
/// Subscribe to the focus event. | ||
/// This event will be triggered when the editor is focused. | ||
focus(t) { | ||
return this.focusListeners.push(t), this; | ||
} | ||
destroy(e) { | ||
return this.destroyListeners.push(e), this; | ||
/// Subscribe to the destroy event. | ||
/// This event will be triggered before the editor is destroyed. | ||
destroy(t) { | ||
return this.destroyListeners.push(t), this; | ||
} | ||
} | ||
const u = c(new l(), "listener"), v = new E("MILKDOWN_LISTENER"), C = (t) => (t.inject(u, new l()), async () => { | ||
await t.wait(w); | ||
const e = t.get(u), { listeners: s } = e; | ||
s.beforeMount.forEach((r) => r(t)), await t.wait(y); | ||
const h = t.get(b); | ||
let i = null, a = null; | ||
const p = new M({ | ||
key: v, | ||
const a = f(new u(), "listener"), E = new b("MILKDOWN_LISTENER"), M = (e) => (e.inject(a, new u()), async () => { | ||
await e.wait(c); | ||
const t = e.get(a), { listeners: r } = t; | ||
r.beforeMount.forEach((s) => s(e)), await e.wait(m); | ||
const h = e.get(L); | ||
let n = null, d = null; | ||
const l = new g({ | ||
key: E, | ||
view: () => ({ | ||
destroy: () => { | ||
s.destroy.forEach((r) => r(t)); | ||
r.destroy.forEach((s) => s(e)); | ||
} | ||
@@ -61,4 +59,4 @@ }), | ||
handleDOMEvents: { | ||
focus: () => (s.focus.forEach((r) => r(t)), !1), | ||
blur: () => (s.blur.forEach((r) => r(t)), !1) | ||
focus: () => (r.focus.forEach((s) => s(e)), !1), | ||
blur: () => (r.blur.forEach((s) => s(e)), !1) | ||
} | ||
@@ -69,19 +67,19 @@ }, | ||
}, | ||
apply: (r) => !r.docChanged || r.getMeta("addToHistory") === !1 ? void 0 : U(() => { | ||
const { doc: o } = r; | ||
if (s.updated.length > 0 && (i == null || !i.eq(o)) && s.updated.forEach((d) => { | ||
d(t, o, i); | ||
}), s.markdownUpdated.length > 0 && (i == null || !i.eq(o))) { | ||
const d = h(o); | ||
s.markdownUpdated.forEach((f) => { | ||
f(t, d, a); | ||
}), a = d; | ||
apply: (s) => !s.docChanged || s.getMeta("addToHistory") === !1 ? void 0 : k(() => { | ||
const { doc: i } = s; | ||
if (r.updated.length > 0 && (n == null || !n.eq(i)) && r.updated.forEach((o) => { | ||
o(e, i, n); | ||
}), r.markdownUpdated.length > 0 && (n == null || !n.eq(i))) { | ||
const o = h(i); | ||
r.markdownUpdated.forEach((p) => { | ||
p(e, o, d); | ||
}), d = o; | ||
} | ||
i = o; | ||
n = i; | ||
}, 200)() | ||
} | ||
}); | ||
t.update(g, (r) => r.concat(p)), await t.wait(k), s.mounted.forEach((r) => r(t)); | ||
e.update(w, (s) => s.concat(l)), await e.wait(y), r.mounted.forEach((s) => s(e)); | ||
}); | ||
C.meta = { | ||
M.meta = { | ||
package: "@milkdown/plugin-listener", | ||
@@ -91,7 +89,7 @@ displayName: "Listener" | ||
export { | ||
l as ListenerManager, | ||
v as key, | ||
C as listener, | ||
u as listenerCtx | ||
u as ListenerManager, | ||
E as key, | ||
M as listener, | ||
a as listenerCtx | ||
}; | ||
//# sourceMappingURL=index.es.js.map |
{ | ||
"name": "@milkdown/plugin-listener", | ||
"type": "module", | ||
"version": "7.2.0", | ||
"version": "7.2.1", | ||
"license": "MIT", | ||
@@ -31,8 +31,8 @@ "repository": { | ||
"tslib": "^2.5.0", | ||
"@milkdown/utils": "7.2.0" | ||
"@milkdown/utils": "7.2.1" | ||
}, | ||
"devDependencies": { | ||
"@milkdown/core": "7.2.0", | ||
"@milkdown/ctx": "7.2.0", | ||
"@milkdown/prose": "7.2.0" | ||
"@milkdown/core": "7.2.1", | ||
"@milkdown/ctx": "7.2.1", | ||
"@milkdown/prose": "7.2.1" | ||
}, | ||
@@ -39,0 +39,0 @@ "nx": { |
Sorry, the diff of this file is not supported yet
27864
382
+ Added@milkdown/exception@7.2.1(transitive)
+ Added@milkdown/utils@7.2.1(transitive)
- Removed@milkdown/exception@7.2.0(transitive)
- Removed@milkdown/utils@7.2.0(transitive)
Updated@milkdown/utils@7.2.1