md-editor-rt
Version:
Markdown editor for react, developed in jsx and typescript, dark theme、beautify content by prettier、render articles directly、paste or clip the picture and upload it...
57 lines (56 loc) • 1.55 kB
JavaScript
const i = "onSave", C = "changeCatalogVisible", h = "changeFullscreen", _ = "pageFullscreenChanged", r = "fullscreenChanged", A = "previewChanged", R = "previewOnlyChanged", p = "htmlPreviewChanged", g = "catalogVisibleChanged", L = "buildFinished", N = "errorCatcher", G = "replace", I = "uploadImage", T = "ctrlZ", d = "ctrlShiftZ", S = "catalogChanged", H = "pushCatalog", D = "rerender", V = "eventListener", O = "taskStateChanged", u = "sendEditorView", f = "getEditorView";
class c {
// 事件池
pools = {};
// 移除事件监听
remove(s, o, a) {
const t = this.pools[s] && this.pools[s][o];
t && (this.pools[s][o] = t.filter((e) => e !== a));
}
// 清空全部事件,由于单一实例,多次注册会被共享内容
clear(s) {
this.pools[s] = {};
}
// 注册事件监听
on(s, o) {
return this.pools[s] || (this.pools[s] = {}), this.pools[s][o.name] || (this.pools[s][o.name] = []), this.pools[s][o.name].push(o.callback), this.pools[s][o.name].includes(o.callback);
}
// 触发事件
emit(s, o, ...a) {
this.pools[s] || (this.pools[s] = {});
const t = this.pools[s][o];
t && t.forEach((e) => {
try {
e(...a);
} catch (E) {
console.error(`${o} monitor event exception!`, E);
}
});
}
}
const F = new c();
export {
L as B,
C,
N as E,
r as F,
f as G,
p as H,
i as O,
H as P,
G as R,
u as S,
O as T,
I as U,
d as a,
F as b,
T as c,
h as d,
V as e,
D as f,
S as g,
_ as h,
A as i,
R as j,
g as k
};