@seafile/sdoc-editor 0.2.21 → 0.2.23-beta
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/dist/api/seafile-api.js +55 -0
- package/dist/basic-sdk/assets/css/sdoc-editor-plugins.css +2 -2
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +14 -32
- package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.js +23 -0
- package/dist/components/doc-info/index.js +3 -1
- package/dist/components/doc-operations/comments-operation/index.js +1 -1
- package/dist/components/doc-operations/index.js +5 -2
- package/dist/components/doc-operations/revision-operations/index.js +8 -7
- package/dist/components/doc-operations/revision-operations/revisions/revisions-dialog/index.js +3 -2
- package/dist/components/doc-operations/tag-operation/constans.js +2 -0
- package/dist/components/doc-operations/tag-operation/index.js +11 -0
- package/dist/components/doc-operations/tag-operation/tag-popover/index.css +70 -0
- package/dist/components/doc-operations/tag-operation/tag-popover/index.js +251 -0
- package/dist/components/doc-operations/tag-operation/utils.js +8 -0
- package/dist/context.js +54 -0
- package/dist/hooks/use-config.js +2 -0
- package/dist/hooks/use-document.js +7 -2
- package/dist/layout/layout.js +11 -1
- package/dist/pages/simple-editor.js +15 -6
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +29 -15
- package/public/locales/de/sdoc-editor.json +29 -15
- package/public/locales/en/sdoc-editor.json +31 -15
- package/public/locales/es/sdoc-editor.json +29 -15
- package/public/locales/fr/sdoc-editor.json +29 -15
- package/public/locales/it/sdoc-editor.json +29 -15
- package/public/locales/ru/sdoc-editor.json +29 -15
- package/public/locales/zh_CN/sdoc-editor.json +31 -15
- package/public/media/sdoc-editor-font/iconfont.svg +0 -4
- package/public/media/sdoc-editor-font.css +0 -8
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import { Badge, Input, PopoverBody, PopoverHeader, UncontrolledPopover } from 'reactstrap';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import context from '../../../../context';
|
|
8
|
+
import { getErrorMsg } from '../../../../utils';
|
|
9
|
+
import toaster from '../../../toast';
|
|
10
|
+
import { generateTagColor, removeForwardSpace } from '../utils';
|
|
11
|
+
import './index.css';
|
|
12
|
+
var TagPopover = function TagPopover() {
|
|
13
|
+
var _useState = useState(''),
|
|
14
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15
|
+
searchContent = _useState2[0],
|
|
16
|
+
setSearchContent = _useState2[1];
|
|
17
|
+
var _useState3 = useState([]),
|
|
18
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
19
|
+
tagList = _useState4[0],
|
|
20
|
+
setTagList = _useState4[1];
|
|
21
|
+
var tagListRef = useRef([]);
|
|
22
|
+
var _useTranslation = useTranslation(),
|
|
23
|
+
t = _useTranslation.t;
|
|
24
|
+
var isShowCreateTag = useMemo(function () {
|
|
25
|
+
var isInputTag = !!searchContent.length;
|
|
26
|
+
var isMathExistTag = tagList.some(function (item) {
|
|
27
|
+
return item.tag_name === searchContent;
|
|
28
|
+
});
|
|
29
|
+
return isInputTag && !isMathExistTag;
|
|
30
|
+
}, [searchContent, tagList]);
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
getTagList();
|
|
33
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
+
}, []);
|
|
35
|
+
var getFileTagList = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
36
|
+
var _yield$context$getFil, file_tags, errorMessage;
|
|
37
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
38
|
+
while (1) switch (_context.prev = _context.next) {
|
|
39
|
+
case 0:
|
|
40
|
+
_context.prev = 0;
|
|
41
|
+
_context.next = 3;
|
|
42
|
+
return context.getFileTagList();
|
|
43
|
+
case 3:
|
|
44
|
+
_yield$context$getFil = _context.sent;
|
|
45
|
+
file_tags = _yield$context$getFil.data.file_tags;
|
|
46
|
+
return _context.abrupt("return", file_tags);
|
|
47
|
+
case 8:
|
|
48
|
+
_context.prev = 8;
|
|
49
|
+
_context.t0 = _context["catch"](0);
|
|
50
|
+
errorMessage = getErrorMsg(_context.t0);
|
|
51
|
+
toaster.danger(t(errorMessage));
|
|
52
|
+
case 12:
|
|
53
|
+
case "end":
|
|
54
|
+
return _context.stop();
|
|
55
|
+
}
|
|
56
|
+
}, _callee, null, [[0, 8]]);
|
|
57
|
+
})), [t]);
|
|
58
|
+
|
|
59
|
+
// Get tag list and set fil_tag_id property when tag is attached on file
|
|
60
|
+
var getTagList = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
61
|
+
var _yield$context$getRep, repo_tags, fileTagList, errorMessage;
|
|
62
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
63
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
64
|
+
case 0:
|
|
65
|
+
_context2.prev = 0;
|
|
66
|
+
_context2.next = 3;
|
|
67
|
+
return context.getRepoTagList();
|
|
68
|
+
case 3:
|
|
69
|
+
_yield$context$getRep = _context2.sent;
|
|
70
|
+
repo_tags = _yield$context$getRep.data.repo_tags;
|
|
71
|
+
_context2.next = 7;
|
|
72
|
+
return getFileTagList();
|
|
73
|
+
case 7:
|
|
74
|
+
fileTagList = _context2.sent;
|
|
75
|
+
// Add file_tag_id property to tag,to mark which tag is added on file
|
|
76
|
+
repo_tags.forEach(function (item) {
|
|
77
|
+
var _matchFileTag$file_ta;
|
|
78
|
+
var matchFileTag = fileTagList.find(function (fileTag) {
|
|
79
|
+
return fileTag.repo_tag_id === item.repo_tag_id;
|
|
80
|
+
});
|
|
81
|
+
item.file_tag_id = (_matchFileTag$file_ta = matchFileTag === null || matchFileTag === void 0 ? void 0 : matchFileTag.file_tag_id) !== null && _matchFileTag$file_ta !== void 0 ? _matchFileTag$file_ta : null;
|
|
82
|
+
});
|
|
83
|
+
setTagList(repo_tags);
|
|
84
|
+
tagListRef.current = repo_tags;
|
|
85
|
+
_context2.next = 17;
|
|
86
|
+
break;
|
|
87
|
+
case 13:
|
|
88
|
+
_context2.prev = 13;
|
|
89
|
+
_context2.t0 = _context2["catch"](0);
|
|
90
|
+
errorMessage = getErrorMsg(_context2.t0);
|
|
91
|
+
toaster.danger(t(errorMessage));
|
|
92
|
+
case 17:
|
|
93
|
+
case "end":
|
|
94
|
+
return _context2.stop();
|
|
95
|
+
}
|
|
96
|
+
}, _callee2, null, [[0, 13]]);
|
|
97
|
+
})), [getFileTagList, t]);
|
|
98
|
+
|
|
99
|
+
// Create tag and add tag on file,then update tag list and clean search content
|
|
100
|
+
// Note: Here we remove the spaces at the beginning and end of the string
|
|
101
|
+
var handleCreateTag = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
102
|
+
var tagColor, _yield$context$create, repo_tag, errorMessage;
|
|
103
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
104
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
105
|
+
case 0:
|
|
106
|
+
_context3.prev = 0;
|
|
107
|
+
tagColor = generateTagColor();
|
|
108
|
+
_context3.next = 4;
|
|
109
|
+
return context.createRepoTag(searchContent.trim(), tagColor);
|
|
110
|
+
case 4:
|
|
111
|
+
_yield$context$create = _context3.sent;
|
|
112
|
+
repo_tag = _yield$context$create.data.repo_tag;
|
|
113
|
+
_context3.next = 8;
|
|
114
|
+
return context.addFileTag(repo_tag.repo_tag_id);
|
|
115
|
+
case 8:
|
|
116
|
+
getTagList();
|
|
117
|
+
setSearchContent('');
|
|
118
|
+
_context3.next = 16;
|
|
119
|
+
break;
|
|
120
|
+
case 12:
|
|
121
|
+
_context3.prev = 12;
|
|
122
|
+
_context3.t0 = _context3["catch"](0);
|
|
123
|
+
errorMessage = getErrorMsg(_context3.t0);
|
|
124
|
+
toaster.danger(t(errorMessage));
|
|
125
|
+
case 16:
|
|
126
|
+
case "end":
|
|
127
|
+
return _context3.stop();
|
|
128
|
+
}
|
|
129
|
+
}, _callee3, null, [[0, 12]]);
|
|
130
|
+
})), [getTagList, searchContent, t]);
|
|
131
|
+
var matchTag = useCallback(function (matchText) {
|
|
132
|
+
if (matchText.length) {
|
|
133
|
+
var filterTagList = tagListRef.current.filter(function (_ref4) {
|
|
134
|
+
var tag_name = _ref4.tag_name;
|
|
135
|
+
return tag_name.indexOf(matchText) !== -1;
|
|
136
|
+
});
|
|
137
|
+
setTagList(filterTagList);
|
|
138
|
+
} else {
|
|
139
|
+
setTagList(tagListRef.current);
|
|
140
|
+
}
|
|
141
|
+
}, []);
|
|
142
|
+
|
|
143
|
+
// Handle input change and match tag showing in popover
|
|
144
|
+
// Note: The input value is not allowed to start with a space,but it can contain spaces in the middle or at the end
|
|
145
|
+
var handleInputChange = useCallback(function (e) {
|
|
146
|
+
var text = e.target.value ??= '';
|
|
147
|
+
var inputText = removeForwardSpace(text).slice(0, 100);
|
|
148
|
+
matchTag(inputText);
|
|
149
|
+
setSearchContent(inputText);
|
|
150
|
+
}, [matchTag]);
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @param {string} repoTagID
|
|
154
|
+
* @param {number | null} file_tag_id
|
|
155
|
+
*/
|
|
156
|
+
var handleClickTag = useCallback( /*#__PURE__*/function () {
|
|
157
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(repoTagID, file_tag_id) {
|
|
158
|
+
var errorMessage;
|
|
159
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
160
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
161
|
+
case 0:
|
|
162
|
+
_context4.prev = 0;
|
|
163
|
+
if (!(file_tag_id !== null)) {
|
|
164
|
+
_context4.next = 6;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
_context4.next = 4;
|
|
168
|
+
return context.removeFileTag(file_tag_id);
|
|
169
|
+
case 4:
|
|
170
|
+
_context4.next = 8;
|
|
171
|
+
break;
|
|
172
|
+
case 6:
|
|
173
|
+
_context4.next = 8;
|
|
174
|
+
return context.addFileTag(repoTagID);
|
|
175
|
+
case 8:
|
|
176
|
+
getTagList();
|
|
177
|
+
_context4.next = 15;
|
|
178
|
+
break;
|
|
179
|
+
case 11:
|
|
180
|
+
_context4.prev = 11;
|
|
181
|
+
_context4.t0 = _context4["catch"](0);
|
|
182
|
+
errorMessage = getErrorMsg(_context4.t0);
|
|
183
|
+
toaster.danger(t(errorMessage));
|
|
184
|
+
case 15:
|
|
185
|
+
case "end":
|
|
186
|
+
return _context4.stop();
|
|
187
|
+
}
|
|
188
|
+
}, _callee4, null, [[0, 11]]);
|
|
189
|
+
}));
|
|
190
|
+
return function (_x, _x2) {
|
|
191
|
+
return _ref5.apply(this, arguments);
|
|
192
|
+
};
|
|
193
|
+
}(), [getTagList, t]);
|
|
194
|
+
return /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
195
|
+
target: "tag-operation-icon-container",
|
|
196
|
+
placement: "bottom-end",
|
|
197
|
+
popperClassName: "sdoc-menu-popover sdoc-dropdown-menu sdoc-tag-popover",
|
|
198
|
+
trigger: "legacy",
|
|
199
|
+
hideArrow: true,
|
|
200
|
+
fade: false,
|
|
201
|
+
security: "fixed"
|
|
202
|
+
}, /*#__PURE__*/React.createElement(PopoverBody, {
|
|
203
|
+
className: "sdoc-popover-container"
|
|
204
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
205
|
+
value: searchContent,
|
|
206
|
+
onChange: handleInputChange,
|
|
207
|
+
placeholder: t('Find_an_option'),
|
|
208
|
+
maxLength: 100,
|
|
209
|
+
className: "sdoc-tag-search-input",
|
|
210
|
+
bsSize: "sm",
|
|
211
|
+
autoFocus: true
|
|
212
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
213
|
+
className: "sdoc-tag-list-container"
|
|
214
|
+
}, tagList.length ? tagList.map(function (item) {
|
|
215
|
+
return /*#__PURE__*/React.createElement(TagItem, Object.assign({
|
|
216
|
+
key: item.repo_tag_id,
|
|
217
|
+
handleClickTag: handleClickTag
|
|
218
|
+
}, item));
|
|
219
|
+
}) : /*#__PURE__*/React.createElement("span", null, t('No_options_available')))), isShowCreateTag && /*#__PURE__*/React.createElement(PopoverHeader, {
|
|
220
|
+
className: "sdoc-create-tag",
|
|
221
|
+
onClick: handleCreateTag
|
|
222
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
223
|
+
className: "sdocfont sdoc-append add-icon"
|
|
224
|
+
}), "".concat(t('Add_option'), " '").concat(searchContent, "'")));
|
|
225
|
+
};
|
|
226
|
+
export default TagPopover;
|
|
227
|
+
var TagItem = function TagItem(_ref6) {
|
|
228
|
+
var repo_tag_id = _ref6.repo_tag_id,
|
|
229
|
+
tag_color = _ref6.tag_color,
|
|
230
|
+
tag_name = _ref6.tag_name,
|
|
231
|
+
handleClickTag = _ref6.handleClickTag,
|
|
232
|
+
file_tag_id = _ref6.file_tag_id;
|
|
233
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
234
|
+
className: "sdoc-tag-item",
|
|
235
|
+
onClick: function onClick() {
|
|
236
|
+
return handleClickTag(repo_tag_id, file_tag_id);
|
|
237
|
+
}
|
|
238
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
239
|
+
className: "sdoc-tag-badge-container"
|
|
240
|
+
}, /*#__PURE__*/React.createElement(Badge, {
|
|
241
|
+
style: {
|
|
242
|
+
backgroundColor: tag_color
|
|
243
|
+
},
|
|
244
|
+
className: "sdoc-tag-badge",
|
|
245
|
+
pill: true
|
|
246
|
+
}, tag_name)), /*#__PURE__*/React.createElement("div", {
|
|
247
|
+
className: "sdoc-tag-added-mark"
|
|
248
|
+
}, file_tag_id !== null && /*#__PURE__*/React.createElement("i", {
|
|
249
|
+
className: "sdocfont sdoc-check-mark"
|
|
250
|
+
})));
|
|
251
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TAG_COLORS } from './constans';
|
|
2
|
+
var generateTagColor = function generateTagColor() {
|
|
3
|
+
return TAG_COLORS[Math.floor(Math.random() * TAG_COLORS.length)];
|
|
4
|
+
};
|
|
5
|
+
var removeForwardSpace = function removeForwardSpace(str) {
|
|
6
|
+
return str.replace(/^\s+/, '');
|
|
7
|
+
};
|
|
8
|
+
export { generateTagColor, removeForwardSpace };
|
package/dist/context.js
CHANGED
|
@@ -114,6 +114,15 @@ var Context = /*#__PURE__*/function () {
|
|
|
114
114
|
value: function saveContent(content) {
|
|
115
115
|
return this.sdocServerApi.saveDocContent(content);
|
|
116
116
|
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @private Get DocUuid
|
|
120
|
+
*/
|
|
121
|
+
}, {
|
|
122
|
+
key: "getDocUuid",
|
|
123
|
+
value: function getDocUuid() {
|
|
124
|
+
return this.getSetting('docUuid');
|
|
125
|
+
}
|
|
117
126
|
}, {
|
|
118
127
|
key: "getCollaborators",
|
|
119
128
|
value: function getCollaborators() {
|
|
@@ -290,6 +299,51 @@ var Context = /*#__PURE__*/function () {
|
|
|
290
299
|
var docUuid = this.getSetting('docUuid');
|
|
291
300
|
return this.api.listRelatedUsers(docUuid);
|
|
292
301
|
}
|
|
302
|
+
// File tags
|
|
303
|
+
}, {
|
|
304
|
+
key: "getFileTagList",
|
|
305
|
+
value: function getFileTagList() {
|
|
306
|
+
var docUuid = this.getDocUuid();
|
|
307
|
+
return this.api.getFileTagList(docUuid);
|
|
308
|
+
}
|
|
309
|
+
}, {
|
|
310
|
+
key: "addFileTag",
|
|
311
|
+
value: function addFileTag(repoTagID) {
|
|
312
|
+
var docUuid = this.getDocUuid();
|
|
313
|
+
return this.api.addFileTag(docUuid, repoTagID);
|
|
314
|
+
}
|
|
315
|
+
}, {
|
|
316
|
+
key: "removeFileTag",
|
|
317
|
+
value: function removeFileTag(fileTagID) {
|
|
318
|
+
var docUuid = this.getDocUuid();
|
|
319
|
+
return this.api.removeFileTag(docUuid, fileTagID);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Repo tags
|
|
323
|
+
}, {
|
|
324
|
+
key: "getRepoTagList",
|
|
325
|
+
value: function getRepoTagList() {
|
|
326
|
+
var docUuid = this.getDocUuid();
|
|
327
|
+
return this.api.getRepoTagList(docUuid);
|
|
328
|
+
}
|
|
329
|
+
}, {
|
|
330
|
+
key: "createRepoTag",
|
|
331
|
+
value: function createRepoTag(repoTagName, color) {
|
|
332
|
+
var docUuid = this.getDocUuid();
|
|
333
|
+
return this.api.createRepoTag(docUuid, repoTagName, color);
|
|
334
|
+
}
|
|
335
|
+
}, {
|
|
336
|
+
key: "removeRepoTag",
|
|
337
|
+
value: function removeRepoTag(fileTagID) {
|
|
338
|
+
var docUuid = this.getDocUuid();
|
|
339
|
+
return this.api.removeRepoTag(docUuid, fileTagID);
|
|
340
|
+
}
|
|
341
|
+
}, {
|
|
342
|
+
key: "updateRepoTag",
|
|
343
|
+
value: function updateRepoTag(repoTagId, repoTagName, color) {
|
|
344
|
+
var docUuid = this.getDocUuid();
|
|
345
|
+
return this.api.updateRepoTag(docUuid, repoTagId, repoTagName, color);
|
|
346
|
+
}
|
|
293
347
|
}]);
|
|
294
348
|
return Context;
|
|
295
349
|
}();
|
|
@@ -3,7 +3,6 @@ import { useCallback, useEffect, useState } from 'react';
|
|
|
3
3
|
import context from '../context';
|
|
4
4
|
export var useDocument = function useDocument() {
|
|
5
5
|
var isSdocRevision = context.getSetting('isSdocRevision');
|
|
6
|
-
var isPublished = context.getSetting('isPublished');
|
|
7
6
|
var _useState = useState(true),
|
|
8
7
|
_useState2 = _slicedToArray(_useState, 2),
|
|
9
8
|
isFirstLoading = _useState2[0],
|
|
@@ -24,6 +23,10 @@ export var useDocument = function useDocument() {
|
|
|
24
23
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
25
24
|
errorMessage = _useState8[0],
|
|
26
25
|
setErrorMessage = _useState8[1];
|
|
26
|
+
var _useState9 = useState(context.getSetting('isPublished')),
|
|
27
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
28
|
+
isPublished = _useState10[0],
|
|
29
|
+
setPublished = _useState10[1];
|
|
27
30
|
var loadDocument = useCallback(function () {
|
|
28
31
|
return new Promise(function (resolve, reject) {
|
|
29
32
|
context.getFileContent().then(function (res) {
|
|
@@ -82,6 +85,8 @@ export var useDocument = function useDocument() {
|
|
|
82
85
|
errorMessage: errorMessage,
|
|
83
86
|
document: document,
|
|
84
87
|
loadDocument: loadDocument,
|
|
85
|
-
reloadDocument: reloadDocument
|
|
88
|
+
reloadDocument: reloadDocument,
|
|
89
|
+
isPublished: isPublished,
|
|
90
|
+
setPublished: setPublished
|
|
86
91
|
};
|
|
87
92
|
};
|
package/dist/layout/layout.js
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
var _excluded = ["children", "className"];
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useEffect } from 'react';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
var Layout = function Layout(_ref) {
|
|
6
6
|
var children = _ref.children,
|
|
7
7
|
className = _ref.className,
|
|
8
8
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
9
|
+
useEffect(function () {
|
|
10
|
+
setTimeout(function () {
|
|
11
|
+
var url = window.location.href;
|
|
12
|
+
var id = url.slice(url.indexOf('#') + 1);
|
|
13
|
+
if (id) {
|
|
14
|
+
var element = document.getElementById(id);
|
|
15
|
+
element && element.scrollIntoView(true);
|
|
16
|
+
}
|
|
17
|
+
}, 500);
|
|
18
|
+
}, []);
|
|
9
19
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
10
20
|
className: classnames('sdoc-editor-page-wrapper', className)
|
|
11
21
|
}, restProps), children);
|
|
@@ -8,7 +8,7 @@ import Layout, { Header, Content } from '../layout';
|
|
|
8
8
|
import context from '../context';
|
|
9
9
|
import ErrorBoundary from './error-boundary';
|
|
10
10
|
import { SDocEditor } from '../basic-sdk';
|
|
11
|
-
import { RevisionDiffViewer } from '../basic-sdk/views';
|
|
11
|
+
import { PublishedRevisionDiffViewer, RevisionDiffViewer } from '../basic-sdk/views';
|
|
12
12
|
import { useDocument } from '../hooks';
|
|
13
13
|
import { resetWebTitleAndURL } from '../utils';
|
|
14
14
|
import '../assets/css/simple-editor.css';
|
|
@@ -23,7 +23,8 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
23
23
|
isReloading = _useDocument.isReloading,
|
|
24
24
|
errorMessage = _useDocument.errorMessage,
|
|
25
25
|
document = _useDocument.document,
|
|
26
|
-
reloadDocument = _useDocument.reloadDocument
|
|
26
|
+
reloadDocument = _useDocument.reloadDocument,
|
|
27
|
+
isPublished = _useDocument.isPublished;
|
|
27
28
|
var _useState = useState(false),
|
|
28
29
|
_useState2 = _slicedToArray(_useState, 2),
|
|
29
30
|
isShowChanges = _useState2[0],
|
|
@@ -47,6 +48,10 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
47
48
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
49
|
}, [isShowChanges]);
|
|
49
50
|
var handleViewChangesToggle = useCallback(function (isShowChanges) {
|
|
51
|
+
if (isPublished) {
|
|
52
|
+
setShowChanges(isShowChanges);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
50
55
|
if (!isShowChanges) {
|
|
51
56
|
setShowChanges(isShowChanges);
|
|
52
57
|
reloadDocument();
|
|
@@ -58,7 +63,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
58
63
|
setRevisionContent(revisionContent);
|
|
59
64
|
setShowChanges(isShowChanges);
|
|
60
65
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
-
}, [document, editorRef.current]);
|
|
66
|
+
}, [document, editorRef.current, isPublished]);
|
|
62
67
|
var handleRevisionPublished = useCallback(function (value) {
|
|
63
68
|
setShowChanges(false);
|
|
64
69
|
editorRef.current.setSlateValue(value);
|
|
@@ -77,17 +82,21 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
77
82
|
return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
|
|
78
83
|
isStarred: isStarred,
|
|
79
84
|
isDraft: isDraft,
|
|
80
|
-
isEditMode: !isShowChanges
|
|
85
|
+
isEditMode: isPublished ? false : !isShowChanges
|
|
81
86
|
}), /*#__PURE__*/React.createElement(DocOperations, {
|
|
82
87
|
isShowChanges: isShowChanges,
|
|
83
88
|
changes: changes,
|
|
84
89
|
handleViewChangesToggle: handleViewChangesToggle,
|
|
85
90
|
handleRevisionPublished: handleRevisionPublished
|
|
86
|
-
})), /*#__PURE__*/React.createElement(Content, null,
|
|
91
|
+
})), /*#__PURE__*/React.createElement(Content, null, isPublished && /*#__PURE__*/React.createElement(PublishedRevisionDiffViewer, {
|
|
92
|
+
isShowChanges: isShowChanges,
|
|
93
|
+
revisionContent: revisionContent,
|
|
94
|
+
didMountCallback: setDiffChanges
|
|
95
|
+
}), !isPublished && !isShowChanges && /*#__PURE__*/React.createElement(SDocEditor, {
|
|
87
96
|
ref: editorRef,
|
|
88
97
|
isReloading: isReloading,
|
|
89
98
|
document: document
|
|
90
|
-
}), isShowChanges && /*#__PURE__*/React.createElement(RevisionDiffViewer, {
|
|
99
|
+
}), !isPublished && isShowChanges && /*#__PURE__*/React.createElement(RevisionDiffViewer, {
|
|
91
100
|
revisionContent: revisionContent,
|
|
92
101
|
didMountCallback: setDiffChanges
|
|
93
102
|
}))));
|
package/package.json
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"Right": "Vpravo",
|
|
51
51
|
"File_saved": "Soubor uložen",
|
|
52
52
|
"File_failed_to_save": "Soubor nebyl uložen",
|
|
53
|
-
"Back_to_parent_directory":"Zpět do nadřazeného adresáře",
|
|
53
|
+
"Back_to_parent_directory": "Zpět do nadřazeného adresáře",
|
|
54
54
|
"Edit": "Upravit",
|
|
55
55
|
"Copy": "Kopírovat",
|
|
56
56
|
"Copied": "Zkopírováno",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"New_draft": "New draft",
|
|
94
94
|
"View_draft": "View draft",
|
|
95
95
|
"Publish": "Zveřejnit",
|
|
96
|
-
"This_file_has_a_draft": "Tento soubor má koncept.",
|
|
96
|
+
"This_file_has_a_draft": "Tento soubor má koncept.",
|
|
97
97
|
"Delete": "Smazat",
|
|
98
98
|
"Reply": "Odpověď",
|
|
99
99
|
"Comment": "Komentář",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"MarkdownLint": {
|
|
147
147
|
"missing_h1": {
|
|
148
148
|
"description": "V dokumentu není žádný h1",
|
|
149
|
-
"issue"
|
|
149
|
+
"issue": "Chybí h1"
|
|
150
150
|
},
|
|
151
151
|
"heading_end_with_colon": {
|
|
152
152
|
"description": "Koncová interpunkce v záhlaví by neměla být dvojtečka",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"title": "Klávesové zkratky",
|
|
163
163
|
"userHelpData": [
|
|
164
164
|
{
|
|
165
|
-
"shortcutType":"Seznam zkratek",
|
|
165
|
+
"shortcutType": "Seznam zkratek",
|
|
166
166
|
"shortcutData": {
|
|
167
167
|
"Make_list": "Vytvořit seznam",
|
|
168
168
|
"Make_ordered_list": "Vytvořit číslovaný seznam",
|
|
@@ -170,7 +170,8 @@
|
|
|
170
170
|
"Insert_child_in_item": "Vložit podpoložku",
|
|
171
171
|
"Increase_depth": "Zvýšit hloubku"
|
|
172
172
|
}
|
|
173
|
-
},
|
|
173
|
+
},
|
|
174
|
+
{
|
|
174
175
|
"shortcutType": "Zkratky záhlaví",
|
|
175
176
|
"shortcutData": {
|
|
176
177
|
"Heading_1": "Záhlaví 1",
|
|
@@ -180,7 +181,8 @@
|
|
|
180
181
|
"Heading_5": "Záhlaví 5",
|
|
181
182
|
"Heading_6": "Záhlaví 6"
|
|
182
183
|
}
|
|
183
|
-
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
184
186
|
"shortcutType": "Zkratky bloků kódu",
|
|
185
187
|
"shortcutData": {
|
|
186
188
|
"Make_code_block": "Vytvořit blok kódu",
|
|
@@ -188,37 +190,43 @@
|
|
|
188
190
|
"Escape_code_block": "Opustit blok kódu",
|
|
189
191
|
"Insert_indent": "Vložit odrážku"
|
|
190
192
|
}
|
|
191
|
-
},
|
|
193
|
+
},
|
|
194
|
+
{
|
|
192
195
|
"shortcutType": "Zkratky bloku citace",
|
|
193
196
|
"shortcutData": {
|
|
194
197
|
"Make_Block_quote": "Vytvořit blokovou citaci",
|
|
195
198
|
"Escape_Block_quote": "Opustit blokovou citaci"
|
|
196
199
|
}
|
|
197
|
-
},
|
|
200
|
+
},
|
|
201
|
+
{
|
|
198
202
|
"shortcutType": "Zkratky tabulky",
|
|
199
203
|
"shortcutData": {
|
|
200
204
|
"Insert_Table_Row": "Vložit řádku tabulky",
|
|
201
205
|
"Escape_table": "Opustit tabulku"
|
|
202
206
|
}
|
|
203
|
-
},
|
|
207
|
+
},
|
|
208
|
+
{
|
|
204
209
|
"shortcutType": "Zkratky vzorečku",
|
|
205
210
|
"shortcutData": {
|
|
206
211
|
"Insert_Formula": "Insert Formula"
|
|
207
212
|
}
|
|
208
|
-
},
|
|
209
|
-
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"shortcutType": "Řádkové zkratky",
|
|
210
216
|
"shortcutData": {
|
|
211
217
|
"Bold": "Tučně",
|
|
212
218
|
"Italic": "Kurzíva",
|
|
213
219
|
"Italic_Bold": "Tučná kurzíva",
|
|
214
220
|
"Inline_code": "Řádkový kód"
|
|
215
221
|
}
|
|
216
|
-
},
|
|
222
|
+
},
|
|
223
|
+
{
|
|
217
224
|
"shortcutType": "Uložit zkratky",
|
|
218
225
|
"shortcutData": {
|
|
219
226
|
"Save_file": "Uložit soubor"
|
|
220
227
|
}
|
|
221
|
-
},
|
|
228
|
+
},
|
|
229
|
+
{
|
|
222
230
|
"shortcutType": "Zkratky obrázku",
|
|
223
231
|
"shortcutData": {
|
|
224
232
|
"Paste_screen_shot": "Vložit snímek obrazovky",
|
|
@@ -267,7 +275,7 @@
|
|
|
267
275
|
"Are_you_sure_to_delete_this_reply": "Are you sure to delete this reply?",
|
|
268
276
|
"Enter_a_comment": "Enter a comment",
|
|
269
277
|
"Enter_a_reply": "Enter a reply",
|
|
270
|
-
"Reopen_discussion"
|
|
278
|
+
"Reopen_discussion": "Adding a reply will reopen this discussion",
|
|
271
279
|
"Confirm": "Potvrdit",
|
|
272
280
|
"View_changes": "View changes",
|
|
273
281
|
"Revision": "Revision",
|
|
@@ -392,5 +400,11 @@
|
|
|
392
400
|
"Insert_caption": "Insert caption",
|
|
393
401
|
"No_collaborators_available": "No_collaborators_available",
|
|
394
402
|
"Find_a_collaborator": "Find a collaborator",
|
|
395
|
-
"Doc_comments": "Document comments"
|
|
403
|
+
"Doc_comments": "Document comments",
|
|
404
|
+
"Tag_not_found": "Tag not found",
|
|
405
|
+
"Create_a_new_tag": "Vytvořit nový štítek",
|
|
406
|
+
"Search_tags": "Search tags",
|
|
407
|
+
"No_options_available": "Tag not found",
|
|
408
|
+
"Add_option": "Vytvořit nový štítek",
|
|
409
|
+
"Find_an_option": "Search tags"
|
|
396
410
|
}
|