@liveblocks/react-lexical 1.12.0-lexical6 → 2.0.0-alpha2

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.
Files changed (80) hide show
  1. package/dist/classnames.js +8 -0
  2. package/dist/classnames.js.map +1 -0
  3. package/dist/classnames.mjs +6 -0
  4. package/dist/classnames.mjs.map +1 -0
  5. package/dist/comments/ThreadPanel.js +27 -7
  6. package/dist/comments/ThreadPanel.js.map +1 -1
  7. package/dist/comments/ThreadPanel.mjs +28 -8
  8. package/dist/comments/ThreadPanel.mjs.map +1 -1
  9. package/dist/comments/comment-plugin-provider.js +18 -106
  10. package/dist/comments/comment-plugin-provider.js.map +1 -1
  11. package/dist/comments/comment-plugin-provider.mjs +17 -104
  12. package/dist/comments/comment-plugin-provider.mjs.map +1 -1
  13. package/dist/comments/floating-composer.js +226 -15
  14. package/dist/comments/floating-composer.js.map +1 -1
  15. package/dist/comments/floating-composer.mjs +224 -15
  16. package/dist/comments/floating-composer.mjs.map +1 -1
  17. package/dist/create-dom-range.js +63 -0
  18. package/dist/create-dom-range.js.map +1 -0
  19. package/dist/create-dom-range.mjs +61 -0
  20. package/dist/create-dom-range.mjs.map +1 -0
  21. package/dist/create-rects-from-dom-range.js +36 -0
  22. package/dist/create-rects-from-dom-range.js.map +1 -0
  23. package/dist/create-rects-from-dom-range.mjs +34 -0
  24. package/dist/create-rects-from-dom-range.mjs.map +1 -0
  25. package/dist/index.d.mts +96 -44
  26. package/dist/index.d.ts +96 -44
  27. package/dist/index.js +9 -6
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +5 -4
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/liveblocks-config.js +3 -75
  32. package/dist/liveblocks-config.js.map +1 -1
  33. package/dist/liveblocks-config.mjs +4 -56
  34. package/dist/liveblocks-config.mjs.map +1 -1
  35. package/dist/liveblocks-plugin-provider.js +12 -29
  36. package/dist/liveblocks-plugin-provider.js.map +1 -1
  37. package/dist/liveblocks-plugin-provider.mjs +13 -29
  38. package/dist/liveblocks-plugin-provider.mjs.map +1 -1
  39. package/dist/mentions/avatar.js +10 -6
  40. package/dist/mentions/avatar.js.map +1 -1
  41. package/dist/mentions/avatar.mjs +10 -6
  42. package/dist/mentions/avatar.mjs.map +1 -1
  43. package/dist/mentions/mention-component.js +5 -18
  44. package/dist/mentions/mention-component.js.map +1 -1
  45. package/dist/mentions/mention-component.mjs +7 -19
  46. package/dist/mentions/mention-component.mjs.map +1 -1
  47. package/dist/mentions/mention-node.js +76 -80
  48. package/dist/mentions/mention-node.js.map +1 -1
  49. package/dist/mentions/mention-node.mjs +75 -81
  50. package/dist/mentions/mention-node.mjs.map +1 -1
  51. package/dist/mentions/mention-plugin.js +102 -90
  52. package/dist/mentions/mention-plugin.js.map +1 -1
  53. package/dist/mentions/mention-plugin.mjs +87 -71
  54. package/dist/mentions/mention-plugin.mjs.map +1 -1
  55. package/dist/mentions/suggestions.js +34 -6
  56. package/dist/mentions/suggestions.js.map +1 -1
  57. package/dist/mentions/suggestions.mjs +28 -3
  58. package/dist/mentions/suggestions.mjs.map +1 -1
  59. package/dist/mentions/user.js +8 -5
  60. package/dist/mentions/user.js.map +1 -1
  61. package/dist/mentions/user.mjs +8 -5
  62. package/dist/mentions/user.mjs.map +1 -1
  63. package/dist/version.js +1 -1
  64. package/dist/version.js.map +1 -1
  65. package/dist/version.mjs +1 -1
  66. package/dist/version.mjs.map +1 -1
  67. package/package.json +13 -13
  68. package/src/styles/constants.css +1 -0
  69. package/src/styles/index.css +142 -0
  70. package/src/styles/utils.css +6 -0
  71. package/styles.css +1 -1
  72. package/styles.css.map +1 -1
  73. package/dist/active-selection.js +0 -143
  74. package/dist/active-selection.js.map +0 -1
  75. package/dist/active-selection.mjs +0 -123
  76. package/dist/active-selection.mjs.map +0 -1
  77. package/dist/floating-selection-container.js +0 -157
  78. package/dist/floating-selection-container.js.map +0 -1
  79. package/dist/floating-selection-container.mjs +0 -155
  80. package/dist/floating-selection-container.mjs.map +0 -1
package/dist/index.js CHANGED
@@ -2,19 +2,22 @@
2
2
 
3
3
  var core = require('@liveblocks/core');
4
4
  var version = require('./version.js');
5
+ var floatingComposer = require('./comments/floating-composer.js');
6
+ var threadMarkNode = require('./comments/thread-mark-node.js');
5
7
  var ThreadPanel = require('./comments/ThreadPanel.js');
6
8
  var liveblocksConfig = require('./liveblocks-config.js');
7
9
  var liveblocksPluginProvider = require('./liveblocks-plugin-provider.js');
8
10
  var mentionComponent = require('./mentions/mention-component.js');
9
- var floatingComposer = require('./comments/floating-composer.js');
10
- var commentPluginProvider = require('./comments/comment-plugin-provider.js');
11
+ var mentionNode = require('./mentions/mention-node.js');
11
12
 
12
13
  core.detectDupes(version.PKG_NAME, version.PKG_VERSION, version.PKG_FORMAT);
13
14
 
15
+ exports.FloatingComposer = floatingComposer.FloatingComposer;
16
+ exports.OPEN_FLOATING_COMPOSER_COMMAND = floatingComposer.OPEN_FLOATING_COMPOSER_COMMAND;
17
+ exports.ThreadMarkNode = threadMarkNode.ThreadMarkNode;
14
18
  exports.ThreadPanel = ThreadPanel.ThreadPanel;
15
- exports.liveblocksLexicalConfig = liveblocksConfig.liveblocksLexicalConfig;
16
- exports.LiveblocksPluginProvider = liveblocksPluginProvider.LiveblocksPluginProvider;
19
+ exports.liveblocksConfig = liveblocksConfig.liveblocksConfig;
20
+ exports.LiveblocksPlugin = liveblocksPluginProvider.LiveblocksPlugin;
17
21
  exports.Mention = mentionComponent.Mention;
18
- exports.FloatingComposer = floatingComposer.FloatingComposer;
19
- exports.useCreateThread = commentPluginProvider.useCreateThread;
22
+ exports.MentionNode = mentionNode.MentionNode;
20
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport { ThreadPanel } from \"./comments/ThreadPanel\";\nexport { liveblocksLexicalConfig } from \"./liveblocks-config\";\nexport { LiveblocksPluginProvider } from \"./liveblocks-plugin-provider\";\nexport { Mention } from \"./mentions/mention-component\";\nexport { FloatingComposer } from \"./comments/floating-composer\";\nexport { useCreateThread } from \"./comments/comment-plugin-provider\";\n"],"names":["detectDupes","PKG_NAME","PKG_VERSION","PKG_FORMAT"],"mappings":";;;;;;;;;;;AAIAA,gBAAY,CAAAC,gBAAA,EAAUC,qBAAaC,kBAAU,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport {\n FloatingComposer,\n OPEN_FLOATING_COMPOSER_COMMAND,\n} from \"./comments/floating-composer\";\nexport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nexport { ThreadPanel } from \"./comments/ThreadPanel\";\nexport { liveblocksConfig } from \"./liveblocks-config\";\nexport { LiveblocksPlugin } from \"./liveblocks-plugin-provider\";\nexport { Mention } from \"./mentions/mention-component\";\nexport { MentionNode } from \"./mentions/mention-node\";\n"],"names":["detectDupes","PKG_NAME","PKG_VERSION","PKG_FORMAT"],"mappings":";;;;;;;;;;;;AAIAA,gBAAY,CAAAC,gBAAA,EAAUC,qBAAaC,kBAAU,CAAA;;;;;;;;;;;"}
package/dist/index.mjs CHANGED
@@ -1,11 +1,12 @@
1
1
  import { detectDupes } from '@liveblocks/core';
2
2
  import { PKG_NAME, PKG_VERSION, PKG_FORMAT } from './version.mjs';
3
+ export { FloatingComposer, OPEN_FLOATING_COMPOSER_COMMAND } from './comments/floating-composer.mjs';
4
+ export { ThreadMarkNode } from './comments/thread-mark-node.mjs';
3
5
  export { ThreadPanel } from './comments/ThreadPanel.mjs';
4
- export { liveblocksLexicalConfig } from './liveblocks-config.mjs';
5
- export { LiveblocksPluginProvider } from './liveblocks-plugin-provider.mjs';
6
+ export { liveblocksConfig } from './liveblocks-config.mjs';
7
+ export { LiveblocksPlugin } from './liveblocks-plugin-provider.mjs';
6
8
  export { Mention } from './mentions/mention-component.mjs';
7
- export { FloatingComposer } from './comments/floating-composer.mjs';
8
- export { useCreateThread } from './comments/comment-plugin-provider.mjs';
9
+ export { MentionNode } from './mentions/mention-node.mjs';
9
10
 
10
11
  detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
11
12
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport { ThreadPanel } from \"./comments/ThreadPanel\";\nexport { liveblocksLexicalConfig } from \"./liveblocks-config\";\nexport { LiveblocksPluginProvider } from \"./liveblocks-plugin-provider\";\nexport { Mention } from \"./mentions/mention-component\";\nexport { FloatingComposer } from \"./comments/floating-composer\";\nexport { useCreateThread } from \"./comments/comment-plugin-provider\";\n"],"names":[],"mappings":";;;;;;;;;AAIA,WAAY,CAAA,QAAA,EAAU,aAAa,UAAU,CAAA"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport {\n FloatingComposer,\n OPEN_FLOATING_COMPOSER_COMMAND,\n} from \"./comments/floating-composer\";\nexport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nexport { ThreadPanel } from \"./comments/ThreadPanel\";\nexport { liveblocksConfig } from \"./liveblocks-config\";\nexport { LiveblocksPlugin } from \"./liveblocks-plugin-provider\";\nexport { Mention } from \"./mentions/mention-component\";\nexport { MentionNode } from \"./mentions/mention-node\";\n"],"names":[],"mappings":";;;;;;;;;;AAIA,WAAY,CAAA,QAAA,EAAU,aAAa,UAAU,CAAA"}
@@ -1,89 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
4
3
  var threadMarkNode = require('./comments/thread-mark-node.js');
5
- var avatar = require('./mentions/avatar.js');
6
- var mentionComponent = require('./mentions/mention-component.js');
7
4
  var mentionNode = require('./mentions/mention-node.js');
8
- var suggestions = require('./mentions/suggestions.js');
9
- var user = require('./mentions/user.js');
10
5
 
11
- function _interopNamespaceDefault(e) {
12
- var n = Object.create(null);
13
- if (e) {
14
- Object.keys(e).forEach(function (k) {
15
- if (k !== 'default') {
16
- var d = Object.getOwnPropertyDescriptor(e, k);
17
- Object.defineProperty(n, k, d.get ? d : {
18
- enumerable: true,
19
- get: function () { return e[k]; }
20
- });
21
- }
22
- });
23
- }
24
- n.default = e;
25
- return Object.freeze(n);
26
- }
27
-
28
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
29
-
30
- let liveblocksConfig = null;
31
- const MENTION_CHARACTER = "@";
32
- const defaultComponents = {
33
- Mention: ({ userId }) => {
34
- return /* @__PURE__ */ React__namespace.createElement(mentionComponent.Mention, {
35
- className: "lb-lexical-mention"
36
- }, MENTION_CHARACTER, /* @__PURE__ */ React__namespace.createElement(user.User, {
37
- userId
38
- }));
39
- },
40
- MentionSuggestions: ({ userIds }) => {
41
- return /* @__PURE__ */ React__namespace.createElement(suggestions.List, {
42
- className: "lb-lexical-suggestions-list"
43
- }, userIds.map((userId) => /* @__PURE__ */ React__namespace.createElement(suggestions.Item, {
44
- key: userId,
45
- value: userId,
46
- className: "lb-lexical-suggestions-list-item"
47
- }, /* @__PURE__ */ React__namespace.createElement(avatar.Avatar, {
48
- userId,
49
- className: "lb-lexical-mention-suggestion-avatar"
50
- }), /* @__PURE__ */ React__namespace.createElement(user.User, {
51
- userId,
52
- className: "lb-lexical-mention-suggestion-user"
53
- }))));
54
- }
55
- };
56
- function liveblocksLexicalConfig(editorConfig, config = {}) {
57
- const { comments = true, components = {} } = config;
6
+ function liveblocksConfig(editorConfig) {
58
7
  const nodes = [...editorConfig.nodes ?? []];
59
- const Mention2 = components.Mention ?? defaultComponents.Mention;
60
- const MentionSuggestions = components.MentionSuggestions ?? defaultComponents.MentionSuggestions;
61
- const mentionFactory = mentionNode.createMentionNodeFactory(Mention2);
62
- nodes.push(threadMarkNode.ThreadMarkNode, mentionFactory.MentionNode);
63
- liveblocksConfig = {
64
- comments,
65
- mentions: {
66
- factory: mentionFactory,
67
- components: {
68
- MentionSuggestions
69
- }
70
- }
71
- };
8
+ nodes.push(threadMarkNode.ThreadMarkNode, mentionNode.MentionNode);
72
9
  return {
73
10
  ...editorConfig,
74
11
  nodes,
75
12
  editorState: null
76
13
  };
77
14
  }
78
- function getLiveblocksLexicalConfig() {
79
- if (liveblocksConfig === null) {
80
- throw new Error("Liveblocks config is not initialized.");
81
- }
82
- return {
83
- ...liveblocksConfig
84
- };
85
- }
86
15
 
87
- exports.getLiveblocksLexicalConfig = getLiveblocksLexicalConfig;
88
- exports.liveblocksLexicalConfig = liveblocksLexicalConfig;
16
+ exports.liveblocksConfig = liveblocksConfig;
89
17
  //# sourceMappingURL=liveblocks-config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"liveblocks-config.js","sources":["../src/liveblocks-config.tsx"],"sourcesContent":["import type { InitialConfigType } from \"@lexical/react/LexicalComposer\";\nimport type { ComponentType } from \"react\";\nimport * as React from \"react\";\n\nimport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nimport type { LiveblocksLexicalInternalConfig } from \"./liveblocks-plugin-provider\";\nimport { Avatar } from \"./mentions/avatar\";\nimport { Mention } from \"./mentions/mention-component\";\nimport { createMentionNodeFactory } from \"./mentions/mention-node\";\nimport * as Suggestions from \"./mentions/suggestions\";\nimport { User } from \"./mentions/user\";\n\nlet liveblocksConfig: LiveblocksLexicalInternalConfig | null = null;\n\nexport interface MentionProps {\n /**\n * The mention's user ID.\n */\n userId: string;\n}\n\nexport interface MentionSuggestionsProps {\n /**\n * The list of suggested user IDs.\n */\n userIds: string[];\n}\n\ninterface EditorComponents {\n Mention: ComponentType<MentionProps>;\n MentionSuggestions: ComponentType<MentionSuggestionsProps>;\n}\n\nexport interface LiveblocksConfig {\n /**\n * Whether comments are enabled. Defaults to true.\n */\n comments?: boolean;\n /**\n * The components displayed within the editor.\n */\n components?: Partial<EditorComponents>;\n}\n\nconst MENTION_CHARACTER = \"@\";\nconst defaultComponents: EditorComponents = {\n Mention: ({ userId }) => {\n return (\n <Mention className=\"lb-lexical-mention\">\n {MENTION_CHARACTER}\n <User userId={userId} />\n </Mention>\n );\n },\n MentionSuggestions: ({ userIds }) => {\n return (\n <Suggestions.List className=\"lb-lexical-suggestions-list\">\n {userIds.map((userId) => (\n <Suggestions.Item\n key={userId}\n value={userId}\n className=\"lb-lexical-suggestions-list-item\"\n >\n <Avatar\n userId={userId}\n className=\"lb-lexical-mention-suggestion-avatar\"\n />\n <User\n userId={userId}\n className=\"lb-lexical-mention-suggestion-user\"\n />\n </Suggestions.Item>\n ))}\n </Suggestions.List>\n );\n },\n};\n\nexport function liveblocksLexicalConfig(\n editorConfig: InitialConfigType,\n config: LiveblocksConfig = {}\n) {\n const { comments = true, components = {} } = config;\n\n const nodes = [...(editorConfig.nodes ?? [])];\n\n const Mention = components.Mention ?? defaultComponents.Mention;\n const MentionSuggestions =\n components.MentionSuggestions ?? defaultComponents.MentionSuggestions;\n\n const mentionFactory = createMentionNodeFactory(Mention);\n\n nodes.push(ThreadMarkNode, mentionFactory.MentionNode);\n\n liveblocksConfig = {\n comments,\n mentions: {\n factory: mentionFactory,\n components: {\n MentionSuggestions,\n },\n },\n };\n\n return {\n ...editorConfig,\n nodes,\n editorState: null, // explicitly null because CollabProvider requires it\n };\n}\n\nexport function getLiveblocksLexicalConfig(): LiveblocksLexicalInternalConfig {\n if (liveblocksConfig === null) {\n throw new Error(\"Liveblocks config is not initialized.\");\n }\n return {\n ...liveblocksConfig,\n };\n}\n"],"names":["React","Mention","User","Suggestions.List","Suggestions.Item","Avatar","createMentionNodeFactory","ThreadMarkNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAI,gBAA2D,GAAA,IAAA,CAAA;AAgC/D,MAAM,iBAAoB,GAAA,GAAA,CAAA;AAC1B,MAAM,iBAAsC,GAAA;AAAA,EAC1C,OAAS,EAAA,CAAC,EAAE,MAAA,EAAa,KAAA;AACvB,IAAA,uBACGA,gBAAA,CAAA,aAAA,CAAAC,wBAAA,EAAA;AAAA,MAAQ,SAAU,EAAA,oBAAA;AAAA,KAAA,EAChB,mCACAD,gBAAA,CAAA,aAAA,CAAAE,SAAA,EAAA;AAAA,MAAK,MAAA;AAAA,KAAgB,CACxB,CAAA,CAAA;AAAA,GAEJ;AAAA,EACA,kBAAoB,EAAA,CAAC,EAAE,OAAA,EAAc,KAAA;AACnC,IACE,uBAAAF,gBAAA,CAAA,aAAA,CAACG,gBAAA,EAAA;AAAA,MAAiB,SAAU,EAAA,6BAAA;AAAA,KAAA,EACzB,QAAQ,GAAI,CAAA,CAAC,MACZ,qBAAAH,gBAAA,CAAA,aAAA,CAACI,gBAAA,EAAA;AAAA,MACC,GAAK,EAAA,MAAA;AAAA,MACL,KAAO,EAAA,MAAA;AAAA,MACP,SAAU,EAAA,kCAAA;AAAA,KAAA,kBAETJ,gBAAA,CAAA,aAAA,CAAAK,aAAA,EAAA;AAAA,MACC,MAAA;AAAA,MACA,SAAU,EAAA,sCAAA;AAAA,KACZ,mBACCL,gBAAA,CAAA,aAAA,CAAAE,SAAA,EAAA;AAAA,MACC,MAAA;AAAA,MACA,SAAU,EAAA,oCAAA;AAAA,KACZ,CACF,CACD,CACH,CAAA,CAAA;AAAA,GAEJ;AACF,CAAA,CAAA;AAEO,SAAS,uBACd,CAAA,YAAA,EACA,MAA2B,GAAA,EAC3B,EAAA;AACA,EAAA,MAAM,EAAE,QAAW,GAAA,IAAA,EAAM,UAAa,GAAA,IAAO,GAAA,MAAA,CAAA;AAE7C,EAAA,MAAM,QAAQ,CAAC,GAAI,YAAa,CAAA,KAAA,IAAS,EAAG,CAAA,CAAA;AAE5C,EAAMD,MAAAA,QAAAA,GAAU,UAAW,CAAA,OAAA,IAAW,iBAAkB,CAAA,OAAA,CAAA;AACxD,EAAM,MAAA,kBAAA,GACJ,UAAW,CAAA,kBAAA,IAAsB,iBAAkB,CAAA,kBAAA,CAAA;AAErD,EAAM,MAAA,cAAA,GAAiBK,qCAAyBL,QAAO,CAAA,CAAA;AAEvD,EAAM,KAAA,CAAA,IAAA,CAAKM,6BAAgB,EAAA,cAAA,CAAe,WAAW,CAAA,CAAA;AAErD,EAAmB,gBAAA,GAAA;AAAA,IACjB,QAAA;AAAA,IACA,QAAU,EAAA;AAAA,MACR,OAAS,EAAA,cAAA;AAAA,MACT,UAAY,EAAA;AAAA,QACV,kBAAA;AAAA,OACF;AAAA,KACF;AAAA,GACF,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,KAAA;AAAA,IACA,WAAa,EAAA,IAAA;AAAA,GACf,CAAA;AACF,CAAA;AAEO,SAAS,0BAA8D,GAAA;AAC5E,EAAA,IAAI,qBAAqB,IAAM,EAAA;AAC7B,IAAM,MAAA,IAAI,MAAM,uCAAuC,CAAA,CAAA;AAAA,GACzD;AACA,EAAO,OAAA;AAAA,IACL,GAAG,gBAAA;AAAA,GACL,CAAA;AACF;;;;;"}
1
+ {"version":3,"file":"liveblocks-config.js","sources":["../src/liveblocks-config.ts"],"sourcesContent":["import type { InitialConfigType } from \"@lexical/react/LexicalComposer\";\n\nimport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nimport { MentionNode } from \"./mentions/mention-node\";\n\nexport function liveblocksConfig(\n editorConfig: Omit<InitialConfigType, \"editorState\">\n) {\n const nodes = [...(editorConfig.nodes ?? [])];\n\n nodes.push(ThreadMarkNode, MentionNode);\n\n return {\n ...editorConfig,\n nodes,\n editorState: null, // explicitly null because CollabProvider requires it\n };\n}\n"],"names":["ThreadMarkNode","MentionNode"],"mappings":";;;;;AAKO,SAAS,iBACd,YACA,EAAA;AACA,EAAA,MAAM,QAAQ,CAAC,GAAI,YAAa,CAAA,KAAA,IAAS,EAAG,CAAA,CAAA;AAE5C,EAAM,KAAA,CAAA,IAAA,CAAKA,+BAAgBC,uBAAW,CAAA,CAAA;AAEtC,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,KAAA;AAAA,IACA,WAAa,EAAA,IAAA;AAAA,GACf,CAAA;AACF;;;;"}
@@ -1,67 +1,15 @@
1
- import * as React from 'react';
2
1
  import { ThreadMarkNode } from './comments/thread-mark-node.mjs';
3
- import { Avatar } from './mentions/avatar.mjs';
4
- import { Mention } from './mentions/mention-component.mjs';
5
- import { createMentionNodeFactory } from './mentions/mention-node.mjs';
6
- import { List, Item } from './mentions/suggestions.mjs';
7
- import { User } from './mentions/user.mjs';
2
+ import { MentionNode } from './mentions/mention-node.mjs';
8
3
 
9
- let liveblocksConfig = null;
10
- const MENTION_CHARACTER = "@";
11
- const defaultComponents = {
12
- Mention: ({ userId }) => {
13
- return /* @__PURE__ */ React.createElement(Mention, {
14
- className: "lb-lexical-mention"
15
- }, MENTION_CHARACTER, /* @__PURE__ */ React.createElement(User, {
16
- userId
17
- }));
18
- },
19
- MentionSuggestions: ({ userIds }) => {
20
- return /* @__PURE__ */ React.createElement(List, {
21
- className: "lb-lexical-suggestions-list"
22
- }, userIds.map((userId) => /* @__PURE__ */ React.createElement(Item, {
23
- key: userId,
24
- value: userId,
25
- className: "lb-lexical-suggestions-list-item"
26
- }, /* @__PURE__ */ React.createElement(Avatar, {
27
- userId,
28
- className: "lb-lexical-mention-suggestion-avatar"
29
- }), /* @__PURE__ */ React.createElement(User, {
30
- userId,
31
- className: "lb-lexical-mention-suggestion-user"
32
- }))));
33
- }
34
- };
35
- function liveblocksLexicalConfig(editorConfig, config = {}) {
36
- const { comments = true, components = {} } = config;
4
+ function liveblocksConfig(editorConfig) {
37
5
  const nodes = [...editorConfig.nodes ?? []];
38
- const Mention2 = components.Mention ?? defaultComponents.Mention;
39
- const MentionSuggestions = components.MentionSuggestions ?? defaultComponents.MentionSuggestions;
40
- const mentionFactory = createMentionNodeFactory(Mention2);
41
- nodes.push(ThreadMarkNode, mentionFactory.MentionNode);
42
- liveblocksConfig = {
43
- comments,
44
- mentions: {
45
- factory: mentionFactory,
46
- components: {
47
- MentionSuggestions
48
- }
49
- }
50
- };
6
+ nodes.push(ThreadMarkNode, MentionNode);
51
7
  return {
52
8
  ...editorConfig,
53
9
  nodes,
54
10
  editorState: null
55
11
  };
56
12
  }
57
- function getLiveblocksLexicalConfig() {
58
- if (liveblocksConfig === null) {
59
- throw new Error("Liveblocks config is not initialized.");
60
- }
61
- return {
62
- ...liveblocksConfig
63
- };
64
- }
65
13
 
66
- export { getLiveblocksLexicalConfig, liveblocksLexicalConfig };
14
+ export { liveblocksConfig };
67
15
  //# sourceMappingURL=liveblocks-config.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"liveblocks-config.mjs","sources":["../src/liveblocks-config.tsx"],"sourcesContent":["import type { InitialConfigType } from \"@lexical/react/LexicalComposer\";\nimport type { ComponentType } from \"react\";\nimport * as React from \"react\";\n\nimport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nimport type { LiveblocksLexicalInternalConfig } from \"./liveblocks-plugin-provider\";\nimport { Avatar } from \"./mentions/avatar\";\nimport { Mention } from \"./mentions/mention-component\";\nimport { createMentionNodeFactory } from \"./mentions/mention-node\";\nimport * as Suggestions from \"./mentions/suggestions\";\nimport { User } from \"./mentions/user\";\n\nlet liveblocksConfig: LiveblocksLexicalInternalConfig | null = null;\n\nexport interface MentionProps {\n /**\n * The mention's user ID.\n */\n userId: string;\n}\n\nexport interface MentionSuggestionsProps {\n /**\n * The list of suggested user IDs.\n */\n userIds: string[];\n}\n\ninterface EditorComponents {\n Mention: ComponentType<MentionProps>;\n MentionSuggestions: ComponentType<MentionSuggestionsProps>;\n}\n\nexport interface LiveblocksConfig {\n /**\n * Whether comments are enabled. Defaults to true.\n */\n comments?: boolean;\n /**\n * The components displayed within the editor.\n */\n components?: Partial<EditorComponents>;\n}\n\nconst MENTION_CHARACTER = \"@\";\nconst defaultComponents: EditorComponents = {\n Mention: ({ userId }) => {\n return (\n <Mention className=\"lb-lexical-mention\">\n {MENTION_CHARACTER}\n <User userId={userId} />\n </Mention>\n );\n },\n MentionSuggestions: ({ userIds }) => {\n return (\n <Suggestions.List className=\"lb-lexical-suggestions-list\">\n {userIds.map((userId) => (\n <Suggestions.Item\n key={userId}\n value={userId}\n className=\"lb-lexical-suggestions-list-item\"\n >\n <Avatar\n userId={userId}\n className=\"lb-lexical-mention-suggestion-avatar\"\n />\n <User\n userId={userId}\n className=\"lb-lexical-mention-suggestion-user\"\n />\n </Suggestions.Item>\n ))}\n </Suggestions.List>\n );\n },\n};\n\nexport function liveblocksLexicalConfig(\n editorConfig: InitialConfigType,\n config: LiveblocksConfig = {}\n) {\n const { comments = true, components = {} } = config;\n\n const nodes = [...(editorConfig.nodes ?? [])];\n\n const Mention = components.Mention ?? defaultComponents.Mention;\n const MentionSuggestions =\n components.MentionSuggestions ?? defaultComponents.MentionSuggestions;\n\n const mentionFactory = createMentionNodeFactory(Mention);\n\n nodes.push(ThreadMarkNode, mentionFactory.MentionNode);\n\n liveblocksConfig = {\n comments,\n mentions: {\n factory: mentionFactory,\n components: {\n MentionSuggestions,\n },\n },\n };\n\n return {\n ...editorConfig,\n nodes,\n editorState: null, // explicitly null because CollabProvider requires it\n };\n}\n\nexport function getLiveblocksLexicalConfig(): LiveblocksLexicalInternalConfig {\n if (liveblocksConfig === null) {\n throw new Error(\"Liveblocks config is not initialized.\");\n }\n return {\n ...liveblocksConfig,\n };\n}\n"],"names":["Suggestions.List","Suggestions.Item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A,QAAAA,GAAU,UAAW,CAAA,OAAA,IAAW,iBAAkB,CAAA,OAAA,CAAA;AACxD,EAAM,MAAA,kBAAA,GACJ,UAAW,CAAA,kBAAA,IAAsB,iBAAkB,CAAA,kBAAA,CAAA;AAErD,EAAM,MAAA,cAAA,GAAiB,yBAAyBA,QAAO,CAAA,CAAA;AAEvD,EAAM,KAAA,CAAA,IAAA,CAAK,cAAgB,EAAA,cAAA,CAAe,WAAW,CAAA,CAAA;AAErD,EAAmB,gBAAA,GAAA;AAAA,IACjB,QAAA;AAAA,IACA,QAAU,EAAA;AAAA,MACR,OAAS,EAAA,cAAA;AAAA,MACT,UAAY,EAAA;AAAA,QACV,kBAAA;AAAA,OACF;AAAA,KACF;AAAA,GACF,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,KAAA;AAAA,IACA,WAAa,EAAA,IAAA;AAAA,GACf,CAAA;AACF,CAAA;AAEO,SAAS,0BAA8D,GAAA;AAC5E,EAAA,IAAI,qBAAqB,IAAM,EAAA;AAC7B,IAAM,MAAA,IAAI,MAAM,uCAAuC,CAAA,CAAA;AAAA,GACzD;AACA,EAAO,OAAA;AAAA,IACL,GAAG,gBAAA;AAAA,GACL,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"liveblocks-config.mjs","sources":["../src/liveblocks-config.ts"],"sourcesContent":["import type { InitialConfigType } from \"@lexical/react/LexicalComposer\";\n\nimport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nimport { MentionNode } from \"./mentions/mention-node\";\n\nexport function liveblocksConfig(\n editorConfig: Omit<InitialConfigType, \"editorState\">\n) {\n const nodes = [...(editorConfig.nodes ?? [])];\n\n nodes.push(ThreadMarkNode, MentionNode);\n\n return {\n ...editorConfig,\n nodes,\n editorState: null, // explicitly null because CollabProvider requires it\n };\n}\n"],"names":[],"mappings":";;;AAKO,SAAS,iBACd,YACA,EAAA;AACA,EAAA,MAAM,QAAQ,CAAC,GAAI,YAAa,CAAA,KAAA,IAAS,EAAG,CAAA,CAAA;AAE5C,EAAM,KAAA,CAAA,IAAA,CAAK,gBAAgB,WAAW,CAAA,CAAA;AAEtC,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,KAAA;AAAA,IACA,WAAa,EAAA,IAAA;AAAA,GACf,CAAA;AACF;;;;"}
@@ -4,26 +4,23 @@ var LexicalCollaborationPlugin = require('@lexical/react/LexicalCollaborationPlu
4
4
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
5
5
  var core = require('@liveblocks/core');
6
6
  var react = require('@liveblocks/react');
7
- var LiveblocksProvider = require('@liveblocks/yjs');
7
+ var yjs$1 = require('@liveblocks/yjs');
8
8
  var React = require('react');
9
9
  var yjs = require('yjs');
10
10
  var commentPluginProvider = require('./comments/comment-plugin-provider.js');
11
- var liveblocksConfig = require('./liveblocks-config.js');
12
11
  var mentionPlugin = require('./mentions/mention-plugin.js');
13
12
 
14
- const LiveblocksLexicalConfigContext = React.createContext(null);
15
- const LiveblocksPluginProvider = ({
13
+ const LiveblocksPlugin = ({
16
14
  children
17
15
  }) => {
18
16
  const client = react.useClient();
19
17
  const hasResolveMentionSuggestions = client[core.kInternal].resolveMentionSuggestions !== void 0;
20
- const { useSelf, useRoom } = react.useRoomContextBundle();
21
18
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
22
- const room = useRoom();
19
+ const room = react.useRoom();
23
20
  const [provider, setProvider] = React.useState();
24
21
  const doc = React.useMemo(() => new yjs.Doc(), []);
25
22
  React.useEffect(() => {
26
- const _provider = new LiveblocksProvider(room, doc);
23
+ const _provider = new yjs$1.LiveblocksYjsProvider(room, doc);
27
24
  setProvider(_provider);
28
25
  return () => {
29
26
  _provider.destroy();
@@ -34,13 +31,15 @@ const LiveblocksPluginProvider = ({
34
31
  if (process.env.NODE_ENV !== "production") {
35
32
  if (!editor.getEditorState().isEmpty()) {
36
33
  console.warn(
37
- "Warning: LiveblocksPluginProvider: editorState in initialConfig detected, but must be null."
34
+ "Warning: LiveblocksPlugin: editorState in initialConfig detected, but must be null."
38
35
  );
39
36
  }
40
37
  }
41
- room[core.kInternal].reportTextEditor("lexical", "root");
42
38
  }, []);
43
- const info = useSelf((me) => me.info);
39
+ React.useEffect(() => {
40
+ room[core.kInternal].reportTextEditor("lexical", "root");
41
+ }, [room]);
42
+ const info = react.useSelf((me) => me.info);
44
43
  const username = info?.name;
45
44
  const cursorcolor = info?.color;
46
45
  const providerFactory = React.useCallback(
@@ -50,30 +49,14 @@ const LiveblocksPluginProvider = ({
50
49
  },
51
50
  [provider, doc]
52
51
  );
53
- const configRef = React.useRef(null);
54
- if (configRef.current === null) {
55
- configRef.current = liveblocksConfig.getLiveblocksLexicalConfig();
56
- }
57
- return /* @__PURE__ */ React.createElement(LiveblocksLexicalConfigContext.Provider, {
58
- value: configRef.current
59
- }, provider && /* @__PURE__ */ React.createElement(LexicalCollaborationPlugin.CollaborationPlugin, {
52
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, provider && /* @__PURE__ */ React.createElement(LexicalCollaborationPlugin.CollaborationPlugin, {
60
53
  providerFactory,
61
54
  id: "liveblocks-document",
62
55
  username,
63
56
  cursorColor: cursorcolor,
64
57
  shouldBootstrap: true
65
- }), hasResolveMentionSuggestions && /* @__PURE__ */ React.createElement(mentionPlugin.default, null), configRef.current.comments && /* @__PURE__ */ React.createElement(commentPluginProvider.CommentPluginProvider, null, children));
58
+ }), hasResolveMentionSuggestions && /* @__PURE__ */ React.createElement(mentionPlugin.MentionPlugin, null), /* @__PURE__ */ React.createElement(commentPluginProvider.CommentPluginProvider, null, children));
66
59
  };
67
- function useLiveblocksLexicalConfigContext() {
68
- const config = React.useContext(LiveblocksLexicalConfigContext);
69
- if (config === null) {
70
- throw new Error(
71
- "useLiveblocksLexicalConfigContext must be used within a LiveblocksPluginProviderProvider"
72
- );
73
- }
74
- return config;
75
- }
76
60
 
77
- exports.LiveblocksPluginProvider = LiveblocksPluginProvider;
78
- exports.useLiveblocksLexicalConfigContext = useLiveblocksLexicalConfigContext;
61
+ exports.LiveblocksPlugin = LiveblocksPlugin;
79
62
  //# sourceMappingURL=liveblocks-plugin-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"liveblocks-plugin-provider.js","sources":["../src/liveblocks-plugin-provider.tsx"],"sourcesContent":["import { CollaborationPlugin } from \"@lexical/react/LexicalCollaborationPlugin\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { Provider } from \"@lexical/yjs\";\nimport type {\n BaseUserMeta,\n Json,\n JsonObject,\n LsonObject,\n} from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport { useClient, useRoomContextBundle } from \"@liveblocks/react\";\nimport LiveblocksProvider from \"@liveblocks/yjs\";\nimport type { ComponentType } from \"react\";\nimport React, {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Doc } from \"yjs\";\n\nimport { CommentPluginProvider } from \"./comments/comment-plugin-provider\";\nimport type { MentionSuggestionsProps } from \"./liveblocks-config\";\nimport { getLiveblocksLexicalConfig } from \"./liveblocks-config\";\nimport type { createMentionNodeFactory } from \"./mentions/mention-node\";\nimport MentionPlugin from \"./mentions/mention-plugin\";\n\nexport type LiveblocksPluginProviderProps = {\n // TODO: Move these configuration options (if applicable and necessary) to the `liveblocksLexicalConfig` function to have all configuration in one place\n // /**\n // * Optionally override user information. If not, user[\"info\"] from auth will be used.\n // */\n // userInfo?: {\n // name: string;\n // color?: string;\n // };\n // /**\n // * Whether or not the user can edit the document before it has been synced\n // * default: true\n // */\n // allowEditsBeforeSync?: boolean;\n\n // /**\n // * Modify the state with this function to set the initial state.\n // * Ex. $createTextNode('initial text content');\n // *\n // * @param editor\n // * @returns void\n // */\n // initialEditorState?: (editor: LexicalEditor) => void;\n\n children?: React.ReactNode;\n};\n\nexport interface LiveblocksLexicalInternalConfig {\n comments: boolean;\n mentions: {\n factory: ReturnType<typeof createMentionNodeFactory>;\n components: {\n MentionSuggestions: ComponentType<MentionSuggestionsProps>;\n };\n };\n}\n\nconst LiveblocksLexicalConfigContext =\n createContext<LiveblocksLexicalInternalConfig | null>(null);\n\nexport const LiveblocksPluginProvider = ({\n // userInfo = undefined,\n // allowEditsBeforeSync = true,\n // initialEditorState = undefined,\n children,\n}: LiveblocksPluginProviderProps): JSX.Element => {\n const client = useClient();\n const hasResolveMentionSuggestions =\n client[kInternal].resolveMentionSuggestions !== undefined;\n const { useSelf, useRoom } = useRoomContextBundle();\n const [editor] = useLexicalComposerContext();\n const room = useRoom();\n\n const [provider, setProvider] = useState<\n LiveblocksProvider<JsonObject, LsonObject, BaseUserMeta, Json> | undefined\n >();\n\n const doc = useMemo(() => new Doc(), []);\n\n useEffect(() => {\n const _provider = new LiveblocksProvider(room, doc);\n setProvider(_provider);\n return () => {\n _provider.destroy();\n setProvider(undefined);\n };\n }, [room, doc]);\n\n // Warn users if initialConfig.editorState, set on the composer, is not null\n useEffect(() => {\n // only in dev mode\n if (process.env.NODE_ENV !== \"production\") {\n // A user should not even be set an emptyState, but when passing null, getEditorState still has initial empty state\n if (!editor.getEditorState().isEmpty()) {\n console.warn(\n \"Warning: LiveblocksPluginProvider: editorState in initialConfig detected, but must be null.\"\n );\n }\n }\n\n // Report that this is lexical and root is the rootKey\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n room[kInternal].reportTextEditor(\"lexical\", \"root\");\n\n // we know editor is already defined as we're inside LexicalComposer, and we only want this running the first time\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Get user info or allow override from props\n const info = useSelf((me) => me.info);\n const username = info?.name;\n const cursorcolor = info?.color as string | undefined;\n\n // const [synced, setSynced] = useState(false);\n\n // useEffect(() => {\n // if (!provider) {\n // return;\n // }\n // provider.on(\"sync\", setSynced);\n // return () => {\n // provider.off(\"sync\", setSynced);\n // };\n // }, [provider]);\n\n // // Disable the editor before sync\n // useEffect(() => {\n // if (!allowEditsBeforeSync) {\n // editor.setEditable(synced);\n // }\n // }, [synced, editor, allowEditsBeforeSync]);\n\n // Create the provider factory\n const providerFactory = useCallback(\n (id: string, yjsDocMap: Map<string, Doc>) => {\n yjsDocMap.set(id, doc);\n return provider as Provider;\n },\n [provider, doc]\n );\n\n const configRef = useRef<LiveblocksLexicalInternalConfig | null>(null);\n if (configRef.current === null) {\n configRef.current = getLiveblocksLexicalConfig();\n }\n\n return (\n <LiveblocksLexicalConfigContext.Provider value={configRef.current}>\n {provider && (\n <CollaborationPlugin\n providerFactory={providerFactory}\n // initialEditorState={initialEditorState}\n id={\"liveblocks-document\"}\n username={username}\n cursorColor={cursorcolor}\n shouldBootstrap={true}\n />\n )}\n\n {hasResolveMentionSuggestions && <MentionPlugin />}\n\n {configRef.current.comments && (\n <CommentPluginProvider>{children}</CommentPluginProvider>\n )}\n </LiveblocksLexicalConfigContext.Provider>\n );\n};\n\nexport function useLiveblocksLexicalConfigContext(): LiveblocksLexicalInternalConfig {\n const config = useContext(LiveblocksLexicalConfigContext);\n if (config === null) {\n throw new Error(\n \"useLiveblocksLexicalConfigContext must be used within a LiveblocksPluginProviderProvider\"\n );\n }\n return config;\n}\n"],"names":["createContext","useClient","kInternal","useRoomContextBundle","useLexicalComposerContext","useState","useMemo","Doc","useEffect","useCallback","useRef","getLiveblocksLexicalConfig","CollaborationPlugin","MentionPlugin","CommentPluginProvider","useContext"],"mappings":";;;;;;;;;;;;;AAmEA,MAAM,8BAAA,GACJA,oBAAsD,IAAI,CAAA,CAAA;AAErD,MAAM,2BAA2B,CAAC;AAAA,EAIvC,QAAA;AACF,CAAkD,KAAA;AAChD,EAAA,MAAM,SAASC,eAAU,EAAA,CAAA;AACzB,EAAM,MAAA,4BAAA,GACJ,MAAO,CAAAC,cAAA,CAAA,CAAW,yBAA8B,KAAA,KAAA,CAAA,CAAA;AAClD,EAAA,MAAM,EAAE,OAAA,EAAS,OAAQ,EAAA,GAAIC,0BAAqB,EAAA,CAAA;AAClD,EAAM,MAAA,CAA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A;AAC3C,MAAU,SAAA,CAAA,GAAA,CAAI,IAAI,GAAG,CAAA,CAAA;AACrB,MAAO,OAAA,QAAA,CAAA;AAAA,KACT;AAAA,IACA,CAAC,UAAU,GAAG,CAAA;AAAA,GAChB,CAAA;AAEA,EAAM,MAAA,SAAA,GAAYC,aAA+C,IAAI,CAAA,CAAA;AACrE,EAAI,IAAA,SAAA,CAAU,YAAY,IAAM,EAAA;AAC9B,IAAA,SAAA,CAAU,UAAUC,2CAA2B,EAAA,CAAA;AAAA,GACjD;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,+BAA+B,QAA/B,EAAA;AAAA,IAAwC,OAAO,SAAU,CAAA,OAAA;AAAA,GAAA,EACvD,4BACE,KAAA,CAAA,aAAA,CAAAC,8CAAA,EAAA;AAAA,IACC,eAAA;AAAA,IAEA,EAAI,EAAA,qBAAA;AAAA,IACJ,QAAA;AAAA,IACA,WAAa,EAAA,WAAA;AAAA,IACb,eAAiB,EAAA,IAAA;AAAA,GACnB,CAAA,EAGD,4BAAgC,oBAAA,KAAA,CAAA,aAAA,CAACC,qBAAc,EAAA,IAAA,CAAA,EAE/C,SAAU,CAAA,OAAA,CAAQ,QACjB,oBAAA,KAAA,CAAA,aAAA,CAACC,2CAAuB,EAAA,IAAA,EAAA,QAAS,CAErC,CAAA,CAAA;AAEJ,EAAA;AAEO,SAAS,iCAAqE,GAAA;AACnF,EAAM,MAAA,MAAA,GAASC,iBAAW,8BAA8B,CAAA,CAAA;AACxD,EAAA,IAAI,WAAW,IAAM,EAAA;AACnB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,0FAAA;AAAA,KACF,CAAA;AAAA,GACF;AACA,EAAO,OAAA,MAAA,CAAA;AACT;;;;;"}
1
+ {"version":3,"file":"liveblocks-plugin-provider.js","sources":["../src/liveblocks-plugin-provider.tsx"],"sourcesContent":["import { CollaborationPlugin } from \"@lexical/react/LexicalCollaborationPlugin\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { Provider } from \"@lexical/yjs\";\nimport type {\n BaseMetadata,\n BaseUserMeta,\n Json,\n JsonObject,\n LsonObject,\n} from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport { useClient, useRoom, useSelf } from \"@liveblocks/react\";\nimport { LiveblocksYjsProvider } from \"@liveblocks/yjs\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Doc } from \"yjs\";\n\nimport { CommentPluginProvider } from \"./comments/comment-plugin-provider\";\nimport { MentionPlugin } from \"./mentions/mention-plugin\";\n\nexport type LiveblocksPluginProps = {\n children?: React.ReactNode;\n};\n\nexport const LiveblocksPlugin = ({\n children,\n}: LiveblocksPluginProps): JSX.Element => {\n const client = useClient();\n const hasResolveMentionSuggestions =\n client[kInternal].resolveMentionSuggestions !== undefined;\n const [editor] = useLexicalComposerContext();\n const room = useRoom();\n\n const [provider, setProvider] = useState<\n | LiveblocksYjsProvider<\n JsonObject,\n LsonObject,\n BaseUserMeta,\n Json,\n BaseMetadata\n >\n | undefined\n >();\n\n const doc = useMemo(() => new Doc(), []);\n\n useEffect(() => {\n const _provider = new LiveblocksYjsProvider(room, doc);\n setProvider(_provider);\n return () => {\n _provider.destroy();\n setProvider(undefined);\n };\n }, [room, doc]);\n\n // Warn users if initialConfig.editorState, set on the composer, is not null\n useEffect(() => {\n // only in dev mode\n if (process.env.NODE_ENV !== \"production\") {\n // A user should not even be set an emptyState, but when passing null, getEditorState still has initial empty state\n if (!editor.getEditorState().isEmpty()) {\n console.warn(\n \"Warning: LiveblocksPlugin: editorState in initialConfig detected, but must be null.\"\n );\n }\n }\n\n // we know editor is already defined as we're inside LexicalComposer, and we only want this running the first time\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n // Report that this is lexical and root is the rootKey\n room[kInternal].reportTextEditor(\"lexical\", \"root\");\n }, [room]);\n\n // Get user info or allow override from props\n const info = useSelf((me) => me.info);\n const username = info?.name;\n const cursorcolor = info?.color as string | undefined;\n\n // Create the provider factory\n const providerFactory = useCallback(\n (id: string, yjsDocMap: Map<string, Doc>) => {\n yjsDocMap.set(id, doc);\n return provider as Provider;\n },\n [provider, doc]\n );\n\n return (\n <>\n {provider && (\n <CollaborationPlugin\n providerFactory={providerFactory}\n id={\"liveblocks-document\"}\n username={username}\n cursorColor={cursorcolor}\n shouldBootstrap={true}\n />\n )}\n\n {hasResolveMentionSuggestions && <MentionPlugin />}\n\n <CommentPluginProvider>{children}</CommentPluginProvider>\n </>\n );\n};\n"],"names":["useClient","kInternal","useLexicalComposerContext","useRoom","useState","useMemo","Doc","useEffect","LiveblocksYjsProvider","useSelf","useCallback","CollaborationPlugin","MentionPlugin","CommentPluginProvider"],"mappings":";;;;;;;;;;;;AAuBO,MAAM,mBAAmB,CAAC;AAAA,EAC/B,QAAA;AACF,CAA0C,KAAA;AACxC,EAAA,MAAM,SAASA,eAAU,EAAA,CAAA;AACzB,EAAM,MAAA,4BAAA,GACJ,MAAO,CAAAC,cAAA,CAAA,CAAW,yBAA8B,KAAA,KAAA,CAAA,CAAA;AAClD,EAAM,MAAA,CAAC,MAAM,CAAA,GAAIC,gDAA0B,EAAA,CAAA;AAC3C,EAAA,MAAM,OAAOC,aAAQ,EAAA,CAAA;AAErB,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAIC,cAS9B,EAAA,CAAA;AAEF,EAAA,MAAM,MAAMC,aAAQ,CAAA,MAAM,IAAIC,OAAI,EAAA,EAAG,EAAE,CAAA,CAAA;AAEvC,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,SAAY,GAAA,IAAIC,2BAAsB,CAAA,IAAA,EAAM,GAAG,CAAA,CAAA;AACrD,IAAA,WAAA,CAAY,SAAS,CAAA,CAAA;AACrB,IAAA,OAAO,MAAM;AACX,MAAA,SAAA,CAAU,OAAQ,EAAA,CAAA;AAClB,MAAA,WAAA,CAAY,KAAS,CAAA,CAAA,CAAA;AAAA,KAC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,aAAA,CAAAC,2BAAA,EAAA,IAAc,mBAE/C,KAAA,CAAA,aAAA,CAAAC,2CAAA,EAAA,IAAA,EAAuB,QAAS,CACnC,CAAA,CAAA;AAEJ;;;;"}
@@ -1,27 +1,24 @@
1
1
  import { CollaborationPlugin } from '@lexical/react/LexicalCollaborationPlugin';
2
2
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
3
3
  import { kInternal } from '@liveblocks/core';
4
- import { useClient, useRoomContextBundle } from '@liveblocks/react';
5
- import LiveblocksProvider from '@liveblocks/yjs';
6
- import React__default, { createContext, useState, useMemo, useEffect, useCallback, useRef, useContext } from 'react';
4
+ import { useClient, useRoom, useSelf } from '@liveblocks/react';
5
+ import { LiveblocksYjsProvider } from '@liveblocks/yjs';
6
+ import React__default, { useState, useMemo, useEffect, useCallback } from 'react';
7
7
  import { Doc } from 'yjs';
8
8
  import { CommentPluginProvider } from './comments/comment-plugin-provider.mjs';
9
- import { getLiveblocksLexicalConfig } from './liveblocks-config.mjs';
10
- import MentionPlugin from './mentions/mention-plugin.mjs';
9
+ import { MentionPlugin } from './mentions/mention-plugin.mjs';
11
10
 
12
- const LiveblocksLexicalConfigContext = createContext(null);
13
- const LiveblocksPluginProvider = ({
11
+ const LiveblocksPlugin = ({
14
12
  children
15
13
  }) => {
16
14
  const client = useClient();
17
15
  const hasResolveMentionSuggestions = client[kInternal].resolveMentionSuggestions !== void 0;
18
- const { useSelf, useRoom } = useRoomContextBundle();
19
16
  const [editor] = useLexicalComposerContext();
20
17
  const room = useRoom();
21
18
  const [provider, setProvider] = useState();
22
19
  const doc = useMemo(() => new Doc(), []);
23
20
  useEffect(() => {
24
- const _provider = new LiveblocksProvider(room, doc);
21
+ const _provider = new LiveblocksYjsProvider(room, doc);
25
22
  setProvider(_provider);
26
23
  return () => {
27
24
  _provider.destroy();
@@ -32,12 +29,14 @@ const LiveblocksPluginProvider = ({
32
29
  if (process.env.NODE_ENV !== "production") {
33
30
  if (!editor.getEditorState().isEmpty()) {
34
31
  console.warn(
35
- "Warning: LiveblocksPluginProvider: editorState in initialConfig detected, but must be null."
32
+ "Warning: LiveblocksPlugin: editorState in initialConfig detected, but must be null."
36
33
  );
37
34
  }
38
35
  }
39
- room[kInternal].reportTextEditor("lexical", "root");
40
36
  }, []);
37
+ useEffect(() => {
38
+ room[kInternal].reportTextEditor("lexical", "root");
39
+ }, [room]);
41
40
  const info = useSelf((me) => me.info);
42
41
  const username = info?.name;
43
42
  const cursorcolor = info?.color;
@@ -48,29 +47,14 @@ const LiveblocksPluginProvider = ({
48
47
  },
49
48
  [provider, doc]
50
49
  );
51
- const configRef = useRef(null);
52
- if (configRef.current === null) {
53
- configRef.current = getLiveblocksLexicalConfig();
54
- }
55
- return /* @__PURE__ */ React__default.createElement(LiveblocksLexicalConfigContext.Provider, {
56
- value: configRef.current
57
- }, provider && /* @__PURE__ */ React__default.createElement(CollaborationPlugin, {
50
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, provider && /* @__PURE__ */ React__default.createElement(CollaborationPlugin, {
58
51
  providerFactory,
59
52
  id: "liveblocks-document",
60
53
  username,
61
54
  cursorColor: cursorcolor,
62
55
  shouldBootstrap: true
63
- }), hasResolveMentionSuggestions && /* @__PURE__ */ React__default.createElement(MentionPlugin, null), configRef.current.comments && /* @__PURE__ */ React__default.createElement(CommentPluginProvider, null, children));
56
+ }), hasResolveMentionSuggestions && /* @__PURE__ */ React__default.createElement(MentionPlugin, null), /* @__PURE__ */ React__default.createElement(CommentPluginProvider, null, children));
64
57
  };
65
- function useLiveblocksLexicalConfigContext() {
66
- const config = useContext(LiveblocksLexicalConfigContext);
67
- if (config === null) {
68
- throw new Error(
69
- "useLiveblocksLexicalConfigContext must be used within a LiveblocksPluginProviderProvider"
70
- );
71
- }
72
- return config;
73
- }
74
58
 
75
- export { LiveblocksPluginProvider, useLiveblocksLexicalConfigContext };
59
+ export { LiveblocksPlugin };
76
60
  //# sourceMappingURL=liveblocks-plugin-provider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"liveblocks-plugin-provider.mjs","sources":["../src/liveblocks-plugin-provider.tsx"],"sourcesContent":["import { CollaborationPlugin } from \"@lexical/react/LexicalCollaborationPlugin\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { Provider } from \"@lexical/yjs\";\nimport type {\n BaseUserMeta,\n Json,\n JsonObject,\n LsonObject,\n} from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport { useClient, useRoomContextBundle } from \"@liveblocks/react\";\nimport LiveblocksProvider from \"@liveblocks/yjs\";\nimport type { ComponentType } from \"react\";\nimport React, {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Doc } from \"yjs\";\n\nimport { CommentPluginProvider } from \"./comments/comment-plugin-provider\";\nimport type { MentionSuggestionsProps } from \"./liveblocks-config\";\nimport { getLiveblocksLexicalConfig } from \"./liveblocks-config\";\nimport type { createMentionNodeFactory } from \"./mentions/mention-node\";\nimport MentionPlugin from \"./mentions/mention-plugin\";\n\nexport type LiveblocksPluginProviderProps = {\n // TODO: Move these configuration options (if applicable and necessary) to the `liveblocksLexicalConfig` function to have all configuration in one place\n // /**\n // * Optionally override user information. If not, user[\"info\"] from auth will be used.\n // */\n // userInfo?: {\n // name: string;\n // color?: string;\n // };\n // /**\n // * Whether or not the user can edit the document before it has been synced\n // * default: true\n // */\n // allowEditsBeforeSync?: boolean;\n\n // /**\n // * Modify the state with this function to set the initial state.\n // * Ex. $createTextNode('initial text content');\n // *\n // * @param editor\n // * @returns void\n // */\n // initialEditorState?: (editor: LexicalEditor) => void;\n\n children?: React.ReactNode;\n};\n\nexport interface LiveblocksLexicalInternalConfig {\n comments: boolean;\n mentions: {\n factory: ReturnType<typeof createMentionNodeFactory>;\n components: {\n MentionSuggestions: ComponentType<MentionSuggestionsProps>;\n };\n };\n}\n\nconst LiveblocksLexicalConfigContext =\n createContext<LiveblocksLexicalInternalConfig | null>(null);\n\nexport const LiveblocksPluginProvider = ({\n // userInfo = undefined,\n // allowEditsBeforeSync = true,\n // initialEditorState = undefined,\n children,\n}: LiveblocksPluginProviderProps): JSX.Element => {\n const client = useClient();\n const hasResolveMentionSuggestions =\n client[kInternal].resolveMentionSuggestions !== undefined;\n const { useSelf, useRoom } = useRoomContextBundle();\n const [editor] = useLexicalComposerContext();\n const room = useRoom();\n\n const [provider, setProvider] = useState<\n LiveblocksProvider<JsonObject, LsonObject, BaseUserMeta, Json> | undefined\n >();\n\n const doc = useMemo(() => new Doc(), []);\n\n useEffect(() => {\n const _provider = new LiveblocksProvider(room, doc);\n setProvider(_provider);\n return () => {\n _provider.destroy();\n setProvider(undefined);\n };\n }, [room, doc]);\n\n // Warn users if initialConfig.editorState, set on the composer, is not null\n useEffect(() => {\n // only in dev mode\n if (process.env.NODE_ENV !== \"production\") {\n // A user should not even be set an emptyState, but when passing null, getEditorState still has initial empty state\n if (!editor.getEditorState().isEmpty()) {\n console.warn(\n \"Warning: LiveblocksPluginProvider: editorState in initialConfig detected, but must be null.\"\n );\n }\n }\n\n // Report that this is lexical and root is the rootKey\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n room[kInternal].reportTextEditor(\"lexical\", \"root\");\n\n // we know editor is already defined as we're inside LexicalComposer, and we only want this running the first time\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Get user info or allow override from props\n const info = useSelf((me) => me.info);\n const username = info?.name;\n const cursorcolor = info?.color as string | undefined;\n\n // const [synced, setSynced] = useState(false);\n\n // useEffect(() => {\n // if (!provider) {\n // return;\n // }\n // provider.on(\"sync\", setSynced);\n // return () => {\n // provider.off(\"sync\", setSynced);\n // };\n // }, [provider]);\n\n // // Disable the editor before sync\n // useEffect(() => {\n // if (!allowEditsBeforeSync) {\n // editor.setEditable(synced);\n // }\n // }, [synced, editor, allowEditsBeforeSync]);\n\n // Create the provider factory\n const providerFactory = useCallback(\n (id: string, yjsDocMap: Map<string, Doc>) => {\n yjsDocMap.set(id, doc);\n return provider as Provider;\n },\n [provider, doc]\n );\n\n const configRef = useRef<LiveblocksLexicalInternalConfig | null>(null);\n if (configRef.current === null) {\n configRef.current = getLiveblocksLexicalConfig();\n }\n\n return (\n <LiveblocksLexicalConfigContext.Provider value={configRef.current}>\n {provider && (\n <CollaborationPlugin\n providerFactory={providerFactory}\n // initialEditorState={initialEditorState}\n id={\"liveblocks-document\"}\n username={username}\n cursorColor={cursorcolor}\n shouldBootstrap={true}\n />\n )}\n\n {hasResolveMentionSuggestions && <MentionPlugin />}\n\n {configRef.current.comments && (\n <CommentPluginProvider>{children}</CommentPluginProvider>\n )}\n </LiveblocksLexicalConfigContext.Provider>\n );\n};\n\nexport function useLiveblocksLexicalConfigContext(): LiveblocksLexicalInternalConfig {\n const config = useContext(LiveblocksLexicalConfigContext);\n if (config === null) {\n throw new Error(\n \"useLiveblocksLexicalConfigContext must be used within a LiveblocksPluginProviderProvider\"\n );\n }\n return config;\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;AAmEA,MAAM,8BAAA,GACJ,cAAsD,IAAI,CAAA,CAAA;AAErD,MAAM,2BAA2B,CAAC;AAAA,EAIvC,QAAA;AACF,CAAkD,KAAA;AAChD,EAAA,MAAM,SAAS,SAAU,EAAA,CAAA;AACzB,EAAM,MAAA,4BAAA,GACJ,MAAO,CAAA,SAAA,CAAA,CAAW,yBAA8B,KAAA,KAAA,CAAA,CAAA;AAClD,EAAA,MAAM,EAAE,OAAA,EAAS,OAAQ,EAAA,GAAI,oBAAqB,EAAA,CAAA;AAClD,EAAM,MAAA,CAAC,MAAM,CAAA,GAAI,yBAA0B,EAAA,CAAA;AAC3C,EAAA,MAAM,OAAO,OAAQ,EAAA,CAAA;AAErB,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,QAE9B,EAAA,CAAA;AAEF,EAAA,MAAM,MAAM,OAAQ,CAAA,MAAM,IAAI,GAAI,EAAA,EAAG,EAAE,CA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AY,IAAM,EAAA;AAC9B,IAAA,SAAA,CAAU,UAAU,0BAA2B,EAAA,CAAA;AAAA,GACjD;AAEA,EACE,uBAAAA,cAAA,CAAA,aAAA,CAAC,+BAA+B,QAA/B,EAAA;AAAA,IAAwC,OAAO,SAAU,CAAA,OAAA;AAAA,GAAA,EACvD,4BACEA,cAAA,CAAA,aAAA,CAAA,mBAAA,EAAA;AAAA,IACC,eAAA;AAAA,IAEA,EAAI,EAAA,qBAAA;AAAA,IACJ,QAAA;AAAA,IACA,WAAa,EAAA,WAAA;AAAA,IACb,eAAiB,EAAA,IAAA;AAAA,GACnB,CAAA,EAGD,4BAAgC,oBAAAA,cAAA,CAAA,aAAA,CAAC,aAAc,EAAA,IAAA,CAAA,EAE/C,SAAU,CAAA,OAAA,CAAQ,QACjB,oBAAAA,cAAA,CAAA,aAAA,CAAC,qBAAuB,EAAA,IAAA,EAAA,QAAS,CAErC,CAAA,CAAA;AAEJ,EAAA;AAEO,SAAS,iCAAqE,GAAA;AACnF,EAAM,MAAA,MAAA,GAAS,WAAW,8BAA8B,CAAA,CAAA;AACxD,EAAA,IAAI,WAAW,IAAM,EAAA;AACnB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,0FAAA;AAAA,KACF,CAAA;AAAA,GACF;AACA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"liveblocks-plugin-provider.mjs","sources":["../src/liveblocks-plugin-provider.tsx"],"sourcesContent":["import { CollaborationPlugin } from \"@lexical/react/LexicalCollaborationPlugin\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { Provider } from \"@lexical/yjs\";\nimport type {\n BaseMetadata,\n BaseUserMeta,\n Json,\n JsonObject,\n LsonObject,\n} from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport { useClient, useRoom, useSelf } from \"@liveblocks/react\";\nimport { LiveblocksYjsProvider } from \"@liveblocks/yjs\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Doc } from \"yjs\";\n\nimport { CommentPluginProvider } from \"./comments/comment-plugin-provider\";\nimport { MentionPlugin } from \"./mentions/mention-plugin\";\n\nexport type LiveblocksPluginProps = {\n children?: React.ReactNode;\n};\n\nexport const LiveblocksPlugin = ({\n children,\n}: LiveblocksPluginProps): JSX.Element => {\n const client = useClient();\n const hasResolveMentionSuggestions =\n client[kInternal].resolveMentionSuggestions !== undefined;\n const [editor] = useLexicalComposerContext();\n const room = useRoom();\n\n const [provider, setProvider] = useState<\n | LiveblocksYjsProvider<\n JsonObject,\n LsonObject,\n BaseUserMeta,\n Json,\n BaseMetadata\n >\n | undefined\n >();\n\n const doc = useMemo(() => new Doc(), []);\n\n useEffect(() => {\n const _provider = new LiveblocksYjsProvider(room, doc);\n setProvider(_provider);\n return () => {\n _provider.destroy();\n setProvider(undefined);\n };\n }, [room, doc]);\n\n // Warn users if initialConfig.editorState, set on the composer, is not null\n useEffect(() => {\n // only in dev mode\n if (process.env.NODE_ENV !== \"production\") {\n // A user should not even be set an emptyState, but when passing null, getEditorState still has initial empty state\n if (!editor.getEditorState().isEmpty()) {\n console.warn(\n \"Warning: LiveblocksPlugin: editorState in initialConfig detected, but must be null.\"\n );\n }\n }\n\n // we know editor is already defined as we're inside LexicalComposer, and we only want this running the first time\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n // Report that this is lexical and root is the rootKey\n room[kInternal].reportTextEditor(\"lexical\", \"root\");\n }, [room]);\n\n // Get user info or allow override from props\n const info = useSelf((me) => me.info);\n const username = info?.name;\n const cursorcolor = info?.color as string | undefined;\n\n // Create the provider factory\n const providerFactory = useCallback(\n (id: string, yjsDocMap: Map<string, Doc>) => {\n yjsDocMap.set(id, doc);\n return provider as Provider;\n },\n [provider, doc]\n );\n\n return (\n <>\n {provider && (\n <CollaborationPlugin\n providerFactory={providerFactory}\n id={\"liveblocks-document\"}\n username={username}\n cursorColor={cursorcolor}\n shouldBootstrap={true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A,SAAA,CAAU,MAAM;AAEd,IAAK,IAAA,CAAA,SAAA,CAAA,CAAW,gBAAiB,CAAA,SAAA,EAAW,MAAM,CAAA,CAAA;AAAA,GACpD,EAAG,CAAC,IAAI,CAAC,CAAA,CAAA;AAGT,EAAA,MAAM,IAAO,GAAA,OAAA,CAAQ,CAAC,EAAA,KAAO,GAAG,IAAI,CAAA,CAAA;AACpC,EAAA,MAAM,WAAW,IAAM,EAAA,IAAA,CAAA;AACvB,EAAA,MAAM,cAAc,IAAM,EAAA,KAAA,CAAA;AAG1B,EAAA,MAAM,eAAkB,GAAA,WAAA;AAAA,IACtB,CAAC,IAAY,SAAgC,KAAA;AAC3C,MAAU,SAAA,CAAA,GAAA,CAAI,IAAI,GAAG,CAAA,CAAA;AACrB,MAAO,OAAA,QAAA,CAAA;AAAA,KACT;AAAA,IACA,CAAC,UAAU,GAAG,CAAA;AAAA,GAChB,CAAA;AAEA,EACE,uBAAAA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA,EACG,4BACEA,cAAA,CAAA,aAAA,CAAA,mBAAA,EAAA;AAAA,IACC,eAAA;AAAA,IACA,EAAI,EAAA,qBAAA;AAAA,IACJ,QAAA;AAAA,IACA,WAAa,EAAA,WAAA;AAAA,IACb,eAAiB,EAAA,IAAA;AAAA,GACnB,CAAA,EAGD,gDAAiCA,cAAA,CAAA,aAAA,CAAA,aAAA,EAAA,IAAc,mBAE/CA,cAAA,CAAA,aAAA,CAAA,qBAAA,EAAA,IAAA,EAAuB,QAAS,CACnC,CAAA,CAAA;AAEJ;;;;"}
@@ -2,19 +2,20 @@
2
2
 
3
3
  var react = require('@liveblocks/react');
4
4
  var React = require('react');
5
+ var classnames = require('../classnames.js');
5
6
 
6
7
  const Avatar = React.forwardRef(
7
8
  function Avatar2(props, forwardedRef) {
8
- const { userId, ...spanProps } = props;
9
- const { useUser } = react.useSharedContextBundle();
10
- const { user, isLoading } = useUser(userId);
9
+ const { userId, className, ...spanProps } = props;
10
+ const { user, isLoading } = react.useUser(userId);
11
11
  const avatar = user ? user.avatar : void 0;
12
12
  const name = user ? user.name : void 0;
13
13
  function Initials() {
14
14
  const initials = name ? getInitials(name) : void 0;
15
15
  if (initials) {
16
16
  return /* @__PURE__ */ React.createElement("span", {
17
- "aria-hidden": true
17
+ "aria-hidden": true,
18
+ className: "lb-avatar-fallback"
18
19
  }, initials);
19
20
  }
20
21
  if (isLoading)
@@ -23,16 +24,19 @@ const Avatar = React.forwardRef(
23
24
  return null;
24
25
  return /* @__PURE__ */ React.createElement("span", {
25
26
  "aria-label": userId,
26
- title: userId
27
+ title: userId,
28
+ className: "lb-avatar-fallback"
27
29
  }, getInitials(userId));
28
30
  }
29
31
  return /* @__PURE__ */ React.createElement("span", {
30
32
  "data-loading": isLoading ? "" : void 0,
31
33
  ...spanProps,
34
+ className: classnames.classNames("lb-avatar", className),
32
35
  ref: forwardedRef
33
36
  }, avatar && /* @__PURE__ */ React.createElement("img", {
34
37
  src: avatar,
35
- alt: name
38
+ alt: name,
39
+ className: "lb-avatar-image"
36
40
  }), /* @__PURE__ */ React.createElement(Initials, null));
37
41
  }
38
42
  );
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.js","sources":["../../src/mentions/avatar.tsx"],"sourcesContent":["import { useSharedContextBundle } from \"@liveblocks/react\";\nimport type { HTMLAttributes } from \"react\";\nimport React, { forwardRef } from \"react\";\n\nexport interface AvatarProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n userId: string;\n}\n\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(\n function Avatar(props, forwardedRef) {\n const { userId, ...spanProps } = props;\n const { useUser } = useSharedContextBundle();\n\n const { user, isLoading } = useUser(userId);\n\n const avatar = user ? user.avatar : undefined;\n\n const name = user ? user.name : undefined;\n\n function Initials() {\n const initials = name ? getInitials(name) : undefined;\n if (initials) {\n return <span aria-hidden>{initials}</span>;\n }\n\n if (isLoading) return null;\n\n if (user === undefined) return null;\n\n return (\n <span aria-label={userId} title={userId}>\n {getInitials(userId)}\n </span>\n );\n }\n\n return (\n <span\n data-loading={isLoading ? \"\" : undefined}\n {...spanProps}\n ref={forwardedRef}\n >\n {avatar && <img src={avatar} alt={name} />}\n\n <Initials />\n </span>\n );\n }\n);\n\nfunction getInitials(name: string) {\n return name\n .trim()\n .split(\" \")\n .reduce((initials, name, index, array) => {\n if (index === 0 || index === array.length - 1) {\n initials += name.charAt(0).toLocaleUpperCase();\n }\n\n return initials;\n }, \"\");\n}\n"],"names":["forwardRef","Avatar","useSharedContextBundle","name"],"mappings":";;;;;AASO,MAAM,MAAS,GAAAA,gBAAA;AAAA,EACpB,SAASC,OAAO,CAAA,KAAA,EAAO,YAAc,EAAA;AACnC,IAAM,MAAA,EAAE,MAAW,EAAA,GAAA,SAAA,EAAc,GAAA,KAAA,CAAA;AACjC,IAAM,MAAA,EAAE,OAAQ,EAAA,GAAIC,4BAAuB,EAAA,CAAA;AAE3C,IAAA,MAAM,EAAE,IAAA,EAAM,SAAU,EAAA,GAAI,QAAQ,MAAM,CAAA,CAAA;AAE1C,IAAM,MAAA,MAAA,GAAS,IAAO,GAAA,IAAA,CAAK,MAAS,GAAA,KAAA,CAAA,CAAA;AAEpC,IAAM,MAAA,IAAA,GAAO,IAAO,GAAA,IAAA,CAAK,IAAO,GAAA,KAAA,CAAA,CAAA;AAEhC,IAAA,SAAS,QAAW,GAAA;AAClB,MAAA,MAAM,QAAW,GAAA,IAAA,GAAO,WAAY,CAAA,IAAI,CAAI,GAAA,KAAA,CAAA,CAAA;AAC5C,MAAA,IAAI,QAAU,EAAA;AACZ,QAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,UAAK,aAAW,EAAA,IAAA;AAAA,SAAA,EAAE,QAAS,CAAA,CAAA;AAAA,OACrC;AAEA,MAAI,IAAA,SAAA;AAAW,QAAO,OAAA,IAAA,CAAA;AAEtB,MAAA,IAAI,IAAS,KAAA,KAAA,CAAA;AAAW,QAAO,OAAA,IAAA,CAAA;AAE/B,MAAA,uBACG,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,QAAK,YAAY,EAAA,MAAA;AAAA,QAAQ,KAAO,EAAA,MAAA;AAAA,OAC9B,EAAA,WAAA,CAAY,MAAM,CACrB,CAAA,CAAA;AAAA,KAEJ;AAEA,IAAA,uBACG,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,MACC,cAAA,EAAc,YAAY,EAAK,GAAA,KAAA,CAAA;AAAA,MAC9B,GAAG,SAAA;AAAA,MACJ,GAAK,EAAA,YAAA;AAAA,KAAA,EAEJ,0BAAW,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MAAI,GAAK,EAAA,MAAA;AAAA,MAAQ,GAAK,EAAA,IAAA;AAAA,KAAM,CAAA,kBAEvC,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAS,CACZ,CAAA,CAAA;AAAA,GAEJ;AACF,EAAA;AAEA,SAAS,YAAY,IAAc,EAAA;AACjC,EAAO,OAAA,IAAA,CACJ,IAAK,EAAA,CACL,KAAM,CAAA,GAAG,CACT,CAAA,MAAA,CAAO,CAAC,QAAA,EAAUC,KAAM,EAAA,KAAA,EAAO,KAAU,KAAA;AACxC,IAAA,IAAI,KAAU,KAAA,CAAA,IAAK,KAAU,KAAA,KAAA,CAAM,SAAS,CAAG,EAAA;AAC7C,MAAA,QAAA,IAAYA,KAAK,CAAA,MAAA,CAAO,CAAC,CAAA,CAAE,iBAAkB,EAAA,CAAA;AAAA,KAC/C;AAEA,IAAO,OAAA,QAAA,CAAA;AAAA,KACN,EAAE,CAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"avatar.js","sources":["../../src/mentions/avatar.tsx"],"sourcesContent":["import { useUser } from \"@liveblocks/react\";\nimport type { HTMLAttributes } from \"react\";\nimport React, { forwardRef } from \"react\";\n\nimport { classNames } from \"../classnames\";\n\nexport interface AvatarProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n userId: string;\n}\n\nexport const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(\n function Avatar(props, forwardedRef) {\n const { userId, className, ...spanProps } = props;\n\n const { user, isLoading } = useUser(userId);\n\n const avatar = user ? user.avatar : undefined;\n\n const name = user ? user.name : undefined;\n\n function Initials() {\n const initials = name ? getInitials(name) : undefined;\n if (initials) {\n return (\n <span aria-hidden className=\"lb-avatar-fallback\">\n {initials}\n </span>\n );\n }\n\n if (isLoading) return null;\n\n if (user === undefined) return null;\n\n return (\n <span aria-label={userId} title={userId} className=\"lb-avatar-fallback\">\n {getInitials(userId)}\n </span>\n );\n }\n\n return (\n <span\n data-loading={isLoading ? \"\" : undefined}\n {...spanProps}\n className={classNames(\"lb-avatar\", className)}\n ref={forwardedRef}\n >\n {avatar && <img src={avatar} alt={name} className=\"lb-avatar-image\" />}\n\n <Initials />\n </span>\n );\n }\n);\n\nfunction getInitials(name: string) {\n return name\n .trim()\n .split(\" \")\n .reduce((initials, name, index, array) => {\n if (index === 0 || index === array.length - 1) {\n initials += name.charAt(0).toLocaleUpperCase();\n }\n\n return initials;\n }, \"\");\n}\n"],"names":["forwardRef","Avatar","useUser","classNames","name"],"mappings":";;;;;;AAWO,MAAM,MAAS,GAAAA,gBAAA;AAAA,EACpB,SAASC,OAAO,CAAA,KAAA,EAAO,YAAc,EAAA;AACnC,IAAA,MAAM,EAAE,MAAA,EAAQ,SAAc,EAAA,GAAA,SAAA,EAAc,GAAA,KAAA,CAAA;AAE5C,IAAA,MAAM,EAAE,IAAA,EAAM,SAAU,EAAA,GAAIC,cAAQ,MAAM,CAAA,CAAA;AAE1C,IAAM,MAAA,MAAA,GAAS,IAAO,GAAA,IAAA,CAAK,MAAS,GAAA,KAAA,CAAA,CAAA;AAEpC,IAAM,MAAA,IAAA,GAAO,IAAO,GAAA,IAAA,CAAK,IAAO,GAAA,KAAA,CAAA,CAAA;AAEhC,IAAA,SAAS,QAAW,GAAA;AAClB,M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