@textbus/xnote 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/index.esm.js +8 -3
- package/bundles/index.js +8 -3
- package/index.tsx +64 -36
- package/package.json +9 -9
package/bundles/index.esm.js
CHANGED
|
@@ -2286,7 +2286,8 @@ function SourceCodeView(props) {
|
|
|
2286
2286
|
}
|
|
2287
2287
|
}
|
|
2288
2288
|
return createVNode('div', {
|
|
2289
|
-
class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : '')
|
|
2289
|
+
class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : ''),
|
|
2290
|
+
key: item.slot.id
|
|
2290
2291
|
}, [
|
|
2291
2292
|
createVNode('span', { class: 'xnote-source-code-line-content' }, children)
|
|
2292
2293
|
]);
|
|
@@ -7527,7 +7528,9 @@ const TableComponentView = withAnnotation({
|
|
|
7527
7528
|
rowMapping.set(row.row, Math.random());
|
|
7528
7529
|
});
|
|
7529
7530
|
if (readonly() || output()) {
|
|
7530
|
-
return (jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": `[${state.columnsConfig.join(',')}]`, children: jsx("div", { class: "xnote-table-inner", ref: props.rootRef, children: jsx("div", { class: "xnote-table-container",
|
|
7531
|
+
return (jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": `[${state.columnsConfig.join(',')}]`, children: jsx("div", { class: "xnote-table-inner", ref: props.rootRef, children: jsx("div", { class: "xnote-table-container", style: {
|
|
7532
|
+
overflow: 'auto'
|
|
7533
|
+
}, children: jsxs("table", { class: [
|
|
7531
7534
|
'xnote-table-content',
|
|
7532
7535
|
{
|
|
7533
7536
|
'hide-selection': props.component.tableSelection()
|
|
@@ -8135,7 +8138,9 @@ class Editor extends Textbus {
|
|
|
8135
8138
|
this.guardReady();
|
|
8136
8139
|
const newModel = this.createModel(content);
|
|
8137
8140
|
const rootComponent = this.get(RootComponentRef).component;
|
|
8138
|
-
|
|
8141
|
+
const slot = newModel.state.content;
|
|
8142
|
+
newModel.state.content = null;
|
|
8143
|
+
rootComponent.state.content = slot;
|
|
8139
8144
|
}
|
|
8140
8145
|
getHTML() {
|
|
8141
8146
|
return this.translator.transform(this.vDomAdapter.host);
|
package/bundles/index.js
CHANGED
|
@@ -2288,7 +2288,8 @@ function SourceCodeView(props) {
|
|
|
2288
2288
|
}
|
|
2289
2289
|
}
|
|
2290
2290
|
return core$1.createVNode('div', {
|
|
2291
|
-
class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : '')
|
|
2291
|
+
class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : ''),
|
|
2292
|
+
key: item.slot.id
|
|
2292
2293
|
}, [
|
|
2293
2294
|
core$1.createVNode('span', { class: 'xnote-source-code-line-content' }, children)
|
|
2294
2295
|
]);
|
|
@@ -7529,7 +7530,9 @@ const TableComponentView = core.withAnnotation({
|
|
|
7529
7530
|
rowMapping.set(row.row, Math.random());
|
|
7530
7531
|
});
|
|
7531
7532
|
if (readonly() || output()) {
|
|
7532
|
-
return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": `[${state.columnsConfig.join(',')}]`, children: jsxRuntime.jsx("div", { class: "xnote-table-inner", ref: props.rootRef, children: jsxRuntime.jsx("div", { class: "xnote-table-container",
|
|
7533
|
+
return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": `[${state.columnsConfig.join(',')}]`, children: jsxRuntime.jsx("div", { class: "xnote-table-inner", ref: props.rootRef, children: jsxRuntime.jsx("div", { class: "xnote-table-container", style: {
|
|
7534
|
+
overflow: 'auto'
|
|
7535
|
+
}, children: jsxRuntime.jsxs("table", { class: [
|
|
7533
7536
|
'xnote-table-content',
|
|
7534
7537
|
{
|
|
7535
7538
|
'hide-selection': props.component.tableSelection()
|
|
@@ -8137,7 +8140,9 @@ class Editor extends core$1.Textbus {
|
|
|
8137
8140
|
this.guardReady();
|
|
8138
8141
|
const newModel = this.createModel(content);
|
|
8139
8142
|
const rootComponent = this.get(core$1.RootComponentRef).component;
|
|
8140
|
-
|
|
8143
|
+
const slot = newModel.state.content;
|
|
8144
|
+
newModel.state.content = null;
|
|
8145
|
+
rootComponent.state.content = slot;
|
|
8141
8146
|
}
|
|
8142
8147
|
getHTML() {
|
|
8143
8148
|
return this.translator.transform(this.vDomAdapter.host);
|
package/index.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import { FileUploader } from './src/interfaces'
|
|
|
6
6
|
import { UserInfo } from './src/xnote-message-bus'
|
|
7
7
|
import { StaticToolbarPlugin, SuspensionToolbarPlugin } from '@textbus/xnote'
|
|
8
8
|
import { VIEW_CONTAINER } from '@textbus/platform-browser'
|
|
9
|
-
import { createRef, onMounted } from '@viewfly/core'
|
|
9
|
+
import { createRef, createSignal, onMounted } from '@viewfly/core'
|
|
10
10
|
import { createApp } from '@viewfly/platform-browser'
|
|
11
11
|
import { RootComponentRef } from '@textbus/core'
|
|
12
12
|
|
|
@@ -83,47 +83,52 @@ class Http extends Organization {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
const editor = new Editor({
|
|
87
|
-
readonly: false,
|
|
88
|
-
// content: document.getElementById('article')!.innerHTML,
|
|
89
|
-
collaborateConfig: {
|
|
90
|
-
userinfo: user,
|
|
91
|
-
createConnector(yDoc): SyncConnector {
|
|
92
|
-
return new YWebsocketConnector('ws://localhost:1234', 'xnote', yDoc)
|
|
93
|
-
// return new YWebsocketConnector('wss://textbus.io/api', 'xnote', yDoc)
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
// plugins: [
|
|
97
|
-
// new SuspensionToolbarPlugin()
|
|
98
|
-
// ],
|
|
99
|
-
providers: [
|
|
100
|
-
{
|
|
101
|
-
provide: Organization,
|
|
102
|
-
useValue: new Http()
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
provide: FileUploader,
|
|
106
|
-
useValue: {
|
|
107
|
-
uploadFile(type: string) {
|
|
108
|
-
console.log(type)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
})
|
|
114
86
|
|
|
115
|
-
function
|
|
87
|
+
function EditorContainer() {
|
|
116
88
|
const editorRef = createRef<HTMLElement>()
|
|
117
89
|
const htmlRef = createRef<HTMLTextAreaElement>()
|
|
118
90
|
|
|
91
|
+
const editor = new Editor({
|
|
92
|
+
readonly: false,
|
|
93
|
+
// content: document.getElementById('article')!.innerHTML,
|
|
94
|
+
collaborateConfig: {
|
|
95
|
+
userinfo: user,
|
|
96
|
+
createConnector(yDoc): SyncConnector {
|
|
97
|
+
return new YWebsocketConnector('ws://localhost:1234', 'xnote', yDoc)
|
|
98
|
+
// return new YWebsocketConnector('wss://textbus.io/api', 'xnote', yDoc)
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
// plugins: [
|
|
102
|
+
// new SuspensionToolbarPlugin()
|
|
103
|
+
// ],
|
|
104
|
+
providers: [
|
|
105
|
+
{
|
|
106
|
+
provide: Organization,
|
|
107
|
+
useValue: new Http()
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
provide: FileUploader,
|
|
111
|
+
useValue: {
|
|
112
|
+
uploadFile(type: string) {
|
|
113
|
+
console.log(type)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
})
|
|
119
119
|
onMounted(() => {
|
|
120
120
|
editor.mount(editorRef.current!).then(() => {
|
|
121
|
-
const root = editor.get(RootComponentRef).component
|
|
122
|
-
root.changeMarker.onChange.subscribe(op => {
|
|
123
|
-
|
|
124
|
-
})
|
|
121
|
+
// const root = editor.get(RootComponentRef).component
|
|
122
|
+
// root.changeMarker.onChange.subscribe(op => {
|
|
123
|
+
// console.log(op)
|
|
124
|
+
// })
|
|
125
125
|
})
|
|
126
|
+
|
|
127
|
+
return () => {
|
|
128
|
+
editor.destroy()
|
|
129
|
+
}
|
|
126
130
|
})
|
|
131
|
+
const contentRef = createRef<HTMLDivElement>()
|
|
127
132
|
return () => {
|
|
128
133
|
return (
|
|
129
134
|
<div>
|
|
@@ -134,14 +139,37 @@ function App() {
|
|
|
134
139
|
<button type="button" onClick={() => {
|
|
135
140
|
const html = editor.getHTML()
|
|
136
141
|
htmlRef.current!.value = html
|
|
137
|
-
|
|
142
|
+
contentRef.current!.innerHTML = html
|
|
143
|
+
}}>获取 HTML
|
|
144
|
+
</button>
|
|
138
145
|
<textarea name="" id="" ref={htmlRef} cols="30" rows="10"></textarea>
|
|
139
146
|
<button type="button" onClick={() => {
|
|
140
147
|
const html = htmlRef.current!.value
|
|
141
148
|
editor.setContent(html)
|
|
142
|
-
}}>设置 HTML
|
|
149
|
+
}}>设置 HTML
|
|
150
|
+
</button>
|
|
143
151
|
</div>
|
|
144
152
|
<div ref={editorRef}></div>
|
|
153
|
+
<div ref={contentRef}></div>
|
|
154
|
+
</div>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function App() {
|
|
160
|
+
const is = createSignal(true)
|
|
161
|
+
return () => {
|
|
162
|
+
return (
|
|
163
|
+
<div>
|
|
164
|
+
<div>
|
|
165
|
+
<button onClick={() => {
|
|
166
|
+
is.set(!is())
|
|
167
|
+
}}>switch
|
|
168
|
+
</button>
|
|
169
|
+
</div>
|
|
170
|
+
{
|
|
171
|
+
is() ? <EditorContainer/> : null
|
|
172
|
+
}
|
|
145
173
|
</div>
|
|
146
174
|
)
|
|
147
175
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@textbus/xnote",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
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,14 +27,14 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@tanbo/color": "^0.1.1",
|
|
30
|
-
"@textbus/adapter-viewfly": "^4.
|
|
31
|
-
"@textbus/collaborate": "^4.
|
|
32
|
-
"@textbus/core": "^4.
|
|
33
|
-
"@textbus/platform-browser": "^4.
|
|
34
|
-
"@viewfly/core": "^1.
|
|
35
|
-
"@viewfly/hooks": "^1.
|
|
36
|
-
"@viewfly/platform-browser": "^1.
|
|
37
|
-
"@viewfly/scoped-css": "^1.
|
|
30
|
+
"@textbus/adapter-viewfly": "^4.5.0",
|
|
31
|
+
"@textbus/collaborate": "^4.5.1",
|
|
32
|
+
"@textbus/core": "^4.5.0",
|
|
33
|
+
"@textbus/platform-browser": "^4.5.0",
|
|
34
|
+
"@viewfly/core": "^1.2.3",
|
|
35
|
+
"@viewfly/hooks": "^1.2.3",
|
|
36
|
+
"@viewfly/platform-browser": "^1.2.3",
|
|
37
|
+
"@viewfly/scoped-css": "^1.2.3",
|
|
38
38
|
"highlight.js": "^11.9.0",
|
|
39
39
|
"katex": "^0.16.10",
|
|
40
40
|
"uuid": "^10.0.0"
|