@seafile/sdoc-editor 0.1.80 → 0.1.82

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 (45) hide show
  1. package/dist/api/seafile-api.js +6 -0
  2. package/dist/basic-sdk/assets/css/dropdown-menu.css +23 -0
  3. package/dist/basic-sdk/assets/css/sdoc-editor-plugins.css +2 -0
  4. package/dist/basic-sdk/comment/comment-item.js +1 -3
  5. package/dist/basic-sdk/comment/style.css +13 -6
  6. package/dist/basic-sdk/editor.js +5 -2
  7. package/dist/basic-sdk/extension/constants/index.js +2 -0
  8. package/dist/basic-sdk/extension/core/queries/index.js +15 -3
  9. package/dist/basic-sdk/extension/plugins/blockquote/helpers.js +28 -8
  10. package/dist/basic-sdk/extension/plugins/blockquote/menu/index.js +2 -3
  11. package/dist/basic-sdk/extension/plugins/check-list/plugin.js +18 -8
  12. package/dist/basic-sdk/extension/plugins/header/menu/index.js +24 -12
  13. package/dist/basic-sdk/extension/plugins/header/menu/style.css +0 -17
  14. package/dist/basic-sdk/extension/plugins/header/plugin.js +20 -4
  15. package/dist/basic-sdk/extension/plugins/image/helpers.js +1 -5
  16. package/dist/basic-sdk/extension/plugins/image/render-elem.js +1 -1
  17. package/dist/basic-sdk/extension/plugins/table/helpers.js +11 -0
  18. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/common-menu.js +1 -4
  19. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.css +0 -4
  20. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +14 -14
  21. package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/row-header.js +13 -0
  22. package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +17 -5
  23. package/dist/basic-sdk/extension/plugins/text-align/menu/style.css +0 -12
  24. package/dist/basic-sdk/socket/socket-manager.js +3 -0
  25. package/dist/basic-sdk/socket/with-socket-io.js +2 -2
  26. package/dist/basic-sdk/views/viewer.js +1 -0
  27. package/dist/components/doc-info/index.js +9 -4
  28. package/dist/components/doc-operations/index.js +10 -3
  29. package/dist/components/doc-operations/revision-operations/index.js +16 -0
  30. package/dist/components/doc-operations/revision-operations/more-revision-operations/index.css +58 -0
  31. package/dist/components/doc-operations/revision-operations/more-revision-operations/index.js +56 -0
  32. package/dist/components/doc-operations/revision-operations/publish-button.js +28 -0
  33. package/dist/components/doc-operations/{revision-operations.js → revision-operations/revision-operations.js} +3 -3
  34. package/dist/components/doc-operations/revision-operations/view-changes/index.css +3 -0
  35. package/dist/components/doc-operations/revision-operations/view-changes/index.js +26 -0
  36. package/dist/components/switch/index.css +14 -0
  37. package/dist/components/switch/index.js +28 -0
  38. package/dist/components/tip-message/index.js +4 -1
  39. package/dist/context.js +6 -0
  40. package/dist/pages/simple-editor.js +132 -116
  41. package/dist/pages/simple-viewer.js +5 -3
  42. package/package.json +1 -1
  43. package/public/locales/en/sdoc-editor.json +3 -1
  44. package/public/locales/zh-CN/sdoc-editor.json +4 -2
  45. package/public/media/sdoc-editor-font.css +6 -6
@@ -1,10 +1,6 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
7
- import React from 'react';
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useCallback, useEffect, useState } from 'react';
3
+ import { withTranslation } from 'react-i18next';
8
4
  import { SDocEditor } from '../basic-sdk';
9
5
  import Loading from '../components/loading';
10
6
  import DocInfo from '../components/doc-info';
@@ -12,116 +8,136 @@ import DocOperations from '../components/doc-operations';
12
8
  import Layout, { Header, Content } from '../layout';
13
9
  import { generateDefaultDocContent } from '../utils';
14
10
  import context from '../context';
11
+ import DiffViewer from './diff-viewer';
15
12
  import '../assets/css/simple-editor.css';
16
- var SimpleEditor = /*#__PURE__*/function (_React$Component) {
17
- _inherits(SimpleEditor, _React$Component);
18
- var _super = _createSuper(SimpleEditor);
19
- function SimpleEditor(props) {
20
- var _this;
21
- _classCallCheck(this, SimpleEditor);
22
- _this = _super.call(this, props);
23
- _this.onValueChanged = function (value) {
24
- _this.isValueChanged = true;
25
- _this.value = value;
26
- };
27
- _this.onSave = function () {
28
- if (_this.isValueChanged) {
29
- _this.isValueChanged = false;
30
- var content = {
31
- version: _this.state.document.version,
32
- children: _this.value
13
+ var SimpleEditor = function SimpleEditor(_ref) {
14
+ var isStarred = _ref.isStarred,
15
+ t = _ref.t;
16
+ var _useState = useState(true),
17
+ _useState2 = _slicedToArray(_useState, 2),
18
+ isFirstLoad = _useState2[0],
19
+ setFirstLoad = _useState2[1];
20
+ var _useState3 = useState(false),
21
+ _useState4 = _slicedToArray(_useState3, 2),
22
+ isContextInit = _useState4[0],
23
+ setContextInit = _useState4[1];
24
+ var _useState5 = useState(''),
25
+ _useState6 = _slicedToArray(_useState5, 2),
26
+ errorMessage = _useState6[0],
27
+ setErrorMessage = _useState6[1];
28
+ var _useState7 = useState(false),
29
+ _useState8 = _slicedToArray(_useState7, 2),
30
+ isShowChanges = _useState8[0],
31
+ setShowChanges = _useState8[1];
32
+ var _useState9 = useState(null),
33
+ _useState10 = _slicedToArray(_useState9, 2),
34
+ document = _useState10[0],
35
+ setDocument = _useState10[1];
36
+ var _useState11 = useState(null),
37
+ _useState12 = _slicedToArray(_useState11, 2),
38
+ currentContent = _useState12[0],
39
+ setCurrentContent = _useState12[1];
40
+ var _useState13 = useState(null),
41
+ _useState14 = _slicedToArray(_useState13, 2),
42
+ lastContent = _useState14[0],
43
+ setLastContent = _useState14[1];
44
+ useEffect(function () {
45
+ context.initApi();
46
+ initDocumentData(true);
47
+
48
+ // eslint-disable-next-line react-hooks/exhaustive-deps
49
+ }, []);
50
+ var initDocumentData = useCallback(function (isFirstLoad) {
51
+ setShowChanges(false);
52
+ context.getFileContent().then(function (res) {
53
+ var result = res.data || generateDefaultDocContent();
54
+ if (result && !result.children) {
55
+ result = {
56
+ version: 0,
57
+ children: result.content,
58
+ cursors: result.cursors || {}
33
59
  };
34
- context.saveContent(JSON.stringify(content)).then(function (res) {
35
- // eslint-disable-next-line
36
- console.log('saved success');
37
- });
38
- }
39
- };
40
- _this.state = {
41
- isContextInit: false,
42
- errorMessage: null,
43
- document: null,
44
- isSaved: false,
45
- isSaving: false
46
- };
47
- _this.saveTimer = null;
48
- return _this;
49
- }
50
- _createClass(SimpleEditor, [{
51
- key: "componentDidMount",
52
- value: function () {
53
- var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
54
- var contentRes, result;
55
- return _regeneratorRuntime().wrap(function _callee$(_context) {
56
- while (1) switch (_context.prev = _context.next) {
57
- case 0:
58
- context.initApi();
59
- _context.prev = 1;
60
- _context.next = 4;
61
- return context.getFileContent();
62
- case 4:
63
- contentRes = _context.sent;
64
- result = contentRes.data || generateDefaultDocContent();
65
- if (result && !result.children) {
66
- result = {
67
- version: 0,
68
- children: result.content,
69
- cursors: result.cursors || {}
70
- };
71
- }
72
- this.setState({
73
- isContextInit: true,
74
- document: result
75
- });
76
- _context.next = 14;
77
- break;
78
- case 10:
79
- _context.prev = 10;
80
- _context.t0 = _context["catch"](1);
81
- // eslint-disable-next-line
82
- console.log(_context.t0);
83
- this.setState({
84
- isContextInit: true,
85
- errorMessage: 'load doc content error',
86
- document: null
87
- });
88
- case 14:
89
- case "end":
90
- return _context.stop();
91
- }
92
- }, _callee, this, [[1, 10]]);
93
- }));
94
- function componentDidMount() {
95
- return _componentDidMount.apply(this, arguments);
96
- }
97
- return componentDidMount;
98
- }()
99
- }, {
100
- key: "render",
101
- value: function render() {
102
- var _this$state = this.state,
103
- isContextInit = _this$state.isContextInit,
104
- errorMessage = _this$state.errorMessage,
105
- document = _this$state.document;
106
- if (!isContextInit) {
107
- return /*#__PURE__*/React.createElement(Loading, null);
108
60
  }
109
- if (errorMessage) {
110
- return /*#__PURE__*/React.createElement("div", {
111
- className: "d-flex justify-content-center"
112
- }, errorMessage);
113
- }
114
- var isOpenSocket = context.getSetting('isOpenSocket');
115
- return /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
116
- isStarred: this.props.isStarred
117
- }), /*#__PURE__*/React.createElement(DocOperations, null)), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(SDocEditor, {
118
- config: context.getEditorConfig(),
119
- document: document,
120
- isOpenSocket: isOpenSocket,
121
- onValueChanged: this.onValueChanged
122
- })));
61
+ setDocument(result);
62
+ setContextInit(true);
63
+ isFirstLoad && setFirstLoad(false);
64
+ }).catch(function (error) {
65
+ // eslint-disable-next-line
66
+ console.log(error);
67
+ setErrorMessage('Load_doc_content_error');
68
+ setDocument(null);
69
+ setContextInit(true);
70
+ isFirstLoad && setFirstLoad(false);
71
+ });
72
+
73
+ // eslint-disable-next-line react-hooks/exhaustive-deps
74
+ }, []);
75
+ var initChangesData = useCallback(function () {
76
+ setShowChanges(true);
77
+ context.getSeadocRevisionDownloadLinks().then(function (res) {
78
+ var _res$data = res.data,
79
+ fileDownloadLink = _res$data.file_download_link,
80
+ originFileDownloadLink = _res$data.origin_file_download_link;
81
+ fetch(fileDownloadLink).then(function (res) {
82
+ return res.json();
83
+ }).then(function (revisionContent) {
84
+ fetch(originFileDownloadLink).then(function (res) {
85
+ return res.json();
86
+ }).then(function (originContent) {
87
+ setCurrentContent(revisionContent);
88
+ setLastContent(originContent);
89
+ setErrorMessage(null);
90
+ setContextInit(true);
91
+ }).catch(function (error) {
92
+ setErrorMessage('Load_doc_content_error');
93
+ setContextInit(true);
94
+ });
95
+ }).catch(function (error) {
96
+ setErrorMessage('Load_doc_content_error');
97
+ setContextInit(true);
98
+ });
99
+ }).catch(function (error) {
100
+ setErrorMessage('Load_doc_content_error');
101
+ setContextInit(true);
102
+ });
103
+
104
+ // eslint-disable-next-line react-hooks/exhaustive-deps
105
+ }, []);
106
+ var toggleViewChanges = useCallback(function (isShowChanges) {
107
+ setContextInit(false);
108
+ if (isShowChanges) {
109
+ initChangesData();
110
+ return;
123
111
  }
124
- }]);
125
- return SimpleEditor;
126
- }(React.Component);
127
- export default SimpleEditor;
112
+ initDocumentData(false);
113
+
114
+ // eslint-disable-next-line react-hooks/exhaustive-deps
115
+ }, []);
116
+ if (isFirstLoad && !isContextInit) {
117
+ return /*#__PURE__*/React.createElement(Loading, null);
118
+ }
119
+ if (isFirstLoad && errorMessage) {
120
+ return /*#__PURE__*/React.createElement("div", {
121
+ className: "d-flex justify-content-center"
122
+ }, t(errorMessage));
123
+ }
124
+ return /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
125
+ isStarred: isStarred,
126
+ isEditMode: !isShowChanges
127
+ }), /*#__PURE__*/React.createElement(DocOperations, {
128
+ isShowChanges: isShowChanges,
129
+ toggleViewChanges: toggleViewChanges
130
+ })), /*#__PURE__*/React.createElement(Content, null, !isContextInit && /*#__PURE__*/React.createElement("div", {
131
+ className: "w-100 h-100 d-flex align-items-center justify-content-center"
132
+ }, /*#__PURE__*/React.createElement(Loading, null)), !isContextInit && errorMessage && /*#__PURE__*/React.createElement("div", {
133
+ className: "w-100 h-100 d-flex justify-content-center align-items-center"
134
+ }, t(errorMessage)), isContextInit && /*#__PURE__*/React.createElement(React.Fragment, null, isShowChanges ? /*#__PURE__*/React.createElement(DiffViewer, {
135
+ currentContent: currentContent,
136
+ lastContent: lastContent
137
+ }) : /*#__PURE__*/React.createElement(SDocEditor, {
138
+ config: context.getEditorConfig(),
139
+ document: document,
140
+ isOpenSocket: context.getSetting('isOpenSocket')
141
+ }))));
142
+ };
143
+ export default withTranslation('sdoc-editor')(SimpleEditor);
@@ -5,6 +5,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
6
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
7
7
  import React from 'react';
8
+ import { withTranslation } from 'react-i18next';
8
9
  import { SDocViewer } from '../basic-sdk';
9
10
  import context from '../context';
10
11
  import Loading from '../components/loading';
@@ -63,7 +64,7 @@ var SimpleViewer = /*#__PURE__*/function (_React$Component) {
63
64
  console.log(_context.t0);
64
65
  this.setState({
65
66
  isContextInit: true,
66
- errorMessage: 'load doc content error',
67
+ errorMessage: 'Load_doc_content_error',
67
68
  document: null
68
69
  });
69
70
  case 14:
@@ -84,13 +85,14 @@ var SimpleViewer = /*#__PURE__*/function (_React$Component) {
84
85
  isContextInit = _this$state.isContextInit,
85
86
  errorMessage = _this$state.errorMessage,
86
87
  document = _this$state.document;
88
+ var t = this.props.t;
87
89
  if (!isContextInit) {
88
90
  return /*#__PURE__*/React.createElement(Loading, null);
89
91
  }
90
92
  if (errorMessage) {
91
93
  return /*#__PURE__*/React.createElement("div", {
92
94
  className: "d-flex justify-content-center"
93
- }, errorMessage);
95
+ }, t(errorMessage));
94
96
  }
95
97
  var docName = context.getSetting('docName');
96
98
  return /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement("div", null, docName)), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(SDocViewer, {
@@ -101,4 +103,4 @@ var SimpleViewer = /*#__PURE__*/function (_React$Component) {
101
103
  }]);
102
104
  return SimpleViewer;
103
105
  }(React.Component);
104
- export default SimpleViewer;
106
+ export default withTranslation('sdoc-editor')(SimpleViewer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.80",
3
+ "version": "0.1.82",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -258,5 +258,7 @@
258
258
  "Revision": "Revision",
259
259
  "Error": "Error",
260
260
  "Start_revise": "Start revise",
261
- "Failed_to_execute_operation_on_server": "Failed to execute operation on server"
261
+ "Failed_to_execute_operation_on_server": "Failed to execute operation on server",
262
+ "Start_revise_tip": "Create a temporary document and modify on it, merge it back after reviewing changes",
263
+ "Load_doc_content_error": "Load doc content error"
262
264
  }
@@ -255,8 +255,10 @@
255
255
  "Are_you_sure_to_delete_this_comment": "你确定要删除这个评论吗?",
256
256
  "Confirm": "确定",
257
257
  "View_changes": "查看改动",
258
- "Revision": "修订",
258
+ "Revision": "修订稿",
259
259
  "Error": "错误",
260
260
  "Start_revise": "开始修订",
261
- "Failed_to_execute_operation_on_server": "无法在服务器上执行操作"
261
+ "Failed_to_execute_operation_on_server": "无法在服务器上执行操作",
262
+ "Start_revise_tip": "创建一个临时文档并对其进行修订,检查更改后将其合并回来",
263
+ "Load_doc_content_error": "加载文档内容错误"
262
264
  }
@@ -1,11 +1,11 @@
1
1
  @font-face {
2
2
  font-family: "sdocfont"; /* Project id 4097705 */
3
- src: url('./sdoc-editor-font/iconfont.eot?t=1689301494065'); /* IE9 */
4
- src: url('./sdoc-editor-font/iconfont.eot?t=1689301494065#iefix') format('embedded-opentype'), /* IE6-IE8 */
5
- url('./sdoc-editor-font/iconfont.woff2?t=1689301494065') format('woff2'),
6
- url('./sdoc-editor-font/iconfont.woff?t=1689301494065') format('woff'),
7
- url('./sdoc-editor-font/iconfont.ttf?t=1689301494065') format('truetype'),
8
- url('./sdoc-editor-font/iconfont.svg?t=1689301494065#sdocfont') format('svg');
3
+ src: url('./sdoc-editor-font/iconfont.eot?t=1689461796012'); /* IE9 */
4
+ src: url('./sdoc-editor-font/iconfont.eot?t=1689461796012#iefix') format('embedded-opentype'), /* IE6-IE8 */
5
+ url('./sdoc-editor-font/iconfont.woff2?t=1689461796012') format('woff2'),
6
+ url('./sdoc-editor-font/iconfont.woff?t=1689461796012') format('woff'),
7
+ url('iconfont.ttf?t=1689461796012') format('truetype'),
8
+ url('./sdoc-editor-font/iconfont.svg?t=1689461796012#sdocfont') format('svg');
9
9
  }
10
10
 
11
11
  .sdocfont {