@seafile/sdoc-editor 0.1.124 → 0.1.125

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.
@@ -97,14 +97,22 @@ var withCodeBlock = function withCodeBlock(editor) {
97
97
  node = _ref2[0],
98
98
  path = _ref2[1];
99
99
  var type = getNodeType(node);
100
- if (type === 'code-line' && path.length <= 1) {
100
+ if (type === CODE_LINE && path.length <= 1) {
101
101
  Transforms.setNodes(newEditor, {
102
102
  type: 'paragraph'
103
103
  }, {
104
104
  at: path
105
105
  });
106
+ return;
106
107
  }
107
108
  if (type === CODE_BLOCK) {
109
+ if (node.children.length === 0) {
110
+ Transforms.delete(newEditor, {
111
+ at: path
112
+ });
113
+ return;
114
+ }
115
+
108
116
  // code-block is the last node in the editor and needs to be followed by a p node
109
117
  var isLast = isLastNode(newEditor, node);
110
118
  if (isLast) {
@@ -8,8 +8,6 @@ import { useScrollContext } from '../../../hooks/use-scroll-context';
8
8
  import CodeBlockHoverMenu from './hover-menu';
9
9
  import { setClipboardData } from './helpers';
10
10
  import { INTERNAL_EVENT } from '../../../constants';
11
- import { findPath, getAboveNode } from '../../core';
12
- import { CODE_BLOCK } from '../../constants';
13
11
  import '../../../assets/css/code-block.css';
14
12
  var CodeBlock = function CodeBlock(_ref) {
15
13
  var codeBlockProps = _ref.codeBlockProps;
@@ -128,6 +126,7 @@ var CodeBlock = function CodeBlock(_ref) {
128
126
  // eslint-disable-next-line react-hooks/exhaustive-deps
129
127
  }, []);
130
128
  return /*#__PURE__*/React.createElement("div", {
129
+ "data-id": element.id,
131
130
  ref: codeBlockRef,
132
131
  className: 'sdoc-code-block-container',
133
132
  onClick: onFocusCodeBlock,
@@ -158,14 +157,9 @@ export var renderCodeLine = function renderCodeLine(props, editor) {
158
157
  var element = props.element,
159
158
  attributes = props.attributes,
160
159
  children = props.children;
161
- var path = findPath(editor, element);
162
- var parentNode = getAboveNode(editor, {
163
- at: path
164
- });
165
- if (parentNode[0].type === CODE_BLOCK) {
166
- return /*#__PURE__*/React.createElement("div", Object.assign({}, attributes, {
167
- className: 'sdoc-code-line'
168
- }), children);
169
- }
170
- return children;
160
+ return /*#__PURE__*/React.createElement("div", Object.assign({
161
+ "data-id": element.id
162
+ }, attributes, {
163
+ className: 'sdoc-code-line'
164
+ }), children);
171
165
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.124",
3
+ "version": "0.1.125",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",