@seafile/sdoc-editor 0.5.64 → 0.5.65

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.
@@ -56,13 +56,14 @@
56
56
  .sdoc-editor-container .article .sdoc-image-wrapper {
57
57
  position: relative;
58
58
  display: inline-block;
59
- padding: 6px 1px 6px 1px;
60
59
  margin: 0 0.15em;
60
+ caret-color: transparent;
61
61
  }
62
62
 
63
63
  .sdoc-editor-container .article .sdoc-image-inner {
64
64
  position: relative;
65
65
  display: inline-block;
66
+ margin: 0 3px;
66
67
  }
67
68
 
68
69
  .sdoc-editor-container .article .sdoc-image-content {
@@ -200,7 +200,8 @@ const Image = _ref => {
200
200
  className: classNames('sdoc-image-wrapper', className)
201
201
  }, attributes, {
202
202
  style: _objectSpread({}, style),
203
- onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected)
203
+ onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected),
204
+ contentEditable: "true"
204
205
  }), /*#__PURE__*/React.createElement("img", {
205
206
  ref: imageRef,
206
207
  src: imagePlaceholder,
@@ -212,9 +213,11 @@ const Image = _ref => {
212
213
  className: classNames('sdoc-image-wrapper', className)
213
214
  }, attributes, {
214
215
  style: _objectSpread({}, style),
215
- onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected)
216
+ onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected),
217
+ contentEditable: "true"
216
218
  }), /*#__PURE__*/React.createElement("span", {
217
- className: "sdoc-image-inner"
219
+ className: "sdoc-image-inner",
220
+ contentEditable: "false"
218
221
  }, /*#__PURE__*/React.createElement("span", {
219
222
  className: "sdoc-image-content"
220
223
  }, /*#__PURE__*/React.createElement("span", {
@@ -311,10 +314,10 @@ export function renderImageBlock(props, editor) {
311
314
  className: "sdoc-image-block-wrapper",
312
315
  style: {
313
316
  display: 'flex',
314
- padding: '5px 0px',
315
317
  justifyContent: "".concat(justifyContent)
316
318
  }
317
319
  }, attributes, {
318
- onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected)
320
+ onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected),
321
+ contentEditable: "false"
319
322
  }), children);
320
323
  }
@@ -8,6 +8,7 @@ import { transformToText } from './helper';
8
8
  import { useScrollContext } from '../../../hooks/use-scroll-context';
9
9
  import { INSERT_POSITION } from '../../constants';
10
10
  import QuickInsertBlockMenu from '../../toolbar/insert-element-toolbar';
11
+ import { isVoidNode } from '../../toolbar/side-toolbar/helpers';
11
12
  const RenderQuickInsert = (_ref, editor) => {
12
13
  let {
13
14
  attributes,
@@ -24,6 +25,7 @@ const RenderQuickInsert = (_ref, editor) => {
24
25
  const insertElmRef = useRef(null);
25
26
  const aboveBlockNode = getAboveBlockNode(editor);
26
27
  const searchText = Node.string(element);
28
+ const isEmptyNode = isVoidNode(aboveBlockNode === null || aboveBlockNode === void 0 ? void 0 : aboveBlockNode[0]);
27
29
  const handleClick = useCallback(e => {
28
30
  if (!insertElmRef.current.contains(e.target)) {
29
31
  transformToText(editor, element);
@@ -74,7 +76,8 @@ const RenderQuickInsert = (_ref, editor) => {
74
76
  ref: sideMenuRef,
75
77
  className: "sdoc-side-menu sdoc-dropdown-menu"
76
78
  }, /*#__PURE__*/React.createElement(QuickInsertBlockMenu, {
77
- insertPosition: INSERT_POSITION.AFTER,
79
+ isEmptyNode: isEmptyNode,
80
+ insertPosition: isEmptyNode ? INSERT_POSITION.CURRENT : INSERT_POSITION.AFTER,
78
81
  slateNode: aboveBlockNode === null || aboveBlockNode === void 0 ? void 0 : aboveBlockNode[0],
79
82
  searchText: searchText,
80
83
  callback: handleInsertBlock
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { useSlateStatic } from '@seafile/slate-react';
4
4
  import { Transforms } from '@seafile/slate';
5
- import { insertElement } from '../side-toolbar/helpers';
5
+ import { insertElement, isVoidNode } from '../side-toolbar/helpers';
6
6
  import { insertTable } from '../../plugins/table/helpers';
7
7
  import TableSizePopover from '../../plugins/table/popover/table-size-popover';
8
8
  import { changeToCodeBlock } from '../../plugins/code-block/helpers';
@@ -21,7 +21,8 @@ const QuickInsertBlockMenu = _ref => {
21
21
  insertPosition,
22
22
  slateNode,
23
23
  searchText,
24
- callback
24
+ callback,
25
+ isEmptyNode
25
26
  } = _ref;
26
27
  const editor = useSlateStatic();
27
28
  const [currentSelectIndex, setCurrentSelectIndex] = useState(0);
@@ -145,6 +146,7 @@ const QuickInsertBlockMenu = _ref => {
145
146
  onClick: onInsertCheckList
146
147
  }),
147
148
  [PARAGRAPH]: /*#__PURE__*/React.createElement(DropdownMenuItem, {
149
+ disabled: isEmptyNode,
148
150
  key: "sdoc-insert-menu-paragraph",
149
151
  menuConfig: _objectSpread({}, SIDE_INSERT_MENUS_CONFIG[ELEMENT_TYPE.PARAGRAPH]),
150
152
  onClick: () => onInsert(ELEMENT_TYPE.PARAGRAPH)
@@ -158,7 +160,7 @@ const QuickInsertBlockMenu = _ref => {
158
160
  });
159
161
  });
160
162
  return items;
161
- }, [createTable, editor, onInsert, onInsertCallout, onInsertCheckList, onInsertCodeBlock, onInsertImageToggle, onInsertList, openLinkDialog]);
163
+ }, [createTable, editor, isEmptyNode, onInsert, onInsertCallout, onInsertCheckList, onInsertCodeBlock, onInsertImageToggle, onInsertList, openLinkDialog]);
162
164
  const getSelectItemDom = selectIndex => {
163
165
  const dropDownItemWrapper = downDownWrapperRef.current;
164
166
  const currentSelectItem = dropDownItemWrapper.children[selectIndex];
@@ -16,7 +16,8 @@ import { wrapCallout } from '../../plugins/callout/helper';
16
16
  const InsertBlockMenu = _ref => {
17
17
  let {
18
18
  insertPosition,
19
- slateNode
19
+ slateNode,
20
+ isNodeEmpty
20
21
  } = _ref;
21
22
  const editor = useSlateStatic();
22
23
  const onInsertImageToggle = useCallback(() => {
@@ -113,6 +114,7 @@ const InsertBlockMenu = _ref => {
113
114
  onClick: onInsertCheckList
114
115
  }), [SIDE_INSERT_MENUS_CONFIG[ELEMENT_TYPE.PARAGRAPH], ...SIDE_INSERT_MENUS_CONFIG[ELEMENT_TYPE.HEADER]].map(item => {
115
116
  return /*#__PURE__*/React.createElement(DropdownMenuItem, {
117
+ disabled: isNodeEmpty && item.type === PARAGRAPH,
116
118
  key: item.id,
117
119
  menuConfig: item,
118
120
  onClick: () => onInsert(item.type)
@@ -85,6 +85,7 @@ const SideMenu = _ref => {
85
85
  slateNode: slateNode,
86
86
  onReset: onReset
87
87
  }))), isNodeEmpty && /*#__PURE__*/React.createElement(InsertBlockMenu, {
88
+ isNodeEmpty: isNodeEmpty,
88
89
  slateNode: slateNode
89
90
  }), !isNodeEmpty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownMenuItem, {
90
91
  menuConfig: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.5.64",
3
+ "version": "0.5.65",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",