@seafile/sdoc-editor 0.1.27-beta → 0.1.27-beta2

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.
@@ -0,0 +1,16 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import { DIFF_TYPE } from '../../constants';
3
+ export var getDiffValue = function getDiffValue(currentValue, oldValue) {
4
+ var currentVersion = currentValue.version,
5
+ currentChildren = currentValue.children;
6
+ var oldVersion = oldValue.version,
7
+ oldChildren = oldValue.children;
8
+ if (currentVersion === oldVersion) return currentChildren;
9
+ var diffDocument = [];
10
+ diffDocument = currentChildren.map(function (item) {
11
+ return _objectSpread(_objectSpread({}, item), {}, {
12
+ diff_type: DIFF_TYPE.MODIFY
13
+ });
14
+ });
15
+ return diffDocument;
16
+ };
@@ -0,0 +1,5 @@
1
+ export var DIFF_TYPE = {
2
+ ADD: 'add',
3
+ DELETE: 'delete',
4
+ MODIFY: 'modify'
5
+ };
@@ -0,0 +1,53 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React, { Component } from 'react';
6
+ import { Editable, Slate } from '@seafile/slate-react';
7
+ import editor, { renderLeaf, renderElement } from '../../basic-sdk/extension';
8
+ import withNodeId from '../../basic-sdk/node-id';
9
+ import { getDiffValue } from '../../basic-sdk/utils/diff';
10
+ var DiffViewer = /*#__PURE__*/function (_Component) {
11
+ _inherits(DiffViewer, _Component);
12
+ var _super = _createSuper(DiffViewer);
13
+ function DiffViewer(_props) {
14
+ var _this;
15
+ _classCallCheck(this, DiffViewer);
16
+ _this = _super.call(this, _props);
17
+ _this.renderLeaf = function (props) {
18
+ console.log('renderLeaf params: ', props);
19
+ return renderLeaf(props, _this.editor);
20
+ };
21
+ _this.renderElement = function (props) {
22
+ console.log('renderElement params: ', props);
23
+ return renderElement(props, _this.editor);
24
+ };
25
+ _this.editor = withNodeId(editor);
26
+ return _this;
27
+ }
28
+ _createClass(DiffViewer, [{
29
+ key: "render",
30
+ value: function render() {
31
+ var _this$props = this.props,
32
+ currentContent = _this$props.currentContent,
33
+ lastContent = _this$props.lastContent;
34
+ var value = getDiffValue(currentContent, lastContent);
35
+ return /*#__PURE__*/React.createElement(Slate, {
36
+ editor: this.editor,
37
+ value: value,
38
+ onChange: function onChange() {}
39
+ }, /*#__PURE__*/React.createElement("div", {
40
+ className: "article mx-auto"
41
+ }, /*#__PURE__*/React.createElement(Editable, {
42
+ readOnly: true,
43
+ placeholder: "",
44
+ renderElement: this.renderElement,
45
+ renderLeaf: this.renderLeaf,
46
+ onDOMBeforeInput: function onDOMBeforeInput() {},
47
+ onKeyDown: function onKeyDown() {}
48
+ })));
49
+ }
50
+ }]);
51
+ return DiffViewer;
52
+ }(Component);
53
+ export default DiffViewer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.27beta",
3
+ "version": "0.1.27beta2",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -1,21 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React, { Component } from 'react';
6
- var DiffViewer = /*#__PURE__*/function (_Component) {
7
- _inherits(DiffViewer, _Component);
8
- var _super = _createSuper(DiffViewer);
9
- function DiffViewer() {
10
- _classCallCheck(this, DiffViewer);
11
- return _super.apply(this, arguments);
12
- }
13
- _createClass(DiffViewer, [{
14
- key: "render",
15
- value: function render() {
16
- return /*#__PURE__*/React.createElement("div", null, "diff-viewer");
17
- }
18
- }]);
19
- return DiffViewer;
20
- }(Component);
21
- export default DiffViewer;