@atlaskit/embedded-document 0.8.11 → 0.8.13
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.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/components/document.js +19 -55
- package/dist/cjs/components/toolbar.js +1 -19
- package/dist/cjs/consumers/consumer.js +2 -31
- package/dist/cjs/consumers/document-body.js +4 -29
- package/dist/cjs/consumers/with-document-actions.js +0 -29
- package/dist/cjs/context/context.js +0 -12
- package/dist/cjs/context/embedded-document.js +5 -82
- package/dist/cjs/index.js +0 -6
- package/dist/cjs/provider/index.js +1 -8
- package/dist/cjs/provider/service-provider.js +0 -36
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/document.js +0 -15
- package/dist/es2019/components/toolbar.js +0 -2
- package/dist/es2019/consumers/consumer.js +0 -12
- package/dist/es2019/consumers/document-body.js +0 -5
- package/dist/es2019/consumers/with-document-actions.js +0 -7
- package/dist/es2019/context/context.js +0 -2
- package/dist/es2019/context/embedded-document.js +1 -25
- package/dist/es2019/provider/index.js +0 -2
- package/dist/es2019/provider/service-provider.js +0 -9
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/document.js +19 -43
- package/dist/esm/components/toolbar.js +1 -8
- package/dist/esm/consumers/consumer.js +2 -23
- package/dist/esm/consumers/document-body.js +4 -20
- package/dist/esm/consumers/with-document-actions.js +0 -18
- package/dist/esm/context/context.js +0 -8
- package/dist/esm/context/embedded-document.js +5 -72
- package/dist/esm/provider/index.js +1 -4
- package/dist/esm/provider/service-provider.js +0 -32
- package/dist/esm/version.json +1 -1
- package/package.json +4 -4
|
@@ -6,41 +6,30 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
|
|
10
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
-
|
|
12
10
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
-
|
|
14
11
|
import React from 'react';
|
|
15
12
|
import { PureComponent } from 'react';
|
|
16
13
|
import { Consumer } from './consumer';
|
|
17
14
|
import { default as Document } from '../components/document';
|
|
18
|
-
|
|
19
15
|
var DocumentBody = /*#__PURE__*/function (_PureComponent) {
|
|
20
16
|
_inherits(DocumentBody, _PureComponent);
|
|
21
|
-
|
|
22
17
|
var _super = _createSuper(DocumentBody);
|
|
23
|
-
|
|
24
18
|
function DocumentBody() {
|
|
25
19
|
var _this;
|
|
26
|
-
|
|
27
20
|
_classCallCheck(this, DocumentBody);
|
|
28
|
-
|
|
29
21
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
22
|
args[_key] = arguments[_key];
|
|
31
23
|
}
|
|
32
|
-
|
|
33
24
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
-
|
|
35
25
|
_defineProperty(_assertThisInitialized(_this), "renderChild", function (props) {
|
|
36
26
|
return /*#__PURE__*/React.createElement(Document, _extends({}, _this.props, props));
|
|
37
27
|
});
|
|
38
|
-
|
|
39
28
|
_defineProperty(_assertThisInitialized(_this), "stateMapper", function (state) {
|
|
40
29
|
var doc = state.doc,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
hasError = state.hasError,
|
|
31
|
+
isLoading = state.isLoading,
|
|
32
|
+
mode = state.mode;
|
|
44
33
|
return {
|
|
45
34
|
doc: doc,
|
|
46
35
|
hasError: hasError,
|
|
@@ -48,19 +37,16 @@ var DocumentBody = /*#__PURE__*/function (_PureComponent) {
|
|
|
48
37
|
mode: mode
|
|
49
38
|
};
|
|
50
39
|
});
|
|
51
|
-
|
|
52
40
|
_defineProperty(_assertThisInitialized(_this), "renderPropsMapper", function (renderProps) {
|
|
53
41
|
var renderTitle = renderProps.renderTitle,
|
|
54
|
-
|
|
42
|
+
renderToolbar = renderProps.renderToolbar;
|
|
55
43
|
return {
|
|
56
44
|
renderTitle: renderTitle,
|
|
57
45
|
renderToolbar: renderToolbar
|
|
58
46
|
};
|
|
59
47
|
});
|
|
60
|
-
|
|
61
48
|
return _this;
|
|
62
49
|
}
|
|
63
|
-
|
|
64
50
|
_createClass(DocumentBody, [{
|
|
65
51
|
key: "render",
|
|
66
52
|
value: function render() {
|
|
@@ -70,8 +56,6 @@ var DocumentBody = /*#__PURE__*/function (_PureComponent) {
|
|
|
70
56
|
}, this.renderChild);
|
|
71
57
|
}
|
|
72
58
|
}]);
|
|
73
|
-
|
|
74
59
|
return DocumentBody;
|
|
75
60
|
}(PureComponent);
|
|
76
|
-
|
|
77
61
|
export { DocumentBody as default };
|
|
@@ -7,31 +7,21 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
-
|
|
11
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
|
|
13
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
-
|
|
15
12
|
import React from 'react';
|
|
16
13
|
import { PureComponent } from 'react';
|
|
17
14
|
import { Consumer } from '../consumers/consumer';
|
|
18
|
-
|
|
19
15
|
var WithDocumentActions = /*#__PURE__*/function (_PureComponent) {
|
|
20
16
|
_inherits(WithDocumentActions, _PureComponent);
|
|
21
|
-
|
|
22
17
|
var _super = _createSuper(WithDocumentActions);
|
|
23
|
-
|
|
24
18
|
function WithDocumentActions() {
|
|
25
19
|
var _this;
|
|
26
|
-
|
|
27
20
|
_classCallCheck(this, WithDocumentActions);
|
|
28
|
-
|
|
29
21
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
22
|
args[_key] = arguments[_key];
|
|
31
23
|
}
|
|
32
|
-
|
|
33
24
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
-
|
|
35
25
|
_defineProperty(_assertThisInitialized(_this), "actionsMapper", function (actions) {
|
|
36
26
|
return {
|
|
37
27
|
createDocument: function createDocument(value) {
|
|
@@ -41,7 +31,6 @@ var WithDocumentActions = /*#__PURE__*/function (_PureComponent) {
|
|
|
41
31
|
switch (_context.prev = _context.next) {
|
|
42
32
|
case 0:
|
|
43
33
|
return _context.abrupt("return", actions.createDocument(value));
|
|
44
|
-
|
|
45
34
|
case 1:
|
|
46
35
|
case "end":
|
|
47
36
|
return _context.stop();
|
|
@@ -57,7 +46,6 @@ var WithDocumentActions = /*#__PURE__*/function (_PureComponent) {
|
|
|
57
46
|
switch (_context2.prev = _context2.next) {
|
|
58
47
|
case 0:
|
|
59
48
|
actions.setDocumentMode('edit');
|
|
60
|
-
|
|
61
49
|
case 1:
|
|
62
50
|
case "end":
|
|
63
51
|
return _context2.stop();
|
|
@@ -73,7 +61,6 @@ var WithDocumentActions = /*#__PURE__*/function (_PureComponent) {
|
|
|
73
61
|
switch (_context3.prev = _context3.next) {
|
|
74
62
|
case 0:
|
|
75
63
|
return _context3.abrupt("return", actions.updateDocument(value));
|
|
76
|
-
|
|
77
64
|
case 1:
|
|
78
65
|
case "end":
|
|
79
66
|
return _context3.stop();
|
|
@@ -89,7 +76,6 @@ var WithDocumentActions = /*#__PURE__*/function (_PureComponent) {
|
|
|
89
76
|
switch (_context4.prev = _context4.next) {
|
|
90
77
|
case 0:
|
|
91
78
|
actions.setDocumentMode('view');
|
|
92
|
-
|
|
93
79
|
case 1:
|
|
94
80
|
case "end":
|
|
95
81
|
return _context4.stop();
|
|
@@ -100,10 +86,8 @@ var WithDocumentActions = /*#__PURE__*/function (_PureComponent) {
|
|
|
100
86
|
}
|
|
101
87
|
};
|
|
102
88
|
});
|
|
103
|
-
|
|
104
89
|
return _this;
|
|
105
90
|
}
|
|
106
|
-
|
|
107
91
|
_createClass(WithDocumentActions, [{
|
|
108
92
|
key: "render",
|
|
109
93
|
value: function render() {
|
|
@@ -112,8 +96,6 @@ var WithDocumentActions = /*#__PURE__*/function (_PureComponent) {
|
|
|
112
96
|
}, this.props.render);
|
|
113
97
|
}
|
|
114
98
|
}]);
|
|
115
|
-
|
|
116
99
|
return WithDocumentActions;
|
|
117
100
|
}(PureComponent);
|
|
118
|
-
|
|
119
101
|
export { WithDocumentActions as default };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import { createContext } from 'react';
|
|
4
|
-
|
|
5
4
|
var noop = function noop() {};
|
|
6
|
-
|
|
7
5
|
export var Context = /*#__PURE__*/createContext({
|
|
8
6
|
value: {},
|
|
9
7
|
actions: {
|
|
@@ -17,7 +15,6 @@ export var Context = /*#__PURE__*/createContext({
|
|
|
17
15
|
switch (_context.prev = _context.next) {
|
|
18
16
|
case 0:
|
|
19
17
|
throw new Error('Not implemented.');
|
|
20
|
-
|
|
21
18
|
case 1:
|
|
22
19
|
case "end":
|
|
23
20
|
return _context.stop();
|
|
@@ -25,11 +22,9 @@ export var Context = /*#__PURE__*/createContext({
|
|
|
25
22
|
}
|
|
26
23
|
}, _callee);
|
|
27
24
|
}));
|
|
28
|
-
|
|
29
25
|
function updateDocument() {
|
|
30
26
|
return _updateDocument.apply(this, arguments);
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
return updateDocument;
|
|
34
29
|
}(),
|
|
35
30
|
createDocument: function () {
|
|
@@ -39,7 +34,6 @@ export var Context = /*#__PURE__*/createContext({
|
|
|
39
34
|
switch (_context2.prev = _context2.next) {
|
|
40
35
|
case 0:
|
|
41
36
|
throw new Error('Not implemented.');
|
|
42
|
-
|
|
43
37
|
case 1:
|
|
44
38
|
case "end":
|
|
45
39
|
return _context2.stop();
|
|
@@ -47,11 +41,9 @@ export var Context = /*#__PURE__*/createContext({
|
|
|
47
41
|
}
|
|
48
42
|
}, _callee2);
|
|
49
43
|
}));
|
|
50
|
-
|
|
51
44
|
function createDocument() {
|
|
52
45
|
return _createDocument.apply(this, arguments);
|
|
53
46
|
}
|
|
54
|
-
|
|
55
47
|
return createDocument;
|
|
56
48
|
}()
|
|
57
49
|
},
|
|
@@ -7,15 +7,10 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
10
|
-
|
|
11
10
|
var _templateObject;
|
|
12
|
-
|
|
13
11
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
14
|
-
|
|
15
12
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
-
|
|
17
13
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
-
|
|
19
14
|
import React from 'react';
|
|
20
15
|
import { Component } from 'react';
|
|
21
16
|
import styled from 'styled-components';
|
|
@@ -24,19 +19,13 @@ import { getProvider } from '../provider';
|
|
|
24
19
|
import { akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
|
|
25
20
|
export var akEditorFullPageMaxWidth = 680;
|
|
26
21
|
var Content = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n line-height: 24px;\n height: 100%;\n width: 100%;\n max-width: ", "px;\n padding-top: 50px;\n margin: 0 auto;\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n padding-bottom: 55px;\n\n & > * {\n padding: 0 32px;\n }\n"])), akEditorFullPageMaxWidth + akEditorGutterPadding * 2);
|
|
27
|
-
|
|
28
22
|
var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
29
23
|
_inherits(EmbeddedDocument, _Component);
|
|
30
|
-
|
|
31
24
|
var _super = _createSuper(EmbeddedDocument);
|
|
32
|
-
|
|
33
25
|
function EmbeddedDocument(props) {
|
|
34
26
|
var _this;
|
|
35
|
-
|
|
36
27
|
_classCallCheck(this, EmbeddedDocument);
|
|
37
|
-
|
|
38
28
|
_this = _super.call(this, props);
|
|
39
|
-
|
|
40
29
|
_defineProperty(_assertThisInitialized(_this), "getDocumentByObjectId", /*#__PURE__*/function () {
|
|
41
30
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(objectId, language) {
|
|
42
31
|
var doc;
|
|
@@ -47,15 +36,11 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
47
36
|
_this.setState({
|
|
48
37
|
isLoading: true
|
|
49
38
|
});
|
|
50
|
-
|
|
51
39
|
_context.next = 3;
|
|
52
40
|
return _this.provider.getDocumentByObjectId(objectId, language);
|
|
53
|
-
|
|
54
41
|
case 3:
|
|
55
42
|
doc = _context.sent;
|
|
56
|
-
|
|
57
43
|
_this.setDocumentState(doc);
|
|
58
|
-
|
|
59
44
|
case 5:
|
|
60
45
|
case "end":
|
|
61
46
|
return _context.stop();
|
|
@@ -63,12 +48,10 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
63
48
|
}
|
|
64
49
|
}, _callee);
|
|
65
50
|
}));
|
|
66
|
-
|
|
67
51
|
return function (_x, _x2) {
|
|
68
52
|
return _ref.apply(this, arguments);
|
|
69
53
|
};
|
|
70
54
|
}());
|
|
71
|
-
|
|
72
55
|
_defineProperty(_assertThisInitialized(_this), "getDocument", /*#__PURE__*/function () {
|
|
73
56
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(documentId, language) {
|
|
74
57
|
var doc;
|
|
@@ -79,15 +62,11 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
79
62
|
_this.setState({
|
|
80
63
|
isLoading: true
|
|
81
64
|
});
|
|
82
|
-
|
|
83
65
|
_context2.next = 3;
|
|
84
66
|
return _this.provider.getDocument(documentId, language);
|
|
85
|
-
|
|
86
67
|
case 3:
|
|
87
68
|
doc = _context2.sent;
|
|
88
|
-
|
|
89
69
|
_this.setDocumentState(doc);
|
|
90
|
-
|
|
91
70
|
case 5:
|
|
92
71
|
case "end":
|
|
93
72
|
return _context2.stop();
|
|
@@ -95,12 +74,10 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
95
74
|
}
|
|
96
75
|
}, _callee2);
|
|
97
76
|
}));
|
|
98
|
-
|
|
99
77
|
return function (_x3, _x4) {
|
|
100
78
|
return _ref2.apply(this, arguments);
|
|
101
79
|
};
|
|
102
80
|
}());
|
|
103
|
-
|
|
104
81
|
_defineProperty(_assertThisInitialized(_this), "setDocumentMode", /*#__PURE__*/function () {
|
|
105
82
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(mode) {
|
|
106
83
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
@@ -110,7 +87,6 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
110
87
|
_this.setState({
|
|
111
88
|
mode: mode
|
|
112
89
|
});
|
|
113
|
-
|
|
114
90
|
case 1:
|
|
115
91
|
case "end":
|
|
116
92
|
return _context3.stop();
|
|
@@ -118,56 +94,43 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
118
94
|
}
|
|
119
95
|
}, _callee3);
|
|
120
96
|
}));
|
|
121
|
-
|
|
122
97
|
return function (_x5) {
|
|
123
98
|
return _ref3.apply(this, arguments);
|
|
124
99
|
};
|
|
125
100
|
}());
|
|
126
|
-
|
|
127
101
|
_defineProperty(_assertThisInitialized(_this), "updateDocument", /*#__PURE__*/function () {
|
|
128
102
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(body) {
|
|
129
103
|
var _ref5, documentId, objectId, language, doc;
|
|
130
|
-
|
|
131
104
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
132
105
|
while (1) {
|
|
133
106
|
switch (_context4.prev = _context4.next) {
|
|
134
107
|
case 0:
|
|
135
108
|
_ref5 = _this.state.doc || _this.props, documentId = _ref5.documentId, objectId = _ref5.objectId, language = _ref5.language;
|
|
136
|
-
|
|
137
109
|
if (documentId) {
|
|
138
110
|
_context4.next = 3;
|
|
139
111
|
break;
|
|
140
112
|
}
|
|
141
|
-
|
|
142
113
|
return _context4.abrupt("return", _this.createDocument(body));
|
|
143
|
-
|
|
144
114
|
case 3:
|
|
145
115
|
_context4.next = 5;
|
|
146
116
|
return _this.provider.updateDocument(documentId, JSON.stringify(body), objectId, '', language);
|
|
147
|
-
|
|
148
117
|
case 5:
|
|
149
118
|
doc = _context4.sent;
|
|
150
|
-
|
|
151
119
|
if (!doc) {
|
|
152
120
|
_context4.next = 11;
|
|
153
121
|
break;
|
|
154
122
|
}
|
|
155
|
-
|
|
156
123
|
_this.setState({
|
|
157
124
|
doc: doc,
|
|
158
125
|
mode: 'view'
|
|
159
126
|
});
|
|
160
|
-
|
|
161
127
|
return _context4.abrupt("return", doc);
|
|
162
|
-
|
|
163
128
|
case 11:
|
|
164
129
|
_this.setState({
|
|
165
130
|
hasError: true,
|
|
166
131
|
mode: 'view'
|
|
167
132
|
});
|
|
168
|
-
|
|
169
133
|
throw new Error('Failed to update document');
|
|
170
|
-
|
|
171
134
|
case 13:
|
|
172
135
|
case "end":
|
|
173
136
|
return _context4.stop();
|
|
@@ -175,16 +138,13 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
175
138
|
}
|
|
176
139
|
}, _callee4);
|
|
177
140
|
}));
|
|
178
|
-
|
|
179
141
|
return function (_x6) {
|
|
180
142
|
return _ref4.apply(this, arguments);
|
|
181
143
|
};
|
|
182
144
|
}());
|
|
183
|
-
|
|
184
145
|
_defineProperty(_assertThisInitialized(_this), "createDocument", /*#__PURE__*/function () {
|
|
185
146
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(body) {
|
|
186
147
|
var _this$props, objectId, language, doc;
|
|
187
|
-
|
|
188
148
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
189
149
|
while (1) {
|
|
190
150
|
switch (_context5.prev = _context5.next) {
|
|
@@ -192,30 +152,23 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
192
152
|
_this$props = _this.props, objectId = _this$props.objectId, language = _this$props.language;
|
|
193
153
|
_context5.next = 3;
|
|
194
154
|
return _this.provider.createDocument(JSON.stringify(body), objectId, '', language);
|
|
195
|
-
|
|
196
155
|
case 3:
|
|
197
156
|
doc = _context5.sent;
|
|
198
|
-
|
|
199
157
|
if (!doc) {
|
|
200
158
|
_context5.next = 9;
|
|
201
159
|
break;
|
|
202
160
|
}
|
|
203
|
-
|
|
204
161
|
_this.setState({
|
|
205
162
|
doc: doc,
|
|
206
163
|
mode: 'view'
|
|
207
164
|
});
|
|
208
|
-
|
|
209
165
|
return _context5.abrupt("return", doc);
|
|
210
|
-
|
|
211
166
|
case 9:
|
|
212
167
|
_this.setState({
|
|
213
168
|
hasError: true,
|
|
214
169
|
mode: 'view'
|
|
215
170
|
});
|
|
216
|
-
|
|
217
171
|
throw new Error('Failed to create document');
|
|
218
|
-
|
|
219
172
|
case 11:
|
|
220
173
|
case "end":
|
|
221
174
|
return _context5.stop();
|
|
@@ -223,12 +176,10 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
223
176
|
}
|
|
224
177
|
}, _callee5);
|
|
225
178
|
}));
|
|
226
|
-
|
|
227
179
|
return function (_x7) {
|
|
228
180
|
return _ref6.apply(this, arguments);
|
|
229
181
|
};
|
|
230
182
|
}());
|
|
231
|
-
|
|
232
183
|
_defineProperty(_assertThisInitialized(_this), "setDocumentState", function (doc) {
|
|
233
184
|
if (doc) {
|
|
234
185
|
_this.setState({
|
|
@@ -242,7 +193,6 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
242
193
|
});
|
|
243
194
|
}
|
|
244
195
|
});
|
|
245
|
-
|
|
246
196
|
_this.actions = {
|
|
247
197
|
getDocument: _this.getDocument,
|
|
248
198
|
setDocumentMode: _this.setDocumentMode,
|
|
@@ -257,35 +207,28 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
257
207
|
};
|
|
258
208
|
return _this;
|
|
259
209
|
}
|
|
260
|
-
|
|
261
210
|
_createClass(EmbeddedDocument, [{
|
|
262
211
|
key: "componentDidMount",
|
|
263
212
|
value: function () {
|
|
264
213
|
var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
265
214
|
var _this$props2, documentId, language, objectId;
|
|
266
|
-
|
|
267
215
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
268
216
|
while (1) {
|
|
269
217
|
switch (_context6.prev = _context6.next) {
|
|
270
218
|
case 0:
|
|
271
219
|
_this$props2 = this.props, documentId = _this$props2.documentId, language = _this$props2.language, objectId = _this$props2.objectId;
|
|
272
|
-
|
|
273
220
|
if (!documentId) {
|
|
274
221
|
_context6.next = 6;
|
|
275
222
|
break;
|
|
276
223
|
}
|
|
277
|
-
|
|
278
224
|
_context6.next = 4;
|
|
279
225
|
return this.getDocument(documentId, language);
|
|
280
|
-
|
|
281
226
|
case 4:
|
|
282
227
|
_context6.next = 8;
|
|
283
228
|
break;
|
|
284
|
-
|
|
285
229
|
case 6:
|
|
286
230
|
_context6.next = 8;
|
|
287
231
|
return this.getDocumentByObjectId(objectId, language);
|
|
288
|
-
|
|
289
232
|
case 8:
|
|
290
233
|
case "end":
|
|
291
234
|
return _context6.stop();
|
|
@@ -293,11 +236,9 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
293
236
|
}
|
|
294
237
|
}, _callee6, this);
|
|
295
238
|
}));
|
|
296
|
-
|
|
297
239
|
function componentDidMount() {
|
|
298
240
|
return _componentDidMount.apply(this, arguments);
|
|
299
241
|
}
|
|
300
|
-
|
|
301
242
|
return componentDidMount;
|
|
302
243
|
}()
|
|
303
244
|
}, {
|
|
@@ -312,51 +253,45 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
312
253
|
function renderToolbar() {
|
|
313
254
|
var mode = this.state.mode;
|
|
314
255
|
var renderToolbar = this.props.renderToolbar;
|
|
315
|
-
|
|
316
256
|
if (mode !== 'view' || !renderToolbar) {
|
|
317
257
|
return;
|
|
318
258
|
}
|
|
319
|
-
|
|
320
259
|
return renderToolbar(mode);
|
|
321
260
|
}
|
|
261
|
+
|
|
322
262
|
/**
|
|
323
263
|
* Title will only be rendered here if we're in "view"-mode.
|
|
324
264
|
*
|
|
325
265
|
* In all other modes, the title rendering will be triggered
|
|
326
266
|
* by the Document-component.
|
|
327
267
|
*/
|
|
328
|
-
|
|
329
268
|
}, {
|
|
330
269
|
key: "renderTitle",
|
|
331
270
|
value: function renderTitle() {
|
|
332
271
|
var _this$state = this.state,
|
|
333
|
-
|
|
334
|
-
|
|
272
|
+
mode = _this$state.mode,
|
|
273
|
+
doc = _this$state.doc;
|
|
335
274
|
var renderTitle = this.props.renderTitle;
|
|
336
|
-
|
|
337
275
|
if (mode !== 'view' || !renderTitle) {
|
|
338
276
|
return;
|
|
339
277
|
}
|
|
340
|
-
|
|
341
278
|
return renderTitle(mode, doc);
|
|
342
279
|
}
|
|
343
280
|
}, {
|
|
344
281
|
key: "renderContent",
|
|
345
282
|
value: function renderContent() {
|
|
346
283
|
var mode = this.state.mode;
|
|
347
|
-
|
|
348
284
|
if (mode === 'view') {
|
|
349
285
|
return /*#__PURE__*/React.createElement(React.Fragment, null, this.renderToolbar(), /*#__PURE__*/React.createElement(Content, null, this.renderTitle(), this.props.children));
|
|
350
286
|
}
|
|
351
|
-
|
|
352
287
|
return this.props.children;
|
|
353
288
|
}
|
|
354
289
|
}, {
|
|
355
290
|
key: "render",
|
|
356
291
|
value: function render() {
|
|
357
292
|
var _this$props3 = this.props,
|
|
358
|
-
|
|
359
|
-
|
|
293
|
+
renderTitle = _this$props3.renderTitle,
|
|
294
|
+
renderToolbar = _this$props3.renderToolbar;
|
|
360
295
|
return /*#__PURE__*/React.createElement(Context.Provider, {
|
|
361
296
|
value: {
|
|
362
297
|
value: this.state,
|
|
@@ -369,8 +304,6 @@ var EmbeddedDocument = /*#__PURE__*/function (_Component) {
|
|
|
369
304
|
}, this.renderContent());
|
|
370
305
|
}
|
|
371
306
|
}]);
|
|
372
|
-
|
|
373
307
|
return EmbeddedDocument;
|
|
374
308
|
}(Component);
|
|
375
|
-
|
|
376
309
|
export { EmbeddedDocument as default };
|
|
@@ -2,17 +2,14 @@ import { default as ServiceProvider } from './service-provider';
|
|
|
2
2
|
export { ServiceProvider };
|
|
3
3
|
export var getProvider = function getProvider(_ref) {
|
|
4
4
|
var provider = _ref.provider,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
url = _ref.url;
|
|
7
6
|
if (provider) {
|
|
8
7
|
return provider;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
if (url) {
|
|
12
10
|
return new ServiceProvider({
|
|
13
11
|
url: url
|
|
14
12
|
});
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
throw new Error('Missing provider');
|
|
18
15
|
};
|