@milkdown/plugin-emoji 6.5.2 → 6.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/constant.d.ts.map +1 -1
- package/lib/filter/helper.d.ts +2 -2
- package/lib/filter/helper.d.ts.map +1 -1
- package/lib/filter/index.d.ts +1 -1
- package/lib/filter/index.d.ts.map +1 -1
- package/lib/filter/style.d.ts +1 -1
- package/lib/filter/style.d.ts.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +158 -170
- package/lib/index.es.js.map +1 -1
- package/lib/node.d.ts +2 -2
- package/lib/node.d.ts.map +1 -1
- package/lib/parse.d.ts.map +1 -1
- package/lib/remark-twemoji.d.ts +1 -1
- package/lib/remark-twemoji.d.ts.map +1 -1
- package/package.json +20 -15
- package/src/constant.ts +3 -3
- package/src/filter/helper.ts +66 -77
- package/src/filter/index.ts +208 -210
- package/src/filter/style.ts +22 -20
- package/src/index.ts +4 -4
- package/src/node.ts +89 -88
- package/src/parse.ts +3 -3
- package/src/remark-twemoji.ts +57 -57
package/lib/constant.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../src/constant.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,IAAI,QAAqB,
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../src/constant.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,IAAI,QAAqB,CAAA;AACtC,eAAO,MAAM,IAAI,QAAwB,CAAA;AACzC,eAAO,MAAM,KAAK,QAAmB,CAAA"}
|
package/lib/filter/helper.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EditorView } from '@milkdown/prose/view';
|
|
1
|
+
import type { EditorView } from '@milkdown/prose/view';
|
|
2
2
|
import type { Emoji } from 'node-emoji';
|
|
3
3
|
export declare const checkTrigger: (view: EditorView, from: number, to: number, text: string, setRange: (from: number, to: number) => void, setSearch: (words: string) => void) => boolean;
|
|
4
|
-
export declare const renderDropdownList: (list: Emoji[], dropDown: HTMLElement,
|
|
4
|
+
export declare const renderDropdownList: (list: Emoji[], dropDown: HTMLElement, onConfirm: () => void, setActive: (active: HTMLElement | null) => void, twemojiOptions?: TwemojiOptions) => void;
|
|
5
5
|
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/filter/helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/filter/helper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAKvC,eAAO,MAAM,YAAY,SACjB,UAAU,QACV,MAAM,MACR,MAAM,QACJ,MAAM,mBACK,MAAM,MAAM,MAAM,KAAK,IAAI,qBACzB,MAAM,KAAK,IAAI,YAsBnC,CAAA;AAED,eAAO,MAAM,kBAAkB,SACvB,KAAK,EAAE,YACH,WAAW,aACV,MAAM,IAAI,sBACD,WAAW,GAAG,IAAI,KAAK,IAAI,mBAC9B,cAAc,SAuChC,CAAA"}
|
package/lib/filter/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Plugin, PluginKey } from '@milkdown/prose/state';
|
|
2
|
-
import { ThemeUtils } from '@milkdown/utils';
|
|
2
|
+
import type { ThemeUtils } from '@milkdown/utils';
|
|
3
3
|
export declare const key: PluginKey<any>;
|
|
4
4
|
export declare const filter: (utils: ThemeUtils, maxListSize: number, twemojiOptions?: TwemojiOptions) => Plugin<any>;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filter/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filter/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAMjD,eAAO,MAAM,GAAG,gBAAyC,CAAA;AAEzD,eAAO,MAAM,MAAM,UAAW,UAAU,eAAe,MAAM,mBAAmB,cAAc,gBA2M7F,CAAA"}
|
package/lib/filter/style.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/filter/style.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/filter/style.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,OAAO,EACP,YAAY,EACb,MAAM,gBAAgB,CAAA;AAUvB,eAAO,MAAM,WAAW,iBAAkB,YAAY,eAAe,OAAO,WA6C3E,CAAA"}
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,cAAc,QAAQ,CAAA;AAEtB,eAAO,MAAM,KAAK,oKAAiC,CAAA"}
|
package/lib/index.es.js
CHANGED
|
@@ -1,58 +1,54 @@
|
|
|
1
|
-
import { createNode as
|
|
2
|
-
import { missingRootElement as N, expectDomTypeError as
|
|
1
|
+
import { createNode as _, AtomList as O } from "@milkdown/utils";
|
|
2
|
+
import { missingRootElement as N, expectDomTypeError as H } from "@milkdown/exception";
|
|
3
3
|
import { InputRule as F } from "@milkdown/prose/inputrules";
|
|
4
|
-
import
|
|
4
|
+
import A from "node-emoji";
|
|
5
5
|
import I from "remark-emoji";
|
|
6
|
-
import { calculateNodePosition as
|
|
7
|
-
import { PluginKey as
|
|
8
|
-
import
|
|
9
|
-
import { ThemeBorder as
|
|
6
|
+
import { calculateNodePosition as $ } from "@milkdown/prose";
|
|
7
|
+
import { PluginKey as R, Plugin as B } from "@milkdown/prose/state";
|
|
8
|
+
import K from "twemoji";
|
|
9
|
+
import { ThemeBorder as W, ThemeShadow as z, ThemeScrollbar as U, ThemeSize as q, ThemeFont as J, ThemeColor as G } from "@milkdown/core";
|
|
10
10
|
import Q from "emoji-regex";
|
|
11
|
-
const X = /:\+1|:-1|:[\w-]+/, Y = /:\+1:|:-1:|:[\w-]+:/, Z = /(:([^:\s]+):)$/, V = (
|
|
12
|
-
if (
|
|
11
|
+
const X = /:\+1|:-1|:[\w-]+/, Y = /:\+1:|:-1:|:[\w-]+:/, Z = /(:([^:\s]+):)$/, V = (n) => ({ title: n }), C = (n, s) => K.parse(n, { attributes: V, ...s }), ee = (n, s, d, e, l, o) => {
|
|
12
|
+
if (n.composing)
|
|
13
13
|
return !1;
|
|
14
|
-
const { state:
|
|
15
|
-
if (
|
|
14
|
+
const { state: r } = n, i = r.doc.resolve(s);
|
|
15
|
+
if (i.parent.type.spec.code)
|
|
16
16
|
return !1;
|
|
17
|
-
const
|
|
18
|
-
if (Y.test(
|
|
17
|
+
const a = (i.parent.textBetween(Math.max(0, i.parentOffset - 10), i.parentOffset, void 0, "\uFFFC") + e).toLowerCase();
|
|
18
|
+
if (Y.test(a))
|
|
19
19
|
return !1;
|
|
20
|
-
const t = X.exec(
|
|
21
|
-
if (t && t[0] &&
|
|
22
|
-
const
|
|
23
|
-
return
|
|
20
|
+
const t = X.exec(a);
|
|
21
|
+
if (t && t[0] && a.endsWith(t[0])) {
|
|
22
|
+
const m = t[0];
|
|
23
|
+
return l(s - (m.length - e.length), d), o(m), !0;
|
|
24
24
|
}
|
|
25
25
|
return !1;
|
|
26
|
-
}, te = (
|
|
27
|
-
for (;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const { target: m } = d;
|
|
42
|
-
m instanceof HTMLElement && m.classList.remove("active");
|
|
43
|
-
}, u = (d) => {
|
|
44
|
-
d.preventDefault(), e();
|
|
26
|
+
}, te = (n, s, d, e, l) => {
|
|
27
|
+
for (; s.firstChild; )
|
|
28
|
+
s.firstChild.remove();
|
|
29
|
+
n.forEach(({ emoji: o, key: r }, i) => {
|
|
30
|
+
const a = document.createElement("div");
|
|
31
|
+
a.className = "milkdown-emoji-filter_item";
|
|
32
|
+
const t = document.createElement("span");
|
|
33
|
+
t.innerHTML = C(o, l), t.className = "milkdown-emoji-filter_item-emoji";
|
|
34
|
+
const m = document.createElement("span");
|
|
35
|
+
m.textContent = `:${r}:`, m.className = "milkdown-emoji-filter_item-key", a.appendChild(t), a.appendChild(m), s.appendChild(a), i === 0 && e(a);
|
|
36
|
+
const c = (u) => {
|
|
37
|
+
const { target: j } = u;
|
|
38
|
+
j instanceof HTMLElement && e(j);
|
|
39
|
+
}, w = (u) => {
|
|
40
|
+
u.preventDefault(), d();
|
|
45
41
|
};
|
|
46
|
-
|
|
42
|
+
a.addEventListener("mouseenter", c), a.addEventListener("mousedown", w);
|
|
47
43
|
});
|
|
48
|
-
}, ne = (
|
|
49
|
-
const e =
|
|
44
|
+
}, ne = (n, { css: s, cx: d }) => {
|
|
45
|
+
const e = n.get(W, void 0), l = n.get(z, void 0), o = n.get(U, void 0), r = n.get(q, "radius"), i = n.get(J, "typography"), a = (m, c = 1) => n.get(G, [m, c]), t = s`
|
|
50
46
|
min-height: 36px;
|
|
51
47
|
max-height: 320px;
|
|
52
48
|
overflow-y: auto;
|
|
53
|
-
border-radius: ${
|
|
49
|
+
border-radius: ${r};
|
|
54
50
|
position: absolute;
|
|
55
|
-
background: ${
|
|
51
|
+
background: ${a("surface")};
|
|
56
52
|
|
|
57
53
|
&.hide {
|
|
58
54
|
display: none;
|
|
@@ -67,11 +63,11 @@ const X = /:\+1|:-1|:[\w-]+/, Y = /:\+1:|:-1:|:[\w-]+:/, Z = /(:([^:\s]+):)$/, V
|
|
|
67
63
|
justify-content: flex-start;
|
|
68
64
|
cursor: pointer;
|
|
69
65
|
line-height: 2;
|
|
70
|
-
font-family: ${
|
|
66
|
+
font-family: ${i};
|
|
71
67
|
font-size: 14px;
|
|
72
68
|
&.active {
|
|
73
|
-
background: ${
|
|
74
|
-
color: ${
|
|
69
|
+
background: ${a("secondary", 0.12)};
|
|
70
|
+
color: ${a("primary")};
|
|
75
71
|
}
|
|
76
72
|
}
|
|
77
73
|
|
|
@@ -82,146 +78,138 @@ const X = /:\+1|:-1|:[\w-]+/, Y = /:\+1:|:-1:|:[\w-]+:/, Z = /(:([^:\s]+):)$/, V
|
|
|
82
78
|
vertical-align: -1.5px;
|
|
83
79
|
}
|
|
84
80
|
`;
|
|
85
|
-
return
|
|
86
|
-
}, oe = new
|
|
87
|
-
let e = !1,
|
|
88
|
-
const
|
|
89
|
-
e = !1,
|
|
81
|
+
return d(e, l, o, t);
|
|
82
|
+
}, oe = new R("MILKDOWN_EMOJI_FILTER"), re = (n, s, d) => {
|
|
83
|
+
let e = !1, l = 0, o = "", r = null;
|
|
84
|
+
const i = () => {
|
|
85
|
+
e = !1, l = 0, o = "", r = null;
|
|
86
|
+
}, a = (t) => {
|
|
87
|
+
r && r.classList.remove("active"), t && t.classList.add("active"), r = t;
|
|
90
88
|
};
|
|
91
|
-
return new
|
|
89
|
+
return new B({
|
|
92
90
|
key: oe,
|
|
93
91
|
props: {
|
|
94
|
-
handleKeyDown(
|
|
95
|
-
return ["Delete", "Backspace"].includes(
|
|
92
|
+
handleKeyDown(t, m) {
|
|
93
|
+
return ["Delete", "Backspace"].includes(m.key) ? (o = o.slice(0, -1), o.length <= 1 && i(), !1) : !(!e || !["ArrowUp", "ArrowDown", "Enter"].includes(m.key));
|
|
96
94
|
},
|
|
97
|
-
handleTextInput(
|
|
95
|
+
handleTextInput(t, m, c, w) {
|
|
98
96
|
return e = ee(
|
|
99
|
-
c,
|
|
100
97
|
t,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
m,
|
|
99
|
+
c,
|
|
100
|
+
w,
|
|
101
|
+
(u) => {
|
|
102
|
+
l = u;
|
|
105
103
|
},
|
|
106
|
-
(
|
|
107
|
-
|
|
104
|
+
(u) => {
|
|
105
|
+
o = u;
|
|
108
106
|
}
|
|
109
|
-
), e ||
|
|
107
|
+
), e || i(), !1;
|
|
110
108
|
}
|
|
111
109
|
},
|
|
112
|
-
view: (
|
|
113
|
-
const { parentNode:
|
|
114
|
-
if (!
|
|
110
|
+
view: (t) => {
|
|
111
|
+
const { parentNode: m } = t.dom;
|
|
112
|
+
if (!m)
|
|
115
113
|
throw N();
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
114
|
+
const c = document.createElement("div");
|
|
115
|
+
c.classList.add("milkdown-emoji-filter", "hide"), n.themeManager.onFlush(() => {
|
|
116
|
+
const h = c.className.split(" ").filter((f) => ["hide", "milkdown-emoji-filter"].includes(f));
|
|
117
|
+
c.className = h.join(" ");
|
|
118
|
+
const p = n.getStyle((f) => ne(n.themeManager, f));
|
|
119
|
+
p && p.split(" ").forEach((f) => c.classList.add(f));
|
|
122
120
|
});
|
|
123
|
-
const
|
|
124
|
-
var
|
|
125
|
-
if (!
|
|
121
|
+
const w = () => {
|
|
122
|
+
var f;
|
|
123
|
+
if (!r)
|
|
126
124
|
return;
|
|
127
|
-
const { tr:
|
|
128
|
-
|
|
125
|
+
const { tr: h } = t.state, p = t.state.schema.node("emoji", { html: (f = r.firstElementChild) == null ? void 0 : f.innerHTML });
|
|
126
|
+
t.dispatch(h.delete(l, l + o.length).insert(l, p)), i(), c.classList.add("hide");
|
|
129
127
|
};
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
if (!e || !(
|
|
128
|
+
m.appendChild(c);
|
|
129
|
+
const u = (h) => {
|
|
130
|
+
if (!e || !(h instanceof KeyboardEvent))
|
|
133
131
|
return;
|
|
134
|
-
const { key:
|
|
135
|
-
if (
|
|
136
|
-
|
|
132
|
+
const { key: p } = h;
|
|
133
|
+
if (p === "Enter") {
|
|
134
|
+
w();
|
|
137
135
|
return;
|
|
138
136
|
}
|
|
139
|
-
if (["ArrowDown", "ArrowUp"].includes(
|
|
140
|
-
const
|
|
141
|
-
if (
|
|
137
|
+
if (["ArrowDown", "ArrowUp"].includes(p)) {
|
|
138
|
+
const f = p === "ArrowDown" ? (r == null ? void 0 : r.nextElementSibling) || c.firstElementChild : (r == null ? void 0 : r.previousElementSibling) || c.lastElementChild;
|
|
139
|
+
if (!f)
|
|
142
140
|
return;
|
|
143
|
-
|
|
144
|
-
return;
|
|
141
|
+
a(f);
|
|
145
142
|
}
|
|
146
|
-
},
|
|
147
|
-
!e || (
|
|
143
|
+
}, j = (h) => {
|
|
144
|
+
!e || (h.stopPropagation(), i(), c.classList.add("hide"));
|
|
148
145
|
};
|
|
149
|
-
return
|
|
150
|
-
update: (
|
|
151
|
-
const { selection:
|
|
152
|
-
if (
|
|
153
|
-
return
|
|
154
|
-
const
|
|
155
|
-
return
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
o,
|
|
159
|
-
h,
|
|
160
|
-
(C) => {
|
|
161
|
-
o = C;
|
|
162
|
-
},
|
|
163
|
-
f
|
|
164
|
-
), R(u, n, (C, j, y) => {
|
|
165
|
-
const E = n.parentElement;
|
|
166
|
-
if (!E)
|
|
146
|
+
return m.addEventListener("keydown", u), m.addEventListener("mousedown", j), {
|
|
147
|
+
update: (h) => {
|
|
148
|
+
const { selection: p } = h.state;
|
|
149
|
+
if (p.from - p.to !== 0 || !e)
|
|
150
|
+
return i(), c.classList.add("hide"), null;
|
|
151
|
+
const f = A.search(o).slice(0, s), { node: D } = h.domAtPos(l);
|
|
152
|
+
return f.length === 0 || !D ? (c.classList.add("hide"), null) : (c.style.maxHeight = "", c.classList.remove("hide"), te(f, c, w, a, d), $(h, c, (me, v, y) => {
|
|
153
|
+
const k = c.parentElement;
|
|
154
|
+
if (!k)
|
|
167
155
|
throw N();
|
|
168
|
-
const
|
|
169
|
-
let
|
|
170
|
-
|
|
171
|
-
let
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
const M =
|
|
177
|
-
return
|
|
156
|
+
const x = h.coordsAtPos(l);
|
|
157
|
+
let E = x.left - y.left;
|
|
158
|
+
E < 0 && (E = 0);
|
|
159
|
+
let L, g;
|
|
160
|
+
const T = x.top - y.top, b = y.height + y.top - x.bottom;
|
|
161
|
+
b >= v.height + 28 ? L = "bottom" : T >= v.height + 28 ? L = "top" : b >= T ? (L = "bottom", g = b - 28) : (L = "top", g = T - 28), (T < 0 || b < 0) && (g = y.height - (x.bottom - x.top) - 28, g > v.height && (g = void 0));
|
|
162
|
+
const P = L === "top" ? x.top - y.top - (g != null ? g : v.height) - 14 + k.scrollTop : x.bottom - y.top + 14 + k.scrollTop;
|
|
163
|
+
c.style.maxHeight = g !== void 0 && g > 0 ? `${g}px` : "";
|
|
164
|
+
const M = k.clientWidth - (c.offsetWidth + 4);
|
|
165
|
+
return E > M && (E = M), [P, E];
|
|
178
166
|
}), null);
|
|
179
167
|
},
|
|
180
168
|
destroy: () => {
|
|
181
|
-
|
|
169
|
+
m.removeEventListener("keydown", u), m.removeEventListener("mousedown", j), c.remove();
|
|
182
170
|
}
|
|
183
171
|
};
|
|
184
172
|
}
|
|
185
173
|
});
|
|
186
|
-
}, S = Q(),
|
|
187
|
-
function le(
|
|
188
|
-
return
|
|
189
|
-
function
|
|
190
|
-
if (
|
|
191
|
-
const
|
|
192
|
-
for (let
|
|
193
|
-
const t = e.children[
|
|
174
|
+
}, S = Q(), ie = (n) => !!n.children, se = (n) => !!n.value;
|
|
175
|
+
function le(n, s) {
|
|
176
|
+
return d(n, 0, null)[0];
|
|
177
|
+
function d(e, l, o) {
|
|
178
|
+
if (ie(e)) {
|
|
179
|
+
const r = [];
|
|
180
|
+
for (let i = 0, a = e.children.length; i < a; i++) {
|
|
181
|
+
const t = e.children[i];
|
|
194
182
|
if (t) {
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
197
|
-
for (let
|
|
198
|
-
const
|
|
199
|
-
|
|
183
|
+
const m = d(t, i, e);
|
|
184
|
+
if (m)
|
|
185
|
+
for (let c = 0, w = m.length; c < w; c++) {
|
|
186
|
+
const u = m[c];
|
|
187
|
+
u && r.push(u);
|
|
200
188
|
}
|
|
201
189
|
}
|
|
202
190
|
}
|
|
203
|
-
e.children =
|
|
191
|
+
e.children = r;
|
|
204
192
|
}
|
|
205
|
-
return
|
|
193
|
+
return s(e, l, o);
|
|
206
194
|
}
|
|
207
195
|
}
|
|
208
|
-
const
|
|
209
|
-
function
|
|
210
|
-
le(
|
|
211
|
-
if (!
|
|
196
|
+
const ce = (n) => () => {
|
|
197
|
+
function s(d) {
|
|
198
|
+
le(d, (e) => {
|
|
199
|
+
if (!se(e))
|
|
212
200
|
return [e];
|
|
213
|
-
const
|
|
214
|
-
let
|
|
215
|
-
for (;
|
|
216
|
-
const { index:
|
|
217
|
-
t && (
|
|
201
|
+
const l = e.value, o = [];
|
|
202
|
+
let r, i = l;
|
|
203
|
+
for (; r = S.exec(i); ) {
|
|
204
|
+
const { index: a } = r, t = r[0];
|
|
205
|
+
t && (a > 0 && o.push({ ...e, value: i.slice(0, a) }), o.push({ ...e, value: C(t, n), type: "emoji" }), i = i.slice(a + t.length)), S.lastIndex = 0;
|
|
218
206
|
}
|
|
219
|
-
return
|
|
207
|
+
return i.length && o.push({ ...e, value: i }), o;
|
|
220
208
|
});
|
|
221
209
|
}
|
|
222
|
-
return
|
|
223
|
-
},
|
|
224
|
-
const
|
|
210
|
+
return s;
|
|
211
|
+
}, ae = _((n, s) => {
|
|
212
|
+
const d = () => n.getStyle(
|
|
225
213
|
({ css: e }) => e`
|
|
226
214
|
.emoji {
|
|
227
215
|
height: 1em;
|
|
@@ -247,55 +235,55 @@ const ae = (r) => () => {
|
|
|
247
235
|
tag: 'span[data-type="emoji"]',
|
|
248
236
|
getAttrs: (e) => {
|
|
249
237
|
if (!(e instanceof HTMLElement))
|
|
250
|
-
throw
|
|
238
|
+
throw H(e);
|
|
251
239
|
return { html: e.innerHTML };
|
|
252
240
|
}
|
|
253
241
|
}
|
|
254
242
|
],
|
|
255
243
|
toDOM: (e) => {
|
|
256
|
-
const
|
|
257
|
-
return
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
}),
|
|
244
|
+
const l = document.createElement("span");
|
|
245
|
+
return l.classList.add("emoji-wrapper"), l.dataset.type = "emoji", n.themeManager.onFlush(() => {
|
|
246
|
+
const o = d();
|
|
247
|
+
o && l.classList.add(o);
|
|
248
|
+
}), l.innerHTML = e.attrs.html, { dom: l };
|
|
261
249
|
},
|
|
262
250
|
parseMarkdown: {
|
|
263
251
|
match: ({ type: e }) => e === "emoji",
|
|
264
|
-
runner: (e,
|
|
265
|
-
e.addNode(
|
|
252
|
+
runner: (e, l, o) => {
|
|
253
|
+
e.addNode(o, { html: l.value });
|
|
266
254
|
}
|
|
267
255
|
},
|
|
268
256
|
toMarkdown: {
|
|
269
257
|
match: (e) => e.type.name === "emoji",
|
|
270
|
-
runner: (e,
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
const
|
|
274
|
-
|
|
258
|
+
runner: (e, l) => {
|
|
259
|
+
const o = document.createElement("span");
|
|
260
|
+
o.innerHTML = l.attrs.html;
|
|
261
|
+
const r = o.querySelector("img"), i = r == null ? void 0 : r.title;
|
|
262
|
+
o.remove(), e.addNode("text", void 0, i);
|
|
275
263
|
}
|
|
276
264
|
}
|
|
277
265
|
}),
|
|
278
266
|
inputRules: (e) => [
|
|
279
|
-
new F(Z, (
|
|
280
|
-
const
|
|
281
|
-
if (!
|
|
267
|
+
new F(Z, (l, o, r, i) => {
|
|
268
|
+
const a = o[0];
|
|
269
|
+
if (!a)
|
|
282
270
|
return null;
|
|
283
|
-
const t =
|
|
284
|
-
if (!t ||
|
|
271
|
+
const t = A.get(a);
|
|
272
|
+
if (!t || a.includes(t))
|
|
285
273
|
return null;
|
|
286
|
-
const
|
|
287
|
-
return
|
|
274
|
+
const m = C(t, s == null ? void 0 : s.twemojiOptions);
|
|
275
|
+
return l.tr.setMeta("emoji", !0).replaceRangeWith(r, i, e.create({ html: m })).scrollIntoView();
|
|
288
276
|
})
|
|
289
277
|
],
|
|
290
|
-
remarkPlugins: () => [I,
|
|
278
|
+
remarkPlugins: () => [I, ce(s == null ? void 0 : s.twemojiOptions)],
|
|
291
279
|
prosePlugins: () => {
|
|
292
280
|
var e;
|
|
293
|
-
return [re(
|
|
281
|
+
return [re(n, (e = s == null ? void 0 : s.maxListSize) != null ? e : 6, s == null ? void 0 : s.twemojiOptions)];
|
|
294
282
|
}
|
|
295
283
|
};
|
|
296
|
-
}),
|
|
284
|
+
}), Ee = O.create([ae()]);
|
|
297
285
|
export {
|
|
298
|
-
|
|
299
|
-
|
|
286
|
+
Ee as emoji,
|
|
287
|
+
ae as emojiNode
|
|
300
288
|
};
|
|
301
289
|
//# sourceMappingURL=index.es.js.map
|