@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
|
@@ -5,46 +5,36 @@ import { Context } from '../context/context';
|
|
|
5
5
|
export class Consumer extends PureComponent {
|
|
6
6
|
constructor(...args) {
|
|
7
7
|
super(...args);
|
|
8
|
-
|
|
9
8
|
_defineProperty(this, "getPropsFromActions", actions => {
|
|
10
9
|
const {
|
|
11
10
|
actionsMapper
|
|
12
11
|
} = this.props;
|
|
13
|
-
|
|
14
12
|
if (actionsMapper) {
|
|
15
13
|
if (!this.previousActions || !this.propsFromActions || this.previousActions !== actions) {
|
|
16
14
|
this.propsFromActions = actionsMapper(actions);
|
|
17
15
|
}
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
this.previousActions = actions;
|
|
21
18
|
return this.propsFromActions;
|
|
22
19
|
});
|
|
23
|
-
|
|
24
20
|
_defineProperty(this, "getPropsFromState", state => {
|
|
25
21
|
const {
|
|
26
22
|
stateMapper
|
|
27
23
|
} = this.props;
|
|
28
|
-
|
|
29
24
|
if (stateMapper) {
|
|
30
25
|
return stateMapper(state);
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
return undefined;
|
|
34
28
|
});
|
|
35
|
-
|
|
36
29
|
_defineProperty(this, "getRenderProps", renderProps => {
|
|
37
30
|
const {
|
|
38
31
|
renderPropsMapper
|
|
39
32
|
} = this.props;
|
|
40
|
-
|
|
41
33
|
if (renderPropsMapper) {
|
|
42
34
|
return renderPropsMapper(renderProps);
|
|
43
35
|
}
|
|
44
|
-
|
|
45
36
|
return undefined;
|
|
46
37
|
});
|
|
47
|
-
|
|
48
38
|
_defineProperty(this, "renderChildren", ({
|
|
49
39
|
actions,
|
|
50
40
|
value,
|
|
@@ -54,9 +44,7 @@ export class Consumer extends PureComponent {
|
|
|
54
44
|
return this.props.children(props);
|
|
55
45
|
});
|
|
56
46
|
}
|
|
57
|
-
|
|
58
47
|
render() {
|
|
59
48
|
return /*#__PURE__*/React.createElement(Context.Consumer, null, this.renderChildren);
|
|
60
49
|
}
|
|
61
|
-
|
|
62
50
|
}
|
|
@@ -7,11 +7,9 @@ import { default as Document } from '../components/document';
|
|
|
7
7
|
export default class DocumentBody extends PureComponent {
|
|
8
8
|
constructor(...args) {
|
|
9
9
|
super(...args);
|
|
10
|
-
|
|
11
10
|
_defineProperty(this, "renderChild", props => {
|
|
12
11
|
return /*#__PURE__*/React.createElement(Document, _extends({}, this.props, props));
|
|
13
12
|
});
|
|
14
|
-
|
|
15
13
|
_defineProperty(this, "stateMapper", state => {
|
|
16
14
|
const {
|
|
17
15
|
doc,
|
|
@@ -26,7 +24,6 @@ export default class DocumentBody extends PureComponent {
|
|
|
26
24
|
mode
|
|
27
25
|
};
|
|
28
26
|
});
|
|
29
|
-
|
|
30
27
|
_defineProperty(this, "renderPropsMapper", renderProps => {
|
|
31
28
|
const {
|
|
32
29
|
renderTitle,
|
|
@@ -38,12 +35,10 @@ export default class DocumentBody extends PureComponent {
|
|
|
38
35
|
};
|
|
39
36
|
});
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
render() {
|
|
43
39
|
return /*#__PURE__*/React.createElement(Consumer, {
|
|
44
40
|
stateMapper: this.stateMapper,
|
|
45
41
|
renderPropsMapper: this.renderPropsMapper
|
|
46
42
|
}, this.renderChild);
|
|
47
43
|
}
|
|
48
|
-
|
|
49
44
|
}
|
|
@@ -5,31 +5,24 @@ import { Consumer } from '../consumers/consumer';
|
|
|
5
5
|
export default class WithDocumentActions extends PureComponent {
|
|
6
6
|
constructor(...args) {
|
|
7
7
|
super(...args);
|
|
8
|
-
|
|
9
8
|
_defineProperty(this, "actionsMapper", actions => ({
|
|
10
9
|
async createDocument(value) {
|
|
11
10
|
return actions.createDocument(value);
|
|
12
11
|
},
|
|
13
|
-
|
|
14
12
|
async editDocument() {
|
|
15
13
|
actions.setDocumentMode('edit');
|
|
16
14
|
},
|
|
17
|
-
|
|
18
15
|
async updateDocument(value) {
|
|
19
16
|
return actions.updateDocument(value);
|
|
20
17
|
},
|
|
21
|
-
|
|
22
18
|
async cancelEdit() {
|
|
23
19
|
actions.setDocumentMode('view');
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
}));
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
render() {
|
|
30
24
|
return /*#__PURE__*/React.createElement(Consumer, {
|
|
31
25
|
actionsMapper: this.actionsMapper
|
|
32
26
|
}, this.props.render);
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
}
|
|
@@ -25,7 +25,6 @@ const Content = styled.div`
|
|
|
25
25
|
export default class EmbeddedDocument extends Component {
|
|
26
26
|
constructor(props) {
|
|
27
27
|
super(props);
|
|
28
|
-
|
|
29
28
|
_defineProperty(this, "getDocumentByObjectId", async (objectId, language) => {
|
|
30
29
|
this.setState({
|
|
31
30
|
isLoading: true
|
|
@@ -33,7 +32,6 @@ export default class EmbeddedDocument extends Component {
|
|
|
33
32
|
const doc = await this.provider.getDocumentByObjectId(objectId, language);
|
|
34
33
|
this.setDocumentState(doc);
|
|
35
34
|
});
|
|
36
|
-
|
|
37
35
|
_defineProperty(this, "getDocument", async (documentId, language) => {
|
|
38
36
|
this.setState({
|
|
39
37
|
isLoading: true
|
|
@@ -41,26 +39,21 @@ export default class EmbeddedDocument extends Component {
|
|
|
41
39
|
const doc = await this.provider.getDocument(documentId, language);
|
|
42
40
|
this.setDocumentState(doc);
|
|
43
41
|
});
|
|
44
|
-
|
|
45
42
|
_defineProperty(this, "setDocumentMode", async mode => {
|
|
46
43
|
this.setState({
|
|
47
44
|
mode
|
|
48
45
|
});
|
|
49
46
|
});
|
|
50
|
-
|
|
51
47
|
_defineProperty(this, "updateDocument", async body => {
|
|
52
48
|
const {
|
|
53
49
|
documentId,
|
|
54
50
|
objectId,
|
|
55
51
|
language
|
|
56
52
|
} = this.state.doc || this.props;
|
|
57
|
-
|
|
58
53
|
if (!documentId) {
|
|
59
54
|
return this.createDocument(body);
|
|
60
55
|
}
|
|
61
|
-
|
|
62
56
|
const doc = await this.provider.updateDocument(documentId, JSON.stringify(body), objectId, '', language);
|
|
63
|
-
|
|
64
57
|
if (doc) {
|
|
65
58
|
this.setState({
|
|
66
59
|
doc,
|
|
@@ -75,14 +68,12 @@ export default class EmbeddedDocument extends Component {
|
|
|
75
68
|
throw new Error('Failed to update document');
|
|
76
69
|
}
|
|
77
70
|
});
|
|
78
|
-
|
|
79
71
|
_defineProperty(this, "createDocument", async body => {
|
|
80
72
|
const {
|
|
81
73
|
objectId,
|
|
82
74
|
language
|
|
83
75
|
} = this.props;
|
|
84
76
|
const doc = await this.provider.createDocument(JSON.stringify(body), objectId, '', language);
|
|
85
|
-
|
|
86
77
|
if (doc) {
|
|
87
78
|
this.setState({
|
|
88
79
|
doc,
|
|
@@ -97,7 +88,6 @@ export default class EmbeddedDocument extends Component {
|
|
|
97
88
|
throw new Error('Failed to create document');
|
|
98
89
|
}
|
|
99
90
|
});
|
|
100
|
-
|
|
101
91
|
_defineProperty(this, "setDocumentState", doc => {
|
|
102
92
|
if (doc) {
|
|
103
93
|
this.setState({
|
|
@@ -111,7 +101,6 @@ export default class EmbeddedDocument extends Component {
|
|
|
111
101
|
});
|
|
112
102
|
}
|
|
113
103
|
});
|
|
114
|
-
|
|
115
104
|
this.actions = {
|
|
116
105
|
getDocument: this.getDocument,
|
|
117
106
|
setDocumentMode: this.setDocumentMode,
|
|
@@ -125,21 +114,18 @@ export default class EmbeddedDocument extends Component {
|
|
|
125
114
|
isLoading: true
|
|
126
115
|
};
|
|
127
116
|
}
|
|
128
|
-
|
|
129
117
|
async componentDidMount() {
|
|
130
118
|
const {
|
|
131
119
|
documentId,
|
|
132
120
|
language,
|
|
133
121
|
objectId
|
|
134
122
|
} = this.props;
|
|
135
|
-
|
|
136
123
|
if (documentId) {
|
|
137
124
|
await this.getDocument(documentId, language);
|
|
138
125
|
} else {
|
|
139
126
|
await this.getDocumentByObjectId(objectId, language);
|
|
140
127
|
}
|
|
141
128
|
}
|
|
142
|
-
|
|
143
129
|
/**
|
|
144
130
|
* Toolbar will only be rendered here if we're in "view"-mode.
|
|
145
131
|
*
|
|
@@ -153,21 +139,18 @@ export default class EmbeddedDocument extends Component {
|
|
|
153
139
|
const {
|
|
154
140
|
renderToolbar
|
|
155
141
|
} = this.props;
|
|
156
|
-
|
|
157
142
|
if (mode !== 'view' || !renderToolbar) {
|
|
158
143
|
return;
|
|
159
144
|
}
|
|
160
|
-
|
|
161
145
|
return renderToolbar(mode);
|
|
162
146
|
}
|
|
147
|
+
|
|
163
148
|
/**
|
|
164
149
|
* Title will only be rendered here if we're in "view"-mode.
|
|
165
150
|
*
|
|
166
151
|
* In all other modes, the title rendering will be triggered
|
|
167
152
|
* by the Document-component.
|
|
168
153
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
154
|
renderTitle() {
|
|
172
155
|
const {
|
|
173
156
|
mode,
|
|
@@ -176,26 +159,20 @@ export default class EmbeddedDocument extends Component {
|
|
|
176
159
|
const {
|
|
177
160
|
renderTitle
|
|
178
161
|
} = this.props;
|
|
179
|
-
|
|
180
162
|
if (mode !== 'view' || !renderTitle) {
|
|
181
163
|
return;
|
|
182
164
|
}
|
|
183
|
-
|
|
184
165
|
return renderTitle(mode, doc);
|
|
185
166
|
}
|
|
186
|
-
|
|
187
167
|
renderContent() {
|
|
188
168
|
const {
|
|
189
169
|
mode
|
|
190
170
|
} = this.state;
|
|
191
|
-
|
|
192
171
|
if (mode === 'view') {
|
|
193
172
|
return /*#__PURE__*/React.createElement(React.Fragment, null, this.renderToolbar(), /*#__PURE__*/React.createElement(Content, null, this.renderTitle(), this.props.children));
|
|
194
173
|
}
|
|
195
|
-
|
|
196
174
|
return this.props.children;
|
|
197
175
|
}
|
|
198
|
-
|
|
199
176
|
render() {
|
|
200
177
|
const {
|
|
201
178
|
renderTitle,
|
|
@@ -212,5 +189,4 @@ export default class EmbeddedDocument extends Component {
|
|
|
212
189
|
}
|
|
213
190
|
}, this.renderContent());
|
|
214
191
|
}
|
|
215
|
-
|
|
216
192
|
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { utils } from '@atlaskit/util-service-support';
|
|
2
|
-
|
|
3
2
|
function queryBuilder(data) {
|
|
4
3
|
return Object.keys(data).map(key => {
|
|
5
4
|
return [key, data[key]].map(encodeURIComponent).join('=');
|
|
6
5
|
}).join('&');
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
export default class ServiceProvider {
|
|
10
8
|
constructor(config) {
|
|
11
9
|
this.config = config;
|
|
12
10
|
}
|
|
13
|
-
|
|
14
11
|
async getDocument(documentId, language) {
|
|
15
12
|
try {
|
|
16
13
|
const document = await utils.requestService(this.config, {
|
|
@@ -23,7 +20,6 @@ export default class ServiceProvider {
|
|
|
23
20
|
return null;
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
async getDocumentByObjectId(objectId, language) {
|
|
28
24
|
try {
|
|
29
25
|
const queryString = queryBuilder({
|
|
@@ -35,11 +31,9 @@ export default class ServiceProvider {
|
|
|
35
31
|
const documents = await utils.requestService(this.config, {
|
|
36
32
|
path: `document?${queryString}`
|
|
37
33
|
});
|
|
38
|
-
|
|
39
34
|
if (documents && documents.length) {
|
|
40
35
|
return documents[0].language[language || 'default'].versions[0];
|
|
41
36
|
}
|
|
42
|
-
|
|
43
37
|
return null;
|
|
44
38
|
} catch (err) {
|
|
45
39
|
// eslint-disable-next-line no-console
|
|
@@ -47,7 +41,6 @@ export default class ServiceProvider {
|
|
|
47
41
|
return null;
|
|
48
42
|
}
|
|
49
43
|
}
|
|
50
|
-
|
|
51
44
|
async updateDocument(documentId, body, objectId, title, language) {
|
|
52
45
|
try {
|
|
53
46
|
const document = await utils.requestService(this.config, {
|
|
@@ -72,7 +65,6 @@ export default class ServiceProvider {
|
|
|
72
65
|
return null;
|
|
73
66
|
}
|
|
74
67
|
}
|
|
75
|
-
|
|
76
68
|
async createDocument(body, objectId, title, language) {
|
|
77
69
|
try {
|
|
78
70
|
const document = await utils.requestService(this.config, {
|
|
@@ -97,5 +89,4 @@ export default class ServiceProvider {
|
|
|
97
89
|
return null;
|
|
98
90
|
}
|
|
99
91
|
}
|
|
100
|
-
|
|
101
92
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -4,36 +4,27 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
4
4
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
|
|
8
7
|
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); }; }
|
|
9
|
-
|
|
10
8
|
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; } }
|
|
11
|
-
|
|
12
9
|
import React from 'react';
|
|
13
10
|
import { Component } from 'react';
|
|
14
11
|
import { Editor, EditorContext, WithEditorActions } from '@atlaskit/editor-core';
|
|
15
12
|
import { ReactRenderer } from '@atlaskit/renderer';
|
|
16
13
|
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
17
14
|
var emptyDoc = '{ "type": "doc", "version": 1, "content": [] }';
|
|
18
|
-
|
|
19
15
|
var Document = /*#__PURE__*/function (_Component) {
|
|
20
16
|
_inherits(Document, _Component);
|
|
21
|
-
|
|
22
17
|
var _super = _createSuper(Document);
|
|
23
|
-
|
|
24
18
|
function Document() {
|
|
25
19
|
_classCallCheck(this, Document);
|
|
26
|
-
|
|
27
20
|
return _super.apply(this, arguments);
|
|
28
21
|
}
|
|
29
|
-
|
|
30
22
|
_createClass(Document, [{
|
|
31
23
|
key: "renderToolbar",
|
|
32
24
|
value: function renderToolbar() {
|
|
33
25
|
var _this$props = this.props,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
mode = _this$props.mode,
|
|
27
|
+
renderToolbar = _this$props.renderToolbar;
|
|
37
28
|
if (renderToolbar) {
|
|
38
29
|
return /*#__PURE__*/React.createElement(WithEditorActions, {
|
|
39
30
|
render: function render(actions) {
|
|
@@ -41,34 +32,29 @@ var Document = /*#__PURE__*/function (_Component) {
|
|
|
41
32
|
}
|
|
42
33
|
});
|
|
43
34
|
}
|
|
44
|
-
|
|
45
35
|
return;
|
|
46
36
|
}
|
|
47
37
|
}, {
|
|
48
38
|
key: "renderTitle",
|
|
49
39
|
value: function renderTitle() {
|
|
50
40
|
var _this$props2 = this.props,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
41
|
+
renderTitle = _this$props2.renderTitle,
|
|
42
|
+
mode = _this$props2.mode,
|
|
43
|
+
doc = _this$props2.doc;
|
|
55
44
|
if (renderTitle) {
|
|
56
45
|
return renderTitle(mode, doc);
|
|
57
46
|
}
|
|
58
|
-
|
|
59
47
|
return;
|
|
60
48
|
}
|
|
61
49
|
}, {
|
|
62
50
|
key: "renderEditor",
|
|
63
51
|
value: function renderEditor() {
|
|
64
52
|
var _this$props3 = this.props,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
53
|
+
doc = _this$props3.doc,
|
|
54
|
+
editorProps = _this$props3.editorProps;
|
|
68
55
|
var _ref = doc || {},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
56
|
+
_ref$body = _ref.body,
|
|
57
|
+
body = _ref$body === void 0 ? emptyDoc : _ref$body;
|
|
72
58
|
return /*#__PURE__*/React.createElement(EditorContext, null, /*#__PURE__*/React.createElement(Editor, _extends({
|
|
73
59
|
appearance: "full-page",
|
|
74
60
|
placeholder: "Write something...",
|
|
@@ -81,47 +67,39 @@ var Document = /*#__PURE__*/function (_Component) {
|
|
|
81
67
|
key: "render",
|
|
82
68
|
value: function render() {
|
|
83
69
|
var _this$props4 = this.props,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
70
|
+
doc = _this$props4.doc,
|
|
71
|
+
isLoading = _this$props4.isLoading,
|
|
72
|
+
hasError = _this$props4.hasError,
|
|
73
|
+
mode = _this$props4.mode,
|
|
74
|
+
editorProps = _this$props4.editorProps,
|
|
75
|
+
rendererProps = _this$props4.rendererProps;
|
|
91
76
|
if (hasError) {
|
|
92
77
|
return /*#__PURE__*/React.createElement("div", null, "Something went wrong \uD83D\uDE14");
|
|
93
78
|
}
|
|
94
|
-
|
|
95
79
|
if (isLoading) {
|
|
96
80
|
return /*#__PURE__*/React.createElement("div", null, "Loading document... \uD83D\uDC28");
|
|
97
81
|
}
|
|
98
|
-
|
|
99
82
|
switch (mode) {
|
|
100
83
|
case 'create':
|
|
101
84
|
case 'edit':
|
|
102
85
|
return this.renderEditor();
|
|
103
|
-
|
|
104
86
|
default:
|
|
105
87
|
var _ref2 = doc || {},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
88
|
+
_ref2$body = _ref2.body,
|
|
89
|
+
body = _ref2$body === void 0 ? emptyDoc : _ref2$body;
|
|
109
90
|
var dataProviders;
|
|
110
|
-
|
|
111
91
|
if (editorProps) {
|
|
112
92
|
var mentionProvider = editorProps.mentionProvider,
|
|
113
|
-
|
|
114
|
-
|
|
93
|
+
emojiProvider = editorProps.emojiProvider,
|
|
94
|
+
media = editorProps.media;
|
|
115
95
|
dataProviders = ProviderFactory.create({
|
|
116
96
|
mentionProvider: mentionProvider,
|
|
117
97
|
emojiProvider: emojiProvider
|
|
118
98
|
});
|
|
119
|
-
|
|
120
99
|
if (media && media.provider) {
|
|
121
100
|
dataProviders.setProvider('mediaProvider', media.provider);
|
|
122
101
|
}
|
|
123
102
|
}
|
|
124
|
-
|
|
125
103
|
return /*#__PURE__*/React.createElement(ReactRenderer, _extends({
|
|
126
104
|
dataProviders: dataProviders,
|
|
127
105
|
document: JSON.parse(body)
|
|
@@ -129,8 +107,6 @@ var Document = /*#__PURE__*/function (_Component) {
|
|
|
129
107
|
}
|
|
130
108
|
}
|
|
131
109
|
}]);
|
|
132
|
-
|
|
133
110
|
return Document;
|
|
134
111
|
}(Component);
|
|
135
|
-
|
|
136
112
|
export { Document as default };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
|
-
|
|
4
3
|
var _templateObject;
|
|
5
|
-
|
|
6
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
5
|
import React from 'react';
|
|
8
6
|
import ButtonGroup from '@atlaskit/button/button-group';
|
|
@@ -12,7 +10,7 @@ import WithDocumentActions from '../consumers/with-document-actions';
|
|
|
12
10
|
var Toolbar = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: flex-end;\n padding: 0 20px;\n height: 80px;\n"])));
|
|
13
11
|
export default (function (props) {
|
|
14
12
|
var mode = props.mode,
|
|
15
|
-
|
|
13
|
+
editorActions = props.editorActions;
|
|
16
14
|
return /*#__PURE__*/React.createElement(WithDocumentActions, {
|
|
17
15
|
render: function render(actions) {
|
|
18
16
|
switch (mode) {
|
|
@@ -28,21 +26,17 @@ export default (function (props) {
|
|
|
28
26
|
case 0:
|
|
29
27
|
_context.next = 2;
|
|
30
28
|
return editorActions.getValue();
|
|
31
|
-
|
|
32
29
|
case 2:
|
|
33
30
|
value = _context.sent;
|
|
34
31
|
_context.prev = 3;
|
|
35
32
|
_context.next = 6;
|
|
36
33
|
return mode === 'create' ? actions.createDocument(value) : actions.updateDocument(value);
|
|
37
|
-
|
|
38
34
|
case 6:
|
|
39
35
|
_context.next = 10;
|
|
40
36
|
break;
|
|
41
|
-
|
|
42
37
|
case 8:
|
|
43
38
|
_context.prev = 8;
|
|
44
39
|
_context.t0 = _context["catch"](3);
|
|
45
|
-
|
|
46
40
|
case 10:
|
|
47
41
|
case "end":
|
|
48
42
|
return _context.stop();
|
|
@@ -56,7 +50,6 @@ export default (function (props) {
|
|
|
56
50
|
return actions.cancelEdit();
|
|
57
51
|
}
|
|
58
52
|
}, "Close"));
|
|
59
|
-
|
|
60
53
|
default:
|
|
61
54
|
return /*#__PURE__*/React.createElement(Toolbar, null, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
|
|
62
55
|
appearance: "primary",
|
|
@@ -5,80 +5,59 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
8
|
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); }; }
|
|
10
|
-
|
|
11
9
|
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; } }
|
|
12
|
-
|
|
13
10
|
import React from 'react';
|
|
14
11
|
import { PureComponent } from 'react';
|
|
15
12
|
import { Context } from '../context/context';
|
|
16
13
|
export var Consumer = /*#__PURE__*/function (_PureComponent) {
|
|
17
14
|
_inherits(Consumer, _PureComponent);
|
|
18
|
-
|
|
19
15
|
var _super = _createSuper(Consumer);
|
|
20
|
-
|
|
21
16
|
function Consumer() {
|
|
22
17
|
var _this;
|
|
23
|
-
|
|
24
18
|
_classCallCheck(this, Consumer);
|
|
25
|
-
|
|
26
19
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
27
20
|
args[_key] = arguments[_key];
|
|
28
21
|
}
|
|
29
|
-
|
|
30
22
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
31
|
-
|
|
32
23
|
_defineProperty(_assertThisInitialized(_this), "getPropsFromActions", function (actions) {
|
|
33
24
|
var actionsMapper = _this.props.actionsMapper;
|
|
34
|
-
|
|
35
25
|
if (actionsMapper) {
|
|
36
26
|
if (!_this.previousActions || !_this.propsFromActions || _this.previousActions !== actions) {
|
|
37
27
|
_this.propsFromActions = actionsMapper(actions);
|
|
38
28
|
}
|
|
39
29
|
}
|
|
40
|
-
|
|
41
30
|
_this.previousActions = actions;
|
|
42
31
|
return _this.propsFromActions;
|
|
43
32
|
});
|
|
44
|
-
|
|
45
33
|
_defineProperty(_assertThisInitialized(_this), "getPropsFromState", function (state) {
|
|
46
34
|
var stateMapper = _this.props.stateMapper;
|
|
47
|
-
|
|
48
35
|
if (stateMapper) {
|
|
49
36
|
return stateMapper(state);
|
|
50
37
|
}
|
|
51
|
-
|
|
52
38
|
return undefined;
|
|
53
39
|
});
|
|
54
|
-
|
|
55
40
|
_defineProperty(_assertThisInitialized(_this), "getRenderProps", function (renderProps) {
|
|
56
41
|
var renderPropsMapper = _this.props.renderPropsMapper;
|
|
57
|
-
|
|
58
42
|
if (renderPropsMapper) {
|
|
59
43
|
return renderPropsMapper(renderProps);
|
|
60
44
|
}
|
|
61
|
-
|
|
62
45
|
return undefined;
|
|
63
46
|
});
|
|
64
|
-
|
|
65
47
|
_defineProperty(_assertThisInitialized(_this), "renderChildren", function (_ref) {
|
|
66
48
|
var actions = _ref.actions,
|
|
67
|
-
|
|
68
|
-
|
|
49
|
+
value = _ref.value,
|
|
50
|
+
renderProps = _ref.renderProps;
|
|
69
51
|
var props = Object.assign({}, _this.getPropsFromState(value), _this.getPropsFromActions(actions), _this.getRenderProps(renderProps));
|
|
70
52
|
return _this.props.children(props);
|
|
71
53
|
});
|
|
72
|
-
|
|
73
54
|
return _this;
|
|
74
55
|
}
|
|
75
|
-
|
|
76
56
|
_createClass(Consumer, [{
|
|
77
57
|
key: "render",
|
|
78
58
|
value: function render() {
|
|
79
59
|
return /*#__PURE__*/React.createElement(Context.Consumer, null, this.renderChildren);
|
|
80
60
|
}
|
|
81
61
|
}]);
|
|
82
|
-
|
|
83
62
|
return Consumer;
|
|
84
63
|
}(PureComponent);
|