@textbus/xnote 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -2
- package/bundles/index.esm.js +18 -3
- package/bundles/index.js +16 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -56,8 +56,6 @@ const editor = new Editor({
|
|
|
56
56
|
|
|
57
57
|
## 粘贴图片 Base64 转 URL
|
|
58
58
|
|
|
59
|
-
base64 转 url 实现思路为 base64 转
|
|
60
|
-
|
|
61
59
|
```ts
|
|
62
60
|
import { Commander } from '@textbus/core'
|
|
63
61
|
import { Injectable } from '@viewfly/core'
|
|
@@ -102,4 +100,42 @@ const editor = new Editor({
|
|
|
102
100
|
})
|
|
103
101
|
```
|
|
104
102
|
|
|
103
|
+
## @ 人
|
|
104
|
+
|
|
105
|
+
在文档中 @ 人功能需实现以下接口,以对接用户信息
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
export abstract class Organization {
|
|
109
|
+
abstract getMembers(name?: string): Promise<Member[]>
|
|
110
|
+
|
|
111
|
+
abstract getMemberById(id: string): Promise<Member | null>
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
然后在编辑器初始化时传入你的实现
|
|
115
|
+
```ts
|
|
116
|
+
const editor = new Editor({
|
|
117
|
+
providers: [{
|
|
118
|
+
provide: Organization,
|
|
119
|
+
useValue: new YourOrganization()
|
|
120
|
+
}]
|
|
121
|
+
})
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## 协作支持
|
|
125
|
+
|
|
126
|
+
Textbus 天然支持协作,只需要在编辑器配置项中添加协作配置信息即可,具体配置你可以参考 [https://textbus.io/guide/collab/](https://textbus.io/guide/collab/)
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
const editor = new Editor({
|
|
130
|
+
collaborateConfig: {
|
|
131
|
+
userinfo: user, // 用户信息
|
|
132
|
+
createConnector(yDoc): SyncConnector {
|
|
133
|
+
// 返回连接器
|
|
134
|
+
return new YWebsocketConnector('wss://example.com', 'docName', yDoc)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
|
|
105
141
|
|
package/bundles/index.esm.js
CHANGED
|
@@ -2,14 +2,14 @@ import { jsxs, jsx, Fragment } from '@viewfly/core/jsx-runtime';
|
|
|
2
2
|
import { withScopedCSS } from '@viewfly/scoped-css';
|
|
3
3
|
import { Injectable, InjectFlags, Injector, inject, createSignal, onUnmounted, createRef, withAnnotation, onUpdated, onMounted, InjectionToken, getCurrentInstance, ReflectiveInjector, createDynamicRef, jsx as jsx$1, viewfly, watch } from '@viewfly/core';
|
|
4
4
|
import { Subject, Selection, fromEvent, Subscription, Attribute, Keyboard, Commander, Controller, useContext, onBreak, onContentInsert, ContentType, merge, createVNode, Slot, Component, Registry, Query, QueryStateType, BehaviorSubject, onSlotApplyFormat, onSlotSetAttribute, onPaste, onFocus, onBlur, useDynamicShortcut, VTextNode, onFocusIn, onFocusOut, onDestroy, onGetRanges, Formatter, onParentSlotUpdated, Textbus, RootComponentRef, filter, map, distinctUntilChanged, sampleTime, debounceTime, throttleTime, delay, onContentInserted, onContentDeleted, switchMap, fromPromise, onCompositionStart } from '@textbus/core';
|
|
5
|
-
import { VIEW_CONTAINER, isMac, DomAdapter, Input, SelectionBridge, BrowserModule, VIEW_DOCUMENT, CollaborateSelectionAwarenessDelegate, isMobileBrowser, Parser } from '@textbus/platform-browser';
|
|
5
|
+
import { VIEW_CONTAINER, isMac, DomAdapter, Input, SelectionBridge, BrowserModule, VIEW_DOCUMENT, CollaborateSelectionAwarenessDelegate, isMobileBrowser, CollaborateCursor, Parser } from '@textbus/platform-browser';
|
|
6
6
|
import { createPortal, createApp, DomRenderer, HTMLRenderer, OutputTranslator } from '@viewfly/platform-browser';
|
|
7
7
|
import { useProduce } from '@viewfly/hooks';
|
|
8
8
|
import highlightjs from 'highlight.js';
|
|
9
9
|
import Katex from 'katex';
|
|
10
10
|
import { ViewflyAdapter, ViewflyVDomAdapter } from '@textbus/adapter-viewfly';
|
|
11
11
|
import { any2Hsl, hsl2Rgb } from '@tanbo/color';
|
|
12
|
-
import { CollaborateModule } from '@textbus/collaborate';
|
|
12
|
+
import { CollaborateModule, UserActivity } from '@textbus/collaborate';
|
|
13
13
|
|
|
14
14
|
var scopedId$n = "vf-d94b56";
|
|
15
15
|
|
|
@@ -4567,6 +4567,9 @@ class AtComponent extends Component {
|
|
|
4567
4567
|
this.selectedIndex = createSignal(0);
|
|
4568
4568
|
}
|
|
4569
4569
|
getSlots() {
|
|
4570
|
+
if (this.state.userInfo) {
|
|
4571
|
+
return [];
|
|
4572
|
+
}
|
|
4570
4573
|
if (this.state.slot) {
|
|
4571
4574
|
return [this.state.slot];
|
|
4572
4575
|
}
|
|
@@ -5743,7 +5746,19 @@ class Editor extends Textbus {
|
|
|
5743
5746
|
], plugins: [
|
|
5744
5747
|
new LeftToolbarPlugin(),
|
|
5745
5748
|
new ToolbarPlugin(),
|
|
5746
|
-
],
|
|
5749
|
+
], setup(textbus) {
|
|
5750
|
+
if (editorConfig.collaborateConfig) {
|
|
5751
|
+
const activity = textbus.get(UserActivity);
|
|
5752
|
+
const collabCursor = textbus.get(CollaborateCursor);
|
|
5753
|
+
const sub = activity.onStateChange.subscribe(ev => {
|
|
5754
|
+
collabCursor.draw(ev);
|
|
5755
|
+
});
|
|
5756
|
+
return () => {
|
|
5757
|
+
sub.unsubscribe();
|
|
5758
|
+
};
|
|
5759
|
+
}
|
|
5760
|
+
},
|
|
5761
|
+
onAfterStartup(textbus) {
|
|
5747
5762
|
registerBoldShortcut(textbus);
|
|
5748
5763
|
registerCodeShortcut(textbus);
|
|
5749
5764
|
registerItalicShortcut(textbus);
|
package/bundles/index.js
CHANGED
|
@@ -4569,6 +4569,9 @@ class AtComponent extends core$1.Component {
|
|
|
4569
4569
|
this.selectedIndex = core.createSignal(0);
|
|
4570
4570
|
}
|
|
4571
4571
|
getSlots() {
|
|
4572
|
+
if (this.state.userInfo) {
|
|
4573
|
+
return [];
|
|
4574
|
+
}
|
|
4572
4575
|
if (this.state.slot) {
|
|
4573
4576
|
return [this.state.slot];
|
|
4574
4577
|
}
|
|
@@ -5745,7 +5748,19 @@ class Editor extends core$1.Textbus {
|
|
|
5745
5748
|
], plugins: [
|
|
5746
5749
|
new LeftToolbarPlugin(),
|
|
5747
5750
|
new ToolbarPlugin(),
|
|
5748
|
-
],
|
|
5751
|
+
], setup(textbus) {
|
|
5752
|
+
if (editorConfig.collaborateConfig) {
|
|
5753
|
+
const activity = textbus.get(collaborate.UserActivity);
|
|
5754
|
+
const collabCursor = textbus.get(platformBrowser.CollaborateCursor);
|
|
5755
|
+
const sub = activity.onStateChange.subscribe(ev => {
|
|
5756
|
+
collabCursor.draw(ev);
|
|
5757
|
+
});
|
|
5758
|
+
return () => {
|
|
5759
|
+
sub.unsubscribe();
|
|
5760
|
+
};
|
|
5761
|
+
}
|
|
5762
|
+
},
|
|
5763
|
+
onAfterStartup(textbus) {
|
|
5749
5764
|
registerBoldShortcut(textbus);
|
|
5750
5765
|
registerCodeShortcut(textbus);
|
|
5751
5766
|
registerItalicShortcut(textbus);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@textbus/xnote",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
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",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@tanbo/color": "^0.1.1",
|
|
30
|
-
"@textbus/adapter-viewfly": "^4.0.
|
|
31
|
-
"@textbus/collaborate": "^4.0.
|
|
32
|
-
"@textbus/core": "^4.0.
|
|
33
|
-
"@textbus/platform-browser": "^4.0.
|
|
30
|
+
"@textbus/adapter-viewfly": "^4.0.2",
|
|
31
|
+
"@textbus/collaborate": "^4.0.2",
|
|
32
|
+
"@textbus/core": "^4.0.1",
|
|
33
|
+
"@textbus/platform-browser": "^4.0.2",
|
|
34
34
|
"@viewfly/core": "^1.0.0-alpha.22",
|
|
35
35
|
"@viewfly/hooks": "^1.0.0-alpha.22",
|
|
36
36
|
"@viewfly/platform-browser": "^1.0.0-alpha.22",
|