@seafile/seafile-editor 0.4.7 → 0.4.8

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.
@@ -2,7 +2,7 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  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
- import React, { Children } from 'react';
5
+ import React from 'react';
6
6
  var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
7
7
  _inherits(ErrorBoundary, _React$Component);
8
8
  var _super = _createSuper(ErrorBoundary);
@@ -1,4 +1,4 @@
1
- import * as React from "react";
1
+ import * as React from 'react';
2
2
  var CheckMarkIcon = function CheckMarkIcon(props) {
3
3
  return /*#__PURE__*/React.createElement("svg", Object.assign({
4
4
  className: "icon",
@@ -1,13 +1,13 @@
1
- import * as React from "react";
1
+ import * as React from 'react';
2
2
  var ColumnIcon = function ColumnIcon(props) {
3
3
  return /*#__PURE__*/React.createElement("svg", Object.assign({
4
4
  xmlns: "http://www.w3.org/2000/svg",
5
5
  viewBox: "0 0 32 32",
6
6
  style: {
7
- enableBackground: "new 0 0 32 32"
7
+ enableBackground: 'new 0 0 32 32'
8
8
  },
9
9
  xmlSpace: "preserve"
10
- }, props), /*#__PURE__*/React.createElement("title", null, "insert-column"), /*#__PURE__*/React.createElement("path", {
10
+ }, props), /*#__PURE__*/React.createElement("title", null, 'insert-column'), /*#__PURE__*/React.createElement("path", {
11
11
  d: "m19.4 14.3 12 6.7-4.5 1.3 2.2 4.7c.5.8.2 1.9-.5 2.5-.8.5-1.8.5-2.5-.2L22 25l-3.5 3.2.9-13.9zM14.5 23c.3 0 .5.2.5.5v4c0 .3-.2.5-.5.5h-13c-.3 0-.5-.2-.5-.5v-4c0-.3.2-.5.5-.5h13zm2-10c.3 0 .5.2.5.5v4c0 .3-.2.5-.5.5h-15c-.3 0-.5-.2-.5-.5v-4c0-.3.2-.5.5-.5h15zm13-10c.3 0 .5.2.5.5v4c0 .3-.2.5-.5.5h-28c-.3 0-.5-.2-.5-.5v-4c0-.3.2-.5.5-.5h28z",
12
12
  style: {
13
13
  fill: props.color
@@ -1,4 +1,4 @@
1
- import * as React from "react";
1
+ import * as React from 'react';
2
2
  var TextIcon = function TextIcon(props) {
3
3
  return /*#__PURE__*/React.createElement("svg", Object.assign({
4
4
  id: "\\u56FE\\u5C42_1",
@@ -7,10 +7,10 @@ var TextIcon = function TextIcon(props) {
7
7
  y: 0,
8
8
  viewBox: "0 0 32 32",
9
9
  style: {
10
- enableBackground: "new 0 0 32 32"
10
+ enableBackground: 'new 0 0 32 32'
11
11
  },
12
12
  xmlSpace: "preserve"
13
- }, props), /*#__PURE__*/React.createElement("title", null, "text-style"), /*#__PURE__*/React.createElement("g", {
13
+ }, props), /*#__PURE__*/React.createElement("title", null, 'text-style'), /*#__PURE__*/React.createElement("g", {
14
14
  id: "text-style"
15
15
  }, /*#__PURE__*/React.createElement("g", {
16
16
  id: "\\u5B57\\u4F53\\u6837\\u5F0F",
package/dist/config.js ADDED
@@ -0,0 +1,15 @@
1
+ var serverConfig = {
2
+ serviceUrl: 'dhttps://dev.seafile.com/seahub',
3
+ username: 'bing.an@seafile.com',
4
+ password: 'Seafile123#$%',
5
+ repoID: '66ffac5c-9cce-4738-a867-bb8931821e04',
6
+ userInfo: {
7
+ username: 'bing.an@seafile.com',
8
+ name: '安冰',
9
+ contact_email: 'bing.an@seafile.com'
10
+ },
11
+ filePath: '/测试.md',
12
+ fileName: '测试.md',
13
+ dirPath: '/'
14
+ };
15
+ export { serverConfig };
@@ -1,5 +1,5 @@
1
- import withBlock from "./block-element-controller";
2
- import withVoid from "./void-element-controller";
3
- import withMarkdownShortcut from "./shortcut-controller";
4
- import withInline from "./inline-element-controller";
1
+ import withBlock from './block-element-controller';
2
+ import withVoid from './void-element-controller';
3
+ import withMarkdownShortcut from './shortcut-controller';
4
+ import withInline from './inline-element-controller';
5
5
  export { withBlock, withInline, withMarkdownShortcut, withVoid };
@@ -5,15 +5,13 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
6
  import React, { Fragment } from 'react';
7
7
  import { withTranslation } from 'react-i18next';
8
- import { Node, Editor, Range } from 'slate';
9
- import { Editable, Slate, ReactEditor } from '@seafile/slate-react';
8
+ import { Node, Editor } from 'slate';
9
+ import { Editable, Slate } from '@seafile/slate-react';
10
10
  import toaster from '../components/toast';
11
11
  import ModalPortal from '../components/modal-portal';
12
12
  import ContextMenu from '../components/context-menu';
13
13
  import TextLinkHoverMenu from '../components/text-link-hover-menu';
14
- import CommentDialog from '../components/dialogs/comment-dialog';
15
14
  import AddLinkDialog from '../components/dialogs/add-link-dialog';
16
- import { serialize } from '../utils/slate2markdown/index';
17
15
  import { isRangeCollapsed } from '../containers/editor-utils/range-utils';
18
16
  import { renderNode, renderLeaf, decorationNode } from '../containers/render-utils/editor-utils';
19
17
  import EditorContext from '../containers/editor-context';
@@ -38,57 +36,11 @@ var MarkdownEditor = /*#__PURE__*/function (_React$Component) {
38
36
  }
39
37
  return node;
40
38
  };
41
- _this.updateCommentBtnPosition = function () {
42
- if (!_this.props.isSupportComment) return;
43
- if (_this.timer) return;
44
- _this.timer = setTimeout(function () {
45
- var selection = _this.editor.selection;
46
- if (!selection || Range.isCollapsed(selection)) {
47
- var _style = _this.commentRef.style;
48
- _style.top = '-1000px';
49
- clearTimeout(_this.timer);
50
- _this.timer = null;
51
- return;
52
- }
53
- var focusNodePath = selection.anchor.path.slice();
54
- focusNodePath.pop();
55
- var focusNode = _this.getDomNodeByPath(focusNodePath);
56
- var style = _this.commentRef.style;
57
- style.right = '40px';
58
- if (focusNode) {
59
- style.top = "".concat(focusNode.offsetTop, "px");
60
- } else {
61
- style.top = '-1000px';
62
- }
63
- clearTimeout(_this.timer);
64
- _this.timer = null;
65
- }, 40);
66
- };
67
- _this.onCommentAdded = function () {
68
- _this.toggleCommentDialog();
69
- _this.props.onAddComment && _this.props.onAddComment();
70
- };
71
- _this.addComment = function (e) {
72
- e.stopPropagation();
73
- _this.getQuote();
74
- _this.toggleCommentDialog();
75
- };
76
- _this.toggleCommentDialog = function () {
77
- _this.setState({
78
- showCommentDialog: !_this.state.showCommentDialog
79
- });
80
- };
81
39
  _this.onToggleLinkDialog = function () {
82
40
  _this.setState({
83
41
  isShowLinkDialog: !_this.state.isShowLinkDialog
84
42
  });
85
43
  };
86
- _this.getQuote = function () {
87
- _this.quote = serialize(Editor.fragment(_this.editor, _this.editor.selection));
88
- _this.setState({
89
- commentPosition: _this.editor.selection.anchor.path
90
- });
91
- };
92
44
  _this.onChange = function (value) {
93
45
  _this.setState({
94
46
  value: value
@@ -125,14 +77,6 @@ var MarkdownEditor = /*#__PURE__*/function (_React$Component) {
125
77
  selection: selection
126
78
  });
127
79
  };
128
- _this.scrollToQuote = function (path) {
129
- if (!path) return;
130
- var editor = _this.editor;
131
- var node = editor.children[path[0]];
132
- var element = ReactEditor.toDOMNode(editor, node);
133
- _this.editorContainerRef.scrollTo(0, element.offsetTop);
134
- Editor.select(_this.editor, path);
135
- };
136
80
  _this.scrollToNode = function (node) {
137
81
  var editor = document.querySelector('.editor-component');
138
82
  var element = editor.childNodes[node.path[0]];
@@ -161,9 +105,6 @@ var MarkdownEditor = /*#__PURE__*/function (_React$Component) {
161
105
  });
162
106
  }
163
107
  };
164
- _this.setCommentRef = function (ref) {
165
- _this.commentRef = ref;
166
- };
167
108
  _this.setEditorRef = function (ref) {
168
109
  _this.editorRef = ref;
169
110
  };
@@ -173,8 +114,6 @@ var MarkdownEditor = /*#__PURE__*/function (_React$Component) {
173
114
  _this.state = {
174
115
  value: props.value,
175
116
  isShowContextMenu: false,
176
- showCommentDialog: false,
177
- commentPosition: null,
178
117
  isShowLinkDialog: false
179
118
  };
180
119
  _this.editor = EditorContext.getEditor(props);
@@ -220,10 +159,7 @@ var MarkdownEditor = /*#__PURE__*/function (_React$Component) {
220
159
  key: "render",
221
160
  value: function render() {
222
161
  var editor = this.editor;
223
- var _this$state = this.state,
224
- value = _this$state.value,
225
- commentPosition = _this$state.commentPosition;
226
- var addCommentClass = 'iconfont icon-plus-square seafile-viewer-comment-btn';
162
+ var value = this.state.value;
227
163
 
228
164
  // link detail message
229
165
  var toolbarStatus = this.editorUtils.getToolbarStatus();
@@ -250,25 +186,15 @@ var MarkdownEditor = /*#__PURE__*/function (_React$Component) {
250
186
  onCut: this.onCut,
251
187
  onCopy: this.onCopy,
252
188
  onKeyDown: this.onKeyDown,
253
- onSelect: this.updateCommentBtnPosition,
189
+ onSelect: function onSelect() {},
254
190
  onContextMenu: this.onContextMenu
255
- }), /*#__PURE__*/React.createElement("i", {
256
- className: addCommentClass,
257
- ref: this.setCommentRef,
258
- onMouseDown: this.addComment
259
191
  })))), /*#__PURE__*/React.createElement(Fragment, null, toolbarStatus.isLinkActive && selectionCollapsed && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(TextLinkHoverMenu, {
260
192
  onToggleLinkDialog: this.onToggleLinkDialog,
261
193
  editorUtils: this.editorUtils
262
194
  })), this.state.isShowContextMenu && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(ContextMenu, {
263
195
  tableUtils: this.tableUtils,
264
196
  contextMenuPosition: this.contextMenuPosition
265
- })), this.state.showCommentDialog && /*#__PURE__*/React.createElement(CommentDialog, {
266
- quote: this.quote,
267
- editorApi: this.editor.editorApi,
268
- commentPosition: commentPosition,
269
- onCommentAdded: this.onCommentAdded,
270
- toggleCommentDialog: this.toggleCommentDialog
271
- }), this.state.isShowLinkDialog && /*#__PURE__*/React.createElement(AddLinkDialog, {
197
+ })), this.state.isShowLinkDialog && /*#__PURE__*/React.createElement(AddLinkDialog, {
272
198
  toggleLinkDialog: this.onToggleLinkDialog
273
199
  })));
274
200
  }
@@ -0,0 +1,14 @@
1
+ export default {
2
+ serviceUrl: 'https://dev.seafile.com/seahub',
3
+ username: 'bing.an@seafile.com',
4
+ password: 'Seafile123#$%',
5
+ name: '安冰',
6
+ contact_email: 'bing.an@seafile.com',
7
+ lib_name: '1',
8
+ repoID: '1284f468-d4fe-4046-a119-669b3d49cb71',
9
+ seafileCollabServer: 'https://dev.seafile.com/',
10
+ dirPath: '/',
11
+ filePath: '/readme.md',
12
+ fileName: 'readme.md'
13
+ // scriptSource: ''
14
+ };
@@ -37,8 +37,8 @@ export var replaceColumnData = function replaceColumnData(mdNodes, columns, getC
37
37
  // change column node to text node
38
38
  var newNode = {
39
39
  'text': value,
40
- "BOLD": data.bold,
41
- "ITALIC": data.italic
40
+ 'BOLD': data.bold,
41
+ 'ITALIC': data.italic
42
42
  };
43
43
  mdNodes.splice(i, 1, newNode);
44
44
  return 1; // continue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "private": false,
5
5
  "description": "This is a custom markdown editor",
6
6
  "main": "dist/index.js",
@@ -118,7 +118,6 @@
118
118
  "react-dom": "16.14.0",
119
119
  "react-hot-loader": "4.13.1",
120
120
  "react-i18next": "12.1.4",
121
- "react-mentions": "4.4.7",
122
121
  "resolve": "1.12.0",
123
122
  "resolve-url-loader": "3.1.5",
124
123
  "sass-loader": "7.2.0",
@@ -1,50 +0,0 @@
1
- .seafile-editor-comment.comment-dialog {
2
- width: 500px;
3
- position: absolute;
4
- top: 30%;
5
- right: 0;
6
- padding: 15px;
7
- background-color: #fafafa;
8
- border: 1px solid rgba(0,0,0,.2);
9
- border-radius: .3rem;
10
- box-shadow: 0 0 3px #ccc;
11
- z-index: 1000;
12
- }
13
-
14
- .seafile-editor-comment.comment-dialog .comment-dialog-triangle {
15
- position: absolute;
16
- left: -5px;
17
- top: 50%;
18
- transform: rotate(45deg);
19
- border: 1px solid rgba(0,0,0,.2);
20
- border-top: none;
21
- border-right: none;
22
- width: 10px;
23
- height: 10px;
24
- background-color: #fafafa;
25
- box-shadow: -1px 1px #ccc;
26
- }
27
-
28
- .seafile-editor-comment.comment-dialog textarea {
29
- width: 100%;
30
- min-height: 100px;
31
- max-height: 300px;
32
- padding: 5px;
33
- background-color: #fff;
34
- }
35
-
36
- .seafile-editor-comment.comment-dialog .button-group .btn {
37
- margin-right: 10px;
38
- }
39
-
40
- .seafile-editor-comment.comment-dialog .comment-dialog-quote {
41
- margin-top: 10px;
42
- max-height: 6rem;
43
- overflow: auto;
44
- padding-left: 1rem;
45
- }
46
-
47
- .seafile-editor-comment.comment-dialog .comment-dialog-quote ul,
48
- .seafile-editor-comment.comment-dialog .comment-dialog-quote ol {
49
- padding-left: 1rem;
50
- }
@@ -1,43 +0,0 @@
1
- .issue-container {
2
- width: 100%;
3
- padding: 0 10px 10px 10px;
4
- margin-top: -10px;
5
- }
6
-
7
- .issue-card {
8
- background-color: #fff;
9
- border: 1px solid rgba(0, 40, 100, 0.12);
10
- border-radius: 5px;
11
- padding-left: 5px;
12
- margin-top: 10px;
13
- position: relative;
14
- word-break: break-word;
15
- box-shadow: 0 5px 5px -2px rgba(200,200,200, 0.5);
16
- }
17
-
18
- .issue-card:before {
19
- position: absolute;
20
- left: 0;
21
- top: 0;
22
- bottom: 0;
23
- width: 3px;
24
- content: '';
25
- background-color: rgb(217, 130, 43);
26
- border-radius: 3px 0 0 3px;
27
- }
28
- .issue-card-title {
29
- font-size: 16px;
30
- padding: 5px 10px 3px 10px;
31
- }
32
-
33
- .issue-card-description {
34
- padding: 0 10px 5px 10px;
35
- color: #aaa;
36
- }
37
-
38
- .size-panel-no-content {
39
- width: 100%;
40
- text-align: center;
41
- color: #9a9a9a;
42
- padding-top: 10px;
43
- }
@@ -1,97 +0,0 @@
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 { withTranslation } from 'react-i18next';
7
- import { Button } from 'reactstrap';
8
- import { processor } from '../../utils/seafile-markdown2html';
9
- import '../../assets/css/comment-dialog.css';
10
- var CommentDialog = /*#__PURE__*/function (_React$Component) {
11
- _inherits(CommentDialog, _React$Component);
12
- var _super = _createSuper(CommentDialog);
13
- function CommentDialog(props) {
14
- var _this;
15
- _classCallCheck(this, CommentDialog);
16
- _this = _super.call(this, props);
17
- _this.handleCommentChange = function (event) {
18
- var comment = event.target.value;
19
- _this.setState({
20
- comment: comment
21
- });
22
- };
23
- _this.submitComment = function () {
24
- var comment = _this.state.comment.trim();
25
- if (comment.length > 0 && _this.props.quote.length > 0) {
26
- var detail = {
27
- quote: _this.props.quote,
28
- position: _this.props.commentPosition
29
- };
30
- var detailJSON = JSON.stringify(detail);
31
- _this.props.editorApi.postComment(comment, detailJSON).then(function (res) {
32
- _this.props.onCommentAdded();
33
- });
34
- }
35
- };
36
- _this.setQuoteText = function (mdQuote) {
37
- processor.process(mdQuote).then(function (result) {
38
- var quote = String(result);
39
- _this.setState({
40
- quote: quote
41
- });
42
- });
43
- };
44
- _this.state = {
45
- comment: '',
46
- quote: ''
47
- };
48
- return _this;
49
- }
50
- _createClass(CommentDialog, [{
51
- key: "componentDidMount",
52
- value: function componentDidMount() {
53
- this.setQuoteText(this.props.quote);
54
- }
55
- }, {
56
- key: "componentWillReceiveProps",
57
- value: function componentWillReceiveProps(nextProps) {
58
- if (this.props.quote !== nextProps.quote) {
59
- this.setQuoteText(nextProps.quote);
60
- }
61
- }
62
- }, {
63
- key: "render",
64
- value: function render() {
65
- var t = this.props.t;
66
- var _this$state = this.state,
67
- comment = _this$state.comment,
68
- quote = _this$state.quote;
69
- return /*#__PURE__*/React.createElement("div", {
70
- className: "seafile-editor-comment comment-dialog"
71
- }, /*#__PURE__*/React.createElement("div", null, this.props.editorApi.name), /*#__PURE__*/React.createElement("blockquote", {
72
- className: "comment-dialog-quote"
73
- }, /*#__PURE__*/React.createElement("div", {
74
- dangerouslySetInnerHTML: {
75
- __html: quote
76
- }
77
- })), /*#__PURE__*/React.createElement("textarea", {
78
- value: comment,
79
- onChange: this.handleCommentChange
80
- }), /*#__PURE__*/React.createElement("div", {
81
- className: "button-group"
82
- }, /*#__PURE__*/React.createElement(Button, {
83
- size: "sm",
84
- color: "primary",
85
- onClick: this.submitComment
86
- }, t('submit')), /*#__PURE__*/React.createElement(Button, {
87
- size: "sm",
88
- color: "secondary",
89
- onClick: this.props.toggleCommentDialog
90
- }, t('cancel'))), /*#__PURE__*/React.createElement("span", {
91
- className: "comment-dialog-triangle"
92
- }));
93
- }
94
- }]);
95
- return CommentDialog;
96
- }(React.Component);
97
- export default withTranslation('seafile-editor')(CommentDialog);
@@ -1,72 +0,0 @@
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 '../assets/css/issue-card.css';
7
- var MarkdownLint = /*#__PURE__*/function (_React$PureComponent) {
8
- _inherits(MarkdownLint, _React$PureComponent);
9
- var _super = _createSuper(MarkdownLint);
10
- function MarkdownLint() {
11
- var _this;
12
- _classCallCheck(this, MarkdownLint);
13
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
14
- args[_key] = arguments[_key];
15
- }
16
- _this = _super.call.apply(_super, [this].concat(args));
17
- _this.onClickCard = function (event, key) {
18
- if (_this.props.document[key]) {
19
- var node = _this.props.document[key];
20
- node.key = key;
21
- _this.props.scrollToNode(node);
22
- }
23
- };
24
- return _this;
25
- }
26
- _createClass(MarkdownLint, [{
27
- key: "render",
28
- value: function render() {
29
- var _this2 = this;
30
- var issueCards = [];
31
- if (this.props.issues.issue_list.length > 0) {
32
- this.props.issues.issue_list.map(function (issue, index) {
33
- if (issue.detail) {
34
- issue.detail.map(function (detail, detailIndex) {
35
- var card = /*#__PURE__*/React.createElement("div", {
36
- key: 'issue-' + index + '-' + detailIndex,
37
- onClick: function onClick(event) {
38
- _this2.onClickCard(event, detail.position);
39
- },
40
- className: 'issue-card'
41
- }, /*#__PURE__*/React.createElement("div", {
42
- className: 'issue-card-title'
43
- }, _this2.props.markdownLint[issue.issue_code].issue), /*#__PURE__*/React.createElement("div", {
44
- className: 'issue-card-description'
45
- }, _this2.props.markdownLint[issue.issue_code].description));
46
- issueCards.push(card);
47
- return true;
48
- });
49
- } else {
50
- var card = /*#__PURE__*/React.createElement("div", {
51
- key: 'issue-' + index,
52
- className: 'issue-card'
53
- }, /*#__PURE__*/React.createElement("div", {
54
- className: 'issue-card-title'
55
- }, _this2.props.markdownLint[issue.issue_code].issue), /*#__PURE__*/React.createElement("div", {
56
- className: 'issue-card-description'
57
- }, _this2.props.markdownLint[issue.issue_code].description));
58
- issueCards.push(card);
59
- }
60
- return true;
61
- });
62
- }
63
- return /*#__PURE__*/React.createElement("div", {
64
- className: 'issue-container'
65
- }, issueCards.length > 0 ? issueCards : /*#__PURE__*/React.createElement("div", {
66
- className: 'size-panel-no-content'
67
- }, this.props.t('no_document_improvement_suggestion')));
68
- }
69
- }]);
70
- return MarkdownLint;
71
- }(React.PureComponent);
72
- export default MarkdownLint;