@textbus/xnote 0.2.0 → 0.2.1
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/bundles/editor.d.ts
CHANGED
|
@@ -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 {
|
package/bundles/index.esm.js
CHANGED
|
@@ -6006,6 +6006,9 @@ class Matcher {
|
|
|
6006
6006
|
}
|
|
6007
6007
|
}
|
|
6008
6008
|
|
|
6009
|
+
/**
|
|
6010
|
+
* 组件架构信息
|
|
6011
|
+
*/
|
|
6009
6012
|
class Organization {
|
|
6010
6013
|
}
|
|
6011
6014
|
function registerAtShortcut(textbus) {
|
|
@@ -6055,6 +6058,8 @@ class AtComponent extends Component {
|
|
|
6055
6058
|
this.focus = new Subject();
|
|
6056
6059
|
this.members = createSignal([]);
|
|
6057
6060
|
this.selectedIndex = createSignal(0);
|
|
6061
|
+
this.selection = this.textbus.get(Selection);
|
|
6062
|
+
this.organization = this.textbus.get(Organization);
|
|
6058
6063
|
}
|
|
6059
6064
|
getSlots() {
|
|
6060
6065
|
if (this.state.userInfo) {
|
|
@@ -6108,10 +6113,7 @@ class AtComponent extends Component {
|
|
|
6108
6113
|
});
|
|
6109
6114
|
onBreak((ev) => {
|
|
6110
6115
|
const member = this.members()[this.selectedIndex()];
|
|
6111
|
-
|
|
6112
|
-
this.state.userInfo = Object.assign({}, member);
|
|
6113
|
-
}
|
|
6114
|
-
selection.selectComponentEnd(this);
|
|
6116
|
+
this.atMember(member);
|
|
6115
6117
|
ev.preventDefault();
|
|
6116
6118
|
});
|
|
6117
6119
|
useDynamicShortcut({
|
|
@@ -6147,12 +6149,18 @@ class AtComponent extends Component {
|
|
|
6147
6149
|
subs.unsubscribe();
|
|
6148
6150
|
});
|
|
6149
6151
|
}
|
|
6152
|
+
atMember(member) {
|
|
6153
|
+
if (member) {
|
|
6154
|
+
this.state.userInfo = Object.assign({}, member);
|
|
6155
|
+
this.organization.atMember(member);
|
|
6156
|
+
}
|
|
6157
|
+
this.selection.selectComponentEnd(this);
|
|
6158
|
+
}
|
|
6150
6159
|
}
|
|
6151
6160
|
AtComponent.componentName = 'AtComponent';
|
|
6152
6161
|
AtComponent.type = ContentType.InlineComponent;
|
|
6153
6162
|
|
|
6154
6163
|
function AtComponentView(props) {
|
|
6155
|
-
const selection = inject(Selection);
|
|
6156
6164
|
const dropdownRef = createRef();
|
|
6157
6165
|
const subscription = props.component.focus.subscribe((b) => {
|
|
6158
6166
|
if (dropdownRef.current && props.component.members().length) {
|
|
@@ -6204,8 +6212,7 @@ function AtComponentView(props) {
|
|
|
6204
6212
|
const yiq = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
|
|
6205
6213
|
const color = yiq >= 128 ? '#000' : '#fff';
|
|
6206
6214
|
return (jsxs("div", { onClick: () => {
|
|
6207
|
-
props.component.
|
|
6208
|
-
selection.selectComponentEnd(props.component);
|
|
6215
|
+
props.component.atMember(member);
|
|
6209
6216
|
}, 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
6217
|
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
6218
|
}) }), children: [jsx("span", { children: "@" }), slot && jsx(SlotRender, { slot: slot, tag: "span", class: "xnote-at-input" })] }) }));
|
|
@@ -7255,7 +7262,7 @@ const stepComponentLoader = {
|
|
|
7255
7262
|
}
|
|
7256
7263
|
};
|
|
7257
7264
|
|
|
7258
|
-
class
|
|
7265
|
+
class XNoteMessageBus extends MessageBus {
|
|
7259
7266
|
constructor(selection, collaborateCursor, userinfo) {
|
|
7260
7267
|
super();
|
|
7261
7268
|
this.selection = selection;
|
|
@@ -7365,9 +7372,9 @@ class Editor extends Textbus {
|
|
|
7365
7372
|
provide: CollaborateSelectionAwarenessDelegate,
|
|
7366
7373
|
useClass: TableSelectionAwarenessDelegate
|
|
7367
7374
|
}, {
|
|
7368
|
-
provide:
|
|
7375
|
+
provide: XNoteMessageBus,
|
|
7369
7376
|
useFactory: (selection, collaborateCursor) => {
|
|
7370
|
-
return new
|
|
7377
|
+
return new XNoteMessageBus(selection, collaborateCursor, editorConfig.collaborateConfig.userinfo);
|
|
7371
7378
|
},
|
|
7372
7379
|
deps: [
|
|
7373
7380
|
Selection,
|
|
@@ -7375,7 +7382,7 @@ class Editor extends Textbus {
|
|
|
7375
7382
|
]
|
|
7376
7383
|
}, {
|
|
7377
7384
|
provide: MessageBus,
|
|
7378
|
-
useExisting:
|
|
7385
|
+
useExisting: XNoteMessageBus
|
|
7379
7386
|
}]
|
|
7380
7387
|
});
|
|
7381
7388
|
}
|
|
@@ -7502,4 +7509,4 @@ class Editor extends Textbus {
|
|
|
7502
7509
|
}
|
|
7503
7510
|
}
|
|
7504
7511
|
|
|
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,
|
|
7512
|
+
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
|
@@ -6008,6 +6008,9 @@ class Matcher {
|
|
|
6008
6008
|
}
|
|
6009
6009
|
}
|
|
6010
6010
|
|
|
6011
|
+
/**
|
|
6012
|
+
* 组件架构信息
|
|
6013
|
+
*/
|
|
6011
6014
|
class Organization {
|
|
6012
6015
|
}
|
|
6013
6016
|
function registerAtShortcut(textbus) {
|
|
@@ -6057,6 +6060,8 @@ class AtComponent extends core$1.Component {
|
|
|
6057
6060
|
this.focus = new core$1.Subject();
|
|
6058
6061
|
this.members = core.createSignal([]);
|
|
6059
6062
|
this.selectedIndex = core.createSignal(0);
|
|
6063
|
+
this.selection = this.textbus.get(core$1.Selection);
|
|
6064
|
+
this.organization = this.textbus.get(Organization);
|
|
6060
6065
|
}
|
|
6061
6066
|
getSlots() {
|
|
6062
6067
|
if (this.state.userInfo) {
|
|
@@ -6110,10 +6115,7 @@ class AtComponent extends core$1.Component {
|
|
|
6110
6115
|
});
|
|
6111
6116
|
core$1.onBreak((ev) => {
|
|
6112
6117
|
const member = this.members()[this.selectedIndex()];
|
|
6113
|
-
|
|
6114
|
-
this.state.userInfo = Object.assign({}, member);
|
|
6115
|
-
}
|
|
6116
|
-
selection.selectComponentEnd(this);
|
|
6118
|
+
this.atMember(member);
|
|
6117
6119
|
ev.preventDefault();
|
|
6118
6120
|
});
|
|
6119
6121
|
core$1.useDynamicShortcut({
|
|
@@ -6149,12 +6151,18 @@ class AtComponent extends core$1.Component {
|
|
|
6149
6151
|
subs.unsubscribe();
|
|
6150
6152
|
});
|
|
6151
6153
|
}
|
|
6154
|
+
atMember(member) {
|
|
6155
|
+
if (member) {
|
|
6156
|
+
this.state.userInfo = Object.assign({}, member);
|
|
6157
|
+
this.organization.atMember(member);
|
|
6158
|
+
}
|
|
6159
|
+
this.selection.selectComponentEnd(this);
|
|
6160
|
+
}
|
|
6152
6161
|
}
|
|
6153
6162
|
AtComponent.componentName = 'AtComponent';
|
|
6154
6163
|
AtComponent.type = core$1.ContentType.InlineComponent;
|
|
6155
6164
|
|
|
6156
6165
|
function AtComponentView(props) {
|
|
6157
|
-
const selection = core.inject(core$1.Selection);
|
|
6158
6166
|
const dropdownRef = core.createRef();
|
|
6159
6167
|
const subscription = props.component.focus.subscribe((b) => {
|
|
6160
6168
|
if (dropdownRef.current && props.component.members().length) {
|
|
@@ -6206,8 +6214,7 @@ function AtComponentView(props) {
|
|
|
6206
6214
|
const yiq = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
|
|
6207
6215
|
const color$1 = yiq >= 128 ? '#000' : '#fff';
|
|
6208
6216
|
return (jsxRuntime.jsxs("div", { onClick: () => {
|
|
6209
|
-
props.component.
|
|
6210
|
-
selection.selectComponentEnd(props.component);
|
|
6217
|
+
props.component.atMember(member);
|
|
6211
6218
|
}, 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
6219
|
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
6220
|
}) }), children: [jsxRuntime.jsx("span", { children: "@" }), slot && jsxRuntime.jsx(SlotRender, { slot: slot, tag: "span", class: "xnote-at-input" })] }) }));
|
|
@@ -7257,7 +7264,7 @@ const stepComponentLoader = {
|
|
|
7257
7264
|
}
|
|
7258
7265
|
};
|
|
7259
7266
|
|
|
7260
|
-
class
|
|
7267
|
+
class XNoteMessageBus extends collaborate.MessageBus {
|
|
7261
7268
|
constructor(selection, collaborateCursor, userinfo) {
|
|
7262
7269
|
super();
|
|
7263
7270
|
this.selection = selection;
|
|
@@ -7367,9 +7374,9 @@ class Editor extends core$1.Textbus {
|
|
|
7367
7374
|
provide: platformBrowser.CollaborateSelectionAwarenessDelegate,
|
|
7368
7375
|
useClass: TableSelectionAwarenessDelegate
|
|
7369
7376
|
}, {
|
|
7370
|
-
provide:
|
|
7377
|
+
provide: XNoteMessageBus,
|
|
7371
7378
|
useFactory: (selection, collaborateCursor) => {
|
|
7372
|
-
return new
|
|
7379
|
+
return new XNoteMessageBus(selection, collaborateCursor, editorConfig.collaborateConfig.userinfo);
|
|
7373
7380
|
},
|
|
7374
7381
|
deps: [
|
|
7375
7382
|
core$1.Selection,
|
|
@@ -7377,7 +7384,7 @@ class Editor extends core$1.Textbus {
|
|
|
7377
7384
|
]
|
|
7378
7385
|
}, {
|
|
7379
7386
|
provide: collaborate.MessageBus,
|
|
7380
|
-
useExisting:
|
|
7387
|
+
useExisting: XNoteMessageBus
|
|
7381
7388
|
}]
|
|
7382
7389
|
});
|
|
7383
7390
|
}
|
|
@@ -7579,7 +7586,7 @@ exports.UnderlineTool = UnderlineTool;
|
|
|
7579
7586
|
exports.UndoTool = UndoTool;
|
|
7580
7587
|
exports.VideoComponent = VideoComponent;
|
|
7581
7588
|
exports.VideoView = VideoView;
|
|
7582
|
-
exports.
|
|
7589
|
+
exports.XNoteMessageBus = XNoteMessageBus;
|
|
7583
7590
|
exports.atComponentLoader = atComponentLoader;
|
|
7584
7591
|
exports.backgroundColorFormatLoader = backgroundColorFormatLoader;
|
|
7585
7592
|
exports.backgroundColorFormatter = backgroundColorFormatter;
|
|
@@ -13,12 +13,17 @@ export interface Member {
|
|
|
13
13
|
/** 成员背景色 */
|
|
14
14
|
color?: string;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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?:
|
|
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
|
|
12
|
+
export declare class XNoteMessageBus extends MessageBus<XNoteMessage> {
|
|
13
13
|
private selection;
|
|
14
14
|
private collaborateCursor;
|
|
15
15
|
private userinfo;
|
package/package.json
CHANGED