@textbus/xnote 0.3.3 → 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.
@@ -7527,7 +7527,9 @@ const TableComponentView = withAnnotation({
7527
7527
  rowMapping.set(row.row, Math.random());
7528
7528
  });
7529
7529
  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", children: jsxs("table", { class: [
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", style: {
7531
+ overflow: 'auto'
7532
+ }, children: jsxs("table", { class: [
7531
7533
  'xnote-table-content',
7532
7534
  {
7533
7535
  'hide-selection': props.component.tableSelection()
@@ -8135,7 +8137,9 @@ class Editor extends Textbus {
8135
8137
  this.guardReady();
8136
8138
  const newModel = this.createModel(content);
8137
8139
  const rootComponent = this.get(RootComponentRef).component;
8138
- Object.assign(rootComponent.state, newModel.state);
8140
+ const slot = newModel.state.content;
8141
+ newModel.state.content = null;
8142
+ rootComponent.state.content = slot;
8139
8143
  }
8140
8144
  getHTML() {
8141
8145
  return this.translator.transform(this.vDomAdapter.host);
package/bundles/index.js CHANGED
@@ -7529,7 +7529,9 @@ const TableComponentView = core.withAnnotation({
7529
7529
  rowMapping.set(row.row, Math.random());
7530
7530
  });
7531
7531
  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", children: jsxRuntime.jsxs("table", { class: [
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", style: {
7533
+ overflow: 'auto'
7534
+ }, children: jsxRuntime.jsxs("table", { class: [
7533
7535
  'xnote-table-content',
7534
7536
  {
7535
7537
  'hide-selection': props.component.tableSelection()
@@ -8137,7 +8139,9 @@ class Editor extends core$1.Textbus {
8137
8139
  this.guardReady();
8138
8140
  const newModel = this.createModel(content);
8139
8141
  const rootComponent = this.get(core$1.RootComponentRef).component;
8140
- Object.assign(rootComponent.state, newModel.state);
8142
+ const slot = newModel.state.content;
8143
+ newModel.state.content = null;
8144
+ rootComponent.state.content = slot;
8141
8145
  }
8142
8146
  getHTML() {
8143
8147
  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 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.3",
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.5",
31
- "@textbus/collaborate": "^4.3.5",
32
- "@textbus/core": "^4.3.5",
33
- "@textbus/platform-browser": "^4.3.5",
34
- "@viewfly/core": "^1.1.10",
35
- "@viewfly/hooks": "^1.1.10",
36
- "@viewfly/platform-browser": "^1.1.10",
37
- "@viewfly/scoped-css": "^1.1.10",
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"