@seafile/seafile-editor 1.0.115 → 1.0.117-alpha.0

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.
@@ -5,16 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.INTERNAL_EVENTS = exports.EXTERNAL_EVENTS = void 0;
7
7
  const INTERNAL_EVENTS = exports.INTERNAL_EVENTS = {
8
- ON_ARTICLE_INFO_TOGGLE: 'on_article_info_toggle',
9
8
  ON_MOUSE_ENTER_BLOCK: 'on_mouse_enter_block',
10
9
  ON_OPEN_LINK_MODAL: 'on_open_link_modal',
11
10
  ON_CLOSE_LINK_POPOVER: 'on_close_link_popover',
12
11
  ON_OPEN_FORMULA_DIALOG: 'on_open_formula_dialog',
13
12
  ON_SELECT_ALL_CELL: 'on_select_all_cell',
14
- ON_TOGGLE_IMAGE_POPOVER: 'on_toggle_image_popover'
13
+ ON_TOGGLE_IMAGE_POPOVER: 'on_toggle_image_popover',
14
+ OUTLINE_STATE_CHANGED: 'outline_state_changed'
15
15
  };
16
16
  const EXTERNAL_EVENTS = exports.EXTERNAL_EVENTS = {
17
17
  ON_HELP_INFO_TOGGLE: 'on_help_info_toggle',
18
+ ON_ARTICLE_INFO_TOGGLE: 'on_article_info_toggle',
18
19
  ON_LINK_CLICK: 'on_link_click',
19
20
  ON_INSERT_IMAGE: 'on_insert_image',
20
21
  INSERT_IMAGE: 'insert_image'
@@ -9,46 +9,95 @@ exports.default = ArticleInfo;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _outline = _interopRequireDefault(require("../outline"));
11
11
  var _slateReact = require("slate-react");
12
+ var _resizeWidth = _interopRequireDefault(require("./resize-width"));
12
13
  require("./style.css");
13
14
  const TAB_TYPES = {
14
- OUTLINE: 'outline',
15
+ // OUTLINE: 'outline',
15
16
  FILE_DETAIL: 'file_detail'
16
17
  };
18
+ const MIN_PANEL_WIDTH = 360;
19
+ const MAX_PANEL_WIDTH = 620;
20
+
21
+ // const { fileName } = window.app.pageOptions;
22
+
17
23
  function ArticleInfo(_ref) {
18
24
  let {
19
25
  children
20
26
  } = _ref;
21
27
  const editor = (0, _slateReact.useSlateStatic)();
22
28
  const [activeTab, setActiveTab] = (0, _react.useState)(TAB_TYPES.OUTLINE);
23
- const onOutlineClick = (0, _react.useCallback)(() => {
24
- if (activeTab === TAB_TYPES.OUTLINE) return;
25
- setActiveTab(TAB_TYPES.OUTLINE);
26
- }, [activeTab]);
29
+ const [width, setWidth] = (0, _react.useState)(MIN_PANEL_WIDTH);
30
+ const [isShown, setIsShown] = (0, _react.useState)(true);
31
+ // const onOutlineClick = useCallback(() => {
32
+ // if (activeTab === TAB_TYPES.OUTLINE) return;
33
+ // setActiveTab(TAB_TYPES.OUTLINE);
34
+ // }, [activeTab]);
35
+
27
36
  const onDetailClick = (0, _react.useCallback)(() => {
28
37
  if (activeTab === TAB_TYPES.FILE_DETAIL) return;
29
38
  setActiveTab(TAB_TYPES.FILE_DETAIL);
30
39
  }, [activeTab]);
40
+ const containerWrapperStyle = (0, _react.useMemo)(() => {
41
+ let style = {
42
+ width,
43
+ zIndex: 101
44
+ };
45
+ if (!style.width || style.width < MIN_PANEL_WIDTH) {
46
+ style.width = MIN_PANEL_WIDTH;
47
+ } else if (style.width > MAX_PANEL_WIDTH) {
48
+ style.width = MAX_PANEL_WIDTH;
49
+ }
50
+ console.log('final wid', style);
51
+ return style;
52
+ }, [width]);
53
+ const resizeWidth = (0, _react.useCallback)(width => {
54
+ console.log(width);
55
+ setWidth(width);
56
+ }, []);
57
+ const resizeWidthEnd = (0, _react.useCallback)(width => {
58
+ const panelWidth = JSON.parse(window.localStorage.getItem('sf-editor-panel-width') || '{}');
59
+ console.log("panelwidth", panelWidth);
60
+ window.localStorage.setItem('sf-editor-panel-width', JSON.stringify({
61
+ ...panelWidth,
62
+ width
63
+ }));
64
+ }, []);
65
+ (0, _react.useEffect)(() => {
66
+ const panelWidth = JSON.parse(window.localStorage.getItem('sf-editor-panel-width', '{}')) || {};
67
+ const width = Math.max(MIN_PANEL_WIDTH, Math.min(parseInt(panelWidth.width) || MAX_PANEL_WIDTH, MAX_PANEL_WIDTH));
68
+ console.log("wid", width);
69
+ setWidth(width);
70
+ }, []);
71
+ const onClose = () => {
72
+ setIsShown(false);
73
+ };
31
74
  return /*#__PURE__*/_react.default.createElement("div", {
75
+ className: "sf-article-info-container-wrapper",
76
+ style: containerWrapperStyle
77
+ }, /*#__PURE__*/_react.default.createElement(_resizeWidth.default, {
78
+ minWidth: MIN_PANEL_WIDTH,
79
+ maxWidth: MAX_PANEL_WIDTH,
80
+ resizeWidth: resizeWidth,
81
+ resizeWidthEnd: resizeWidthEnd
82
+ }), isShown && /*#__PURE__*/_react.default.createElement("div", {
32
83
  className: "sf-article-info-container"
33
- }, /*#__PURE__*/_react.default.createElement("ul", {
84
+ }, /*#__PURE__*/_react.default.createElement("div", {
85
+ className: "detail-header"
86
+ }, /*#__PURE__*/_react.default.createElement("div", {
87
+ className: "detail-title dirent-title"
88
+ })), /*#__PURE__*/_react.default.createElement("ul", {
34
89
  className: "sf-article-info-nav nav"
35
90
  }, /*#__PURE__*/_react.default.createElement("li", {
36
91
  className: "nav-item"
37
- }, /*#__PURE__*/_react.default.createElement("span", {
38
- className: "nav-link ".concat(activeTab === TAB_TYPES.OUTLINE && 'active'),
39
- onClick: onOutlineClick
40
- }, /*#__PURE__*/_react.default.createElement("i", {
41
- className: "iconfont icon-list-ul"
42
- }))), /*#__PURE__*/_react.default.createElement("li", {
43
- className: "nav-item"
44
92
  }, /*#__PURE__*/_react.default.createElement("span", {
45
93
  className: "nav-link ".concat(activeTab === TAB_TYPES.FILE_DETAIL && 'active'),
46
94
  onClick: onDetailClick
47
95
  }, /*#__PURE__*/_react.default.createElement("i", {
48
96
  className: 'iconfont icon-info-circle'
49
- })))), /*#__PURE__*/_react.default.createElement("div", {
97
+ })), /*#__PURE__*/_react.default.createElement("span", {
98
+ className: "iconfont icon-x",
99
+ onClick: onClose
100
+ }))), /*#__PURE__*/_react.default.createElement("div", {
50
101
  className: "sf-article-info-content"
51
- }, activeTab === TAB_TYPES.OUTLINE && /*#__PURE__*/_react.default.createElement(_outline.default, {
52
- editor: editor
53
- }), activeTab === TAB_TYPES.FILE_DETAIL && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children)));
102
+ }, activeTab === TAB_TYPES.FILE_DETAIL && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children))));
54
103
  }
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ require("./style.css");
10
+ const ResizeWidth = _ref => {
11
+ let {
12
+ minWidth,
13
+ maxWidth,
14
+ resizeWidth: resizeWidthAPI,
15
+ resizeWidthEnd
16
+ } = _ref;
17
+ const [isShowHandlerBar, setIsShowHandlerBar] = (0, _react.useState)(false);
18
+ const [drag, setDrag] = (0, _react.useState)(null);
19
+ const handlerRef = (0, _react.useRef)(null);
20
+ const handlerBarRef = (0, _react.useRef)(null);
21
+ const setHandlerBarTop = handlerTop => {
22
+ if (!handlerBarRef.current || handlerTop < 0) return;
23
+ handlerBarRef.current.style.top = handlerTop + 'px';
24
+ };
25
+ const setHandlerBarPosition = event => {
26
+ if (!handlerRef.current) return;
27
+ const {
28
+ top
29
+ } = handlerRef.current.getBoundingClientRect();
30
+ const handlerTop = event.pageY - top - 26 / 2;
31
+ setHandlerBarTop(handlerTop);
32
+ };
33
+ const getWidthFromMouseEvent = event => {
34
+ return event.pageX || event.touches && event.touches[0] && event.touches[0].pageX || event.changedTouches && event.changedTouches[event.changedTouches.length - 1].pageX;
35
+ };
36
+ const calculateResizedWidth = event => {
37
+ const width = getWidthFromMouseEvent(event);
38
+ const resizedWidth = document.body.clientWidth - width;
39
+ if (minWidth && resizedWidth < minWidth || maxWidth && resizedWidth > maxWidth) return -1;
40
+ return resizedWidth;
41
+ };
42
+ const onResizeWidth = event => {
43
+ const resizedWidth = calculateResizedWidth(event);
44
+ if (resizedWidth < 0) return;
45
+ if (resizeWidthAPI) {
46
+ resizeWidthAPI(resizedWidth);
47
+ }
48
+ };
49
+ const onDrag = event => {
50
+ onResizeWidth(event);
51
+ };
52
+ const onDragStart = (0, _react.useCallback)(event => {
53
+ if (event && event.dataTransfer && event.dataTransfer.setData) {
54
+ event.dataTransfer.setData('text/plain', 'dummy');
55
+ }
56
+ }, []);
57
+ const onDragEnd = event => {
58
+ onResizeWidth(event);
59
+ };
60
+ const onMouseLeave = () => {
61
+ setIsShowHandlerBar(false);
62
+ };
63
+ const onMouseEnter = event => {
64
+ setIsShowHandlerBar(true);
65
+ setHandlerBarPosition(event);
66
+ if (handlerRef.current) {
67
+ handlerRef.current.addEventListener('mouseleave', onMouseLeave);
68
+ }
69
+ };
70
+ const onMouseOver = event => {
71
+ setHandlerBarPosition(event);
72
+ };
73
+ const onMouseDown = event => {
74
+ event.preventDefault && event.preventDefault();
75
+ const currDrag = onDragStart(event);
76
+ if (currDrag === null && event.button !== 0) return;
77
+ window.addEventListener('mouseup', onMouseUp);
78
+ window.addEventListener('mousemove', onMouseMove);
79
+ if (handlerRef.current) {
80
+ handlerRef.current.removeEventListener('mouseleave', onMouseLeave);
81
+ }
82
+ setDrag(currDrag);
83
+ };
84
+ const onMouseMove = event => {
85
+ event.preventDefault && event.preventDefault();
86
+ // if (!drag === null) return;
87
+ if (!drag) return;
88
+ onDrag(event);
89
+ };
90
+ const onMouseUp = event => {
91
+ window.removeEventListener('mouseup', onMouseUp);
92
+ window.removeEventListener('mousemove', onMouseMove);
93
+ onDragEnd(event, drag);
94
+ setHandlerBarTop(-9999);
95
+ setDrag(null);
96
+ setIsShowHandlerBar(false);
97
+ if (resizeWidthEnd) {
98
+ const resizeWidth = calculateResizedWidth(event);
99
+ if (resizeWidth < 0) return;
100
+ resizeWidthEnd(resizeWidth);
101
+ }
102
+ };
103
+ (0, _react.useEffect)(() => {
104
+ return () => {
105
+ window.removeEventListener('mouseup', onMouseUp);
106
+ window.removeEventListener('mousemove', onMouseMove);
107
+ };
108
+
109
+ // eslint-disable-next-line
110
+ }, []);
111
+ return /*#__PURE__*/_react.default.createElement("div", {
112
+ className: "sf-editor-resize-width-handler resize-handler-placement-right",
113
+ ref: handlerRef,
114
+ onMouseDown: onMouseDown,
115
+ onMouseOver: onMouseOver,
116
+ onMouseEnter: onMouseEnter,
117
+ onDrag: onDrag,
118
+ onDragStart: onDragStart,
119
+ onDragEnd: onDragEnd,
120
+ style: {
121
+ zIndex: 4
122
+ }
123
+ }, /*#__PURE__*/_react.default.createElement("div", {
124
+ className: "sf-editor-resize-width-handler-content"
125
+ }, isShowHandlerBar && /*#__PURE__*/_react.default.createElement("div", {
126
+ className: "sf-editor-resize-width-handler-bar",
127
+ ref: handlerBarRef,
128
+ style: {
129
+ height: 26
130
+ }
131
+ })));
132
+ };
133
+ var _default = exports.default = ResizeWidth;
@@ -0,0 +1,38 @@
1
+ .sf-editor-resize-width-handler {
2
+ height: 100%;
3
+ position: absolute;
4
+ right: 0;
5
+ top: 0;
6
+ width: 6px;
7
+ }
8
+
9
+ .sf-editor-resize-width-handler.resize-handler-placement-right {
10
+ left: 0;
11
+ right: auto;
12
+ }
13
+
14
+ .sf-editor-resize-width-handler:hover {
15
+ cursor: col-resize;
16
+ }
17
+
18
+ .sf-editor-resize-width-handler .sf-editor-resize-width-handler-content {
19
+ background-color: initial;
20
+ height: 100%;
21
+ position: relative;
22
+ width: 2px;
23
+ }
24
+
25
+ .sf-editor-resize-width-handler:hover .sf-editor-resize-width-handler-content {
26
+ background-color: #ccc;
27
+ }
28
+
29
+ .sf-editor-resize-width-handler .sf-editor-resize-width-handler-bar {
30
+ background-color: #2d7ff9;
31
+ border-radius: 3px;
32
+ content: "";
33
+ left: 50%;
34
+ margin-left: -3px;
35
+ position: absolute;
36
+ width: 6px;
37
+ }
38
+
@@ -1,15 +1,35 @@
1
+ .sf-article-info-container-wrapper {
2
+ display: flex;
3
+ flex-direction: row;
4
+ max-width: 620px;
5
+ min-width: 360px;
6
+ position: relative;
7
+ flex-basis: 620px;
8
+ /* width: 100% !important; */
9
+ /* height: 100vh; */
10
+ }
11
+
1
12
  .sf-article-info-container {
2
13
  flex: 1;
3
- display: flex;
14
+ /* display: flex;
4
15
  flex-direction: column;
5
16
  background-color: #f5f5f5;
6
17
  user-select: none;
7
18
  min-height: 0;
19
+ width: 100%;
20
+ height: 100%;
21
+ /* overflow: hidden; */
22
+ /* border-left: 1px solid #d8d8d8; */
23
+ width: auto;
24
+ height: 100%;
25
+ overflow: hidden;
26
+ border-left: 1px solid #d8d8d8;
8
27
  }
9
28
 
10
29
  .sf-article-info-container .nav {
11
30
  padding: 10px 0;
12
- min-width: 125px;
31
+ /* min-width: 125px; */
32
+ width: auto;
13
33
  height: 36px;
14
34
  border-bottom: 1px solid #eee;
15
35
  background-color: #fff;
@@ -52,3 +72,51 @@
52
72
  .sf-article-info-container .sf-article-info-content:hover {
53
73
  overflow: auto;
54
74
  }
75
+
76
+
77
+
78
+
79
+ .detail-header {
80
+ position: relative;
81
+ display: flex;
82
+ align-items: center;
83
+ justify-content: space-between;
84
+ line-height: 2.5rem;
85
+ border-bottom: 1px solid #e8e8e8;
86
+ height: 48px;
87
+ padding: 8px 16px;
88
+ }
89
+
90
+ .detail-header .detail-title {
91
+ display: flex;
92
+ flex: 1;
93
+ align-items: center;
94
+ width: 0; /* prevent strut flex layout */
95
+ }
96
+
97
+ .detail-header .detail-title .name {
98
+ margin: 0 0.5rem 0 6px;
99
+ line-height: 1.5rem;
100
+ vertical-align: middle;
101
+ font-size: 1rem;
102
+ color: #212529;
103
+ }
104
+
105
+ .detail-header .detail-control {
106
+ height: 24px;
107
+ width: 24px;
108
+ display: flex;
109
+ align-items: center;
110
+ justify-content: center;
111
+ cursor: pointer;
112
+ }
113
+
114
+ .detail-header .detail-control .detail-control-close {
115
+ font-size: 16px;
116
+ fill: #666;
117
+ }
118
+
119
+ .detail-header .detail-control:hover {
120
+ background-color: #EFEFEF;
121
+ border-radius: 3px;
122
+ }
@@ -1,5 +1,6 @@
1
1
 
2
2
  .sf-editor-helper {
3
+ width: 300px;
3
4
  height: 100%;
4
5
  flex: 1 0 350px;
5
6
  background-color: #fff;
@@ -11,6 +11,8 @@ var _reactI18next = require("react-i18next");
11
11
  var _outlineItem = _interopRequireDefault(require("./outline-item"));
12
12
  var _useScrollContext = require("../../hooks/use-scroll-context");
13
13
  var _constants = require("../../constants");
14
+ var _eventBus = _interopRequireDefault(require("../../utils/event-bus"));
15
+ var _eventTypes = require("../../constants/event-types");
14
16
  require("./style.css");
15
17
  const getHeaderList = children => {
16
18
  const headerList = [];
@@ -31,6 +33,7 @@ const Outline = _ref => {
31
33
  const scrollRef = (0, _useScrollContext.useScrollContext)();
32
34
  const [headerList, setHeaderList] = (0, _react.useState)([]);
33
35
  const [activeId, setActiveId] = (0, _react.useState)('');
36
+ const [isShown, setIsShown] = (0, _react.useState)(false);
34
37
  (0, _react.useEffect)(() => {
35
38
  const headerList = getHeaderList(editor.children);
36
39
  setHeaderList(headerList);
@@ -64,16 +67,50 @@ const Outline = _ref => {
64
67
  observerRefValue.removeEventListener('scroll', handleScroll);
65
68
  };
66
69
  }, [handleScroll, scrollRef]);
70
+ const toggleShow = (0, _react.useCallback)(() => {
71
+ // updateOutlineState(!isShown);
72
+ // const TAB_TYPES = { OUTLINE: 'outline'};
73
+ // if (activeTab === TAB_TYPES.OUTLINE)
74
+
75
+ // setIsShown(!isShown);
76
+ // const eventBus =EventBus.getInstance();
77
+ // eventBus.dispatch(INTERNAL_EVENTS.OUTLINE_STATE_CHANGED, isShown)
78
+ setIsShown(prevIsShown => {
79
+ const newIsShown = !prevIsShown;
80
+ setTimeout(() => {
81
+ const eventBus = _eventBus.default.getInstance();
82
+ eventBus.dispatch(_eventTypes.INTERNAL_EVENTS.OUTLINE_STATE_CHANGED, newIsShown);
83
+ }, 0);
84
+ // const eventBus = EventBus.getInstance();
85
+ // eventBus.dispatch(INTERNAL_EVENTS.OUTLINE_STATE_CHANGED, newIsShown);
86
+ return newIsShown;
87
+ });
88
+ }, []);
67
89
  return /*#__PURE__*/_react.default.createElement("div", {
68
90
  className: "sf-editor-outline"
69
- }, headerList.length === 0 && /*#__PURE__*/_react.default.createElement("div", {
91
+ }, isShown && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
92
+ className: "sf-editor-outline-header"
93
+ }, /*#__PURE__*/_react.default.createElement("h2", {
94
+ className: "sf-editor-outline-header_title"
95
+ }, t('Outline')), /*#__PURE__*/_react.default.createElement("span", {
96
+ className: "sf-editor-outline-header_close iconfont icon-x",
97
+ onClick: toggleShow
98
+ })), headerList.length === 0 && /*#__PURE__*/_react.default.createElement("div", {
70
99
  className: "empty-container"
71
- }, t('No_outline')), headerList.length > 0 && headerList.map((node, index) => {
100
+ }, t('No_outline')), headerList.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
101
+ className: "sf-editor-outline-list-container"
102
+ }, headerList.map((node, index) => {
72
103
  return /*#__PURE__*/_react.default.createElement(_outlineItem.default, {
73
104
  key: index,
74
105
  node: node,
75
106
  activeId: activeId
76
107
  });
77
- }));
108
+ }))), !isShown && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
109
+ id: "sf-editor-outline-menu",
110
+ className: "sf-editor-outline-menu sf-edito-tooltip iconfont icon-outline",
111
+ onClick: toggleShow
112
+ }, /*#__PURE__*/_react.default.createElement("span", {
113
+ className: "custom-tooltip"
114
+ }, t('Outline')))));
78
115
  };
79
116
  var _default = exports.default = Outline;
@@ -19,7 +19,7 @@ const OutlineItem = _ref => {
19
19
  } = node;
20
20
  document.getElementById(id).scrollIntoView();
21
21
  }, [node]);
22
- const className = (0, _classnames.default)({
22
+ const className = (0, _classnames.default)('sf-editor-outline-item', {
23
23
  'outline-h2': node.type === 'header2',
24
24
  'outline-h3': node.type === 'header3',
25
25
  'active': node.id === activeId
@@ -1,8 +1,118 @@
1
1
  .sf-editor-outline {
2
- border-left: 1px solid #ddd;
3
- padding: .5rem 1rem .5rem 0;
2
+ /* flex: 1; */
3
+ width: 220px;
4
+ display: flex;
5
+ min-height: 0;
6
+ flex-direction: column;
7
+ font-size: 14px;
8
+ position: fixed;
9
+ margin: 20px 30px 20px 16px;
10
+ /* overflow-x: hidden;
11
+ overflow-y: auto;
12
+ max-height: 400px */
13
+ /* pointer-events: none; */
4
14
  }
5
15
 
16
+ .sf-editor-outline.active {
17
+ pointer-events: all;
18
+ }
19
+
20
+ .sf-editor-outline-header {
21
+ display: flex;
22
+ justify-content: space-between;
23
+ align-items: center;
24
+ padding: 0.25rem 0;
25
+ color: #999;
26
+ border-bottom: 1px solid #dbdbdb;
27
+ }
28
+
29
+ .sf-editor-outline-header_title {
30
+ font-size: 14px;
31
+ line-height: 1.1;
32
+ margin: 0 !important;
33
+ }
34
+
35
+ .sf-editor-outline-header_close {
36
+ cursor: pointer;
37
+ font-size: 14px;
38
+ }
39
+
40
+ .sf-editor-outline-header_close:hover {
41
+ color: #555;
42
+ }
43
+
44
+ .sf-editor-outline-list-container {
45
+ /* list-style: none; */
46
+ padding: 0.5rem 0;
47
+ flex: 1 1;
48
+ display: flex;
49
+ flex-direction: column;
50
+ overflow-x: hidden;
51
+ overflow-y: auto;
52
+ /* max-height: calc(100vh - 140px); */
53
+ max-height: 400px;
54
+ }
55
+
56
+ .sf-editor-outline-item {
57
+ padding: 4px 0;
58
+ padding-right: 6px;
59
+ max-width: 100%;
60
+ overflow-wrap: anywhere;
61
+ cursor: pointer;
62
+ }
63
+
64
+ .sf-editor-outline-menu {
65
+ line-height: 1;
66
+ font-size: 14px;
67
+ color: #888;
68
+ cursor: pointer;
69
+ width: 28px;
70
+ height: 28px;
71
+ background: #fff;
72
+ border-radius: 0 50% 50% 0;
73
+ box-shadow: 0 0 6px rgba(0, 0, 0, 0.12);
74
+ display: flex;
75
+ align-items: center;
76
+ justify-content: center;
77
+ position: absolute;
78
+ top: 20px;
79
+ left: -15px;
80
+ pointer-events: all;
81
+ }
82
+
83
+ .custom-tooltip {
84
+ visibility: hidden;
85
+ opacity: 0;
86
+ width: 80px;
87
+ background-color: rgba(0, 0, 0, 0.7);
88
+ color: #fff;
89
+ text-align: center;
90
+ border-radius: 4px;
91
+ padding: 5px 0;
92
+ position: absolute;
93
+ z-index: 1;
94
+ /* top: 50%; */
95
+ left: 100%;
96
+ margin-left: 42px;
97
+ transform: translateX(-50%);
98
+ transition: opacity 0.3s;
99
+ }
100
+
101
+ .sf-editor-outline-menu:hover .custom-tooltip {
102
+ visibility: visible;
103
+ opacity: 1;
104
+ }
105
+
106
+ .sf-editor-outline-menu.disabled {
107
+ opacity: .65;
108
+ }
109
+
110
+ .sf-editor-outline-menu:not(.disabled):hover {
111
+ color: #333;
112
+ }
113
+
114
+
115
+
6
116
  .sf-editor-outline .outline-h2,
7
117
  .sf-editor-outline .outline-h3 {
8
118
  white-space: nowrap;
@@ -32,6 +32,7 @@
32
32
  height: 100%;
33
33
  width: 100%;
34
34
  overflow: auto;
35
+ display: flex;
35
36
  }
36
37
 
37
38
  .sf-simple-slate-editor-container .sf-slate-scroll-container.isWin::-webkit-scrollbar {
@@ -59,9 +60,16 @@
59
60
  } */
60
61
 
61
62
  .sf-simple-slate-editor-container .sf-slate-article-container {
62
- height: 100%;
63
+ position: relative;
64
+ top: 0;
65
+ width: 794px;
66
+ margin: 0 auto;
67
+ padding-top: 20px;
68
+ padding-bottom: 20px;
69
+ margin-left: 280px;
70
+ /* height: 100%;
63
71
  width: 100%;
64
- overflow: auto;
72
+ overflow: auto; */
65
73
  }
66
74
 
67
75
  .sf-simple-slate-editor-container .sf-slate-editor-content .article {
@@ -29,7 +29,7 @@ function EditorHelp(_ref) {
29
29
  }, []);
30
30
  (0, _react.useEffect)(() => {
31
31
  const eventBus = _eventBus.default.getInstance();
32
- const unsubscribeArticleInfo = eventBus.subscribe(_eventTypes.INTERNAL_EVENTS.ON_ARTICLE_INFO_TOGGLE, updateArticleInfoState);
32
+ const unsubscribeArticleInfo = eventBus.subscribe(_eventTypes.EXTERNAL_EVENTS.ON_ARTICLE_INFO_TOGGLE, updateArticleInfoState);
33
33
  const unsubscribeHelpInfo = eventBus.subscribe(_eventTypes.EXTERNAL_EVENTS.ON_HELP_INFO_TOGGLE, updateHelpInfoState);
34
34
  return () => {
35
35
  unsubscribeHelpInfo();
@@ -40,9 +40,9 @@ function EditorHelp(_ref) {
40
40
  const containerClass = (0, _classnames.default)('sf-markdown-help-wrapper', {
41
41
  'active': isShowArticleInfo || isShowHelpInfo
42
42
  });
43
- return /*#__PURE__*/_react.default.createElement("div", {
43
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
44
44
  className: containerClass
45
45
  }, isShowArticleInfo && /*#__PURE__*/_react.default.createElement(_articleInfo.default, {
46
46
  children: children
47
- }), isShowHelpInfo && /*#__PURE__*/_react.default.createElement(_hotkeysHelper.default, null));
47
+ }), isShowHelpInfo && /*#__PURE__*/_react.default.createElement(_hotkeysHelper.default, null)));
48
48
  }
@@ -6,7 +6,7 @@
6
6
  height: 100%;
7
7
  overflow-x: hidden;
8
8
  overflow-y: auto;
9
- width: 300px;
9
+ /* width: 300px; */
10
10
  }
11
11
 
12
12
  .sf-markdown-help-wrapper.active {
@@ -18,6 +18,8 @@ var _core = require("../../extension/core");
18
18
  var _useScrollContext = require("../../hooks/use-scroll-context");
19
19
  var _useInsertImage = _interopRequireDefault(require("../../hooks/use-insert-image"));
20
20
  var _common = require("../../utils/common");
21
+ var _outline = _interopRequireDefault(require("../../containers/outline"));
22
+ var _eventTypes = require("../../constants/event-types");
21
23
  require("./style.css");
22
24
  const isMacOS = (0, _common.isMac)();
23
25
  function SlateEditor(_ref) {
@@ -31,6 +33,8 @@ function SlateEditor(_ref) {
31
33
  children
32
34
  } = _ref;
33
35
  const [slateValue, setSlateValue] = (0, _react.useState)(value);
36
+ const [scrollLeft, setScrollLeft] = (0, _react.useState)(0);
37
+ const [containerStyle, setContainerStyle] = (0, _react.useState)({});
34
38
  const scrollRef = (0, _react.useRef)(null);
35
39
  const editor = (0, _react.useMemo)(() => (0, _withPropsEditor.default)(_extension.baseEditor, {
36
40
  editorApi,
@@ -41,6 +45,25 @@ function SlateEditor(_ref) {
41
45
  }, [editor]);
42
46
  (0, _useInsertImage.default)(editor);
43
47
  const decorate = (0, _extension.useHighlight)(editor);
48
+
49
+ //Adjust article container margin-left value according to isShown of the outline and width of window
50
+ const handleWindowResize = newIsShown => {
51
+ var _document$querySelect;
52
+ const rect = scrollRef.current.getBoundingClientRect();
53
+ const articleRect = (_document$querySelect = document.querySelector('.article')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.getBoundingClientRect();
54
+ if (newIsShown && (rect.width - articleRect.width) / 2 < 280) {
55
+ setContainerStyle({
56
+ marginLeft: '280px'
57
+ });
58
+ } else {
59
+ setContainerStyle({});
60
+ }
61
+ };
62
+ (0, _react.useEffect)(() => {
63
+ const eventBus = _eventBus.default.getInstance();
64
+ const unsubscribeOutline = eventBus.subscribe(_eventTypes.INTERNAL_EVENTS.OUTLINE_STATE_CHANGED, handleWindowResize);
65
+ return unsubscribeOutline;
66
+ }, [handleWindowResize]);
44
67
  const onChange = (0, _react.useCallback)(value => {
45
68
  setSlateValue(value);
46
69
  if (editor.forceNormalize) return;
@@ -102,6 +125,12 @@ function SlateEditor(_ref) {
102
125
  focusFirstNode(editor);
103
126
  }
104
127
  }, [editor, focusFirstNode]);
128
+ const onWrapperScroll = (0, _react.useCallback)(event => {
129
+ const {
130
+ scrollLeft
131
+ } = event.target;
132
+ setScrollLeft(scrollLeft);
133
+ }, []);
105
134
  return /*#__PURE__*/_react.default.createElement("div", {
106
135
  className: "sf-slate-editor-container"
107
136
  }, /*#__PURE__*/_react.default.createElement(_extension.Toolbar, {
@@ -122,9 +151,13 @@ function SlateEditor(_ref) {
122
151
  onChange: onChange
123
152
  }, /*#__PURE__*/_react.default.createElement("div", {
124
153
  ref: scrollRef,
125
- className: "sf-slate-scroll-container ".concat(isMacOS ? '' : 'isWin')
126
- }, /*#__PURE__*/_react.default.createElement("div", {
127
- className: "sf-slate-article-container"
154
+ className: "sf-slate-scroll-container ".concat(isMacOS ? '' : 'isWin'),
155
+ onScroll: onWrapperScroll
156
+ }, /*#__PURE__*/_react.default.createElement(_outline.default, {
157
+ editor: editor
158
+ }), /*#__PURE__*/_react.default.createElement("div", {
159
+ className: "sf-slate-article-container",
160
+ style: containerStyle
128
161
  }, /*#__PURE__*/_react.default.createElement("div", {
129
162
  className: "article"
130
163
  }, /*#__PURE__*/_react.default.createElement(_extension.SetNodeToDecorations, null), /*#__PURE__*/_react.default.createElement(_slateReact.Editable, {
@@ -105,6 +105,7 @@
105
105
 
106
106
  .sf-slate-article-container {
107
107
  width: 100%;
108
+ margin-left: 280px;
108
109
  }
109
110
 
110
111
  .sf-slate-article-container .article {
@@ -103,6 +103,21 @@ const withCodeBlock = editor => {
103
103
  at: path
104
104
  });
105
105
  return;
106
+ } else if (type === _elementTypes.CODE_LINE && node.children.length > 1) {
107
+ // If one code_line has more than one text nodes, merge all text nodes into a single text node
108
+ const mergedText = node.children.map(textNode => textNode.text).join('');
109
+ _slate.Transforms.removeNodes(editor, {
110
+ at: [...path]
111
+ });
112
+ _slate.Transforms.insertNodes(editor, {
113
+ type: _elementTypes.CODE_LINE,
114
+ children: [{
115
+ text: mergedText
116
+ }]
117
+ }, {
118
+ at: [...path]
119
+ });
120
+ return;
106
121
  }
107
122
  if (type === _elementTypes.CODE_BLOCK) {
108
123
  if (node.children.length === 0) {
@@ -149,7 +164,6 @@ const withCodeBlock = editor => {
149
164
  });
150
165
  }
151
166
  }
152
-
153
167
  // Perform default behavior
154
168
  return normalizeNode([node, path]);
155
169
  };
@@ -136,9 +136,10 @@
136
136
  min-height: 100% !important;
137
137
  margin: 0 !important;
138
138
  color: #212529;
139
+ overflow-x: hidden;
139
140
  }
140
141
 
141
- .longtext-content-container .sf-simple-slate-editor-container .article > div[role="textbox"] > :first-child {
142
+ .longtext-content-container .sf-simple-slate-editor-container .article>div[role="textbox"]> :first-child {
142
143
  margin-top: 0;
143
144
  }
144
145
 
@@ -35,10 +35,23 @@ const tableRule = (element, parseChild) => {
35
35
  };
36
36
  }
37
37
  if (nodeName === 'TH' || nodeName === 'TD') {
38
+ const children = Array.from(childNodes);
39
+ const cellChildren = children.flatMap(child => {
40
+ //Replace paragraph node with text node
41
+ if (child.nodeName === 'P') {
42
+ const textContent = Array.from(child.childNodes).map(child => child.textContent).join('');
43
+ return {
44
+ id: _slugid.default.nice(),
45
+ type: 'text',
46
+ text: textContent
47
+ };
48
+ }
49
+ return parseChild([child]);
50
+ });
38
51
  return {
39
52
  id: _slugid.default.nice(),
40
53
  type: _constants.TABLE_CELL,
41
- children: parseChild(childNodes)
54
+ children: cellChildren
42
55
  };
43
56
  }
44
57
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "1.0.115",
3
+ "version": "1.0.117-alpha.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -14,6 +14,8 @@
14
14
  />
15
15
  <missing-glyph />
16
16
 
17
+ <glyph glyph-name="outline" unicode="&#59015;" d="M64 800h512c35.2 0 64-28.8 64-64s-28.8-64-64-64H64c-35.2 0-64 28.8-64 64s28.8 64 64 64z m934.4-444.8l-12.8-12.8-172.8-172.8c-25.6-25.6-64-25.6-89.6 0-25.6 25.6-25.6 64 0 89.6l134.4 134.4L723.2 528c-25.6 25.6-25.6 64 0 89.6 25.6 25.6 64 25.6 89.6 0l172.8-172.8 9.6-9.6c12.8-12.8 19.2-25.6 19.2-41.6v-3.2c0-12.8-9.6-28.8-16-35.2zM64 448h800c35.2 0 64-28.8 64-64s-28.8-64-64-64H64c-35.2 0-64 28.8-64 64s28.8 64 64 64z m0-352h512c35.2 0 64-28.8 64-64s-28.8-64-64-64H64c-35.2 0-64 28.8-64 64s28.8 64 64 64z" horiz-adv-x="1024" />
18
+
17
19
  <glyph glyph-name="description" unicode="&#58919;" d="M512 864C249.6 864 32 649.6 32 384s217.6-480 480-480 480 214.4 480 480S777.6 864 512 864z m-32-755.2c-19.2 0-35.2 16-35.2 35.2V419.2c0 19.2 16 35.2 35.2 35.2h67.2c19.2 0 35.2-16 35.2-35.2V144c0-19.2-16-35.2-35.2-35.2H480z m0 412.8c-19.2 0-35.2 16-35.2 35.2V624c0 19.2 16 35.2 35.2 35.2h67.2c19.2 0 35.2-16 35.2-35.2v-67.2c0-19.2-16-35.2-35.2-35.2H480z" horiz-adv-x="1024" />
18
20
 
19
21
  <glyph glyph-name="more" unicode="&#58918;" d="M835.2 387.2c0-54.4 41.6-96 96-96s96 41.6 96 96-41.6 96-96 96c-51.2 0-96-41.6-96-96z m-416 0c0-54.4 41.6-96 96-96s96 41.6 96 96-41.6 96-96 96c-51.2 0-96-41.6-96-96z m-416 0c0-54.4 41.6-96 96-96s96 41.6 96 96-41.6 96-96 96c-51.2 0-96-41.6-96-96z" horiz-adv-x="1027" />
@@ -1,11 +1,14 @@
1
1
  @font-face {
2
- font-family: "iconfont"; /* Project id 4375832 */
3
- src: url('./seafile-editor-font/iconfont.eot?t=1724814278764'); /* IE9 */
4
- src: url('./seafile-editor-font/iconfont.eot?t=1724814278764#iefix') format('embedded-opentype'), /* IE6-IE8 */
5
- url('./seafile-editor-font/iconfont.woff2?t=1724814278764') format('woff2'),
6
- url('./seafile-editor-font/iconfont.woff?t=1724814278764') format('woff'),
7
- url('./seafile-editor-font/iconfont.ttf?t=1724814278764') format('truetype'),
8
- url('./seafile-editor-font/iconfont.svg?t=1724814278764#iconfont') format('svg');
2
+ font-family: "iconfont";
3
+ /* Project id 4375832 */
4
+ src: url('./seafile-editor-font/iconfont.eot?t=1726105923189');
5
+ /* IE9 */
6
+ src: url('./seafile-editor-font/iconfont.eot?t=1726105923189#iefix') format('embedded-opentype'),
7
+ /* IE6-IE8 */
8
+ url('./seafile-editor-font/iconfont.woff2?t=1726105923189') format('woff2'),
9
+ url('./seafile-editor-font/iconfont.woff?t=1726105923189') format('woff'),
10
+ url('./seafile-editor-font/iconfont.ttf?t=1726105923189') format('truetype'),
11
+ url('./seafile-editor-font/iconfont.svg?t=1726105923189#iconfont') format('svg');
9
12
  }
10
13
 
11
14
  .iconfont {
@@ -16,6 +19,10 @@
16
19
  -moz-osx-font-smoothing: grayscale;
17
20
  }
18
21
 
22
+ .icon-outline:before {
23
+ content: "\e687";
24
+ }
25
+
19
26
  .icon-description:before {
20
27
  content: "\e627";
21
28
  }
@@ -255,4 +262,3 @@
255
262
  .icon-users:before {
256
263
  content: "\e67f";
257
264
  }
258
-