@milkdown/plugin-emoji 7.6.2 → 7.6.3

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/README.md CHANGED
@@ -4,7 +4,7 @@ The emoji plugin of [milkdown](https://milkdown.dev/).
4
4
 
5
5
  # Official Documentation
6
6
 
7
- Documentation can be found on the [Milkdown website](https://milkdown.dev/docs/api/plugin-emoji).
7
+ Documentation can be found on the [Milkdown website](https://milkdown.dev/).
8
8
 
9
9
  # License
10
10
 
package/lib/index.es.js CHANGED
@@ -1,76 +1,76 @@
1
1
  import { expectDomTypeError as M } from "@milkdown/exception";
2
- import { InputRule as R } from "@milkdown/prose/inputrules";
3
- import { $nodeAttr as v, $nodeSchema as x, $remark as y, $inputRule as T } from "@milkdown/utils";
2
+ import { InputRule as v } from "@milkdown/prose/inputrules";
3
+ import { $nodeAttr as R, $nodeSchema as x, $remark as y, $inputRule as T } from "@milkdown/utils";
4
4
  import { get as P } from "node-emoji";
5
5
  import A from "remark-emoji";
6
6
  import I from "twemoji";
7
7
  import L from "emoji-regex";
8
- const b = (n) => ({ title: n });
9
- function w(n, t) {
10
- return I.parse(n, {
8
+ const b = (r) => ({ title: r });
9
+ function w(r, e) {
10
+ return I.parse(r, {
11
11
  attributes: b,
12
12
  base: "https://cdn.jsdelivr.net/gh/twitter/twemoji/assets/",
13
- ...t
13
+ ...e
14
14
  });
15
15
  }
16
- const k = L(), C = (n) => !!n.children, H = (n) => !!n.value;
17
- function S(n, t) {
18
- return m(n, 0, null)[0];
19
- function m(e, r, i) {
20
- if (C(e)) {
16
+ const k = L(), C = (r) => !!r.children, H = (r) => !!r.value;
17
+ function S(r, e) {
18
+ return m(r, 0, null)[0];
19
+ function m(t, n, i) {
20
+ if (C(t)) {
21
21
  const a = [];
22
- for (let o = 0, c = e.children.length; o < c; o++) {
23
- const l = e.children[o];
22
+ for (let o = 0, c = t.children.length; o < c; o++) {
23
+ const l = t.children[o];
24
24
  if (l) {
25
- const f = m(l, o, e);
25
+ const f = m(l, o, t);
26
26
  if (f)
27
27
  for (let h = 0, N = f.length; h < N; h++) {
28
- const g = f[h];
29
- g && a.push(g);
28
+ const d = f[h];
29
+ d && a.push(d);
30
30
  }
31
31
  }
32
32
  }
33
- e.children = a;
33
+ t.children = a;
34
34
  }
35
- return t(e, r, i);
35
+ return e(t, n, i);
36
36
  }
37
37
  }
38
- const $ = (n) => {
39
- function t(m) {
40
- S(m, (e) => {
41
- if (!H(e)) return [e];
42
- if (e.type === "code") return [e];
43
- const r = e.value, i = [];
44
- let a, o = r;
38
+ const $ = (r) => {
39
+ function e(m) {
40
+ S(m, (t) => {
41
+ if (!H(t)) return [t];
42
+ if (t.type === "code") return [t];
43
+ const n = t.value, i = [];
44
+ let a, o = n;
45
45
  for (; a = k.exec(o); ) {
46
46
  const { index: c } = a, l = a[0];
47
- l && (c > 0 && i.push({ ...e, value: o.slice(0, c) }), i.push({
48
- ...e,
49
- value: w(l, n),
47
+ l && (c > 0 && i.push({ ...t, value: o.slice(0, c) }), i.push({
48
+ ...t,
49
+ value: w(l, r),
50
50
  type: "emoji"
51
51
  }), o = o.slice(c + l.length)), k.lastIndex = 0;
52
52
  }
53
- return o.length && i.push({ ...e, value: o }), i;
53
+ return o.length && i.push({ ...t, value: o }), i;
54
54
  });
55
55
  }
56
- return t;
56
+ return e;
57
57
  };
58
- function s(n, t) {
59
- return Object.assign(n, {
58
+ function s(r, e) {
59
+ return Object.assign(r, {
60
60
  meta: {
61
61
  package: "@milkdown/plugin-emoji",
62
- ...t
62
+ ...e
63
63
  }
64
- }), n;
64
+ }), r;
65
65
  }
66
- const j = v("emoji", () => ({
66
+ const j = R("emoji", () => ({
67
67
  span: {},
68
68
  img: {}
69
69
  }));
70
70
  s(j, {
71
71
  displayName: "Attr<emoji>"
72
72
  });
73
- const u = x("emoji", (n) => ({
73
+ const u = x("emoji", (r) => ({
74
74
  group: "inline",
75
75
  inline: !0,
76
76
  attrs: {
@@ -81,34 +81,34 @@ const u = x("emoji", (n) => ({
81
81
  parseDOM: [
82
82
  {
83
83
  tag: 'span[data-type="emoji"]',
84
- getAttrs: (t) => {
85
- if (!(t instanceof HTMLElement)) throw M(t);
86
- return { html: t.innerHTML };
84
+ getAttrs: (e) => {
85
+ if (!(e instanceof HTMLElement)) throw M(e);
86
+ return { html: e.innerHTML };
87
87
  }
88
88
  }
89
89
  ],
90
- toDOM: (t) => {
90
+ toDOM: (e) => {
91
91
  var i;
92
- const m = n.get(j.key)(t), e = document.createElement("span");
93
- e.innerHTML = t.attrs.html;
94
- const r = (i = e.firstElementChild) == null ? void 0 : i.cloneNode();
95
- return e.remove(), r && r instanceof HTMLElement && Object.entries(m.img).forEach(
96
- ([a, o]) => r.setAttribute(a, o)
97
- ), ["span", { ...m.container, "data-type": "emoji" }, r];
92
+ const m = r.get(j.key)(e), t = document.createElement("span");
93
+ t.innerHTML = e.attrs.html;
94
+ const n = (i = t.firstElementChild) == null ? void 0 : i.cloneNode();
95
+ return t.remove(), n && n instanceof HTMLElement && Object.entries(m.img).forEach(
96
+ ([a, o]) => n.setAttribute(a, o)
97
+ ), ["span", { ...m.container, "data-type": "emoji" }, n];
98
98
  },
99
99
  parseMarkdown: {
100
- match: ({ type: t }) => t === "emoji",
101
- runner: (t, m, e) => {
102
- t.addNode(e, { html: m.value });
100
+ match: ({ type: e }) => e === "emoji",
101
+ runner: (e, m, t) => {
102
+ e.addNode(t, { html: m.value });
103
103
  }
104
104
  },
105
105
  toMarkdown: {
106
- match: (t) => t.type.name === "emoji",
107
- runner: (t, m) => {
108
- const e = document.createElement("span");
109
- e.innerHTML = m.attrs.html;
110
- const r = e.querySelector("img"), i = (r == null ? void 0 : r.title) || (r == null ? void 0 : r.alt);
111
- e.remove(), t.addNode("text", void 0, i);
106
+ match: (e) => e.type.name === "emoji",
107
+ runner: (e, m) => {
108
+ const t = document.createElement("span");
109
+ t.innerHTML = m.attrs.html;
110
+ const n = t.querySelector("img"), i = (n == null ? void 0 : n.title) || (n == null ? void 0 : n.alt);
111
+ t.remove(), e.addNode("text", void 0, i);
112
112
  }
113
113
  }
114
114
  }));
@@ -118,14 +118,14 @@ s(u.node, {
118
118
  s(u.ctx, {
119
119
  displayName: "NodeSchemaCtx<emoji>"
120
120
  });
121
- const d = y(
121
+ const g = y(
122
122
  "remarkEmoji",
123
123
  () => A
124
124
  );
125
- s(d.plugin, {
125
+ s(g.plugin, {
126
126
  displayName: "Remark<remarkEmojiPlugin>"
127
127
  });
128
- s(d.options, {
128
+ s(g.options, {
129
129
  displayName: "RemarkConfig<remarkEmojiPlugin>"
130
130
  });
131
131
  const p = y("remarkTwemoji", () => $);
@@ -136,13 +136,13 @@ s(p.options, {
136
136
  displayName: "RemarkConfig<remarkTwemojiPlugin>"
137
137
  });
138
138
  const E = T(
139
- (n) => new R(/(:([^:\s]+):)$/, (t, m, e, r) => {
139
+ (r) => new v(/(:([^:\s]+):)$/, (e, m, t, n) => {
140
140
  const i = m[0];
141
141
  if (!i) return null;
142
142
  const a = P(i);
143
143
  if (!a || i.includes(a)) return null;
144
- const o = w(a, n.get(p.options.key));
145
- return t.tr.setMeta("emoji", !0).replaceRangeWith(e, r, u.type(n).create({ html: o })).scrollIntoView();
144
+ const o = w(a, r.get(p.options.key));
145
+ return e.tr.setMeta("emoji", !0).replaceRangeWith(t, n, u.type(r).create({ html: o })).scrollIntoView();
146
146
  })
147
147
  );
148
148
  s(E, {
@@ -150,7 +150,7 @@ s(E, {
150
150
  });
151
151
  const F = [
152
152
  j,
153
- d,
153
+ g,
154
154
  p,
155
155
  u,
156
156
  E
@@ -160,7 +160,7 @@ export {
160
160
  j as emojiAttr,
161
161
  u as emojiSchema,
162
162
  E as insertEmojiInputRule,
163
- d as remarkEmojiPlugin,
163
+ g as remarkEmojiPlugin,
164
164
  p as remarkTwemojiPlugin
165
165
  };
166
166
  //# sourceMappingURL=index.es.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@milkdown/plugin-emoji",
3
3
  "type": "module",
4
- "version": "7.6.2",
4
+ "version": "7.6.3",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -37,14 +37,14 @@
37
37
  "tslib": "^2.8.1",
38
38
  "twemoji": "^14.0.2",
39
39
  "unist-util-visit": "^5.0.0",
40
- "@milkdown/exception": "7.6.2",
41
- "@milkdown/utils": "7.6.2"
40
+ "@milkdown/exception": "7.6.3",
41
+ "@milkdown/utils": "7.6.3"
42
42
  },
43
43
  "devDependencies": {
44
- "@milkdown/core": "7.6.2",
45
- "@milkdown/prose": "7.6.2",
46
- "@milkdown/ctx": "7.6.2",
47
- "@milkdown/transformer": "7.6.2"
44
+ "@milkdown/core": "7.6.3",
45
+ "@milkdown/ctx": "7.6.3",
46
+ "@milkdown/prose": "7.6.3",
47
+ "@milkdown/transformer": "7.6.3"
48
48
  },
49
49
  "nx": {
50
50
  "targets": {