@seafile/sdoc-editor 0.1.36 → 0.1.38

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.
@@ -1,15 +1,16 @@
1
- .seafile-ed-hovermenu {
2
- width: 250px;
3
- height: 40px;
1
+ .link-op-menu {
2
+ height: 36px;
3
+ padding: 7px 8px;
4
4
  display: flex;
5
5
  position: absolute;
6
6
  background-color: #fff;
7
- border: 1px solid rgba(0, 40, 100, 0.12);
8
- box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
7
+ border: 1px solid #e5e5e5;
8
+ border-radius: 3px;
9
+ box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
9
10
  z-index: 1000;
10
11
  }
11
12
 
12
- .seafile-ed-hovermenu .seafile-ed-hovermenu-triangle {
13
+ .link-op-menu .link-op-menu-triangle {
13
14
  width: 8px;
14
15
  height: 8px;
15
16
  transform: rotate(45deg);
@@ -17,35 +18,46 @@
17
18
  border-right: 1px solid rgba(0, 40, 100, 0.12);
18
19
  border-bottom: 1px solid rgba(0, 40, 100, 0.12);
19
20
  position: absolute;
20
- top: 34px;
21
+ top: 31px;
21
22
  right: 50%;
22
23
  z-index: 1001;
23
24
  }
24
25
 
25
- .seafile-ed-hovermenu .seafile-ed-hovermenu-link {
26
- height: 38px;
27
- max-width: 170px;
28
- padding: 6px 12px;
29
- display: inline-block;
30
- line-height: 28px;
31
- overflow: hidden;
32
- cursor: pointer;
26
+ .link-op-menu-link {
27
+ font-size: 12px;
28
+ color: #212529;
29
+ padding: 0 5px;
30
+ border-radius: 2px;
33
31
  }
34
32
 
35
- .seafile-ed-hovermenu .seafile-ed-hovermenu-btn {
36
- background-color: #fff;
37
- width: 35px;
38
- font-weight: normal;
33
+ .link-op-menu-link:hover {
34
+ color: #212529;
35
+ text-decoration: none;
36
+ background: #f1f1f1;
37
+ }
38
+
39
+ .link-op-icons {
40
+ margin-left: 8px;
41
+ border-left: 1px solid #e5e5e5;
42
+ }
43
+
44
+ .link-op-icon {
39
45
  color: #999999;
40
- line-height: 26px;
41
- font-size: 16px;
46
+ padding: 4px;
47
+ border-radius: 2px;
48
+ margin-left: 8px;
49
+ display: flex;
50
+ align-items: center;
51
+ }
52
+
53
+ .link-op-icon .iconfont {
54
+ font-size: 12px;
42
55
  }
43
56
 
44
- .seafile-ed-hovermenu .seafile-ed-hovermenu-btn, .seafile-ed-hovermenu .seafile-ed-hovermenu-btn:focus {
45
- border: 0;
46
- box-shadow: 0;
57
+ .link-op-icon:hover {
58
+ background: #f1f1f1;
47
59
  }
48
60
 
49
61
  .seafile-ed-hovermenu-mouseclick {
50
- background-color: #ddd;
62
+ background-color: #e5e5e5;
51
63
  }
@@ -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 { createPortal } from 'react-dom';
7
+ import { withTranslation } from 'react-i18next';
7
8
  import '../../../../assets/css/textlink-hovermenu.css';
8
9
  var LinkHoverComponent = /*#__PURE__*/function (_React$Component) {
9
10
  _inherits(LinkHoverComponent, _React$Component);
@@ -17,33 +18,36 @@ var LinkHoverComponent = /*#__PURE__*/function (_React$Component) {
17
18
  value: function render() {
18
19
  var _this$props = this.props,
19
20
  menuPosition = _this$props.menuPosition,
20
- href = _this$props.href;
21
+ href = _this$props.href,
22
+ t = _this$props.t;
21
23
  return /*#__PURE__*/React.createElement(React.Fragment, null, createPortal( /*#__PURE__*/React.createElement("div", {
22
- id: "loading",
23
- className: "seafile-ed-hovermenu",
24
+ id: "link-op-menu",
25
+ className: "link-op-menu",
24
26
  style: menuPosition
25
27
  }, /*#__PURE__*/React.createElement("a", {
26
28
  href: href,
27
29
  target: "_blank",
28
30
  rel: "noopener noreferrer",
29
- className: "seafile-ed-hovermenu-link"
30
- }, href), /*#__PURE__*/React.createElement("button", {
31
- color: "",
32
- className: "seafile-ed-hovermenu-btn",
31
+ className: "link-op-menu-link"
32
+ }, t('Open_link')), /*#__PURE__*/React.createElement("div", {
33
+ className: "link-op-icons d-flex"
34
+ }, /*#__PURE__*/React.createElement("span", {
35
+ role: "button",
36
+ className: "link-op-icon",
33
37
  onClick: this.props.onDeleteLink
34
38
  }, /*#__PURE__*/React.createElement("i", {
35
39
  className: "iconfont icon-delete"
36
- })), /*#__PURE__*/React.createElement("button", {
37
- color: "",
38
- className: "seafile-ed-hovermenu-btn",
40
+ })), /*#__PURE__*/React.createElement("span", {
41
+ role: "button",
42
+ className: "link-op-icon",
39
43
  onClick: this.props.onEditLink
40
44
  }, /*#__PURE__*/React.createElement("i", {
41
- className: "iconfont icon-edit"
42
- })), /*#__PURE__*/React.createElement("span", {
43
- className: "seafile-ed-hovermenu-triangle"
45
+ className: "iconfont icon-edit2"
46
+ }))), /*#__PURE__*/React.createElement("span", {
47
+ className: "link-op-menu-triangle"
44
48
  })), document.body));
45
49
  }
46
50
  }]);
47
51
  return LinkHoverComponent;
48
52
  }(React.Component);
49
- export default LinkHoverComponent;
53
+ export default withTranslation('sdoc-editor')(LinkHoverComponent);
@@ -27,14 +27,16 @@ var LinkHoverMenuComponent = /*#__PURE__*/function (_React$Component) {
27
27
  });
28
28
  };
29
29
  _this.onLinkClick = function (e) {
30
+ e.stopPropagation();
31
+ e.nativeEvent.stopImmediatePropagation();
30
32
  var _e$target$getBounding = e.target.getBoundingClientRect(),
31
33
  top = _e$target$getBounding.top,
32
34
  left = _e$target$getBounding.left,
33
35
  width = _e$target$getBounding.width;
34
36
  // top = top distance - menu height
35
- var menuTop = top - 50;
37
+ var menuTop = top - 42;
36
38
  // left = left distance - (menu width / 2) + (link with / 2)
37
- var menuLeft = left - 250 / 2 + width / 2;
39
+ var menuLeft = left - 140 / 2 + width / 2;
38
40
  _this.setState({
39
41
  isShowLinkMenu: true,
40
42
  menuPosition: {
@@ -1,5 +1,7 @@
1
+ import withTextStyle from './plugin';
1
2
  import renderText from "./render-elem";
2
3
  var TextPlugin = {
4
+ editorPlugin: withTextStyle,
3
5
  renderElements: [renderText]
4
6
  };
5
7
  export default TextPlugin;
@@ -0,0 +1,23 @@
1
+ import { getValue, isMenuDisabled, addMark, removeMark } from './helpers';
2
+ var withTextStyle = function withTextStyle(editor) {
3
+ var toggleTextStyle = function toggleTextStyle(type) {
4
+ var isDisabled = isMenuDisabled(editor);
5
+ if (isDisabled) {
6
+ return false;
7
+ }
8
+ var isActive = !!getValue(editor, type);
9
+ if (isActive) {
10
+ removeMark(editor, type);
11
+ } else {
12
+ addMark(editor, type);
13
+ }
14
+ };
15
+ editor.toggleTextBold = function () {
16
+ toggleTextStyle('BOLD');
17
+ };
18
+ editor.toggleTextItalic = function () {
19
+ toggleTextStyle('ITALIC');
20
+ };
21
+ return editor;
22
+ };
23
+ export default withTextStyle;
@@ -6,6 +6,43 @@ var EventProxy = /*#__PURE__*/_createClass(function EventProxy(_editor) {
6
6
  _classCallCheck(this, EventProxy);
7
7
  this.onKeyDown = function (event) {
8
8
  var editor = _this.editor;
9
+
10
+ // bold
11
+ if (isHotkey('mod+b', event)) {
12
+ event.preventDefault();
13
+ editor.toggleTextBold();
14
+ }
15
+
16
+ // italic
17
+ if (isHotkey('mod+i', event)) {
18
+ event.preventDefault();
19
+ editor.toggleTextItalic();
20
+ }
21
+
22
+ // disable the default 'save page'
23
+ if (isHotkey('mod+s', event)) {
24
+ event.preventDefault();
25
+ }
26
+
27
+ // redo
28
+ if (isHotkey('mod+y', event)) {
29
+ event.preventDefault();
30
+ var history = editor.history;
31
+ if (history.redos.length === 0) {
32
+ return false;
33
+ }
34
+ editor.redo();
35
+ }
36
+
37
+ // undo
38
+ if (isHotkey('mod+z', event)) {
39
+ event.preventDefault();
40
+ var _history = editor.history;
41
+ if (_history.undos.length === 0) {
42
+ return false;
43
+ }
44
+ editor.undo();
45
+ }
9
46
  if (isHotkey('tab', event) || isHotkey('shift+tab', event)) {
10
47
  editor.handleTab && editor.handleTab(event);
11
48
  }
@@ -4,7 +4,6 @@ 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 isHotkey from 'is-hotkey';
8
7
  import editor, { renderLeaf as _renderLeaf, renderElement as _renderElement } from './extension';
9
8
  import { SocketManager, withSocketIO } from './socket';
10
9
  import withNodeId from './node-id';
@@ -69,12 +68,7 @@ var SDocViewer = /*#__PURE__*/function (_React$Component) {
69
68
  renderLeaf: function renderLeaf(props) {
70
69
  return _renderLeaf(props, _this2.editor);
71
70
  },
72
- onDOMBeforeInput: function onDOMBeforeInput(event) {},
73
- onKeyDown: function onKeyDown(event) {
74
- if (isHotkey('tab', event) || isHotkey('shift+tab', event)) {
75
- editor.handleTab && editor.handleTab(event);
76
- }
77
- }
71
+ onDOMBeforeInput: function onDOMBeforeInput(event) {}
78
72
  }))))));
79
73
  }
80
74
  }]);
@@ -29,13 +29,14 @@ var DocInfo = /*#__PURE__*/function (_React$Component) {
29
29
  value: function render() {
30
30
  var t = this.props.t;
31
31
  var docName = context.getSetting('docName');
32
+ var isShowInternalLink = context.getSetting('isShowInternalLink');
32
33
  return /*#__PURE__*/React.createElement("div", {
33
34
  className: "doc-info"
34
35
  }, /*#__PURE__*/React.createElement("div", {
35
36
  className: "doc-name"
36
37
  }, docName), /*#__PURE__*/React.createElement("span", {
37
38
  className: "doc-icon"
38
- }, /*#__PURE__*/React.createElement("span", {
39
+ }, isShowInternalLink && /*#__PURE__*/React.createElement("span", {
39
40
  className: "internal-link iconfont icon-link",
40
41
  title: t('internal_link'),
41
42
  onClick: this.onInternalLinkClick
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.36",
3
+ "version": "0.1.38",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -19,7 +19,7 @@
19
19
  "insert_file": "Insert File",
20
20
  "code": "Inline Code",
21
21
  "code_block": "Code Block",
22
- "insert_link": "Insert Link",
22
+ "insert_link": "Insert link",
23
23
  "insert_table": "Insert Table",
24
24
  "save": "Save",
25
25
  "more": "More",
@@ -238,5 +238,6 @@
238
238
  "Headings_you_add_to_the_document_will_appear_here": "Headings you add to the document will appear here",
239
239
  "Open_parent_folder": "Open parent folder",
240
240
  "redo": "redo",
241
- "undo": "undo"
241
+ "undo": "undo",
242
+ "Open_link": "Open link"
242
243
  }
@@ -14,6 +14,8 @@
14
14
  />
15
15
  <missing-glyph />
16
16
 
17
+ <glyph glyph-name="rename" unicode="&#58949;" d="M467.2 41.6h105.6V-64H467.2V41.6z m192 0H768V-64H662.4V41.6z m195.2 0H960V-64H854.4V41.6zM156.8 224c-9.6-9.6-16-25.6-19.2-38.4L67.2-25.6c-3.2-9.6 0-25.6 6.4-32 6.4-6.4 19.2-9.6 32-6.4l211.2 70.4c12.8 3.2 28.8 9.6 38.4 19.2l457.6 457.6-198.4 198.4L156.8 224z m777.6 387.2c32 32 28.8 105.6-12.8 150.4l-16 16-16 12.8c-44.8 44.8-121.6 48-153.6 16l-48-48L886.4 560l48 51.2z" horiz-adv-x="1024" />
18
+
17
19
  <glyph glyph-name="revoke" unicode="&#58947;" d="M380.8 438.4c0-41.6-51.2-67.2-86.4-41.6L57.6 550.4c-32 19.2-32 64 0 83.2l236.8 153.6c35.2 25.6 86.4 0 86.4-41.6v-92.8H672c41.6 0 83.2-9.6 121.6-25.6 38.4-16 70.4-38.4 99.2-70.4 28.8-28.8 51.2-64 67.2-102.4 16-38.4 25.6-83.2 25.6-124.8s-6.4-96-22.4-134.4c-16-38.4-38.4-73.6-67.2-102.4-32-28.8-64-51.2-102.4-67.2-38.4-16-80-25.6-121.6-25.6H243.2c-32 0-60.8 28.8-60.8 64s25.6 64 60.8 64H672c105.6 0 188.8 96 188.8 204.8S777.6 528 672 528H380.8v-89.6z" horiz-adv-x="1024" />
18
20
 
19
21
  <glyph glyph-name="redo" unicode="&#58948;" d="M643.2 438.4c0-41.6 51.2-67.2 86.4-41.6l236.8 153.6c32 19.2 32 64 0 83.2L729.6 787.2c-35.2 25.6-86.4 0-86.4-41.6v-92.8H352c-41.6 0-83.2-9.6-121.6-25.6-38.4-16-70.4-38.4-99.2-70.4C102.4 528 80 492.8 64 454.4 48 416 38.4 371.2 38.4 329.6s6.4-96 22.4-134.4c16-38.4 38.4-73.6 67.2-102.4 32-28.8 64-51.2 102.4-67.2 38.4-16 80-25.6 121.6-25.6h428.8c32 0 60.8 28.8 60.8 64s-25.6 64-60.8 64H352c-105.6 0-188.8 96-188.8 204.8S246.4 528 352 528h291.2v-89.6z" horiz-adv-x="1024" />
@@ -16,6 +16,10 @@
16
16
  -moz-osx-font-smoothing: grayscale;
17
17
  }
18
18
 
19
+ .icon-edit2:before {
20
+ content: "\e645";
21
+ }
22
+
19
23
  .icon-revoke:before {
20
24
  content: "\e643";
21
25
  }