@etrepum/lexical-emoji-plan 0.0.4 → 0.0.5

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
@@ -1,3 +1,4 @@
1
- # `@etrepum/lexical-builder`
1
+ # `@etrepum/lexical-emoji-plan`
2
2
 
3
- **EXPERIMENTAL** A high-level way to manage Lexical config and plug-ins for any framework
3
+ **EXPERIMENTAL** A lexical builder optimized Emoji plugin with deferred
4
+ loading of the emoji database
@@ -5,8 +5,17 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export declare const EmojiPlan: import('@etrepum/lexical-builder').LexicalPlan<{
8
+ declare const NAME = "@etrepum/lexical-builder/emoji-plan";
9
+ export interface EmojiPlanConfig {
9
10
  emojiBaseUrl: string;
10
11
  emojiClass: string;
11
- }, "@lexical/examples/vanilla-js/emoji-plan">;
12
+ emojiLoadedClass: string;
13
+ }
14
+ declare module '@etrepum/lexical-builder' {
15
+ interface LexicalPlanRegistry {
16
+ [NAME]: EmojiPlanConfig;
17
+ }
18
+ }
19
+ export declare const EmojiPlan: import('@etrepum/lexical-builder').LexicalPlan<EmojiPlanConfig, "@etrepum/lexical-builder/emoji-plan">;
20
+ export {};
12
21
  //# sourceMappingURL=EmojiPlan.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmojiPlan.d.ts","sourceRoot":"","sources":["../src/EmojiPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,eAAO,MAAM,SAAS;;;6CAqCpB,CAAC"}
1
+ {"version":3,"file":"EmojiPlan.d.ts","sourceRoot":"","sources":["../src/EmojiPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,QAAA,MAAM,IAAI,wCAAwC,CAAC;AACnD,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,OAAO,QAAQ,0BAA0B,CAAC;IACxC,UAAU,mBAAmB;QAC3B,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC;KACzB;CACF;AAED,eAAO,MAAM,SAAS,wGA8CpB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=findEmoji.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findEmoji.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/findEmoji.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=unifiedID.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unifiedID.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/unifiedID.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -1,4 +1,4 @@
1
- import { $ as i } from "./index-C6HoUNop.js";
1
+ import { $ as i } from "./index-DgoyRltj.js";
2
2
  const _ = `🀄 mahjong
3
3
  🃏 black_joker
4
4
  🅰️ a
@@ -0,0 +1,66 @@
1
+ import { definePlan as p, safeCast as u } from "@etrepum/lexical-builder";
2
+ import { mergeRegister as j } from "@lexical/utils";
3
+ import { TextNode as d } from "lexical";
4
+ class r extends d {
5
+ static getType() {
6
+ return "emoji";
7
+ }
8
+ static clone(e) {
9
+ return new r(e.__text, e.__key);
10
+ }
11
+ static importJSON(e) {
12
+ return g(e.text);
13
+ }
14
+ exportJSON() {
15
+ return {
16
+ ...super.exportJSON(),
17
+ type: "emoji"
18
+ };
19
+ }
20
+ }
21
+ function g(t) {
22
+ return new r(t).setMode("token");
23
+ }
24
+ function f(t) {
25
+ return Array.from(
26
+ t,
27
+ (e) => e.codePointAt(0).toString(16).padStart(4, "0")
28
+ ).join("-");
29
+ }
30
+ const x = "@etrepum/lexical-builder/emoji-plan", L = p({
31
+ config: u({
32
+ emojiBaseUrl: "https://cdn.jsdelivr.net/npm/@etrepum/lexical-emoji-plan@0.0.5/dist/emoji",
33
+ emojiClass: "emoji-node",
34
+ emojiLoadedClass: "emoji-node-loaded"
35
+ }),
36
+ name: x,
37
+ nodes: [r],
38
+ register(t, e, s) {
39
+ let n = t.registerMutationListener(r, (i) => {
40
+ for (const [l, c] of i)
41
+ if (c !== "destroyed") {
42
+ const o = t.getElementByKey(l);
43
+ if (o) {
44
+ const a = `${e.emojiBaseUrl}/${f(o.innerText)}.png`;
45
+ o.classList.add(e.emojiClass), o.style.backgroundImage = `url(${a})`;
46
+ const m = new Image();
47
+ m.addEventListener(
48
+ "load",
49
+ () => o.classList.add(e.emojiLoadedClass),
50
+ { signal: s.signal, once: !0 }
51
+ ), m.src = a;
52
+ }
53
+ }
54
+ });
55
+ return import("./_textNodeTransform-BK8SL6Gn.js").then(({ $textNodeTransform: i }) => {
56
+ s.signal.aborted || (n = j(
57
+ n,
58
+ t.registerNodeTransform(d, i)
59
+ ));
60
+ }), () => n();
61
+ }
62
+ });
63
+ export {
64
+ g as $,
65
+ L as E
66
+ };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,2 @@
1
- import { LexicalPlanConfig } from '@etrepum/lexical-builder';
2
- import { EmojiPlan } from './EmojiPlan';
3
-
4
- export type EmojiConfig = LexicalPlanConfig<typeof EmojiPlan>;
5
- export { EmojiPlan };
1
+ export { EmojiPlan, type EmojiPlanConfig } from './EmojiPlan';
6
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { E as m } from "./index-C6HoUNop.js";
1
+ import { E as m } from "./index-DgoyRltj.js";
2
2
  export {
3
3
  m as EmojiPlan
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"supportedEmojis.data.d.ts","sourceRoot":"","sources":["../src/supportedEmojis.data.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,eAAe,QAef,CAAC"}
1
+ {"version":3,"file":"supportedEmojis.data.d.ts","sourceRoot":"","sources":["../src/supportedEmojis.data.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,eAAe,QAYf,CAAC"}
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "test": "vitest run",
16
16
  "test:watch": "vitest"
17
17
  },
18
- "version": "0.0.4",
18
+ "version": "0.0.5",
19
19
  "license": "MIT",
20
20
  "repository": {
21
21
  "type": "git",
@@ -42,6 +42,7 @@
42
42
  "vite": "^5.2.11",
43
43
  "vite-plugin-data": "^0.2.5",
44
44
  "vite-plugin-dts": "^3.9.1",
45
+ "vite-plugin-package-version": "^1.1.0",
45
46
  "vite-plugin-static-copy": "^1.0.5",
46
47
  "vitest": "^1.6.0"
47
48
  },