@seafile/seafile-editor 2.0.35 → 2.0.36-beta

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.
@@ -21,7 +21,8 @@ function SlateViewer(_ref) {
21
21
  value,
22
22
  isShowOutline,
23
23
  scrollRef: externalScrollRef,
24
- onLinkClick
24
+ onLinkClick,
25
+ ...params
25
26
  } = _ref;
26
27
  const scrollRef = (0, _react.useRef)(null);
27
28
  const {
@@ -69,7 +70,10 @@ function SlateViewer(_ref) {
69
70
  }, /*#__PURE__*/_react.default.createElement(_extension.SetNodeToDecorations, null), /*#__PURE__*/_react.default.createElement(_slateReact.Editable, {
70
71
  readOnly: true,
71
72
  decorate: decorate,
72
- renderElement: _extension.renderElement,
73
+ renderElement: props => (0, _extension.renderElement)({
74
+ ...params,
75
+ ...props
76
+ }),
73
77
  renderLeaf: _extension.renderLeaf
74
78
  }))))))));
75
79
  }
@@ -14,9 +14,13 @@ const renderDefinition = (_ref, editor) => {
14
14
  let {
15
15
  attributes,
16
16
  children,
17
- element
17
+ element,
18
+ option
18
19
  } = _ref;
19
20
  const [isShowConfirmDialog, setIsShowConfirmDialog] = (0, _react.useState)(false);
21
+ const {
22
+ render
23
+ } = option || {};
20
24
  const onHrefClick = (0, _react.useCallback)(event => {
21
25
  event.preventDefault();
22
26
  if (element.url.startsWith(window.location.origin)) {
@@ -28,6 +32,14 @@ const renderDefinition = (_ref, editor) => {
28
32
  const onToggle = (0, _react.useCallback)(() => {
29
33
  setIsShowConfirmDialog(!isShowConfirmDialog);
30
34
  }, [isShowConfirmDialog]);
35
+ if ( /*#__PURE__*/(0, _react.isValidElement)(render)) {
36
+ return /*#__PURE__*/(0, _react.cloneElement)(render, {
37
+ element,
38
+ onClick: onHrefClick,
39
+ attributes,
40
+ editor
41
+ });
42
+ }
31
43
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", Object.assign({
32
44
  "data-url": element.url,
33
45
  "data-id": element.id,
@@ -15,8 +15,12 @@ const renderLinkReference = (_ref, editor) => {
15
15
  let {
16
16
  attributes,
17
17
  children,
18
- element
18
+ element,
19
+ option
19
20
  } = _ref;
21
+ const {
22
+ render
23
+ } = option || {};
20
24
  const onClick = (0, _react.useCallback)(() => {
21
25
  const doms = (0, _core.getNodesByType)(editor.children, _elementTypes.DEFINITION);
22
26
  const dom = doms.find(d => d.identifier === element.identifier);
@@ -29,6 +33,14 @@ const renderLinkReference = (_ref, editor) => {
29
33
  block: 'center'
30
34
  });
31
35
  }, [element, editor]);
36
+ if (render && /*#__PURE__*/(0, _react.isValidElement)(render)) {
37
+ return /*#__PURE__*/(0, _react.cloneElement)(render, {
38
+ element,
39
+ onClick,
40
+ attributes,
41
+ editor
42
+ });
43
+ }
32
44
  return /*#__PURE__*/_react.default.createElement("sup", Object.assign({
33
45
  onClick: onClick,
34
46
  className: "sf-virtual-link-reference",
@@ -10,10 +10,18 @@ var _react = _interopRequireDefault(require("react"));
10
10
  var _slateReact = require("slate-react");
11
11
  var ElementType = _interopRequireWildcard(require("../constants/element-types"));
12
12
  var _plugins = require("../plugins");
13
- const SlateElement = props => {
14
- const {
13
+ const SlateElement = _ref => {
14
+ let {
15
+ element,
16
+ options,
17
+ ...params
18
+ } = _ref;
19
+ const option = options ? options[element.type] : null;
20
+ const props = {
21
+ ...params,
22
+ option,
15
23
  element
16
- } = props;
24
+ };
17
25
  const editor = (0, _slateReact.useSlateStatic)();
18
26
  switch (element.type) {
19
27
  case ElementType.BLOCKQUOTE:
@@ -19,7 +19,8 @@ function MarkdownViewer(_ref) {
19
19
  isShowOutline,
20
20
  scrollRef,
21
21
  onLinkClick,
22
- beforeRenderCallback
22
+ beforeRenderCallback,
23
+ ...params
23
24
  } = _ref;
24
25
  const [richValue, setRichValue] = (0, _react.useState)([]);
25
26
  const [isLoading, setIsLoading] = (0, _react.useState)(true);
@@ -39,6 +40,7 @@ function MarkdownViewer(_ref) {
39
40
  // eslint-disable-next-line react-hooks/exhaustive-deps
40
41
  }, [isFetching, value]);
41
42
  const props = {
43
+ ...params,
42
44
  isSupportFormula: !!mathJaxSource,
43
45
  value: richValue,
44
46
  isShowOutline: isShowOutline,
@@ -46,6 +48,16 @@ function MarkdownViewer(_ref) {
46
48
  onLinkClick: onLinkClick
47
49
  };
48
50
  if (isFetching || isLoading || isLoadingMathJax) {
51
+ const {
52
+ options
53
+ } = params;
54
+ const loadingOption = (options === null || options === void 0 ? void 0 : options.loading) || {};
55
+ const {
56
+ render
57
+ } = loadingOption || {};
58
+ if (render && /*#__PURE__*/(0, _react.isValidElement)(render)) {
59
+ return /*#__PURE__*/(0, _react.cloneElement)(render);
60
+ }
49
61
  return /*#__PURE__*/_react.default.createElement(_loading.default, null);
50
62
  }
51
63
  return /*#__PURE__*/_react.default.createElement(_slateViewer.default, props);
@@ -12,7 +12,9 @@ const PARAGRAPH_TAGS = ['DIV', 'P'];
12
12
  const listRule = (element, parseChild) => {
13
13
  const {
14
14
  nodeName,
15
- childNodes
15
+ childNodes,
16
+ firstChild,
17
+ parentElement
16
18
  } = element;
17
19
  if (nodeName === 'UL') {
18
20
  return {
@@ -28,14 +30,14 @@ const listRule = (element, parseChild) => {
28
30
  children: parseChild(childNodes)
29
31
  };
30
32
  }
31
- if (nodeName === 'LI' && PARAGRAPH_TAGS.includes(element.firstChild.nodeName)) {
33
+ if (nodeName === 'LI' && firstChild && PARAGRAPH_TAGS.includes(firstChild.nodeName)) {
32
34
  return {
33
35
  id: _slugid.default.nice(),
34
36
  type: _constants.LIST_ITEM,
35
37
  children: parseChild(childNodes)
36
38
  };
37
39
  }
38
- if (nodeName === 'LI' && !PARAGRAPH_TAGS.includes(element.firstChild.nodeName)) {
40
+ if (nodeName === 'LI' && firstChild && !PARAGRAPH_TAGS.includes(firstChild.nodeName)) {
39
41
  return {
40
42
  id: _slugid.default.nice(),
41
43
  type: _constants.LIST_ITEM,
@@ -46,7 +48,7 @@ const listRule = (element, parseChild) => {
46
48
  }]
47
49
  };
48
50
  }
49
- if (PARAGRAPH_TAGS.includes(nodeName) && element.parentElement.nodeName === 'LI') {
51
+ if (PARAGRAPH_TAGS.includes(nodeName) && parentElement && parentElement.nodeName === 'LI') {
50
52
  if (Array.from(childNodes).length === 0) {
51
53
  return {
52
54
  id: _slugid.default.nice(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "2.0.35",
3
+ "version": "2.0.36beta",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {