@textbus/xnote 0.2.0 → 0.2.2

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
@@ -108,7 +108,7 @@ const editor = new Editor({
108
108
  export abstract class Organization {
109
109
  abstract getMembers(name?: string): Promise<Member[]>
110
110
 
111
- abstract getMemberById(id: string): Promise<Member | null>
111
+ abstract atMember(member: Member): void
112
112
  }
113
113
  ```
114
114
  然后在编辑器初始化时传入你的实现
@@ -11,9 +11,15 @@ export interface XNoteCollaborateConfig extends CollaborateConfig {
11
11
  id: string;
12
12
  };
13
13
  }
14
+ /**
15
+ * XNote 配置项
16
+ */
14
17
  export interface EditorConfig extends TextbusConfig {
18
+ /** 默认 HTML 内容*/
15
19
  content?: string;
20
+ /** 协作服务配置 */
16
21
  collaborateConfig?: XNoteCollaborateConfig;
22
+ /** 视图配置项 */
17
23
  viewOptions?: Partial<ViewOptions>;
18
24
  }
19
25
  export declare class Editor extends Textbus {
@@ -691,7 +691,13 @@ const DropdownMenuPortal = withAnnotation({
691
691
  const documentClientHeight = document.documentElement.clientHeight;
692
692
  const bottomDistance = documentClientHeight - triggerRect.bottom;
693
693
  const isToTop = bottomDistance < 200 && triggerRect.top > bottomDistance;
694
- menuElement.style.left = triggerRect.left - containerRect.left + 'px';
694
+ let left = triggerRect.left - containerRect.left;
695
+ const clientWidth = document.documentElement.clientWidth;
696
+ const menuWidth = menuElement.offsetWidth;
697
+ const maxLeft = clientWidth - menuWidth - 20;
698
+ left = Math.min(maxLeft, left);
699
+ // left = Math.max(left, 20)
700
+ menuElement.style.left = left + 'px';
695
701
  if (isToTop) {
696
702
  const maxHeight = Math.max(menuElement.scrollHeight, menuElement.offsetHeight);
697
703
  const height = Math.min(triggerRect.top - 20, maxHeight, 400);
@@ -2607,7 +2613,7 @@ class TableComponent extends Component {
2607
2613
  };
2608
2614
  const start = getSelfSlot(this.selection.startSlot);
2609
2615
  const end = getSelfSlot(this.selection.endSlot);
2610
- if (start && end) {
2616
+ if (start && end && start !== end) {
2611
2617
  return this.getMaxRectangle(start, end);
2612
2618
  }
2613
2619
  return null;
@@ -5641,30 +5647,41 @@ const InlineToolbar = withAnnotation({
5641
5647
  const toolbarRef = createRef();
5642
5648
  function getTop() {
5643
5649
  const docRect = viewDocument.getBoundingClientRect();
5650
+ // const toolbarRect = toolbarRef.current!.getBoundingClientRect()
5644
5651
  const toolbarHeight = 36;
5645
5652
  // const documentHeight = document.documentElement.clientHeight
5646
5653
  let selectionFocusRect = null;
5647
5654
  const commonAncestorComponent = selection.commonAncestorComponent;
5648
5655
  if (commonAncestorComponent instanceof TableComponent) {
5649
- const slots = commonAncestorComponent.getSelectedNormalizedSlots().map(item => {
5650
- return item.cells.filter(i => {
5651
- return i.visible;
5652
- }).map(cell => {
5653
- return cell.raw.slot;
5656
+ const normalizedSlots = commonAncestorComponent.getSelectedNormalizedSlots();
5657
+ if (normalizedSlots) {
5658
+ const slots = normalizedSlots.map(item => {
5659
+ return item.cells.filter(i => {
5660
+ return i.visible;
5661
+ }).map(cell => {
5662
+ return cell.raw.slot;
5663
+ });
5664
+ }).flat();
5665
+ const startSlot = slots.at(0);
5666
+ const endSlot = slots.at(-1);
5667
+ const rect = commonAncestorComponent.getSelectedRect();
5668
+ const startRect = adapter.getNativeNodeBySlot(startSlot).getBoundingClientRect();
5669
+ const endEle = adapter.getNativeNodeBySlot(endSlot).getBoundingClientRect();
5670
+ const width = sum(commonAncestorComponent.state.columnsConfig.slice(rect.x1, rect.x2));
5671
+ selectionFocusRect = {
5672
+ left: startRect.left + width / 2,
5673
+ // left: Math.max(startRect.left + width / 2, toolbarRect.width / 2 + 10 - docRect.left),
5674
+ top: startRect.top,
5675
+ height: endEle.bottom - startRect.top,
5676
+ width
5677
+ };
5678
+ }
5679
+ else {
5680
+ selectionFocusRect = bridge.getRect({
5681
+ slot: selection.focusSlot,
5682
+ offset: selection.focusOffset
5654
5683
  });
5655
- }).flat();
5656
- const startSlot = slots.at(0);
5657
- const endSlot = slots.at(-1);
5658
- const rect = commonAncestorComponent.getSelectedRect();
5659
- const startRect = adapter.getNativeNodeBySlot(startSlot).getBoundingClientRect();
5660
- const endEle = adapter.getNativeNodeBySlot(endSlot).getBoundingClientRect();
5661
- const width = sum(commonAncestorComponent.state.columnsConfig.slice(rect.x1, rect.x2));
5662
- selectionFocusRect = {
5663
- left: startRect.left + width / 2,
5664
- top: startRect.top,
5665
- height: endEle.bottom - startRect.top,
5666
- width
5667
- };
5684
+ }
5668
5685
  }
5669
5686
  else {
5670
5687
  selectionFocusRect = bridge.getRect({
@@ -5683,6 +5700,7 @@ const InlineToolbar = withAnnotation({
5683
5700
  updateViewPosition(draft => {
5684
5701
  draft.transitionDuration = .15;
5685
5702
  draft.left = centerLeft - docRect.left;
5703
+ // draft.left = Math.max(centerLeft - docRect.left, toolbarRect.width / 2 + 10 - docRect.left)
5686
5704
  draft.top = top + 10;
5687
5705
  });
5688
5706
  return top;
@@ -6006,6 +6024,9 @@ class Matcher {
6006
6024
  }
6007
6025
  }
6008
6026
 
6027
+ /**
6028
+ * 组件架构信息
6029
+ */
6009
6030
  class Organization {
6010
6031
  }
6011
6032
  function registerAtShortcut(textbus) {
@@ -6055,6 +6076,8 @@ class AtComponent extends Component {
6055
6076
  this.focus = new Subject();
6056
6077
  this.members = createSignal([]);
6057
6078
  this.selectedIndex = createSignal(0);
6079
+ this.selection = this.textbus.get(Selection);
6080
+ this.organization = this.textbus.get(Organization);
6058
6081
  }
6059
6082
  getSlots() {
6060
6083
  if (this.state.userInfo) {
@@ -6108,10 +6131,7 @@ class AtComponent extends Component {
6108
6131
  });
6109
6132
  onBreak((ev) => {
6110
6133
  const member = this.members()[this.selectedIndex()];
6111
- if (member) {
6112
- this.state.userInfo = Object.assign({}, member);
6113
- }
6114
- selection.selectComponentEnd(this);
6134
+ this.atMember(member);
6115
6135
  ev.preventDefault();
6116
6136
  });
6117
6137
  useDynamicShortcut({
@@ -6147,12 +6167,18 @@ class AtComponent extends Component {
6147
6167
  subs.unsubscribe();
6148
6168
  });
6149
6169
  }
6170
+ atMember(member) {
6171
+ if (member) {
6172
+ this.state.userInfo = Object.assign({}, member);
6173
+ this.organization.atMember(member);
6174
+ }
6175
+ this.selection.selectComponentEnd(this);
6176
+ }
6150
6177
  }
6151
6178
  AtComponent.componentName = 'AtComponent';
6152
6179
  AtComponent.type = ContentType.InlineComponent;
6153
6180
 
6154
6181
  function AtComponentView(props) {
6155
- const selection = inject(Selection);
6156
6182
  const dropdownRef = createRef();
6157
6183
  const subscription = props.component.focus.subscribe((b) => {
6158
6184
  if (dropdownRef.current && props.component.members().length) {
@@ -6204,8 +6230,7 @@ function AtComponentView(props) {
6204
6230
  const yiq = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
6205
6231
  const color = yiq >= 128 ? '#000' : '#fff';
6206
6232
  return (jsxs("div", { onClick: () => {
6207
- props.component.state.userInfo = member;
6208
- selection.selectComponentEnd(props.component);
6233
+ props.component.atMember(member);
6209
6234
  }, class: ['xnote-at-member', { selected: index === selectedIndex }], children: [jsx("div", { class: "xnote-at-member-avatar", children: member.avatar ? jsx("img", { src: member.avatar, alt: member.name }) :
6210
6235
  jsx("span", { class: "xnote-at-member-avatar-bg", style: { background: member.color, color }, children: member.name }) }), jsxs("div", { class: "xnote-at-member-info", children: [jsx("div", { class: "xnote-at-member-name", children: member.name }), jsx("div", { class: "xnote-at-member-desc", children: member.groupName })] })] }, member.id));
6211
6236
  }) }), children: [jsx("span", { children: "@" }), slot && jsx(SlotRender, { slot: slot, tag: "span", class: "xnote-at-input" })] }) }));
@@ -7255,7 +7280,7 @@ const stepComponentLoader = {
7255
7280
  }
7256
7281
  };
7257
7282
 
7258
- class XNoteMessageBug extends MessageBus {
7283
+ class XNoteMessageBus extends MessageBus {
7259
7284
  constructor(selection, collaborateCursor, userinfo) {
7260
7285
  super();
7261
7286
  this.selection = selection;
@@ -7365,9 +7390,9 @@ class Editor extends Textbus {
7365
7390
  provide: CollaborateSelectionAwarenessDelegate,
7366
7391
  useClass: TableSelectionAwarenessDelegate
7367
7392
  }, {
7368
- provide: XNoteMessageBug,
7393
+ provide: XNoteMessageBus,
7369
7394
  useFactory: (selection, collaborateCursor) => {
7370
- return new XNoteMessageBug(selection, collaborateCursor, editorConfig.collaborateConfig.userinfo);
7395
+ return new XNoteMessageBus(selection, collaborateCursor, editorConfig.collaborateConfig.userinfo);
7371
7396
  },
7372
7397
  deps: [
7373
7398
  Selection,
@@ -7375,7 +7400,7 @@ class Editor extends Textbus {
7375
7400
  ]
7376
7401
  }, {
7377
7402
  provide: MessageBus,
7378
- useExisting: XNoteMessageBug
7403
+ useExisting: XNoteMessageBus
7379
7404
  }]
7380
7405
  });
7381
7406
  }
@@ -7502,4 +7527,4 @@ class Editor extends Textbus {
7502
7527
  }
7503
7528
  }
7504
7529
 
7505
- export { AtComponent, AtComponentView, AttrTool, BlockTool, BlockquoteComponent, BlockquoteView, BoldTool, Button, CellAlignTool, CellBackgroundTool, CleanFormatsTool, CodeTool, ColorPicker, ColorTool, ComponentToolbar, Divider, DragResize, Dropdown, DropdownContextService, DropdownMenuContainer, DropdownMenuPortal, DropdownService, Editor, EditorService, FileUploader, FontFamilyTool, FontSizeTool, HighlightBoxComponent, HighlightBoxView, ImageComponent, ImageView, InlineToolbar, InlineToolbarPlugin, InsertMenu, InsertTool, ItalicTool, KatexComponent, KatexComponentView, Keymap, LeftToolbar, LeftToolbarPlugin, LinkJump, LinkTool, ListComponent, ListComponentView, Matcher, MenuHeading, MenuItem, MergeCellsTool, Organization, OutputInjectionToken, ParagraphComponent, ParagraphView, Picker, Popup, RedoTool, RefreshService, RootComponent, RootView, SourceCodeComponent, SourceCodeView, SplitCellsTool, SplitLine, StaticToolbar, StaticToolbarPlugin, StrikeThroughTool, SubscriptTool, SuperscriptTool, SuspensionToolbar, SuspensionToolbarPlugin, TableComponent, TableComponentView, TodolistComponent, TodolistView, ToolbarItem, UnderlineTool, UndoTool, VideoComponent, VideoView, XNoteMessageBug, atComponentLoader, backgroundColorFormatLoader, backgroundColorFormatter, blockquoteComponentLoader, boldFormatLoader, boldFormatter, cellAlignAttr, cellAlignAttrLoader, cellBackgroundAttr, cellBackgroundAttrLoader, codeFormatLoader, codeFormatter, colorFormatLoader, colorFormatter, deltaToBlock, fontFamilyFormatLoader, fontFamilyFormatter, fontSizeFormatLoader, fontSizeFormatter, headingAttr, headingAttrLoader, highlightBoxComponentLoader, imageComponentLoader, isSupportFont, italicFormatLoader, italicFormatter, katexComponentLoader, languageList, linkFormatLoader, linkFormatter, listComponentLoader, paragraphComponentLoader, registerAtShortcut, registerBlockquoteShortcut, registerBoldShortcut, registerCodeShortcut, registerHeadingShortcut, registerItalicShortcut, registerListShortcut, registerStrikeThroughShortcut, registerTextAlignShortcut, registerTextIndentShortcut, registerUnderlineShortcut, rootComponentLoader, sourceCodeComponentLoader, sourceCodeThemes, strikeThroughFormatLoader, strikeThroughFormatter, subscriptFormatLoader, subscriptFormatter, superscriptFormatLoader, superscriptFormatter, tableComponentLoader, textAlignAttr, textAlignAttrLoader, textIndentAttr, textIndentAttrLoader, toBlockquote, toList, todolistComponentLoader, toggleBold, toggleCode, toggleItalic, toggleStrikeThrough, toggleUnderline, underlineFormatLoader, underlineFormatter, useActiveBlock, useBlockContent, useBlockTransform, useOutput, useReadonly, videoComponentLoader };
7530
+ export { AtComponent, AtComponentView, AttrTool, BlockTool, BlockquoteComponent, BlockquoteView, BoldTool, Button, CellAlignTool, CellBackgroundTool, CleanFormatsTool, CodeTool, ColorPicker, ColorTool, ComponentToolbar, Divider, DragResize, Dropdown, DropdownContextService, DropdownMenuContainer, DropdownMenuPortal, DropdownService, Editor, EditorService, FileUploader, FontFamilyTool, FontSizeTool, HighlightBoxComponent, HighlightBoxView, ImageComponent, ImageView, InlineToolbar, InlineToolbarPlugin, InsertMenu, InsertTool, ItalicTool, KatexComponent, KatexComponentView, Keymap, LeftToolbar, LeftToolbarPlugin, LinkJump, LinkTool, ListComponent, ListComponentView, Matcher, MenuHeading, MenuItem, MergeCellsTool, Organization, OutputInjectionToken, ParagraphComponent, ParagraphView, Picker, Popup, RedoTool, RefreshService, RootComponent, RootView, SourceCodeComponent, SourceCodeView, SplitCellsTool, SplitLine, StaticToolbar, StaticToolbarPlugin, StrikeThroughTool, SubscriptTool, SuperscriptTool, SuspensionToolbar, SuspensionToolbarPlugin, TableComponent, TableComponentView, TodolistComponent, TodolistView, ToolbarItem, UnderlineTool, UndoTool, VideoComponent, VideoView, XNoteMessageBus, atComponentLoader, backgroundColorFormatLoader, backgroundColorFormatter, blockquoteComponentLoader, boldFormatLoader, boldFormatter, cellAlignAttr, cellAlignAttrLoader, cellBackgroundAttr, cellBackgroundAttrLoader, codeFormatLoader, codeFormatter, colorFormatLoader, colorFormatter, deltaToBlock, fontFamilyFormatLoader, fontFamilyFormatter, fontSizeFormatLoader, fontSizeFormatter, headingAttr, headingAttrLoader, highlightBoxComponentLoader, imageComponentLoader, isSupportFont, italicFormatLoader, italicFormatter, katexComponentLoader, languageList, linkFormatLoader, linkFormatter, listComponentLoader, paragraphComponentLoader, registerAtShortcut, registerBlockquoteShortcut, registerBoldShortcut, registerCodeShortcut, registerHeadingShortcut, registerItalicShortcut, registerListShortcut, registerStrikeThroughShortcut, registerTextAlignShortcut, registerTextIndentShortcut, registerUnderlineShortcut, rootComponentLoader, sourceCodeComponentLoader, sourceCodeThemes, strikeThroughFormatLoader, strikeThroughFormatter, subscriptFormatLoader, subscriptFormatter, superscriptFormatLoader, superscriptFormatter, tableComponentLoader, textAlignAttr, textAlignAttrLoader, textIndentAttr, textIndentAttrLoader, toBlockquote, toList, todolistComponentLoader, toggleBold, toggleCode, toggleItalic, toggleStrikeThrough, toggleUnderline, underlineFormatLoader, underlineFormatter, useActiveBlock, useBlockContent, useBlockTransform, useOutput, useReadonly, videoComponentLoader };
package/bundles/index.js CHANGED
@@ -693,7 +693,13 @@ const DropdownMenuPortal = core.withAnnotation({
693
693
  const documentClientHeight = document.documentElement.clientHeight;
694
694
  const bottomDistance = documentClientHeight - triggerRect.bottom;
695
695
  const isToTop = bottomDistance < 200 && triggerRect.top > bottomDistance;
696
- menuElement.style.left = triggerRect.left - containerRect.left + 'px';
696
+ let left = triggerRect.left - containerRect.left;
697
+ const clientWidth = document.documentElement.clientWidth;
698
+ const menuWidth = menuElement.offsetWidth;
699
+ const maxLeft = clientWidth - menuWidth - 20;
700
+ left = Math.min(maxLeft, left);
701
+ // left = Math.max(left, 20)
702
+ menuElement.style.left = left + 'px';
697
703
  if (isToTop) {
698
704
  const maxHeight = Math.max(menuElement.scrollHeight, menuElement.offsetHeight);
699
705
  const height = Math.min(triggerRect.top - 20, maxHeight, 400);
@@ -2609,7 +2615,7 @@ class TableComponent extends core$1.Component {
2609
2615
  };
2610
2616
  const start = getSelfSlot(this.selection.startSlot);
2611
2617
  const end = getSelfSlot(this.selection.endSlot);
2612
- if (start && end) {
2618
+ if (start && end && start !== end) {
2613
2619
  return this.getMaxRectangle(start, end);
2614
2620
  }
2615
2621
  return null;
@@ -5643,30 +5649,41 @@ const InlineToolbar = core.withAnnotation({
5643
5649
  const toolbarRef = core.createRef();
5644
5650
  function getTop() {
5645
5651
  const docRect = viewDocument.getBoundingClientRect();
5652
+ // const toolbarRect = toolbarRef.current!.getBoundingClientRect()
5646
5653
  const toolbarHeight = 36;
5647
5654
  // const documentHeight = document.documentElement.clientHeight
5648
5655
  let selectionFocusRect = null;
5649
5656
  const commonAncestorComponent = selection.commonAncestorComponent;
5650
5657
  if (commonAncestorComponent instanceof TableComponent) {
5651
- const slots = commonAncestorComponent.getSelectedNormalizedSlots().map(item => {
5652
- return item.cells.filter(i => {
5653
- return i.visible;
5654
- }).map(cell => {
5655
- return cell.raw.slot;
5658
+ const normalizedSlots = commonAncestorComponent.getSelectedNormalizedSlots();
5659
+ if (normalizedSlots) {
5660
+ const slots = normalizedSlots.map(item => {
5661
+ return item.cells.filter(i => {
5662
+ return i.visible;
5663
+ }).map(cell => {
5664
+ return cell.raw.slot;
5665
+ });
5666
+ }).flat();
5667
+ const startSlot = slots.at(0);
5668
+ const endSlot = slots.at(-1);
5669
+ const rect = commonAncestorComponent.getSelectedRect();
5670
+ const startRect = adapter.getNativeNodeBySlot(startSlot).getBoundingClientRect();
5671
+ const endEle = adapter.getNativeNodeBySlot(endSlot).getBoundingClientRect();
5672
+ const width = sum(commonAncestorComponent.state.columnsConfig.slice(rect.x1, rect.x2));
5673
+ selectionFocusRect = {
5674
+ left: startRect.left + width / 2,
5675
+ // left: Math.max(startRect.left + width / 2, toolbarRect.width / 2 + 10 - docRect.left),
5676
+ top: startRect.top,
5677
+ height: endEle.bottom - startRect.top,
5678
+ width
5679
+ };
5680
+ }
5681
+ else {
5682
+ selectionFocusRect = bridge.getRect({
5683
+ slot: selection.focusSlot,
5684
+ offset: selection.focusOffset
5656
5685
  });
5657
- }).flat();
5658
- const startSlot = slots.at(0);
5659
- const endSlot = slots.at(-1);
5660
- const rect = commonAncestorComponent.getSelectedRect();
5661
- const startRect = adapter.getNativeNodeBySlot(startSlot).getBoundingClientRect();
5662
- const endEle = adapter.getNativeNodeBySlot(endSlot).getBoundingClientRect();
5663
- const width = sum(commonAncestorComponent.state.columnsConfig.slice(rect.x1, rect.x2));
5664
- selectionFocusRect = {
5665
- left: startRect.left + width / 2,
5666
- top: startRect.top,
5667
- height: endEle.bottom - startRect.top,
5668
- width
5669
- };
5686
+ }
5670
5687
  }
5671
5688
  else {
5672
5689
  selectionFocusRect = bridge.getRect({
@@ -5685,6 +5702,7 @@ const InlineToolbar = core.withAnnotation({
5685
5702
  updateViewPosition(draft => {
5686
5703
  draft.transitionDuration = .15;
5687
5704
  draft.left = centerLeft - docRect.left;
5705
+ // draft.left = Math.max(centerLeft - docRect.left, toolbarRect.width / 2 + 10 - docRect.left)
5688
5706
  draft.top = top + 10;
5689
5707
  });
5690
5708
  return top;
@@ -6008,6 +6026,9 @@ class Matcher {
6008
6026
  }
6009
6027
  }
6010
6028
 
6029
+ /**
6030
+ * 组件架构信息
6031
+ */
6011
6032
  class Organization {
6012
6033
  }
6013
6034
  function registerAtShortcut(textbus) {
@@ -6057,6 +6078,8 @@ class AtComponent extends core$1.Component {
6057
6078
  this.focus = new core$1.Subject();
6058
6079
  this.members = core.createSignal([]);
6059
6080
  this.selectedIndex = core.createSignal(0);
6081
+ this.selection = this.textbus.get(core$1.Selection);
6082
+ this.organization = this.textbus.get(Organization);
6060
6083
  }
6061
6084
  getSlots() {
6062
6085
  if (this.state.userInfo) {
@@ -6110,10 +6133,7 @@ class AtComponent extends core$1.Component {
6110
6133
  });
6111
6134
  core$1.onBreak((ev) => {
6112
6135
  const member = this.members()[this.selectedIndex()];
6113
- if (member) {
6114
- this.state.userInfo = Object.assign({}, member);
6115
- }
6116
- selection.selectComponentEnd(this);
6136
+ this.atMember(member);
6117
6137
  ev.preventDefault();
6118
6138
  });
6119
6139
  core$1.useDynamicShortcut({
@@ -6149,12 +6169,18 @@ class AtComponent extends core$1.Component {
6149
6169
  subs.unsubscribe();
6150
6170
  });
6151
6171
  }
6172
+ atMember(member) {
6173
+ if (member) {
6174
+ this.state.userInfo = Object.assign({}, member);
6175
+ this.organization.atMember(member);
6176
+ }
6177
+ this.selection.selectComponentEnd(this);
6178
+ }
6152
6179
  }
6153
6180
  AtComponent.componentName = 'AtComponent';
6154
6181
  AtComponent.type = core$1.ContentType.InlineComponent;
6155
6182
 
6156
6183
  function AtComponentView(props) {
6157
- const selection = core.inject(core$1.Selection);
6158
6184
  const dropdownRef = core.createRef();
6159
6185
  const subscription = props.component.focus.subscribe((b) => {
6160
6186
  if (dropdownRef.current && props.component.members().length) {
@@ -6206,8 +6232,7 @@ function AtComponentView(props) {
6206
6232
  const yiq = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
6207
6233
  const color$1 = yiq >= 128 ? '#000' : '#fff';
6208
6234
  return (jsxRuntime.jsxs("div", { onClick: () => {
6209
- props.component.state.userInfo = member;
6210
- selection.selectComponentEnd(props.component);
6235
+ props.component.atMember(member);
6211
6236
  }, class: ['xnote-at-member', { selected: index === selectedIndex }], children: [jsxRuntime.jsx("div", { class: "xnote-at-member-avatar", children: member.avatar ? jsxRuntime.jsx("img", { src: member.avatar, alt: member.name }) :
6212
6237
  jsxRuntime.jsx("span", { class: "xnote-at-member-avatar-bg", style: { background: member.color, color: color$1 }, children: member.name }) }), jsxRuntime.jsxs("div", { class: "xnote-at-member-info", children: [jsxRuntime.jsx("div", { class: "xnote-at-member-name", children: member.name }), jsxRuntime.jsx("div", { class: "xnote-at-member-desc", children: member.groupName })] })] }, member.id));
6213
6238
  }) }), children: [jsxRuntime.jsx("span", { children: "@" }), slot && jsxRuntime.jsx(SlotRender, { slot: slot, tag: "span", class: "xnote-at-input" })] }) }));
@@ -7257,7 +7282,7 @@ const stepComponentLoader = {
7257
7282
  }
7258
7283
  };
7259
7284
 
7260
- class XNoteMessageBug extends collaborate.MessageBus {
7285
+ class XNoteMessageBus extends collaborate.MessageBus {
7261
7286
  constructor(selection, collaborateCursor, userinfo) {
7262
7287
  super();
7263
7288
  this.selection = selection;
@@ -7367,9 +7392,9 @@ class Editor extends core$1.Textbus {
7367
7392
  provide: platformBrowser.CollaborateSelectionAwarenessDelegate,
7368
7393
  useClass: TableSelectionAwarenessDelegate
7369
7394
  }, {
7370
- provide: XNoteMessageBug,
7395
+ provide: XNoteMessageBus,
7371
7396
  useFactory: (selection, collaborateCursor) => {
7372
- return new XNoteMessageBug(selection, collaborateCursor, editorConfig.collaborateConfig.userinfo);
7397
+ return new XNoteMessageBus(selection, collaborateCursor, editorConfig.collaborateConfig.userinfo);
7373
7398
  },
7374
7399
  deps: [
7375
7400
  core$1.Selection,
@@ -7377,7 +7402,7 @@ class Editor extends core$1.Textbus {
7377
7402
  ]
7378
7403
  }, {
7379
7404
  provide: collaborate.MessageBus,
7380
- useExisting: XNoteMessageBug
7405
+ useExisting: XNoteMessageBus
7381
7406
  }]
7382
7407
  });
7383
7408
  }
@@ -7579,7 +7604,7 @@ exports.UnderlineTool = UnderlineTool;
7579
7604
  exports.UndoTool = UndoTool;
7580
7605
  exports.VideoComponent = VideoComponent;
7581
7606
  exports.VideoView = VideoView;
7582
- exports.XNoteMessageBug = XNoteMessageBug;
7607
+ exports.XNoteMessageBus = XNoteMessageBus;
7583
7608
  exports.atComponentLoader = atComponentLoader;
7584
7609
  exports.backgroundColorFormatLoader = backgroundColorFormatLoader;
7585
7610
  exports.backgroundColorFormatter = backgroundColorFormatter;
@@ -13,12 +13,17 @@ export interface Member {
13
13
  /** 成员背景色 */
14
14
  color?: string;
15
15
  }
16
- export declare abstract class Organization {
17
- abstract getMembers(name?: string): Promise<Member[]>;
18
- abstract getMemberById(id: string): Promise<Member | null>;
16
+ /**
17
+ * 组件架构信息
18
+ */
19
+ export declare abstract class Organization<T extends Member = Member> {
20
+ /** 根据当前输入获取成员列表 */
21
+ abstract getMembers(name?: string): Promise<T[]>;
22
+ /** 当 @ 某个成员时的回调 */
23
+ abstract atMember(member: T): void;
19
24
  }
20
- export interface AtComponentState {
21
- userInfo?: Member;
25
+ export interface AtComponentState<T extends Member = Member> {
26
+ userInfo?: T;
22
27
  slot?: Slot;
23
28
  }
24
29
  export declare function registerAtShortcut(textbus: Textbus): void;
@@ -29,7 +34,10 @@ export declare class AtComponent extends Component<AtComponentState> {
29
34
  focus: Subject<boolean>;
30
35
  members: import("@viewfly/core").Signal<Member[]>;
31
36
  selectedIndex: import("@viewfly/core").Signal<number>;
37
+ private selection;
38
+ private organization;
32
39
  constructor(textbus: Textbus, state?: AtComponentState);
33
40
  getSlots(): Slot[];
34
41
  setup(): void;
42
+ atMember(member?: Member): void;
35
43
  }
@@ -9,7 +9,7 @@ export interface UserInfo {
9
9
  export interface XNoteMessage extends UserSelectionCursor {
10
10
  id: string;
11
11
  }
12
- export declare class XNoteMessageBug extends MessageBus<XNoteMessage> {
12
+ export declare class XNoteMessageBus extends MessageBus<XNoteMessage> {
13
13
  private selection;
14
14
  private collaborateCursor;
15
15
  private userinfo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/xnote",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "A high-performance rich text editor that supports multiplayer online collaboration.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -31,10 +31,10 @@
31
31
  "@textbus/collaborate": "^4.2.4",
32
32
  "@textbus/core": "^4.2.4",
33
33
  "@textbus/platform-browser": "^4.2.5",
34
- "@viewfly/core": "^1.1.0",
35
- "@viewfly/hooks": "^1.1.0",
36
- "@viewfly/platform-browser": "^1.1.0",
37
- "@viewfly/scoped-css": "^1.1.0",
34
+ "@viewfly/core": "^1.1.1",
35
+ "@viewfly/hooks": "^1.1.1",
36
+ "@viewfly/platform-browser": "^1.1.1",
37
+ "@viewfly/scoped-css": "^1.1.1",
38
38
  "highlight.js": "^11.9.0",
39
39
  "katex": "^0.16.10",
40
40
  "uuid": "^10.0.0"
@@ -47,7 +47,7 @@
47
47
  "@types/uuid": "^10.0.0",
48
48
  "@typescript-eslint/eslint-plugin": "^5.8.0",
49
49
  "@typescript-eslint/parser": "^5.8.0",
50
- "@viewfly/devtools": "^1.0.8",
50
+ "@viewfly/devtools": "^1.1.1",
51
51
  "autoprefixer": "^10.4.0",
52
52
  "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
53
53
  "core-js": "^3.20.1",