@seafile/seafile-editor 0.3.76
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/README.md +119 -0
- package/TODO.md +55 -0
- package/dist/components/add-formula-dialog.js +135 -0
- package/dist/components/add-image-dialog.js +78 -0
- package/dist/components/add-link-dialog.js +148 -0
- package/dist/components/comment-dialog.js +107 -0
- package/dist/components/comment-panel.js +452 -0
- package/dist/components/context-menu.js +112 -0
- package/dist/components/detail-list-view.js +119 -0
- package/dist/components/generate-share-link.js +412 -0
- package/dist/components/internal-link-dialog.js +96 -0
- package/dist/components/loading.js +32 -0
- package/dist/components/markdown-lint.js +87 -0
- package/dist/components/modal-portal.js +46 -0
- package/dist/components/outline.js +130 -0
- package/dist/components/participants-list.js +126 -0
- package/dist/components/related-files-list.js +75 -0
- package/dist/components/shortcut-dialog.js +167 -0
- package/dist/components/side-panel.js +175 -0
- package/dist/components/toast/alert.js +150 -0
- package/dist/components/toast/index.js +3 -0
- package/dist/components/toast/toast.js +179 -0
- package/dist/components/toast/toastManager.js +158 -0
- package/dist/components/toast/toaster.js +76 -0
- package/dist/components/toolbar.js +235 -0
- package/dist/components/topbar-component/button-group.js +31 -0
- package/dist/components/topbar-component/editor-toolbar.js +545 -0
- package/dist/components/topbar-component/file-info.js +65 -0
- package/dist/components/topbar-component/header-list.js +128 -0
- package/dist/components/topbar-component/icon-button.js +99 -0
- package/dist/components/topbar-component/insert-file.js +67 -0
- package/dist/components/topbar-component/table-toolbar.js +175 -0
- package/dist/components/topbar-component/upload-img.js +122 -0
- package/dist/components/user-help.js +205 -0
- package/dist/css/diff-viewer.css +105 -0
- package/dist/css/history-viewer.css +104 -0
- package/dist/css/keyboard-shortcuts.css +59 -0
- package/dist/css/layout.css +110 -0
- package/dist/css/markdown-viewer-slate/file-tags-list.css +76 -0
- package/dist/css/markdown-viewer.css +69 -0
- package/dist/css/plaineditor/markdown-editor.css +12 -0
- package/dist/css/react-mentions-default-style.js +72 -0
- package/dist/css/related-files-list.css +56 -0
- package/dist/css/richeditor/comments-list.css +184 -0
- package/dist/css/richeditor/detail-list-view.css +114 -0
- package/dist/css/richeditor/document-info.css +57 -0
- package/dist/css/richeditor/formula.css +19 -0
- package/dist/css/richeditor/image.css +141 -0
- package/dist/css/richeditor/link.css +7 -0
- package/dist/css/richeditor/navbar-imgbutton.css +79 -0
- package/dist/css/richeditor/participants-list.css +22 -0
- package/dist/css/richeditor/rich-editor-main.css +42 -0
- package/dist/css/richeditor/right-panel.css +84 -0
- package/dist/css/richeditor/side-panel.css +190 -0
- package/dist/css/richeditor/table.css +57 -0
- package/dist/css/richeditor/textlink-hovermenu.css +47 -0
- package/dist/css/richeditor/tree-view.css +67 -0
- package/dist/css/topbar.css +400 -0
- package/dist/editor/code-highlight-package.js +27 -0
- package/dist/editor/controller/block-element-controller.js +376 -0
- package/dist/editor/controller/inline-element-controller.js +129 -0
- package/dist/editor/controller/normalize-controller.js +107 -0
- package/dist/editor/controller/shortcut-controller.js +394 -0
- package/dist/editor/controller/void-element-controller.js +12 -0
- package/dist/editor/custom/custom.js +17 -0
- package/dist/editor/custom/get-event-transfer.js +34 -0
- package/dist/editor/custom/getNodesByTypeAtRange.js +69 -0
- package/dist/editor/custom/insertNodes.js +140 -0
- package/dist/editor/custom/is-empty-paragraph.js +13 -0
- package/dist/editor/custom/set-event-transfer.js +31 -0
- package/dist/editor/custom/split-nodes-at-point.js +162 -0
- package/dist/editor/custom/unwrap-node-by-type-at-range.js +81 -0
- package/dist/editor/editor-component/check-list-item.js +64 -0
- package/dist/editor/editor-component/code-block.js +150 -0
- package/dist/editor/editor-component/formula.js +79 -0
- package/dist/editor/editor-component/image.js +215 -0
- package/dist/editor/editor-component/link.js +11 -0
- package/dist/editor/editor-component/table.js +172 -0
- package/dist/editor/editor-component/textlink-hovermenu.js +136 -0
- package/dist/editor/editor-plugin.js +249 -0
- package/dist/editor/editor-utils/block-element-utils/blockquote-utils.js +96 -0
- package/dist/editor/editor-utils/block-element-utils/code-utils.js +162 -0
- package/dist/editor/editor-utils/block-element-utils/formula-utils.js +58 -0
- package/dist/editor/editor-utils/block-element-utils/index.js +38 -0
- package/dist/editor/editor-utils/block-element-utils/list-utils.js +398 -0
- package/dist/editor/editor-utils/block-element-utils/table-utils.js +418 -0
- package/dist/editor/editor-utils/common-editor-utils.js +587 -0
- package/dist/editor/editor-utils/inline-element-utils/index.js +95 -0
- package/dist/editor/editor-utils/mark-utils.js +25 -0
- package/dist/editor/editor-utils/range-utils.js +9 -0
- package/dist/editor/editor-utils/selection-utils.js +33 -0
- package/dist/editor/editor-utils/text-utils.js +130 -0
- package/dist/editor/editor.js +66 -0
- package/dist/editor/element-model/blockquote.js +16 -0
- package/dist/editor/element-model/image.js +19 -0
- package/dist/editor/element-model/link.js +19 -0
- package/dist/editor/element-model/table.js +50 -0
- package/dist/editor/element-model/text.js +13 -0
- package/dist/editor/load-script.js +83 -0
- package/dist/editor/plain-markdown-editor.js +324 -0
- package/dist/editor/rich-markdown-editor.js +580 -0
- package/dist/editor/seafile-editor.js +326 -0
- package/dist/editor/simple-editor.js +245 -0
- package/dist/editor-api.js +261 -0
- package/dist/index.css +97 -0
- package/dist/lib/slate-hyperscript/creators.js +263 -0
- package/dist/lib/slate-hyperscript/hyperscript.js +92 -0
- package/dist/lib/slate-hyperscript/index.js +3 -0
- package/dist/lib/slate-hyperscript/tokens.js +102 -0
- package/dist/lib/unified/index.js +470 -0
- package/dist/lib/vfile/core.js +172 -0
- package/dist/lib/vfile/index.js +48 -0
- package/dist/seafile-editor-chooser.js +45 -0
- package/dist/seafile-markdown-editor.js +301 -0
- package/dist/seafile-markdown-viewer.js +79 -0
- package/dist/seafile-simple-editor.js +56 -0
- package/dist/utils/copy-to-clipboard.js +47 -0
- package/dist/utils/deserialize-html.js +282 -0
- package/dist/utils/diff/compare-strings.js +46 -0
- package/dist/utils/diff/diff.js +855 -0
- package/dist/utils/diff/index.js +2 -0
- package/dist/utils/render-slate.js +219 -0
- package/dist/utils/seafile-markdown2html.js +62 -0
- package/dist/utils/slate2markdown/deserialize.js +689 -0
- package/dist/utils/slate2markdown/index.js +3 -0
- package/dist/utils/slate2markdown/serialize.js +407 -0
- package/dist/utils/utils.js +28 -0
- package/dist/viewer/diff-viewer.js +98 -0
- package/dist/viewer/markdown-viewer.js +139 -0
- package/dist/viewer/slate-viewer.js +73 -0
- package/dist/viewer/viewer-formula.js +67 -0
- package/dist/viewer/viewer-image.js +93 -0
- package/dist/viewer/viewer-outline.js +118 -0
- package/package.json +215 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +45 -0
- package/public/locales/cs/seafile-editor.json +169 -0
- package/public/locales/de/seafile-editor.json +169 -0
- package/public/locales/en/seafile-editor.json +222 -0
- package/public/locales/es/seafile-editor.json +169 -0
- package/public/locales/es-AR/seafile-editor.json +169 -0
- package/public/locales/es-MX/seafile-editor.json +169 -0
- package/public/locales/fr/seafile-editor.json +169 -0
- package/public/locales/it/seafile-editor.json +169 -0
- package/public/locales/ru/seafile-editor.json +169 -0
- package/public/locales/zh-CN/seafile-editor.json +219 -0
- package/public/manifest.json +15 -0
- package/public/media/scripts/mathjax/tex-svg.js +1 -0
- package/public/media/seafile-editor-font/iconfont.eot +0 -0
- package/public/media/seafile-editor-font/iconfont.svg +164 -0
- package/public/media/seafile-editor-font/iconfont.ttf +0 -0
- package/public/media/seafile-editor-font/iconfont.woff +0 -0
- package/public/media/seafile-editor-font/iconfont.woff2 +0 -0
- package/public/media/seafile-editor-font.css +201 -0
- package/public/media/seafile-logo.png +0 -0
- package/public/media/seafile-ui.css +11169 -0
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
|
|
2
|
+
|
|
3
|
+
## Folder Structure
|
|
4
|
+
|
|
5
|
+
After creation, your project should look like this:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
seafile-editor/
|
|
9
|
+
README.md
|
|
10
|
+
node_modules/
|
|
11
|
+
package.json
|
|
12
|
+
public/
|
|
13
|
+
index.html
|
|
14
|
+
favicon.ico
|
|
15
|
+
src/
|
|
16
|
+
App.css
|
|
17
|
+
App.js
|
|
18
|
+
App.test.js
|
|
19
|
+
index.css
|
|
20
|
+
index.js
|
|
21
|
+
logo.svg
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
For the project to build, **these files must exist with exact filenames**:
|
|
25
|
+
|
|
26
|
+
* `public/index.html` is the page template;
|
|
27
|
+
* `src/index.js` is the JavaScript entry point.
|
|
28
|
+
|
|
29
|
+
You can delete or rename the other files.
|
|
30
|
+
|
|
31
|
+
You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.<br>
|
|
32
|
+
You need to **put any JS and CSS files inside `src`**, otherwise Webpack won’t see them.
|
|
33
|
+
|
|
34
|
+
Only files inside `public` can be used from `public/index.html`.<br>
|
|
35
|
+
Read instructions below for using assets from JavaScript and HTML.
|
|
36
|
+
|
|
37
|
+
You can, however, create more top-level directories.<br>
|
|
38
|
+
They will not be included in the production build so you can use them for things like documentation.
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
Install dependency
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
npm install
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
create `src/config.js` with the following contents
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
const serverConfig = {
|
|
52
|
+
serviceUrl: "https://download.seafile.top",
|
|
53
|
+
username: "xxx",
|
|
54
|
+
password: "xxx",
|
|
55
|
+
repoID: "xxxxxxx-xxxx-xxx-xxx-xxxx",
|
|
56
|
+
userInfo: {
|
|
57
|
+
username: 'xxx',
|
|
58
|
+
name: 'xxx',
|
|
59
|
+
contact_email: 'xxxx',
|
|
60
|
+
},
|
|
61
|
+
filePath: '/demo.md',
|
|
62
|
+
fileName: 'demo.md',
|
|
63
|
+
dirPath: '/'
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { serverConfig }
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Make sure you have a file `test.md` in the root of your Seafile library.
|
|
70
|
+
|
|
71
|
+
Start the example application
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
npm start
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## Available Scripts
|
|
79
|
+
|
|
80
|
+
In the project directory, you can run:
|
|
81
|
+
|
|
82
|
+
### `npm start`
|
|
83
|
+
|
|
84
|
+
Runs the app in the development mode.<br>
|
|
85
|
+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
|
86
|
+
|
|
87
|
+
The page will reload if you make edits.<br>
|
|
88
|
+
You will also see any lint errors in the console.
|
|
89
|
+
|
|
90
|
+
### `npm test`
|
|
91
|
+
|
|
92
|
+
Launches the test runner in the interactive watch mode.<br>
|
|
93
|
+
See the section about [running tests](#running-tests) for more information.
|
|
94
|
+
|
|
95
|
+
### `npm run build`
|
|
96
|
+
|
|
97
|
+
Builds the app for production to the `build` folder.<br>
|
|
98
|
+
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
99
|
+
|
|
100
|
+
The build is minified and the filenames include the hashes.<br>
|
|
101
|
+
Your app is ready to be deployed!
|
|
102
|
+
|
|
103
|
+
See the section about [deployment](#deployment) for more information.
|
|
104
|
+
|
|
105
|
+
### `npm run eject`
|
|
106
|
+
|
|
107
|
+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
|
108
|
+
|
|
109
|
+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
|
110
|
+
|
|
111
|
+
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
|
112
|
+
|
|
113
|
+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
|
114
|
+
|
|
115
|
+
### `npm run prepublish`
|
|
116
|
+
|
|
117
|
+
Run this command before publish to npm registry. And increase verison number in `package.json`.
|
|
118
|
+
|
|
119
|
+
Publish project by `npm publish` and view at [package page](https://www.npmjs.com/package/@seafile/seafile-editor).
|
package/TODO.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
## Version beta 1
|
|
2
|
+
|
|
3
|
+
Release data: 2018.05.30
|
|
4
|
+
|
|
5
|
+
* [X] Support table (https://github.com/GitbookIO/slate-edit-table)
|
|
6
|
+
* [X] Support coding blocks
|
|
7
|
+
* [X] Support list editing (https://github.com/GitbookIO/slate-edit-list)
|
|
8
|
+
* [X] Support images
|
|
9
|
+
|
|
10
|
+
### Image
|
|
11
|
+
|
|
12
|
+
* [x] Slate image node
|
|
13
|
+
* [x] renderNode() supports readering image node to <img>
|
|
14
|
+
* [x] Add image icon, click image icon, popup a dialog to let user input an image
|
|
15
|
+
|
|
16
|
+
## Version beta 2
|
|
17
|
+
|
|
18
|
+
* [x] Improve table
|
|
19
|
+
* [x] Improve CSS
|
|
20
|
+
* [x] Copy/paste image from clipboard
|
|
21
|
+
* [-] Improve code block
|
|
22
|
+
* [-] Change toolbar button icons
|
|
23
|
+
* [-] Support task list
|
|
24
|
+
|
|
25
|
+
### Tree view
|
|
26
|
+
|
|
27
|
+
* [-] Folder/File icons
|
|
28
|
+
* [-] Click and show content
|
|
29
|
+
* [-] Drag and create link
|
|
30
|
+
|
|
31
|
+
## Version beta 3
|
|
32
|
+
|
|
33
|
+
* Switch to plain markdown editor
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Future versions
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
Not important
|
|
40
|
+
|
|
41
|
+
* Support quotation
|
|
42
|
+
|
|
43
|
+
Integrating into Seafile
|
|
44
|
+
|
|
45
|
+
* Support TOC
|
|
46
|
+
|
|
47
|
+
### Tree view
|
|
48
|
+
|
|
49
|
+
* [] Add file
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Plain react markdown editor
|
|
54
|
+
|
|
55
|
+
https://github.com/rexxars/react-markdown
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React, { Fragment } from 'react';
|
|
6
|
+
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input } from 'reactstrap';
|
|
7
|
+
import { withTranslation } from 'react-i18next';
|
|
8
|
+
import { Editor } from 'slate';
|
|
9
|
+
import { EditorUtils } from '../editor/editor-utils/common-editor-utils';
|
|
10
|
+
|
|
11
|
+
var AddFormulaDialog = /*#__PURE__*/function (_React$PureComponent) {
|
|
12
|
+
_inherits(AddFormulaDialog, _React$PureComponent);
|
|
13
|
+
|
|
14
|
+
var _super = _createSuper(AddFormulaDialog);
|
|
15
|
+
|
|
16
|
+
function AddFormulaDialog(props) {
|
|
17
|
+
var _this;
|
|
18
|
+
|
|
19
|
+
_classCallCheck(this, AddFormulaDialog);
|
|
20
|
+
|
|
21
|
+
_this = _super.call(this, props);
|
|
22
|
+
|
|
23
|
+
_this.setInitialValue = function () {
|
|
24
|
+
var nodes = Editor.match(window.editor, window.editor.selection, {
|
|
25
|
+
type: 'formula'
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (nodes) {
|
|
29
|
+
var data = nodes[0].data;
|
|
30
|
+
|
|
31
|
+
_this.setState({
|
|
32
|
+
formula: data.formula
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
_this.formulaNode = nodes;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
_this.handleFormulaChange = function (event) {
|
|
40
|
+
_this.renderFormula(event.target.value);
|
|
41
|
+
|
|
42
|
+
_this.setState({
|
|
43
|
+
formula: event.target.value
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
_this.renderFormula = function (formula) {
|
|
48
|
+
_this.formulaPreviewer.innerHTML = '';
|
|
49
|
+
var dom = window.MathJax.tex2svg(formula);
|
|
50
|
+
|
|
51
|
+
_this.formulaPreviewer.appendChild(dom);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
_this.handleSubmit = function (event) {
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
var formula = _this.state.formula;
|
|
57
|
+
|
|
58
|
+
if (_this.formulaNode) {
|
|
59
|
+
_this.editorUtils.setFormula({
|
|
60
|
+
formula: formula,
|
|
61
|
+
at: _this.formulaNode[1]
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
_this.editorUtils.onAddFormula({
|
|
65
|
+
formula: formula,
|
|
66
|
+
at: _this.editorSelection
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_this.props.toggleFormulaDialog();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
_this.editorUtils = new EditorUtils(window.editor);
|
|
74
|
+
_this.state = {
|
|
75
|
+
formula: ''
|
|
76
|
+
};
|
|
77
|
+
_this.formulaNode = null;
|
|
78
|
+
_this.editorSelection = null;
|
|
79
|
+
return _this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_createClass(AddFormulaDialog, [{
|
|
83
|
+
key: "componentDidMount",
|
|
84
|
+
value: function componentDidMount() {
|
|
85
|
+
this.editorSelection = window.editor.selection;
|
|
86
|
+
|
|
87
|
+
if (this.formulaNode) {
|
|
88
|
+
this.renderFormula(this.state.formula);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "componentWillMount",
|
|
93
|
+
value: function componentWillMount() {
|
|
94
|
+
this.setInitialValue();
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "render",
|
|
98
|
+
value: function render() {
|
|
99
|
+
var _this2 = this;
|
|
100
|
+
|
|
101
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
102
|
+
isOpen: true,
|
|
103
|
+
toggle: this.props.toggleFormulaDialog,
|
|
104
|
+
className: this.props.className
|
|
105
|
+
}, /*#__PURE__*/React.createElement(ModalHeader, {
|
|
106
|
+
toggle: this.props.toggleFormulaDialog
|
|
107
|
+
}, this.props.t('insert_formula')), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
108
|
+
className: "form-group"
|
|
109
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
110
|
+
className: "form-check-label"
|
|
111
|
+
}, this.props.t('formula')), /*#__PURE__*/React.createElement(Input, {
|
|
112
|
+
type: "textarea",
|
|
113
|
+
className: "form-control",
|
|
114
|
+
value: this.state.formula,
|
|
115
|
+
onChange: this.handleFormulaChange
|
|
116
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
117
|
+
ref: function ref(_ref) {
|
|
118
|
+
return _this2.formulaPreviewer = _ref;
|
|
119
|
+
},
|
|
120
|
+
className: "formula-preview"
|
|
121
|
+
}))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
122
|
+
color: "secondary",
|
|
123
|
+
onClick: this.props.toggleFormulaDialog
|
|
124
|
+
}, this.props.t('cancel')), /*#__PURE__*/React.createElement(Button, {
|
|
125
|
+
color: "primary",
|
|
126
|
+
disabled: false,
|
|
127
|
+
onClick: this.handleSubmit
|
|
128
|
+
}, this.props.t('insert_formula'))));
|
|
129
|
+
}
|
|
130
|
+
}]);
|
|
131
|
+
|
|
132
|
+
return AddFormulaDialog;
|
|
133
|
+
}(React.PureComponent);
|
|
134
|
+
|
|
135
|
+
export default withTranslation('seafile-editor')(AddFormulaDialog);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Form, FormGroup, Label, Input } from 'reactstrap';
|
|
7
|
+
import { withTranslation } from 'react-i18next';
|
|
8
|
+
|
|
9
|
+
var AddImageDialog = /*#__PURE__*/function (_React$PureComponent) {
|
|
10
|
+
_inherits(AddImageDialog, _React$PureComponent);
|
|
11
|
+
|
|
12
|
+
var _super = _createSuper(AddImageDialog);
|
|
13
|
+
|
|
14
|
+
function AddImageDialog(props) {
|
|
15
|
+
var _this;
|
|
16
|
+
|
|
17
|
+
_classCallCheck(this, AddImageDialog);
|
|
18
|
+
|
|
19
|
+
_this = _super.call(this, props);
|
|
20
|
+
|
|
21
|
+
_this.handleUrlChange = function (event) {
|
|
22
|
+
_this.setState({
|
|
23
|
+
url: event.target.value
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
_this.handleSubmit = function (event) {
|
|
28
|
+
_this.props.insertImage({
|
|
29
|
+
url: _this.state.url,
|
|
30
|
+
selection: _this.editorSelection
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
_this.props.onToggleImageDialog();
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
_this.state = {
|
|
37
|
+
url: ''
|
|
38
|
+
};
|
|
39
|
+
_this.editorSelection = null;
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_createClass(AddImageDialog, [{
|
|
44
|
+
key: "componentDidMount",
|
|
45
|
+
value: function componentDidMount() {
|
|
46
|
+
this.editorSelection = window.editor.selection;
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
key: "render",
|
|
50
|
+
value: function render() {
|
|
51
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
52
|
+
isOpen: true,
|
|
53
|
+
toggle: this.props.onToggleImageDialog,
|
|
54
|
+
className: this.props.className
|
|
55
|
+
}, /*#__PURE__*/React.createElement(ModalHeader, {
|
|
56
|
+
toggle: this.props.onToggleImageDialog
|
|
57
|
+
}, this.props.t('insert_image')), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(FormGroup, null, /*#__PURE__*/React.createElement(Label, {
|
|
58
|
+
for: "columnName"
|
|
59
|
+
}, this.props.t('image_address')), /*#__PURE__*/React.createElement(Input, {
|
|
60
|
+
id: "columnName",
|
|
61
|
+
value: this.state.value,
|
|
62
|
+
onChange: this.handleUrlChange,
|
|
63
|
+
autoFocus: true
|
|
64
|
+
})))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
65
|
+
color: "secondary",
|
|
66
|
+
onClick: this.props.onToggleImageDialog
|
|
67
|
+
}, this.props.t('cancel')), /*#__PURE__*/React.createElement(Button, {
|
|
68
|
+
color: "primary",
|
|
69
|
+
disabled: this.state.url.length === 0,
|
|
70
|
+
onClick: this.handleSubmit
|
|
71
|
+
}, this.props.t('submit')), ' '));
|
|
72
|
+
}
|
|
73
|
+
}]);
|
|
74
|
+
|
|
75
|
+
return AddImageDialog;
|
|
76
|
+
}(React.PureComponent);
|
|
77
|
+
|
|
78
|
+
export default withTranslation('seafile-editor')(AddImageDialog);
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React, { Fragment } from 'react';
|
|
6
|
+
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
|
7
|
+
import { withTranslation } from 'react-i18next';
|
|
8
|
+
import { EditorUtils } from '../editor/editor-utils/common-editor-utils';
|
|
9
|
+
|
|
10
|
+
var AddLinkDialog = /*#__PURE__*/function (_React$PureComponent) {
|
|
11
|
+
_inherits(AddLinkDialog, _React$PureComponent);
|
|
12
|
+
|
|
13
|
+
var _super = _createSuper(AddLinkDialog);
|
|
14
|
+
|
|
15
|
+
function AddLinkDialog(props) {
|
|
16
|
+
var _this;
|
|
17
|
+
|
|
18
|
+
_classCallCheck(this, AddLinkDialog);
|
|
19
|
+
|
|
20
|
+
_this = _super.call(this, props);
|
|
21
|
+
|
|
22
|
+
_this.setInitialValue = function () {
|
|
23
|
+
var text = _this.editorUtils.getSelectedText();
|
|
24
|
+
|
|
25
|
+
if (_this.isLinkActive) {
|
|
26
|
+
var linkNode = _this.editorUtils.getCurrentLinkNode();
|
|
27
|
+
|
|
28
|
+
_this.setState({
|
|
29
|
+
title: _this.editorUtils.getLinkText(linkNode),
|
|
30
|
+
url: linkNode.data.href
|
|
31
|
+
});
|
|
32
|
+
} else {
|
|
33
|
+
_this.setState({
|
|
34
|
+
title: text,
|
|
35
|
+
url: ''
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
_this.handleUrlChange = function (event) {
|
|
41
|
+
_this.setState({
|
|
42
|
+
url: event.target.value
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
_this.handleTitleChange = function (event) {
|
|
47
|
+
_this.setState({
|
|
48
|
+
title: event.target.value
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
_this.handleSubmit = function (event) {
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
if (_this.state.title.length === 0 || _this.state.url.length === 0) return;
|
|
55
|
+
|
|
56
|
+
if (!_this.isLinkActive) {
|
|
57
|
+
_this.editorUtils.insertLink({
|
|
58
|
+
text: _this.state.title,
|
|
59
|
+
url: _this.state.url,
|
|
60
|
+
selection: _this.editorSelection
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
_this.editorUtils.setLink({
|
|
64
|
+
text: _this.state.title,
|
|
65
|
+
url: _this.state.url,
|
|
66
|
+
selection: _this.editorSelection
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_this.props.toggleLinkDialog();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
_this.onKeyDown = function (e) {
|
|
74
|
+
if (e.keyCode === 13) {
|
|
75
|
+
_this.handleSubmit(e);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
_this.editorUtils = new EditorUtils(window.editor);
|
|
80
|
+
_this.isLinkActive = _this.editorUtils.isLinkActive();
|
|
81
|
+
_this.editorSelection = null;
|
|
82
|
+
_this.state = {
|
|
83
|
+
url: '',
|
|
84
|
+
title: ''
|
|
85
|
+
};
|
|
86
|
+
return _this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
_createClass(AddLinkDialog, [{
|
|
90
|
+
key: "componentDidMount",
|
|
91
|
+
value: function componentDidMount() {
|
|
92
|
+
this.editorSelection = window.editor.selection;
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "componentWillMount",
|
|
96
|
+
value: function componentWillMount() {
|
|
97
|
+
this.setInitialValue();
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "render",
|
|
101
|
+
value: function render() {
|
|
102
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
103
|
+
isOpen: true,
|
|
104
|
+
autoFocus: false,
|
|
105
|
+
toggle: this.props.toggleLinkDialog,
|
|
106
|
+
className: this.props.className
|
|
107
|
+
}, /*#__PURE__*/React.createElement(ModalHeader, {
|
|
108
|
+
toggle: this.props.toggleLinkDialog
|
|
109
|
+
}, this.props.t('insert_link')), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
110
|
+
className: "form-group"
|
|
111
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
112
|
+
className: "form-check-label",
|
|
113
|
+
htmlFor: "addLink"
|
|
114
|
+
}, this.props.t('link_address')), /*#__PURE__*/React.createElement("input", {
|
|
115
|
+
onKeyDown: this.onKeyDown,
|
|
116
|
+
autoFocus: true,
|
|
117
|
+
type: "url",
|
|
118
|
+
className: "form-control",
|
|
119
|
+
id: "addLink",
|
|
120
|
+
value: this.state.url,
|
|
121
|
+
onChange: this.handleUrlChange
|
|
122
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
123
|
+
className: "form-group"
|
|
124
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
125
|
+
className: "form-check-label",
|
|
126
|
+
htmlFor: "addTitle"
|
|
127
|
+
}, this.props.t('link_title')), /*#__PURE__*/React.createElement("input", {
|
|
128
|
+
onKeyDown: this.onKeyDown,
|
|
129
|
+
type: "text",
|
|
130
|
+
className: "form-control",
|
|
131
|
+
id: "addTitle",
|
|
132
|
+
value: this.state.title,
|
|
133
|
+
onChange: this.handleTitleChange
|
|
134
|
+
})))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
135
|
+
color: "secondary",
|
|
136
|
+
onClick: this.props.toggleLinkDialog
|
|
137
|
+
}, this.props.t('cancel')), /*#__PURE__*/React.createElement(Button, {
|
|
138
|
+
color: "primary",
|
|
139
|
+
disabled: false,
|
|
140
|
+
onClick: this.handleSubmit
|
|
141
|
+
}, this.props.t('add_link'))));
|
|
142
|
+
}
|
|
143
|
+
}]);
|
|
144
|
+
|
|
145
|
+
return AddLinkDialog;
|
|
146
|
+
}(React.PureComponent);
|
|
147
|
+
|
|
148
|
+
export default withTranslation('seafile-editor')(AddLinkDialog);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Button } from 'reactstrap';
|
|
7
|
+
import { processor } from '../utils/seafile-markdown2html';
|
|
8
|
+
|
|
9
|
+
var CommentDialog = /*#__PURE__*/function (_React$Component) {
|
|
10
|
+
_inherits(CommentDialog, _React$Component);
|
|
11
|
+
|
|
12
|
+
var _super = _createSuper(CommentDialog);
|
|
13
|
+
|
|
14
|
+
function CommentDialog(props) {
|
|
15
|
+
var _this;
|
|
16
|
+
|
|
17
|
+
_classCallCheck(this, CommentDialog);
|
|
18
|
+
|
|
19
|
+
_this = _super.call(this, props);
|
|
20
|
+
|
|
21
|
+
_this.handleCommentChange = function (event) {
|
|
22
|
+
var comment = event.target.value;
|
|
23
|
+
|
|
24
|
+
_this.setState({
|
|
25
|
+
comment: comment
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
_this.submitComment = function () {
|
|
30
|
+
var comment = _this.state.comment.trim();
|
|
31
|
+
|
|
32
|
+
if (comment.length > 0 && _this.props.quote.length > 0) {
|
|
33
|
+
var detail = {
|
|
34
|
+
quote: _this.props.quote,
|
|
35
|
+
position: _this.props.commentPosition
|
|
36
|
+
};
|
|
37
|
+
var detailJSON = JSON.stringify(detail);
|
|
38
|
+
|
|
39
|
+
_this.props.editorApi.postComment(comment, detailJSON).then(function (res) {
|
|
40
|
+
_this.props.onCommentAdded();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
_this.setQuoteText = function (mdQuote) {
|
|
46
|
+
processor.process(mdQuote).then(function (result) {
|
|
47
|
+
var quote = String(result);
|
|
48
|
+
|
|
49
|
+
_this.setState({
|
|
50
|
+
quote: quote
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
_this.state = {
|
|
56
|
+
comment: '',
|
|
57
|
+
quote: ''
|
|
58
|
+
};
|
|
59
|
+
return _this;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
_createClass(CommentDialog, [{
|
|
63
|
+
key: "componentDidMount",
|
|
64
|
+
value: function componentDidMount() {
|
|
65
|
+
this.setQuoteText(this.props.quote);
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
key: "componentWillReceiveProps",
|
|
69
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
70
|
+
if (this.props.quote !== nextProps.quote) {
|
|
71
|
+
this.setQuoteText(nextProps.quote);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "render",
|
|
76
|
+
value: function render() {
|
|
77
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: "comment-dialog"
|
|
79
|
+
}, /*#__PURE__*/React.createElement("div", null, this.props.editorApi.name), /*#__PURE__*/React.createElement("blockquote", {
|
|
80
|
+
className: "comment-dialog-quote"
|
|
81
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
dangerouslySetInnerHTML: {
|
|
83
|
+
__html: this.state.quote
|
|
84
|
+
}
|
|
85
|
+
})), /*#__PURE__*/React.createElement("textarea", {
|
|
86
|
+
value: this.state.comment,
|
|
87
|
+
onChange: this.handleCommentChange
|
|
88
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
89
|
+
className: "button-group"
|
|
90
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
91
|
+
size: "sm",
|
|
92
|
+
color: "primary",
|
|
93
|
+
onClick: this.submitComment
|
|
94
|
+
}, this.props.t('submit')), /*#__PURE__*/React.createElement(Button, {
|
|
95
|
+
size: "sm",
|
|
96
|
+
color: "secondary",
|
|
97
|
+
onClick: this.props.toggleCommentDialog
|
|
98
|
+
}, this.props.t('cancel'))), /*#__PURE__*/React.createElement("span", {
|
|
99
|
+
className: "comment-dialog-triangle"
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
}]);
|
|
103
|
+
|
|
104
|
+
return CommentDialog;
|
|
105
|
+
}(React.Component);
|
|
106
|
+
|
|
107
|
+
export default CommentDialog;
|