@seafile/seafile-editor 0.3.100 → 0.3.103-lj-test-1

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 (36) hide show
  1. package/README.md +42 -110
  2. package/dist/assets/css/topbar.css +31 -125
  3. package/dist/components/outline/index.js +13 -0
  4. package/dist/config-0.js +15 -0
  5. package/dist/config.js +16 -0
  6. package/dist/editor/index.js +4 -4
  7. package/dist/index.js +1 -1
  8. package/dist/utils/slate2markdown/serialize.js +12 -1
  9. package/dist/viewer/markdown-viewer.js +7 -3
  10. package/dist/viewer/slate-viewer.js +31 -4
  11. package/package.json +15 -6
  12. package/dist/_i18n/index.js +0 -20
  13. package/dist/assets/css/index.css +0 -97
  14. package/dist/assets/editor/rich-editor.css +0 -104
  15. package/dist/assets/rich-editor/document-info.css +0 -57
  16. package/dist/editor/rich-markdown-editor.js +0 -442
  17. package/dist/editor-api.js +0 -256
  18. package/dist/example/assets/css/comments-list.css +0 -139
  19. package/dist/example/assets/css/detail-list-view.css +0 -105
  20. package/dist/example/assets/css/participants-list.css +0 -22
  21. package/dist/example/assets/css/react-mentions-default-style.js +0 -76
  22. package/dist/example/assets/css/seafile-editor-main.css +0 -125
  23. package/dist/example/assets/css/seafile-editor-side.css +0 -89
  24. package/dist/example/assets/css/side-panel.css +0 -81
  25. package/dist/example/components/comment-panel.js +0 -437
  26. package/dist/example/components/detail-list-view.js +0 -104
  27. package/dist/example/components/participants-list.js +0 -126
  28. package/dist/example/components/side-panel.js +0 -172
  29. package/dist/example/seafile-editor.js +0 -137
  30. package/dist/index.local.js +0 -58
  31. package/dist/pages/seafile-editor/index.js +0 -38
  32. package/dist/pages/seafile-editor/seafile-editor.js +0 -309
  33. package/dist/pages/seafile-editor-chooser.js +0 -45
  34. package/dist/pages/seafile-markdown-editor.js +0 -289
  35. package/dist/pages/seafile-markdown-viewer.js +0 -78
  36. package/dist/pages/seafile-simple-editor.js +0 -59
package/README.md CHANGED
@@ -1,119 +1,51 @@
1
- This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
1
+ # Seafile-editor
2
2
 
3
- ## Folder Structure
3
+ 项目是基于 react-slate 组件库的二次封装, 用于满足公司富文本编辑器的使用需求
4
4
 
5
- After creation, your project should look like this:
5
+ ## 目录结构
6
6
 
7
7
  ```
8
8
  seafile-editor/
9
- README.md
10
- node_modules/
11
- package.json
12
- public/
13
- index.html
9
+ dist // 打包后的文件
10
+ node_modules/ // 依赖第三方组件库
11
+ public/ // 公共资源文件库
12
+ index.html
14
13
  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
14
+ site(demo 模块, 基于组件库创建的测试模块)
15
+ _i18n // 国际化模块
16
+ api // api 模块
17
+ assets // css 文件, 图片文件
18
+ commons // 公共组件
19
+ components // 应用组件
20
+ containers // 容器组件
21
+ pages // 页面组件
22
+ app.js // 应用对象
23
+ index.html // 主页
24
+ index.js // 应用入口
25
+ setting.js // 应用配置文件
26
+ setting.local.dist.js // 应用配置模版
27
+ setting.local.dist // 用户基于 setting.local.dist.js copy 一份的配置文件
28
+ src/(组件库)
29
+ assets // css 文件, 资源文件
30
+ components // 封装的视图组件
31
+ editor // 封装的编辑器组件
32
+ lib // 底层接口
33
+ utils // 工具接口
34
+ viewer // 封装的视图组件
35
+ index.js // 组件库导出内容入口文件
36
+ tests // 测试
37
+ webpack // site 打包文件
38
+ config.js // site 打包配置文件
39
+ dev-server.js // site 后端服务器
40
+ package.json
41
+ readme.md // 组件库说明文档
75
42
  ```
76
43
 
44
+ ## 本地测试步骤
45
+ 1. 新增本地配置文件 setting.local.js(基于 /site/setting.local.dist.js copy 一份)
46
+ 2. 在 seahub 项目创建一个测试文件, 根据需要的配置信息完善配置内容
47
+ 3. 执行 npm run start, 启动测试服务, 可以打开相应的网址, 对封装的组件进行测试
77
48
 
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).
49
+ ## 新版本发布
50
+ 1. 更新 package.json 中的 version 属性
51
+ 2. 执行 npm publish 完成新版本发布
@@ -1,29 +1,3 @@
1
- .seafile-btn-view-review {
2
- display: flex;
3
- align-items: center;
4
- }
5
-
6
- .seafile-btn-view-review .tag:hover {
7
- cursor: pointer;
8
- }
9
-
10
- .topbar-btn-container {
11
- display: flex;
12
- align-items: center;
13
- }
14
-
15
- .seafile-btn-add-review {
16
- margin-right: 10px;
17
- }
18
-
19
- .btn-new-draft {
20
- margin-right: 10px;
21
- }
22
-
23
- .collab-users-dropdown.dropdown {
24
- margin-right: 6px;
25
- }
26
-
27
1
  .sf-editor-toolbar {
28
2
  height: 39px;
29
3
  background-color: #fcfcfc;
@@ -43,6 +17,19 @@
43
17
  transform: scale(0.8);
44
18
  }
45
19
 
20
+ /* reset menu style*/
21
+ .sf-editor-toolbar .menu > * {
22
+ display: inline-block;
23
+ }
24
+
25
+ .sf-editor-toolbar .menu > * + * {
26
+ margin-left: 10px;
27
+ }
28
+
29
+ .sf-editor-toolbar .menu {
30
+ margin-right: 20px;
31
+ }
32
+
46
33
  .seafile-btn-group div button {
47
34
  border: none;
48
35
  }
@@ -68,15 +55,6 @@
68
55
  border-color: #e5e5e5;
69
56
  }
70
57
 
71
- /*topbar style*/
72
- .menu > * {
73
- display: inline-block;
74
- }
75
-
76
- .menu > * + * {
77
- margin-left: 10px;
78
- }
79
-
80
58
  .btn-active {
81
59
  color: #0c0c0c;
82
60
  cursor: pointer;
@@ -89,11 +67,18 @@
89
67
  .btn-active[data-active='true'] {
90
68
  color: #eb8205;
91
69
  }
70
+
92
71
  .tableToolBar {
93
72
  font-size: 12px;
94
73
  display: inline-flex;
95
74
  }
96
75
 
76
+ .tableToolBar:after {
77
+ content: '';
78
+ display: block;
79
+ clear: both;
80
+ }
81
+
97
82
  .tableToolBar div .symbol {
98
83
  font-size: 14px;
99
84
  }
@@ -102,10 +87,15 @@
102
87
  color: #555555;
103
88
  }
104
89
 
105
- .tableToolBar:after {
106
- content: '';
107
- display: block;
108
- clear: both;
90
+ .tableToolBar div:not(first):not(.drop-list) {
91
+ /*display: inline-block;*/
92
+ margin-left:10px;
93
+ }
94
+
95
+ .tableToolBar .table-toolbar-btn {
96
+ line-height: 28px;
97
+ padding: 0 15px;
98
+ height: 30px;
109
99
  }
110
100
 
111
101
  .table-toolbar-group {
@@ -116,11 +106,6 @@
116
106
  padding-right: 10px;
117
107
  }
118
108
 
119
- .tableToolBar div:not(first):not(.drop-list) {
120
- /*display: inline-block;*/
121
- margin-left:10px;
122
- }
123
-
124
109
  .sf-editor-table-btn-wrapper {
125
110
  position: relative;
126
111
  }
@@ -173,12 +158,6 @@
173
158
  background-color: #ffa94d;
174
159
  }
175
160
 
176
- /*topbar style*/
177
-
178
- .menu {
179
- margin-right: 20px;
180
- }
181
-
182
161
  .rich-menu {
183
162
  flex: 1;
184
163
  display: flex;
@@ -198,11 +177,6 @@
198
177
  padding: 4px 10px;
199
178
  }
200
179
 
201
- .editor-info {
202
- display: flex;
203
- align-items: center;
204
- }
205
-
206
180
  .button-container {
207
181
  height: 100%;
208
182
  display: flex;
@@ -258,11 +232,11 @@
258
232
  padding: 0 3px;
259
233
  }
260
234
 
261
-
262
235
  .list-body div {
263
236
  display: inline-block;
264
237
  line-height: 30px;
265
238
  }
239
+
266
240
  .header-list-container .list-dropdown {
267
241
  position: absolute;
268
242
  left: 0;
@@ -311,72 +285,6 @@
311
285
  color: #555555;
312
286
  }
313
287
 
314
- .tableToolBar .table-toolbar-btn {
315
- line-height: 28px;
316
- padding: 0 15px;
317
- height: 30px;
318
- }
319
-
320
- .file-go-back {
321
- display: inline-block;
322
- font-size: 28px;
323
- color: #c0c0c0;
324
- margin-right: 8px;
325
- }
326
- .file-go-back:hover {
327
- cursor: pointer;
328
- }
329
- .file-go-back i {
330
- vertical-align: 5px;
331
- }
332
-
333
- .topbar-file-info {
334
- display: inline-block;
335
- margin-left: 8px;
336
- /*
337
- only select file info text
338
- */
339
- user-select: text;
340
- }
341
- .topbar-file-info .file-title {
342
- font-size: 1.2rem;
343
- font-weight: bold;
344
- }
345
-
346
- .topbar-file-info .file-title .iconfont {
347
- font-size: 0.875rem;
348
- }
349
-
350
- .file-title .file-star,
351
- .file-title .file-internal-link {
352
- font-size: 0.875rem;
353
- cursor: pointer;
354
- margin-left: 0.5rem;
355
- vertical-align: text-bottom;
356
- color: #999;
357
- }
358
-
359
- .file-title .file-star .star {
360
- color: #999;
361
- }
362
-
363
- .topbar-file-info .file-state .file-modifier-name {
364
- margin-right: 0.5rem;
365
- }
366
-
367
- .topbar-file-info .file-state .file-modifier-savedraft {
368
- margin-left: 0.5rem;
369
- color: #888;
370
- }
371
-
372
- .topbar-file-info .file-state {
373
- font-size: 0.8125rem;
374
- }
375
-
376
- .file-internal-link:hover {
377
- color: #333;
378
- }
379
-
380
288
  p.tip {
381
289
  color: #bbb;
382
290
  }
@@ -407,6 +315,7 @@ p.tip {
407
315
  background-color: #e5e5e5;
408
316
  border-radius: 3px;
409
317
  }
318
+
410
319
  .custom-dropdown-list .custom-dropdown-menu {
411
320
  position: absolute;
412
321
  left: 0;
@@ -420,9 +329,6 @@ p.tip {
420
329
  .seafile-md-viewer-main-panel {
421
330
  margin: 0 2%;
422
331
  }
423
- .topbar-file-info .file-title {
424
- min-width: 150px;
425
- }
426
332
  .rich-menu {
427
333
  overflow-x: auto;
428
334
  }
@@ -21,6 +21,13 @@ var OutlineView = /*#__PURE__*/function (_React$PureComponent) {
21
21
  _this = _super.call(this, props);
22
22
 
23
23
  _this.scrollToNode = function (node) {
24
+ // wiki module
25
+ if (_this.props.scrollToNode) {
26
+ _this.props.scrollToNode(node);
27
+
28
+ return;
29
+ }
30
+
24
31
  var editorRef = EditorBuilder.getEditorRef();
25
32
  editorRef.scrollToNode(node);
26
33
  };
@@ -37,6 +44,12 @@ var OutlineView = /*#__PURE__*/function (_React$PureComponent) {
37
44
 
38
45
  _this.setState({
39
46
  headerList: headerList
47
+ }, function () {
48
+ var updateForNoOutline = _this.props.updateForNoOutline;
49
+
50
+ if (headerList.length == 0 && updateForNoOutline) {
51
+ updateForNoOutline();
52
+ }
40
53
  });
41
54
  };
42
55
 
@@ -0,0 +1,15 @@
1
+ var serverConfig = {
2
+ serviceUrl: "https://download.seafile.top",
3
+ username: "xxx",
4
+ password: "xxx",
5
+ repoID: "xxxxxxx-xxxx-xxx-xxx-xxxx",
6
+ userInfo: {
7
+ username: 'xxx',
8
+ name: 'xxx',
9
+ contact_email: 'xxxx'
10
+ },
11
+ filePath: '/demo.md',
12
+ fileName: 'demo.md',
13
+ dirPath: '/'
14
+ };
15
+ export { serverConfig };
package/dist/config.js ADDED
@@ -0,0 +1,16 @@
1
+ var serverConfig = {
2
+ //serviceUrl: "http://127.0.0.1:8000",
3
+ serviceUrl: "http://192.168.1.100:8000",
4
+ username: "lj@11.com",
5
+ password: "11",
6
+ repoID: "79d1fa93-4b5f-4d6c-8fb5-ad3958e1fa47",
7
+ userInfo: {
8
+ username: 'lj@11.com',
9
+ name: 'lj-',
10
+ contact_email: 'lj@11.com'
11
+ },
12
+ filePath: '/xxx.md',
13
+ fileName: 'xxx.md',
14
+ dirPath: '/'
15
+ };
16
+ export { serverConfig };
@@ -3,11 +3,11 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
- import MarkdownEditor from "./markdown-editor";
7
- import SimpleEditor from "./simple-editor";
8
- import PlainMarkdownEditor from "./plain-markdown-editor";
6
+ import MarkdownEditor from './markdown-editor';
7
+ import SimpleEditor from './simple-editor';
8
+ import PlainMarkdownEditor from './plain-markdown-editor';
9
9
  import LoadScript from './load-script';
10
- import EditorBuilder from "./editor-builder";
10
+ import EditorBuilder from './editor-builder';
11
11
 
12
12
  var SimpleEditorWithErrorBoundary = /*#__PURE__*/function (_React$Component) {
13
13
  _inherits(SimpleEditorWithErrorBoundary, _React$Component);
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import DiffViewer from './viewer/diff-viewer';
2
2
  import MarkdownViewer from './viewer/markdown-viewer';
3
- import { deserialize, serialize } from "./utils/slate2markdown";
3
+ import { deserialize, serialize } from './utils/slate2markdown';
4
4
  import { processor } from './utils/seafile-markdown2html';
5
5
  import { EditorBuilder, MarkdownEditor, SimpleEditor, PlainMarkdownEditor } from './editor';
6
6
  import Toolbar from './components/toolbar';
@@ -17,6 +17,17 @@ var processor = unified().use(stringify, {
17
17
  fences: true
18
18
  }).use(math);
19
19
 
20
+ function _getCodeValue(node) {
21
+ // code > bold | code > italic
22
+ // code > bold > italic | code > italic > italic
23
+ if (node && node.children) {
24
+ node = node.children[0];
25
+ return _getCodeValue(node);
26
+ }
27
+
28
+ return node.value;
29
+ }
30
+
20
31
  function _applyMark(node, markString) {
21
32
  switch (markString) {
22
33
  case 'BOLD':
@@ -34,7 +45,7 @@ function _applyMark(node, markString) {
34
45
  case 'CODE':
35
46
  return {
36
47
  type: 'inlineCode',
37
- value: node.value
48
+ value: _getCodeValue(node)
38
49
  };
39
50
 
40
51
  default:
@@ -97,7 +97,8 @@ var MarkdownViewer = /*#__PURE__*/function (_React$Component) {
97
97
  var _this$props = this.props,
98
98
  scriptSource = _this$props.scriptSource,
99
99
  showTOC = _this$props.showTOC,
100
- activeTitleIndex = _this$props.activeTitleIndex;
100
+ activeTitleIndex = _this$props.activeTitleIndex,
101
+ updateForNoOutline = _this$props.updateForNoOutline;
101
102
 
102
103
  if (scriptSource) {
103
104
  return /*#__PURE__*/React.createElement(LoadScript, {
@@ -109,7 +110,9 @@ var MarkdownViewer = /*#__PURE__*/function (_React$Component) {
109
110
  }, /*#__PURE__*/React.createElement(OutlineView, {
110
111
  document: value,
111
112
  isViewer: true,
112
- activeTitleIndex: activeTitleIndex
113
+ activeTitleIndex: activeTitleIndex,
114
+ scrollToNode: this.scrollToNode,
115
+ updateForNoOutline: updateForNoOutline
113
116
  })));
114
117
  }
115
118
 
@@ -120,7 +123,8 @@ var MarkdownViewer = /*#__PURE__*/function (_React$Component) {
120
123
  }, /*#__PURE__*/React.createElement(OutlineView, {
121
124
  document: value,
122
125
  isViewer: true,
123
- activeTitleIndex: activeTitleIndex
126
+ activeTitleIndex: activeTitleIndex,
127
+ scrollToNode: this.scrollToNode
124
128
  })));
125
129
  }
126
130
  }]);
@@ -4,6 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import { Editable, Slate } from '@seafile/slate-react';
7
+ import { Editor } from 'slate';
7
8
  import { decorationNode } from '../editor/editor-utils/common-editor-utils';
8
9
  import { renderNode, renderLeaf } from '../utils/render-slate';
9
10
  import EditorBuilder from '../editor/editor-builder';
@@ -20,15 +21,39 @@ var SlateViewer = /*#__PURE__*/function (_React$Component) {
20
21
  _classCallCheck(this, SlateViewer);
21
22
 
22
23
  _this = _super.call(this, props);
24
+
25
+ _this.onChange = function () {// nothing todo
26
+ };
27
+
28
+ _this.scrollToNode = function (node) {
29
+ var editor = document.querySelector('.viewer-component');
30
+ var element = editor.childNodes[node.path[0]];
31
+
32
+ _this.editorContainerRef.scrollTo(0, element.offsetTop);
33
+
34
+ window.location.hash = encodeURI(node.children[0].text);
35
+ Editor.select(_this.editor, node.path);
36
+ };
37
+
38
+ _this.setEditorContainerRef = function (ref) {
39
+ _this.editorContainerRef = ref;
40
+ };
41
+
23
42
  _this.editor = EditorBuilder.getSlateEditor();
24
43
  window.viewer = _this.editor;
25
44
  return _this;
26
45
  }
27
46
 
28
47
  _createClass(SlateViewer, [{
48
+ key: "componentDidMount",
49
+ value: function componentDidMount() {
50
+ window.abcdef_editor = this;
51
+ }
52
+ }, {
29
53
  key: "componentWillUnmount",
30
54
  value: function componentWillUnmount() {
31
55
  EditorBuilder.resetEditor();
56
+ window.abcdef_editor = null;
32
57
  }
33
58
  }, {
34
59
  key: "render",
@@ -37,11 +62,13 @@ var SlateViewer = /*#__PURE__*/function (_React$Component) {
37
62
  value = _this$props.value,
38
63
  renderDiffElement = _this$props.renderDiffElement,
39
64
  renderDiffLeaf = _this$props.renderDiffLeaf;
40
- return /*#__PURE__*/React.createElement("div", {
41
- className: "article"
42
- }, /*#__PURE__*/React.createElement(Slate, {
65
+ return /*#__PURE__*/React.createElement(Slate, {
43
66
  editor: this.editor,
44
- value: value
67
+ value: value,
68
+ onChange: this.onChange
69
+ }, /*#__PURE__*/React.createElement("div", {
70
+ className: "article",
71
+ ref: this.setEditorContainerRef
45
72
  }, /*#__PURE__*/React.createElement(Editable, {
46
73
  readOnly: true,
47
74
  className: 'viewer-component',