@textbus/xnote 0.3.2 → 0.3.4

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.
@@ -1,7 +1,7 @@
1
1
  import { Slot } from '@textbus/core';
2
2
  import { DynamicRef } from '@viewfly/core';
3
3
  import { HTMLAttributes } from '@viewfly/platform-browser';
4
- interface Props extends HTMLAttributes<unknown> {
4
+ export interface SlotRenderProps extends HTMLAttributes<unknown> {
5
5
  slot: Slot;
6
6
  /** 默认值为 div */
7
7
  tag?: string;
@@ -10,5 +10,4 @@ interface Props extends HTMLAttributes<unknown> {
10
10
  elRef?: DynamicRef<HTMLElement>;
11
11
  elKey?: number | string;
12
12
  }
13
- export declare function SlotRender(props: Props): () => any;
14
- export {};
13
+ export declare function SlotRender(props: SlotRenderProps): () => any;
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 App() {
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
- console.log(op)
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
- }}>获取 HTML</button>
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</button>
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.2",
3
+ "version": "0.3.4",
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.3.3",
31
- "@textbus/collaborate": "^4.3.3",
32
- "@textbus/core": "^4.3.3",
33
- "@textbus/platform-browser": "^4.3.3",
34
- "@viewfly/core": "^1.1.2",
35
- "@viewfly/hooks": "^1.1.2",
36
- "@viewfly/platform-browser": "^1.1.5",
37
- "@viewfly/scoped-css": "^1.1.2",
30
+ "@textbus/adapter-viewfly": "^4.4.2",
31
+ "@textbus/collaborate": "^4.4.2",
32
+ "@textbus/core": "^4.4.2",
33
+ "@textbus/platform-browser": "^4.4.2",
34
+ "@viewfly/core": "^1.2.2",
35
+ "@viewfly/hooks": "^1.2.2",
36
+ "@viewfly/platform-browser": "^1.2.2",
37
+ "@viewfly/scoped-css": "^1.2.2",
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.1.4",
50
+ "@viewfly/devtools": "^1.1.10",
51
51
  "autoprefixer": "^10.4.0",
52
52
  "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
53
53
  "core-js": "^3.20.1",