@seafile/sdoc-editor 0.1.2 → 0.1.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.
Files changed (86) hide show
  1. package/dist/assets/css/textlink-hovermenu.css +51 -0
  2. package/dist/editor.js +13 -20
  3. package/dist/{slate-extension → extension}/constants/index.js +4 -0
  4. package/dist/{slate-extension → extension}/core/queries/index.js +44 -15
  5. package/dist/{slate-extension → extension}/core/transforms/focus-editor.js +2 -2
  6. package/dist/extension/core/transforms/index.js +3 -0
  7. package/dist/{slate-extension → extension}/core/transforms/move-children.js +1 -1
  8. package/dist/extension/core/transforms/remove-node-children.js +24 -0
  9. package/dist/{slate-extension → extension}/core/utils/index.js +10 -0
  10. package/dist/{slate-extension → extension}/index.js +2 -2
  11. package/dist/{slate-extension → extension}/plugins/blockquote/helpers.js +1 -1
  12. package/dist/{slate-extension → extension}/plugins/blockquote/menu/index.js +1 -2
  13. package/dist/{slate-extension → extension}/plugins/blockquote/plugin.js +5 -9
  14. package/dist/extension/plugins/blockquote/render-elem.js +10 -0
  15. package/dist/{slate-extension → extension}/plugins/check-list/helpers.js +1 -1
  16. package/dist/{slate-extension → extension}/plugins/check-list/plugin.js +1 -1
  17. package/dist/{slate-extension → extension}/plugins/check-list/render-elem.js +5 -3
  18. package/dist/{slate-extension → extension}/plugins/header/helpers.js +1 -1
  19. package/dist/{slate-extension → extension}/plugins/header/plugin.js +4 -7
  20. package/dist/{slate-extension → extension}/plugins/header/render-elem.js +3 -1
  21. package/dist/extension/plugins/index.js +9 -0
  22. package/dist/extension/plugins/link/helpers.js +152 -0
  23. package/dist/extension/plugins/link/index.js +14 -0
  24. package/dist/extension/plugins/link/menu/add-link-dialog.js +146 -0
  25. package/dist/extension/plugins/link/menu/hover-link-dialog.js +49 -0
  26. package/dist/extension/plugins/link/menu/index.js +67 -0
  27. package/dist/extension/plugins/link/model.js +13 -0
  28. package/dist/extension/plugins/link/plugin.js +60 -0
  29. package/dist/extension/plugins/link/render-elem.js +114 -0
  30. package/dist/{slate-extension → extension}/plugins/list/helpers.js +1 -1
  31. package/dist/{slate-extension → extension}/plugins/list/menu/index.js +1 -1
  32. package/dist/{slate-extension → extension}/plugins/list/plugin/normalize-list.js +1 -1
  33. package/dist/{slate-extension → extension}/plugins/list/plugin/on-tab-handle.js +1 -1
  34. package/dist/{slate-extension → extension}/plugins/list/queries/index.js +1 -1
  35. package/dist/{slate-extension → extension}/plugins/list/render-elem.js +11 -4
  36. package/dist/{slate-extension → extension}/plugins/list/transforms/insert-list-item.js +17 -22
  37. package/dist/{slate-extension → extension}/plugins/list/transforms/move-list-item-down.js +1 -1
  38. package/dist/{slate-extension → extension}/plugins/list/transforms/move-list-item-up.js +1 -1
  39. package/dist/{slate-extension → extension}/plugins/list/transforms/move-list-items-to-list.js +1 -1
  40. package/dist/{slate-extension → extension}/plugins/list/transforms/move-list-items.js +1 -1
  41. package/dist/{slate-extension → extension}/plugins/list/transforms/normalize-list-item.js +1 -1
  42. package/dist/{slate-extension → extension}/plugins/list/transforms/normalize-nested-list.js +1 -1
  43. package/dist/{slate-extension → extension}/plugins/list/transforms/toggle-list.js +1 -1
  44. package/dist/{slate-extension → extension}/plugins/list/transforms/unwrap-list.js +1 -1
  45. package/dist/{slate-extension → extension}/plugins/text-style/render-elem.js +3 -1
  46. package/dist/{slate-extension → extension}/render/render-element.js +14 -4
  47. package/dist/{slate-extension → extension}/toolbar/index.js +4 -1
  48. package/dist/node-id/constants.js +18 -0
  49. package/dist/node-id/helpers.js +80 -0
  50. package/dist/node-id/index.js +11 -0
  51. package/dist/socket/helpers.js +258 -0
  52. package/dist/socket/index.js +3 -0
  53. package/dist/socket/socket-client.js +138 -0
  54. package/dist/socket/socket-manager.js +180 -0
  55. package/dist/socket/with-socket-io.js +18 -0
  56. package/package.json +9 -6
  57. package/public/locales/en/seafile-editor.json +4 -1
  58. package/public/locales/zh-CN/seafile-editor.json +4 -1
  59. package/dist/slate-extension/core/transforms/index.js +0 -2
  60. package/dist/slate-extension/plugins/blockquote/render-elem.js +0 -7
  61. package/dist/slate-extension/plugins/index.js +0 -9
  62. package/dist/slate-extension/plugins/socket/index.js +0 -6
  63. package/dist/slate-extension/plugins/socket/plugin.js +0 -23
  64. package/dist/slate-extension/socket/socket-client.js +0 -94
  65. package/dist/slate-extension/socket/socket-manager.js +0 -63
  66. /package/dist/{slate-extension → extension}/core/index.js +0 -0
  67. /package/dist/{slate-extension → extension}/menu/index.js +0 -0
  68. /package/dist/{slate-extension → extension}/menu/menu-group.js +0 -0
  69. /package/dist/{slate-extension → extension}/menu/menu-item.js +0 -0
  70. /package/dist/{slate-extension → extension}/menu/menu.css +0 -0
  71. /package/dist/{slate-extension → extension}/plugins/blockquote/index.js +0 -0
  72. /package/dist/{slate-extension → extension}/plugins/blockquote/model.js +0 -0
  73. /package/dist/{slate-extension → extension}/plugins/check-list/index.js +0 -0
  74. /package/dist/{slate-extension → extension}/plugins/check-list/menu/index.js +0 -0
  75. /package/dist/{slate-extension → extension}/plugins/check-list/model.js +0 -0
  76. /package/dist/{slate-extension → extension}/plugins/header/index.js +0 -0
  77. /package/dist/{slate-extension → extension}/plugins/header/menu/index.js +0 -0
  78. /package/dist/{slate-extension → extension}/plugins/list/index.js +0 -0
  79. /package/dist/{slate-extension → extension}/plugins/list/model.js +0 -0
  80. /package/dist/{slate-extension → extension}/plugins/list/plugin/index.js +0 -0
  81. /package/dist/{slate-extension → extension}/plugins/list/plugin/insert-break-list.js +0 -0
  82. /package/dist/{slate-extension → extension}/plugins/list/transforms/index.js +0 -0
  83. /package/dist/{slate-extension → extension}/plugins/list/transforms/remove-first-list-item.js +0 -0
  84. /package/dist/{slate-extension → extension}/plugins/text-style/index.js +0 -0
  85. /package/dist/{slate-extension → extension}/plugins/text-style/model.js +0 -0
  86. /package/dist/{slate-extension → extension}/render/render-leaf.js +0 -0
@@ -0,0 +1,180 @@
1
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import Debug from 'debug';
4
+ import EventBus from '../utils/event-bus';
5
+ import { syncRemoteOperations, reExecRevertOperationList, revertOperationList } from './helpers';
6
+ import SocketClient from './socket-client';
7
+ var debug = Debug('sdoc:socket-client');
8
+ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, document, config) {
9
+ var _this = this;
10
+ _classCallCheck(this, SocketManager);
11
+ this.addOperations = function (operations) {
12
+ _this.pendingOperationList.push(operations);
13
+ _this.sendOperations();
14
+ };
15
+ this.getDocumentVersion = function () {
16
+ var version = _this.document.version;
17
+ return version;
18
+ };
19
+ this.sendOperations = function () {
20
+ if (_this.isSending || _this.pendingOperationList.length === 0) return;
21
+ _this.isSending = true;
22
+ _this.sendNextOperations();
23
+ };
24
+ this.sendNextOperations = function () {
25
+ if (_this.pendingOperationList.length === 0) {
26
+ _this.isSending = false;
27
+ return;
28
+ }
29
+ var version = _this.document.version;
30
+ var operations = _this.pendingOperationList.shift();
31
+ _this.socketClient.sendOperations(operations, version, _this.sendOperationsCallback);
32
+ };
33
+ this.sendOperationsCallback = function (result) {
34
+ if (result && result.success) {
35
+ var serverVersion = result.version;
36
+ _this.document['version'] = serverVersion;
37
+ _this.sendNextOperations();
38
+ return;
39
+ }
40
+
41
+ // Operations are execute failure
42
+ var operations = result.operations;
43
+ // Put the failed operation into the pending list and re-execute it
44
+ _this.pendingOperationList.unshift(operations);
45
+ _this.sendNextOperations();
46
+ };
47
+ this.receiveOperations = function (params) {
48
+ _this.remoteOperationsList.push(params);
49
+ // sort operations by version
50
+ if (_this.remoteOperationsList.length > 1) {
51
+ _this.remoteOperationsList = _this.remoteOperationsList.sort(function (prev, next) {
52
+ return prev.version - next.version;
53
+ });
54
+ }
55
+ if (_this.isExecRemoteOperations) return;
56
+ _this.isExecRemoteOperations = true;
57
+ _this.editor.isRemote = true;
58
+ _this.execRemoteOperations();
59
+
60
+ // reset control flag
61
+ Promise.resolve().then(function (_) {
62
+ _this.isExecRemoteOperations = false;
63
+ _this.editor.isRemote = false;
64
+ });
65
+ };
66
+ this.execRemoteOperations = function () {
67
+ if (_this.remoteOperationsList.length > 0) {
68
+ var params = _this.remoteOperationsList.shift();
69
+ var serverVersion = params.version;
70
+ var clientVersion = _this.document.version;
71
+ if (serverVersion === clientVersion + 1) {
72
+ // When performing remote operations, the revert operation is only required for the first time
73
+ if (_this.revertOperationList.length === 0) {
74
+ // 1. Revert operations
75
+ // 1.1 record reverted operationList & clear pendingOperationList
76
+ _this.revertOperationList = _this.pendingOperationList.slice();
77
+ _this.pendingOperationList = [];
78
+
79
+ // 1.2 Revert operationList
80
+ debug('revert locale operations: %O', _this.revertOperationList);
81
+ revertOperationList(_this.editor, _this.revertOperationList);
82
+ }
83
+
84
+ // 2. execute operations
85
+ var operations = params.operations;
86
+ // 2.1 Update content & version
87
+ debug('execute remote operations: %O', operations);
88
+ syncRemoteOperations(_this.editor, operations);
89
+
90
+ // 2.2 Update document
91
+ _this.document.version = serverVersion;
92
+ _this.document.children = _this.editor.children;
93
+
94
+ // Execute next operations
95
+ if (_this.remoteOperationsList.length > 0) {
96
+ _this.execRemoteOperations();
97
+ return;
98
+ }
99
+
100
+ // Re-execute undone operations after isRemote is set to false
101
+ // Need resend this operations to server
102
+ Promise.resolve().then(function (_) {
103
+ debug('Editor isRemote is false: %s', _this.editor.isRemote);
104
+ debug('Re-execute pending operations, %O', _this.revertOperationList);
105
+
106
+ // 3. Execute pending operations
107
+ // 3.1 Re-execute operations
108
+ reExecRevertOperationList(_this.editor, _this.revertOperationList);
109
+
110
+ // 3.2 Clear revert operationList
111
+ _this.revertOperationList = [];
112
+ });
113
+ } else {
114
+ // conflict:
115
+ // remote operations is not empty, waiting until remote operations all executed
116
+ debug('remote operations is not empty, and local version is not match remote version.');
117
+ }
118
+ }
119
+ };
120
+ this.syncDocumentBySocket = function (result) {
121
+ var mode = result.mode,
122
+ content = result.content;
123
+ // sync document
124
+ if (mode === 'document') {
125
+ var version = content.version,
126
+ children = content.children;
127
+ // 1. update document
128
+ _this.document.children = children;
129
+ _this.document.version = version;
130
+ _this.editor.children = children;
131
+ _this.editor.isRemote = true;
132
+ _this.editor.onChange();
133
+ _this.editor.isRemote = false;
134
+
135
+ // 2. exec client operationList
136
+ var pendingOperationList = _this.pendingOperationList.slice();
137
+ _this.pendingOperationList = [];
138
+
139
+ // need resend this operations to server
140
+ debug('Editor isRemote is false: %s', _this.editor.isRemote);
141
+ reExecRevertOperationList(_this.editor, pendingOperationList);
142
+ return;
143
+ }
144
+
145
+ // sync operations
146
+ // content is [{version, operations}, {version, operations}, ...]
147
+ _this.remoteOperationsList = content;
148
+ _this.isExecRemoteOperations = true;
149
+ _this.editor.isRemote = true;
150
+ _this.execRemoteOperations();
151
+
152
+ // reset control flag
153
+ Promise.resolve().then(function (_) {
154
+ _this.isExecRemoteOperations = false;
155
+ _this.editor.isRemote = false;
156
+ });
157
+ };
158
+ this.dispatchConnectState = function (type, message) {
159
+ console.log(type);
160
+ };
161
+ this.editor = editor;
162
+ this.document = document;
163
+ this.socketClient = new SocketClient(config);
164
+ this.isSending = false;
165
+ this.pendingOperationList = []; // Two-dimensional arrays: [operations, operations, ...]
166
+ this.remoteOperationsList = []; // Same with pending operations
167
+ this.revertOperationList = [];
168
+ this.eventBus = new EventBus();
169
+ });
170
+ SocketManager.getInstance = function (editor, document, socketConfig) {
171
+ if (SocketManager.instance) {
172
+ return SocketManager.instance;
173
+ }
174
+ if (!document || !socketConfig) {
175
+ throw new Error('SocketManager init params is invalid. Place check your code to fix it.');
176
+ }
177
+ SocketManager.instance = new SocketManager(editor, document, socketConfig);
178
+ return SocketManager.instance;
179
+ };
180
+ export default SocketManager;
@@ -0,0 +1,18 @@
1
+ import SocketManager from './socket-manager';
2
+ var withSocketIO = function withSocketIO(editor, options) {
3
+ var onChange = editor.onChange;
4
+ var newEditor = editor;
5
+ newEditor.onChange = function () {
6
+ var operations = newEditor.operations;
7
+ operations = operations.filter(function (item) {
8
+ return item.type !== 'set_selection';
9
+ });
10
+ if (!newEditor.isRemote && operations.length > 0) {
11
+ var socketManager = SocketManager.getInstance();
12
+ socketManager.addOperations && socketManager.addOperations(operations);
13
+ }
14
+ onChange();
15
+ };
16
+ return newEditor;
17
+ };
18
+ export default withSocketIO;
package/package.json CHANGED
@@ -1,19 +1,22 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
7
7
  "dependencies": {
8
8
  "@seafile/react-image-lightbox": "2.0.2",
9
+ "@seafile/slate": "0.91.8",
10
+ "@seafile/slate-hyperscript": "0.81.7",
11
+ "@seafile/slate-react": "0.92.2",
12
+ "deep-copy": "1.4.2",
9
13
  "is-hotkey": "0.2.0",
14
+ "is-url": "^1.2.4",
10
15
  "react-cookies": "0.1.1",
11
16
  "reactstrap": "8.9.0",
12
- "slate": "0.91.4",
13
- "slate-history": "0.86.0",
14
- "slate-hyperscript": "0.77.0",
15
- "slate-react": "0.92.0",
16
- "socket.io-client": "4.6.1"
17
+ "slugid": "3.2.0",
18
+ "socket.io-client": "4.6.1",
19
+ "uuid": "9.0.0"
17
20
  },
18
21
  "scripts": {
19
22
  "clean": "rm -rf dist && mkdir dist",
@@ -222,5 +222,8 @@
222
222
  },
223
223
  "Select_field": "Select field",
224
224
  "Font_style": "Font style",
225
- "Insert_column": "Insert column"
225
+ "Insert_column": "Insert column",
226
+ "The_link_address_is_required": "The link address is required.",
227
+ "The_link_title_is_required": "The link title is required.",
228
+ "The_link_address_is_invalid": "The link address is invalid, please enter a correct connection address."
226
229
  }
@@ -218,5 +218,8 @@
218
218
  }
219
219
  }
220
220
  ]
221
- }
221
+ },
222
+ "The_link_address_is_required": "链接地址是必填项。",
223
+ "The_link_title_is_required": "链接标题是必填项。",
224
+ "The_link_address_is_invalid": "链接地址不合法,请输入一个正确的连接地址。"
222
225
  }
@@ -1,2 +0,0 @@
1
- export * from './move-children';
2
- export * from './focus-editor';
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- var renderBlockquote = function renderBlockquote(props, editor) {
3
- var attributes = props.attributes,
4
- children = props.children;
5
- return /*#__PURE__*/React.createElement("blockquote", attributes, children);
6
- };
7
- export default renderBlockquote;
@@ -1,9 +0,0 @@
1
- import HeaderPlugin from './header';
2
- import BlockquotePlugin from './blockquote';
3
- import ListPlugin from './list';
4
- import CheckListPlugin from './check-list';
5
- import TextPlugin from './text-style';
6
- import SocketPlugin from './socket';
7
- var Plugins = [HeaderPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, TextPlugin, SocketPlugin];
8
- export default Plugins;
9
- export { HeaderPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, TextPlugin, SocketPlugin };
@@ -1,6 +0,0 @@
1
- import withSocket from './plugin';
2
- var SocketPlugin = {
3
- type: 'socket',
4
- editorPlugin: withSocket
5
- };
6
- export default SocketPlugin;
@@ -1,23 +0,0 @@
1
- import SocketManager from "../../socket/socket-manager";
2
- var withSocket = function withSocket(editor) {
3
- var apply = editor.apply;
4
- var newEditor = editor;
5
- newEditor.apply = function (operation) {
6
- var isRemote = operation.is_remote;
7
- if (isRemote) {
8
- apply(operation);
9
- return;
10
- }
11
-
12
- // 合并 op
13
- try {
14
- var socketManager = SocketManager.getInstance();
15
- socketManager.addOperation && socketManager.addOperation(operation);
16
- } catch (err) {
17
- // first load, socketManager has not been init
18
- }
19
- apply(operation);
20
- };
21
- return newEditor;
22
- };
23
- export default withSocket;
@@ -1,94 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
- import io from 'socket.io-client';
5
- import Debug from 'debug';
6
- import SocketManager from './socket-manager';
7
- var debug = Debug('sdoc:socket-client');
8
- var SocketClient = /*#__PURE__*/_createClass(function SocketClient(config) {
9
- var _this = this;
10
- _classCallCheck(this, SocketClient);
11
- this.getParams = function () {
12
- var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
13
- return _objectSpread({}, params);
14
- };
15
- this.onConnected = function () {
16
- var socketManager = SocketManager.getInstance();
17
- var _this$config = _this.config,
18
- fileUuid = _this$config.fileUuid,
19
- filePath = _this$config.filePath,
20
- fileName = _this$config.fileName,
21
- accessToken = _this$config.accessToken;
22
- var params = {
23
- file_uuid: fileUuid,
24
- file_path: filePath,
25
- file_name: fileName,
26
- access_token: accessToken
27
- };
28
- _this.socket.emit('join-room', params, function (result) {
29
- if (result.status) {
30
- socketManager.dispatchConnectState('connect', result);
31
- return;
32
- }
33
-
34
- // Disconnect the server in the client side. There will be no reconnection.
35
- _this.socket.disconnect();
36
- socketManager.dispatchConnectState('connect-error', result);
37
- });
38
- };
39
- this.onReconnect = function (data) {
40
- debug('reconnect.');
41
- var socketManager = SocketManager.getInstance();
42
- socketManager.dispatchConnectState('reconnect');
43
- };
44
- this.onReconnecting = function (attemptNumber) {
45
- debug('reconnecting.', attemptNumber);
46
- var socketManager = SocketManager.getInstance();
47
- socketManager.dispatchConnectState('reconnecting', attemptNumber);
48
- };
49
- this.onDisconnected = function (data) {
50
- debug('disconnect message: %s', data);
51
- var socketManager = SocketManager.getInstance();
52
- socketManager.dispatchConnectState('disconnect');
53
- };
54
- this.onJoinRoom = function (username) {
55
- debug('%s joined room success.', username);
56
- var socketManager = SocketManager.getInstance();
57
- socketManager.dispatchConnectState('join-room', username);
58
- };
59
- this.onLeaveRoom = function (username) {
60
- debug('%s leaved room success.', username);
61
- var socketManager = SocketManager.getInstance();
62
- socketManager.dispatchConnectState('leave-room', username);
63
- };
64
- this.sendOperation = function (operation, callback) {
65
- debug('==================================');
66
- debug('send operation: %s' + operation.toString());
67
- debug('==================================');
68
- _this.socket.emit('update-document', _this.getParams({
69
- operation: operation
70
- }), function (result) {
71
- callback && callback(result);
72
- });
73
- };
74
- this.receiveOperation = function (operation, version) {
75
- debug('==================================');
76
- debug('received operation: %s' + operation.toString());
77
- debug('==================================');
78
- var socketManager = SocketManager.getInstance();
79
- socketManager.receiveOperation(operation, version);
80
- };
81
- this.disconnectWithServer = function () {
82
- _this.socket.disconnect();
83
- };
84
- this.config = config;
85
- this.socket = io(config.sdocServer);
86
- this.socket.on('connect', this.onConnected);
87
- this.socket.on('reconnect', this.onReconnect);
88
- this.socket.on('reconnecting', this.onReconnecting);
89
- this.socket.on('disconnect', this.onDisconnected);
90
- this.socket.on('join-room', this.onJoinRoom);
91
- this.socket.on('leave-room', this.onLeaveRoom);
92
- this.socket.on('update-document', this.receiveOperation);
93
- });
94
- export default SocketClient;
@@ -1,63 +0,0 @@
1
- import _createClass from "@babel/runtime/helpers/esm/createClass";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import EventBus from '../../utils/event-bus';
4
- import SocketClient from './socket-client';
5
- var SocketManager = /*#__PURE__*/_createClass(function SocketManager(document, config) {
6
- var _this = this;
7
- _classCallCheck(this, SocketManager);
8
- this.addOperation = function (operation) {
9
- _this.pendingOperations.push(operation);
10
- _this.sendOperation();
11
- };
12
- this.sendOperation = function () {
13
- if (_this.isSendingOperation || _this.pendingOperations.length === 0) return;
14
- _this.isSendingOperation = true;
15
- _this.sendNextOperation();
16
- };
17
- this.sendNextOperation = function () {
18
- if (_this.pendingOperations.length === 0) {
19
- _this.isSendingOperation = false;
20
- return;
21
- }
22
- var operation = _this.pendingOperations.shift();
23
- _this.sendingOperation = operation;
24
- _this.socketClient.sendOperation(operation, _this.sendOperationCallback);
25
- };
26
- this.sendOperationCallback = function (result) {
27
- if (result && result.success) {
28
- _this.sendingOperation = null;
29
- var remoteVersion = result.version;
30
- var localeVersion = _this.doc.version;
31
- _this.doc['version'] = remoteVersion > localeVersion ? remoteVersion : localeVersion;
32
- _this.sendNextOperation();
33
- return;
34
- }
35
-
36
- // operation is execute failure
37
- _this.sendingOperation = null;
38
- _this.sendNextOperation();
39
- };
40
- this.receiveOperation = function (params, last_version) {
41
- _this.eventBus.dispatch('receive-operation', params);
42
- };
43
- this.dispatchConnectState = function (type, message) {
44
- console.log(type);
45
- };
46
- this.doc = document;
47
- this.socketClient = new SocketClient(config);
48
- this.sendingOperation = null;
49
- this.pendingOperations = [];
50
- this.isSendingOperation = false;
51
- this.eventBus = new EventBus();
52
- });
53
- SocketManager.getInstance = function (document, socketConfig) {
54
- if (SocketManager.instance) {
55
- return SocketManager.instance;
56
- }
57
- if (!document || !socketConfig) {
58
- throw new Error('SocketManager init params is invalid. Place check your code to fix it.');
59
- }
60
- SocketManager.instance = new SocketManager(document, socketConfig);
61
- return SocketManager.instance;
62
- };
63
- export default SocketManager;