@atlaskit/editor-core 188.8.0 → 188.9.0
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 +13 -0
- package/dist/cjs/composable-editor/editor-internal.js +2 -2
- package/dist/cjs/create-editor/ReactEditorView.js +796 -8
- package/dist/cjs/labs/next/presets/universal.js +7 -4
- package/dist/cjs/plugins/index.js +0 -21
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/composable-editor/editor-internal.js +1 -1
- package/dist/es2019/create-editor/ReactEditorView.js +753 -2
- package/dist/es2019/labs/next/presets/universal.js +4 -1
- package/dist/es2019/plugins/index.js +0 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/composable-editor/editor-internal.js +1 -1
- package/dist/esm/create-editor/ReactEditorView.js +797 -8
- package/dist/esm/labs/next/presets/universal.js +4 -1
- package/dist/esm/plugins/index.js +0 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/ReactEditorView.d.ts +119 -5
- package/dist/types/plugins/index.d.ts +0 -3
- package/dist/types/plugins/insert-block/types.d.ts +1 -1
- package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
- package/dist/types-ts4.5/create-editor/ReactEditorView.d.ts +119 -5
- package/dist/types-ts4.5/plugins/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
- package/package.json +5 -3
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +0 -812
- package/dist/cjs/create-editor/ReactEditorViewNext.js +0 -15
- package/dist/cjs/plugins/save-on-enter/index.js +0 -70
- package/dist/cjs/plugins/scroll-into-view/index.js +0 -55
- package/dist/cjs/plugins/status/actions.js +0 -158
- package/dist/cjs/plugins/status/analytics.js +0 -31
- package/dist/cjs/plugins/status/index.js +0 -143
- package/dist/cjs/plugins/status/keymap.js +0 -22
- package/dist/cjs/plugins/status/nodeviews/status.js +0 -58
- package/dist/cjs/plugins/status/plugin-key.js +0 -9
- package/dist/cjs/plugins/status/plugin.js +0 -133
- package/dist/cjs/plugins/status/types.js +0 -5
- package/dist/cjs/plugins/status/ui/statusPicker.js +0 -314
- package/dist/cjs/plugins/status/utils.js +0 -22
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +0 -753
- package/dist/es2019/create-editor/ReactEditorViewNext.js +0 -7
- package/dist/es2019/plugins/save-on-enter/index.js +0 -63
- package/dist/es2019/plugins/scroll-into-view/index.js +0 -44
- package/dist/es2019/plugins/status/actions.js +0 -144
- package/dist/es2019/plugins/status/analytics.js +0 -18
- package/dist/es2019/plugins/status/index.js +0 -135
- package/dist/es2019/plugins/status/keymap.js +0 -13
- package/dist/es2019/plugins/status/nodeviews/status.js +0 -60
- package/dist/es2019/plugins/status/plugin-key.js +0 -3
- package/dist/es2019/plugins/status/plugin.js +0 -113
- package/dist/es2019/plugins/status/types.js +0 -1
- package/dist/es2019/plugins/status/ui/statusPicker.js +0 -293
- package/dist/es2019/plugins/status/utils.js +0 -12
- package/dist/esm/create-editor/ReactEditorViewInternal.js +0 -806
- package/dist/esm/create-editor/ReactEditorViewNext.js +0 -7
- package/dist/esm/plugins/save-on-enter/index.js +0 -63
- package/dist/esm/plugins/scroll-into-view/index.js +0 -50
- package/dist/esm/plugins/status/actions.js +0 -151
- package/dist/esm/plugins/status/analytics.js +0 -24
- package/dist/esm/plugins/status/index.js +0 -136
- package/dist/esm/plugins/status/keymap.js +0 -15
- package/dist/esm/plugins/status/nodeviews/status.js +0 -51
- package/dist/esm/plugins/status/plugin-key.js +0 -3
- package/dist/esm/plugins/status/plugin.js +0 -115
- package/dist/esm/plugins/status/types.js +0 -1
- package/dist/esm/plugins/status/ui/statusPicker.js +0 -308
- package/dist/esm/plugins/status/utils.js +0 -16
- package/dist/types/create-editor/ReactEditorViewInternal.d.ts +0 -119
- package/dist/types/create-editor/ReactEditorViewNext.d.ts +0 -8
- package/dist/types/plugins/save-on-enter/index.d.ts +0 -10
- package/dist/types/plugins/scroll-into-view/index.d.ts +0 -14
- package/dist/types/plugins/status/actions.d.ts +0 -16
- package/dist/types/plugins/status/analytics.d.ts +0 -4
- package/dist/types/plugins/status/index.d.ts +0 -15
- package/dist/types/plugins/status/keymap.d.ts +0 -3
- package/dist/types/plugins/status/nodeviews/status.d.ts +0 -25
- package/dist/types/plugins/status/plugin-key.d.ts +0 -4
- package/dist/types/plugins/status/plugin.d.ts +0 -7
- package/dist/types/plugins/status/types.d.ts +0 -18
- package/dist/types/plugins/status/ui/statusPicker.d.ts +0 -63
- package/dist/types/plugins/status/utils.d.ts +0 -5
- package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +0 -119
- package/dist/types-ts4.5/create-editor/ReactEditorViewNext.d.ts +0 -8
- package/dist/types-ts4.5/plugins/save-on-enter/index.d.ts +0 -10
- package/dist/types-ts4.5/plugins/scroll-into-view/index.d.ts +0 -14
- package/dist/types-ts4.5/plugins/status/actions.d.ts +0 -16
- package/dist/types-ts4.5/plugins/status/analytics.d.ts +0 -4
- package/dist/types-ts4.5/plugins/status/index.d.ts +0 -17
- package/dist/types-ts4.5/plugins/status/keymap.d.ts +0 -3
- package/dist/types-ts4.5/plugins/status/nodeviews/status.d.ts +0 -25
- package/dist/types-ts4.5/plugins/status/plugin-key.d.ts +0 -4
- package/dist/types-ts4.5/plugins/status/plugin.d.ts +0 -7
- package/dist/types-ts4.5/plugins/status/types.d.ts +0 -18
- package/dist/types-ts4.5/plugins/status/ui/statusPicker.d.ts +0 -63
- package/dist/types-ts4.5/plugins/status/utils.d.ts +0 -5
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.ReactEditorViewEditor = ReactEditorViewEditor;
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _ReactEditorViewInternal = require("./ReactEditorViewInternal");
|
|
11
|
-
var _reactIntlNext = require("react-intl-next");
|
|
12
|
-
function ReactEditorViewEditor(props) {
|
|
13
|
-
return /*#__PURE__*/_react.default.createElement(_ReactEditorViewInternal.ReactEditorView, props);
|
|
14
|
-
}
|
|
15
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(ReactEditorViewEditor);
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createPlugin = createPlugin;
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
9
|
-
var _analytics = require("../../plugins/analytics");
|
|
10
|
-
var _consts = require("../analytics/consts");
|
|
11
|
-
function createPlugin(eventDispatch, onSave) {
|
|
12
|
-
if (!onSave) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
return (0, _keymap.keymap)({
|
|
16
|
-
Enter: function Enter(state, _dispatch, editorView) {
|
|
17
|
-
if (editorView && canSaveOnEnter(editorView)) {
|
|
18
|
-
eventDispatch(_consts.analyticsEventKey, analyticsPayload(state));
|
|
19
|
-
onSave(editorView);
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function canSaveOnEnter(editorView) {
|
|
27
|
-
var _ref = editorView.state.selection,
|
|
28
|
-
$cursor = _ref.$cursor;
|
|
29
|
-
var _editorView$state$sch = editorView.state.schema.nodes,
|
|
30
|
-
decisionItem = _editorView$state$sch.decisionItem,
|
|
31
|
-
paragraph = _editorView$state$sch.paragraph,
|
|
32
|
-
taskItem = _editorView$state$sch.taskItem;
|
|
33
|
-
return !$cursor || $cursor.parent.type === paragraph && $cursor.depth === 1 || $cursor.parent.type === decisionItem && !isEmptyAtCursor($cursor) || $cursor.parent.type === taskItem && !isEmptyAtCursor($cursor);
|
|
34
|
-
}
|
|
35
|
-
function isEmptyAtCursor($cursor) {
|
|
36
|
-
var content = $cursor.parent.content;
|
|
37
|
-
return !(content && content.size);
|
|
38
|
-
}
|
|
39
|
-
var analyticsPayload = function analyticsPayload(state) {
|
|
40
|
-
return {
|
|
41
|
-
payload: {
|
|
42
|
-
action: _analytics.ACTION.STOPPED,
|
|
43
|
-
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
44
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SAVE,
|
|
45
|
-
attributes: {
|
|
46
|
-
inputMethod: _analytics.INPUT_METHOD.SHORTCUT,
|
|
47
|
-
documentSize: state.doc.nodeSize
|
|
48
|
-
// TODO add individual node counts - tables, headings, lists, mediaSingles, mediaGroups, mediaCards, panels, extensions, decisions, action, codeBlocks
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
eventType: _analytics.EVENT_TYPE.UI
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
var saveOnEnterPlugin = function saveOnEnterPlugin(_ref2) {
|
|
56
|
-
var onSave = _ref2.config;
|
|
57
|
-
return {
|
|
58
|
-
name: 'saveOnEnter',
|
|
59
|
-
pmPlugins: function pmPlugins() {
|
|
60
|
-
return [{
|
|
61
|
-
name: 'saveOnEnter',
|
|
62
|
-
plugin: function plugin(_ref3) {
|
|
63
|
-
var dispatch = _ref3.dispatch;
|
|
64
|
-
return createPlugin(dispatch, onSave);
|
|
65
|
-
}
|
|
66
|
-
}];
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
var _default = exports.default = saveOnEnterPlugin;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.scrollIntoViewPluginKey = exports.default = void 0;
|
|
7
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
-
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
10
|
-
/**
|
|
11
|
-
* Plugin to scroll the user's selection into view whenever the user updates
|
|
12
|
-
* the document eg. inserting, deleting, formatting
|
|
13
|
-
*
|
|
14
|
-
* Behaviour is on by default, can be explicitly opted out of for a transaction by
|
|
15
|
-
* setting scrollIntoView=false meta
|
|
16
|
-
* We ignore collab transactions, appended transactions, transactions without steps,
|
|
17
|
-
* transactions with addToHistory=false meta and typeahead trigger transactions
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
var scrollIntoViewPluginKey = exports.scrollIntoViewPluginKey = new _state.PluginKey('scrollIntoViewPlugin');
|
|
21
|
-
var createPlugin = function createPlugin() {
|
|
22
|
-
return new _safePlugin.SafePlugin({
|
|
23
|
-
key: scrollIntoViewPluginKey,
|
|
24
|
-
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
25
|
-
if (!transactions.length) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
var tr = transactions[0];
|
|
29
|
-
if ((tr.docChanged || tr.storedMarksSet) && !tr.scrolledIntoView && tr.getMeta('scrollIntoView') !== false &&
|
|
30
|
-
// ignore anything we would not want to undo
|
|
31
|
-
// this covers things like autofixing layouts, hovering table rows/cols
|
|
32
|
-
tr.getMeta('addToHistory') !== false &&
|
|
33
|
-
// ignore collab changes from another user
|
|
34
|
-
!tr.getMeta('isRemote') &&
|
|
35
|
-
// ignore any transaction coming from the input text rule plugin
|
|
36
|
-
!tr.getMeta(_prosemirrorInputRules.TEXT_INPUT_RULE_TRANSACTION_KEY)) {
|
|
37
|
-
return newState.tr.scrollIntoView();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
var scrollIntoViewPlugin = function scrollIntoViewPlugin() {
|
|
43
|
-
return {
|
|
44
|
-
name: 'scrollIntoView',
|
|
45
|
-
pmPlugins: function pmPlugins() {
|
|
46
|
-
return [{
|
|
47
|
-
name: 'scrollIntoView',
|
|
48
|
-
plugin: function plugin() {
|
|
49
|
-
return createPlugin();
|
|
50
|
-
}
|
|
51
|
-
}];
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
var _default = exports.default = scrollIntoViewPlugin;
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.updateStatusWithAnalytics = exports.updateStatus = exports.setStatusPickerAt = exports.removeStatus = exports.createStatus = exports.commitStatusPicker = exports.DEFAULT_STATUS = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
12
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
-
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
14
|
-
var _pluginKey = require("./plugin-key");
|
|
15
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
16
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
|
-
var DEFAULT_STATUS = exports.DEFAULT_STATUS = {
|
|
19
|
-
text: '',
|
|
20
|
-
color: 'neutral'
|
|
21
|
-
};
|
|
22
|
-
var createStatus = exports.createStatus = function createStatus() {
|
|
23
|
-
var showStatusPickerAtOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
24
|
-
return function (insert, state) {
|
|
25
|
-
var statusNode = state.schema.nodes.status.createChecked(_objectSpread(_objectSpread({}, DEFAULT_STATUS), {}, {
|
|
26
|
-
localId: _adfSchema.uuid.generate()
|
|
27
|
-
}));
|
|
28
|
-
var space = state.schema.text(' ');
|
|
29
|
-
var tr = insert(_model.Fragment.from([statusNode, space]), {
|
|
30
|
-
selectInlineNode: true
|
|
31
|
-
});
|
|
32
|
-
var showStatusPickerAt = tr.selection.from + showStatusPickerAtOffset;
|
|
33
|
-
return tr.setSelection(_state.NodeSelection.create(tr.doc, showStatusPickerAt)).setMeta(_pluginKey.pluginKey, {
|
|
34
|
-
showStatusPickerAt: showStatusPickerAt,
|
|
35
|
-
isNew: true
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
var updateStatus = exports.updateStatus = function updateStatus(status) {
|
|
40
|
-
return function (state, dispatch) {
|
|
41
|
-
var schema = state.schema;
|
|
42
|
-
var selectedStatus = status ? Object.assign(status, {
|
|
43
|
-
text: status.text.trim(),
|
|
44
|
-
localId: status.localId || _adfSchema.uuid.generate()
|
|
45
|
-
}) : status;
|
|
46
|
-
var statusProps = _objectSpread(_objectSpread({}, DEFAULT_STATUS), selectedStatus);
|
|
47
|
-
var tr = state.tr;
|
|
48
|
-
var _ref = _pluginKey.pluginKey.getState(state) || {},
|
|
49
|
-
showStatusPickerAt = _ref.showStatusPickerAt;
|
|
50
|
-
if (!showStatusPickerAt) {
|
|
51
|
-
// Same behaviour as quick insert (used in createStatus)
|
|
52
|
-
var statusNode = schema.nodes.status.createChecked(statusProps);
|
|
53
|
-
var fragment = _model.Fragment.fromArray([statusNode, state.schema.text(' ')]);
|
|
54
|
-
var insertable = (0, _utils.canInsert)(tr.selection.$from, fragment);
|
|
55
|
-
if (!insertable) {
|
|
56
|
-
var parentSelection = _state.NodeSelection.create(tr.doc, tr.selection.from - tr.selection.$anchor.parentOffset - 1);
|
|
57
|
-
tr.insert(parentSelection.to, fragment).setSelection(_state.NodeSelection.create(tr.doc, parentSelection.to + 1));
|
|
58
|
-
} else {
|
|
59
|
-
tr.insert(tr.selection.from, fragment).setSelection(_state.NodeSelection.create(tr.doc, tr.selection.from - fragment.size));
|
|
60
|
-
}
|
|
61
|
-
tr.setMeta(_pluginKey.pluginKey, {
|
|
62
|
-
showStatusPickerAt: tr.selection.from,
|
|
63
|
-
isNew: true
|
|
64
|
-
}).scrollIntoView();
|
|
65
|
-
if (dispatch) {
|
|
66
|
-
dispatch(tr);
|
|
67
|
-
}
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
if (state.doc.nodeAt(showStatusPickerAt)) {
|
|
71
|
-
tr.setNodeMarkup(showStatusPickerAt, schema.nodes.status, statusProps).setSelection(_state.NodeSelection.create(tr.doc, showStatusPickerAt)).setMeta(_pluginKey.pluginKey, {
|
|
72
|
-
showStatusPickerAt: showStatusPickerAt
|
|
73
|
-
}).scrollIntoView();
|
|
74
|
-
if (dispatch) {
|
|
75
|
-
dispatch(tr);
|
|
76
|
-
}
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
var updateStatusWithAnalytics = exports.updateStatusWithAnalytics = function updateStatusWithAnalytics(editorAnalyticsAPI) {
|
|
83
|
-
return function (inputMethod, status) {
|
|
84
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
85
|
-
action: _analytics.ACTION.INSERTED,
|
|
86
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
87
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.STATUS,
|
|
88
|
-
attributes: {
|
|
89
|
-
inputMethod: inputMethod
|
|
90
|
-
},
|
|
91
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
92
|
-
})(updateStatus(status));
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
var setStatusPickerAt = exports.setStatusPickerAt = function setStatusPickerAt(showStatusPickerAt) {
|
|
96
|
-
return function (state, dispatch) {
|
|
97
|
-
dispatch(state.tr.setMeta(_pluginKey.pluginKey, {
|
|
98
|
-
showStatusPickerAt: showStatusPickerAt,
|
|
99
|
-
isNew: false
|
|
100
|
-
}));
|
|
101
|
-
return true;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
var removeStatus = exports.removeStatus = function removeStatus(showStatusPickerAt) {
|
|
105
|
-
return function (state, dispatch) {
|
|
106
|
-
var tr = state.tr;
|
|
107
|
-
tr.replace(showStatusPickerAt, showStatusPickerAt + 1);
|
|
108
|
-
if (dispatch) {
|
|
109
|
-
dispatch(tr);
|
|
110
|
-
}
|
|
111
|
-
return true;
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
var handleClosingByArrows = function handleClosingByArrows(closingMethod, state, showStatusPickerAt, tr) {
|
|
115
|
-
if (closingMethod === 'arrowLeft') {
|
|
116
|
-
// put cursor right before status Lozenge
|
|
117
|
-
tr = tr.setSelection(_state.Selection.near(state.tr.doc.resolve(showStatusPickerAt), -1));
|
|
118
|
-
} else if (closingMethod === 'arrowRight') {
|
|
119
|
-
// put cursor right after status Lozenge
|
|
120
|
-
tr = tr.setSelection(_state.Selection.near(state.tr.doc.resolve(showStatusPickerAt + 1)));
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
var commitStatusPicker = exports.commitStatusPicker = function commitStatusPicker(closingPayload) {
|
|
124
|
-
return function (editorView) {
|
|
125
|
-
var state = editorView.state,
|
|
126
|
-
dispatch = editorView.dispatch;
|
|
127
|
-
var _ref2 = _pluginKey.pluginKey.getState(state) || {},
|
|
128
|
-
showStatusPickerAt = _ref2.showStatusPickerAt;
|
|
129
|
-
var _ref3 = closingPayload || {},
|
|
130
|
-
closingMethod = _ref3.closingMethod;
|
|
131
|
-
if (!showStatusPickerAt) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
var statusNode = state.tr.doc.nodeAt(showStatusPickerAt);
|
|
135
|
-
if (!statusNode) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
var tr = state.tr;
|
|
139
|
-
tr = tr.setMeta(_pluginKey.pluginKey, {
|
|
140
|
-
showStatusPickerAt: null,
|
|
141
|
-
isNew: false
|
|
142
|
-
});
|
|
143
|
-
if (closingMethod) {
|
|
144
|
-
handleClosingByArrows(closingMethod, state, showStatusPickerAt, tr);
|
|
145
|
-
} else if (statusNode.attrs.text) {
|
|
146
|
-
// still has content - keep content
|
|
147
|
-
// move selection after status if selection did not change
|
|
148
|
-
if (tr.selection.from === showStatusPickerAt) {
|
|
149
|
-
tr = tr.setSelection(_state.Selection.near(state.tr.doc.resolve(showStatusPickerAt + 2)));
|
|
150
|
-
}
|
|
151
|
-
} else {
|
|
152
|
-
// no content - remove node
|
|
153
|
-
tr = tr.delete(showStatusPickerAt, showStatusPickerAt + 1);
|
|
154
|
-
}
|
|
155
|
-
dispatch(tr);
|
|
156
|
-
editorView.focus();
|
|
157
|
-
};
|
|
158
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createStatusAnalyticsAndFire = exports.analyticsState = exports.FABRIC_CHANNEL = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _versionWrapper = require("../../version-wrapper");
|
|
10
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
-
var FABRIC_CHANNEL = exports.FABRIC_CHANNEL = 'fabric-elements';
|
|
13
|
-
var createStatusAnalyticsAndFire = exports.createStatusAnalyticsAndFire = function createStatusAnalyticsAndFire(createAnalyticsEvent) {
|
|
14
|
-
return function (payload) {
|
|
15
|
-
if (createAnalyticsEvent && payload) {
|
|
16
|
-
var statusPayload = _objectSpread(_objectSpread({}, payload), {}, {
|
|
17
|
-
eventType: 'ui'
|
|
18
|
-
});
|
|
19
|
-
if (!statusPayload.attributes) {
|
|
20
|
-
statusPayload.attributes = {};
|
|
21
|
-
}
|
|
22
|
-
statusPayload.attributes.packageName = _versionWrapper.name;
|
|
23
|
-
statusPayload.attributes.packageVersion = _versionWrapper.version;
|
|
24
|
-
statusPayload.attributes.componentName = 'status';
|
|
25
|
-
createAnalyticsEvent(statusPayload).fire(FABRIC_CHANNEL);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
var analyticsState = exports.analyticsState = function analyticsState(isNew) {
|
|
30
|
-
return isNew ? 'new' : 'update';
|
|
31
|
-
};
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
11
|
-
var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
|
|
12
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
|
-
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
15
|
-
var _actions = require("./actions");
|
|
16
|
-
var _keymap = require("./keymap");
|
|
17
|
-
var _plugin = _interopRequireDefault(require("./plugin"));
|
|
18
|
-
var _pluginKey = require("./plugin-key");
|
|
19
|
-
var _statusPicker = _interopRequireDefault(require("./ui/statusPicker"));
|
|
20
|
-
var baseStatusPlugin = function baseStatusPlugin(_ref) {
|
|
21
|
-
var _api$analytics;
|
|
22
|
-
var options = _ref.config,
|
|
23
|
-
api = _ref.api;
|
|
24
|
-
return {
|
|
25
|
-
name: 'status',
|
|
26
|
-
nodes: function nodes() {
|
|
27
|
-
return [{
|
|
28
|
-
name: 'status',
|
|
29
|
-
node: _adfSchema.status
|
|
30
|
-
}];
|
|
31
|
-
},
|
|
32
|
-
pmPlugins: function pmPlugins() {
|
|
33
|
-
return [{
|
|
34
|
-
name: 'status',
|
|
35
|
-
plugin: function plugin(pmPluginFactoryParams) {
|
|
36
|
-
return (0, _plugin.default)(pmPluginFactoryParams, options);
|
|
37
|
-
}
|
|
38
|
-
}, {
|
|
39
|
-
name: 'statusKeymap',
|
|
40
|
-
plugin: _keymap.keymapPlugin
|
|
41
|
-
}];
|
|
42
|
-
},
|
|
43
|
-
actions: {
|
|
44
|
-
commitStatusPicker: _actions.commitStatusPicker,
|
|
45
|
-
updateStatus: (0, _actions.updateStatusWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
46
|
-
},
|
|
47
|
-
contentComponent: function contentComponent(_ref2) {
|
|
48
|
-
var editorView = _ref2.editorView,
|
|
49
|
-
popupsMountPoint = _ref2.popupsMountPoint,
|
|
50
|
-
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
51
|
-
popupsScrollableElement = _ref2.popupsScrollableElement;
|
|
52
|
-
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
53
|
-
return /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
|
|
54
|
-
plugins: {
|
|
55
|
-
statusState: _pluginKey.pluginKey
|
|
56
|
-
},
|
|
57
|
-
render: function render(_ref3) {
|
|
58
|
-
var _ref3$statusState = _ref3.statusState,
|
|
59
|
-
statusState = _ref3$statusState === void 0 ? {} : _ref3$statusState;
|
|
60
|
-
var showStatusPickerAt = statusState.showStatusPickerAt;
|
|
61
|
-
if (typeof showStatusPickerAt !== 'number') {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
var target = (0, _utils.findDomRefAtPos)(showStatusPickerAt, domAtPos);
|
|
65
|
-
var statusNode = editorView.state.doc.nodeAt(showStatusPickerAt);
|
|
66
|
-
if (!statusNode || statusNode.type.name !== 'status') {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
var _statusNode$attrs = statusNode.attrs,
|
|
70
|
-
text = _statusNode$attrs.text,
|
|
71
|
-
color = _statusNode$attrs.color,
|
|
72
|
-
localId = _statusNode$attrs.localId;
|
|
73
|
-
return /*#__PURE__*/_react.default.createElement(_statusPicker.default, {
|
|
74
|
-
isNew: statusState.isNew,
|
|
75
|
-
target: target,
|
|
76
|
-
defaultText: text,
|
|
77
|
-
defaultColor: color,
|
|
78
|
-
defaultLocalId: localId,
|
|
79
|
-
mountTo: popupsMountPoint,
|
|
80
|
-
boundariesElement: popupsBoundariesElement,
|
|
81
|
-
scrollableElement: popupsScrollableElement,
|
|
82
|
-
onSelect: function onSelect(status) {
|
|
83
|
-
(0, _actions.updateStatus)(status)(editorView.state, editorView.dispatch);
|
|
84
|
-
},
|
|
85
|
-
onTextChanged: function onTextChanged(status) {
|
|
86
|
-
(0, _actions.updateStatus)(status)(editorView.state, editorView.dispatch);
|
|
87
|
-
},
|
|
88
|
-
closeStatusPicker: function closeStatusPicker(closingPayload) {
|
|
89
|
-
(0, _actions.commitStatusPicker)(closingPayload)(editorView);
|
|
90
|
-
},
|
|
91
|
-
onEnter: function onEnter() {
|
|
92
|
-
(0, _actions.commitStatusPicker)()(editorView);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
var decorateWithPluginOptions = function decorateWithPluginOptions(plugin, options, api) {
|
|
101
|
-
if ((options === null || options === void 0 ? void 0 : options.menuDisabled) === true) {
|
|
102
|
-
return plugin;
|
|
103
|
-
}
|
|
104
|
-
plugin.pluginsOptions = {
|
|
105
|
-
quickInsert: function quickInsert(_ref4) {
|
|
106
|
-
var formatMessage = _ref4.formatMessage;
|
|
107
|
-
return [{
|
|
108
|
-
id: 'status',
|
|
109
|
-
title: formatMessage(_messages.toolbarInsertBlockMessages.status),
|
|
110
|
-
description: formatMessage(_messages.toolbarInsertBlockMessages.statusDescription),
|
|
111
|
-
priority: 700,
|
|
112
|
-
keywords: ['lozenge'],
|
|
113
|
-
icon: function icon() {
|
|
114
|
-
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconStatus, null);
|
|
115
|
-
},
|
|
116
|
-
action: function action(insert, state) {
|
|
117
|
-
var _api$analytics2;
|
|
118
|
-
var tr = (0, _actions.createStatus)()(insert, state);
|
|
119
|
-
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
|
|
120
|
-
action: _analytics.ACTION.INSERTED,
|
|
121
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
122
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.STATUS,
|
|
123
|
-
attributes: {
|
|
124
|
-
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
125
|
-
},
|
|
126
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
127
|
-
})(tr);
|
|
128
|
-
return tr;
|
|
129
|
-
}
|
|
130
|
-
}];
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
return plugin;
|
|
134
|
-
};
|
|
135
|
-
var statusPlugin = function statusPlugin(_ref5) {
|
|
136
|
-
var options = _ref5.config,
|
|
137
|
-
api = _ref5.api;
|
|
138
|
-
return decorateWithPluginOptions(baseStatusPlugin({
|
|
139
|
-
config: options,
|
|
140
|
-
api: api
|
|
141
|
-
}), options, api);
|
|
142
|
-
};
|
|
143
|
-
var _default = exports.default = statusPlugin;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
exports.keymapPlugin = keymapPlugin;
|
|
8
|
-
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
9
|
-
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
function keymapPlugin() {
|
|
12
|
-
var list = {};
|
|
13
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.enter.common, consumeKeyEvent, list);
|
|
14
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.tab.common, consumeKeyEvent, list);
|
|
15
|
-
return (0, _keymap.keymap)(list);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// consume event to prevent status node problems with positioning and selection
|
|
19
|
-
var consumeKeyEvent = function consumeKeyEvent(state, _dispatch) {
|
|
20
|
-
return !!(0, _utils.mayGetStatusAtSelection)(state.tr.selection);
|
|
21
|
-
};
|
|
22
|
-
var _default = exports.default = keymapPlugin;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.StatusNodeView = exports.IntlStatusContainerView = void 0;
|
|
8
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _react2 = require("@emotion/react");
|
|
11
|
-
var _reactIntlNext = require("react-intl-next");
|
|
12
|
-
var _element = require("@atlaskit/status/element");
|
|
13
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
|
-
var _templateObject, _templateObject2;
|
|
15
|
-
/** @jsx jsx */
|
|
16
|
-
var styledStatus = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n opacity: 1;\n"])));
|
|
17
|
-
var styledStatusPlaceholder = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n opacity: 0.5;\n"])));
|
|
18
|
-
var StatusContainerView = function StatusContainerView(props) {
|
|
19
|
-
var text = props.text,
|
|
20
|
-
color = props.color,
|
|
21
|
-
localId = props.localId,
|
|
22
|
-
style = props.style,
|
|
23
|
-
formatMessage = props.intl.formatMessage;
|
|
24
|
-
var statusText = text ? text : formatMessage(_messages.statusMessages.placeholder);
|
|
25
|
-
var handleClick = function handleClick(event) {
|
|
26
|
-
if (event.nativeEvent.stopImmediatePropagation) {
|
|
27
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
28
|
-
}
|
|
29
|
-
// handling of popup is done in plugin.apply on selection change.
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return (0, _react2.jsx)("span", {
|
|
33
|
-
css: text ? styledStatus : styledStatusPlaceholder,
|
|
34
|
-
"data-testid": "statusContainerView"
|
|
35
|
-
}, (0, _react2.jsx)(_element.Status, {
|
|
36
|
-
text: statusText,
|
|
37
|
-
color: color,
|
|
38
|
-
localId: localId,
|
|
39
|
-
style: style,
|
|
40
|
-
onClick: handleClick
|
|
41
|
-
}));
|
|
42
|
-
};
|
|
43
|
-
var IntlStatusContainerView = exports.IntlStatusContainerView = (0, _reactIntlNext.injectIntl)(StatusContainerView);
|
|
44
|
-
var StatusNodeView = exports.StatusNodeView = function StatusNodeView(props) {
|
|
45
|
-
var view = props.view;
|
|
46
|
-
var _props$node$attrs = props.node.attrs,
|
|
47
|
-
text = _props$node$attrs.text,
|
|
48
|
-
color = _props$node$attrs.color,
|
|
49
|
-
localId = _props$node$attrs.localId,
|
|
50
|
-
style = _props$node$attrs.style;
|
|
51
|
-
return (0, _react2.jsx)(IntlStatusContainerView, {
|
|
52
|
-
view: view,
|
|
53
|
-
text: text,
|
|
54
|
-
color: color,
|
|
55
|
-
style: style,
|
|
56
|
-
localId: localId
|
|
57
|
-
});
|
|
58
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.pluginKeyName = exports.pluginKey = void 0;
|
|
7
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var pluginKeyName = exports.pluginKeyName = 'statusPlugin';
|
|
9
|
-
var pluginKey = exports.pluginKey = new _state.PluginKey('statusPlugin');
|