@atlaskit/editor-core 185.12.1 → 185.12.2
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 +6 -0
- package/dist/cjs/plugins/block-type/commands/block-type.js +79 -44
- package/dist/cjs/plugins/code-block/index.js +7 -3
- package/dist/cjs/plugins/expand/commands.js +6 -2
- package/dist/cjs/plugins/expand/index.js +5 -1
- package/dist/cjs/plugins/panel/index.js +81 -43
- package/dist/cjs/plugins/quick-insert/commands.js +2 -0
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +10 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/block-type/commands/block-type.js +86 -51
- package/dist/es2019/plugins/code-block/index.js +7 -2
- package/dist/es2019/plugins/expand/commands.js +6 -2
- package/dist/es2019/plugins/expand/index.js +5 -1
- package/dist/es2019/plugins/panel/index.js +82 -41
- package/dist/es2019/plugins/quick-insert/commands.js +2 -0
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +10 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/block-type/commands/block-type.js +76 -43
- package/dist/esm/plugins/code-block/index.js +7 -2
- package/dist/esm/plugins/expand/commands.js +6 -2
- package/dist/esm/plugins/expand/index.js +5 -1
- package/dist/esm/plugins/panel/index.js +81 -43
- package/dist/esm/plugins/quick-insert/commands.js +2 -0
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +10 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/block-type/commands/block-type.d.ts +25 -0
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +25 -0
- package/package.json +2 -2
|
@@ -8,25 +8,10 @@ import { IconPanel, IconPanelNote, IconPanelSuccess, IconPanelWarning, IconPanel
|
|
|
8
8
|
import { messages } from '../block-type/messages';
|
|
9
9
|
import IconCustomPanel from '../quick-insert/assets/custom-panel';
|
|
10
10
|
import { T50 } from '@atlaskit/theme/colors';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
action: ACTION.INSERTED,
|
|
16
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
17
|
-
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
18
|
-
attributes: {
|
|
19
|
-
inputMethod: INPUT_METHOD.QUICK_INSERT,
|
|
20
|
-
panelType: panelAttributes.panelType
|
|
21
|
-
},
|
|
22
|
-
eventType: EVENT_TYPE.TRACK
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return tr;
|
|
26
|
-
};
|
|
27
|
-
var insertPanelType = function insertPanelType(panelAttributes, state) {
|
|
28
|
-
return state.schema.nodes.panel.createChecked(panelAttributes, state.schema.nodes.paragraph.createChecked());
|
|
29
|
-
};
|
|
11
|
+
// Theres an existing interelationship between these files, where the imported function is being called for panel
|
|
12
|
+
// Insertions via the drop down menu
|
|
13
|
+
// tslint-ignore-next-line
|
|
14
|
+
import { createWrapSelectionTransaction } from '../block-type/commands/block-type';
|
|
30
15
|
var panelPlugin = function panelPlugin() {
|
|
31
16
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
32
17
|
var api = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -67,9 +52,12 @@ var panelPlugin = function panelPlugin() {
|
|
|
67
52
|
return /*#__PURE__*/React.createElement(IconPanel, null);
|
|
68
53
|
},
|
|
69
54
|
action: function action(insert, state) {
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
55
|
+
return createPanelAction({
|
|
56
|
+
state: state,
|
|
57
|
+
attributes: {
|
|
58
|
+
panelType: PanelType.INFO
|
|
59
|
+
}
|
|
60
|
+
});
|
|
73
61
|
}
|
|
74
62
|
}, {
|
|
75
63
|
id: 'notepanel',
|
|
@@ -80,9 +68,12 @@ var panelPlugin = function panelPlugin() {
|
|
|
80
68
|
return /*#__PURE__*/React.createElement(IconPanelNote, null);
|
|
81
69
|
},
|
|
82
70
|
action: function action(insert, state) {
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
return createPanelAction({
|
|
72
|
+
state: state,
|
|
73
|
+
attributes: {
|
|
74
|
+
panelType: PanelType.NOTE
|
|
75
|
+
}
|
|
76
|
+
});
|
|
86
77
|
}
|
|
87
78
|
}, {
|
|
88
79
|
id: 'successpanel',
|
|
@@ -94,9 +85,12 @@ var panelPlugin = function panelPlugin() {
|
|
|
94
85
|
return /*#__PURE__*/React.createElement(IconPanelSuccess, null);
|
|
95
86
|
},
|
|
96
87
|
action: function action(insert, state) {
|
|
97
|
-
return
|
|
98
|
-
|
|
99
|
-
|
|
88
|
+
return createPanelAction({
|
|
89
|
+
state: state,
|
|
90
|
+
attributes: {
|
|
91
|
+
panelType: PanelType.SUCCESS
|
|
92
|
+
}
|
|
93
|
+
});
|
|
100
94
|
}
|
|
101
95
|
}, {
|
|
102
96
|
id: 'warningpanel',
|
|
@@ -107,9 +101,12 @@ var panelPlugin = function panelPlugin() {
|
|
|
107
101
|
return /*#__PURE__*/React.createElement(IconPanelWarning, null);
|
|
108
102
|
},
|
|
109
103
|
action: function action(insert, state) {
|
|
110
|
-
return
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
return createPanelAction({
|
|
105
|
+
state: state,
|
|
106
|
+
attributes: {
|
|
107
|
+
panelType: PanelType.WARNING
|
|
108
|
+
}
|
|
109
|
+
});
|
|
113
110
|
}
|
|
114
111
|
}, {
|
|
115
112
|
id: 'errorpanel',
|
|
@@ -120,9 +117,12 @@ var panelPlugin = function panelPlugin() {
|
|
|
120
117
|
return /*#__PURE__*/React.createElement(IconPanelError, null);
|
|
121
118
|
},
|
|
122
119
|
action: function action(insert, state) {
|
|
123
|
-
return
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
return createPanelAction({
|
|
121
|
+
state: state,
|
|
122
|
+
attributes: {
|
|
123
|
+
panelType: PanelType.ERROR
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
126
|
}
|
|
127
127
|
}];
|
|
128
128
|
if (options.allowCustomPanel && options.allowCustomPanelEdit) {
|
|
@@ -135,15 +135,18 @@ var panelPlugin = function panelPlugin() {
|
|
|
135
135
|
return /*#__PURE__*/React.createElement(IconCustomPanel, null);
|
|
136
136
|
},
|
|
137
137
|
action: function action(insert, state) {
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
138
|
+
return createPanelAction({
|
|
139
|
+
state: state,
|
|
140
|
+
attributes: {
|
|
141
|
+
panelType: PanelType.CUSTOM,
|
|
142
|
+
panelIcon: ':rainbow:',
|
|
143
|
+
panelIconId: '1f308',
|
|
144
|
+
panelIconText: '🌈',
|
|
145
|
+
// TODO: https://product-fabric.atlassian.net/browse/DSP-7268
|
|
146
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
147
|
+
panelColor: T50
|
|
148
|
+
}
|
|
149
|
+
});
|
|
147
150
|
}
|
|
148
151
|
});
|
|
149
152
|
}
|
|
@@ -155,4 +158,39 @@ var panelPlugin = function panelPlugin() {
|
|
|
155
158
|
}
|
|
156
159
|
};
|
|
157
160
|
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Creates panel action and wrap selection transaction with analytics for the panel insertion.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* const tr = createPanelAction({
|
|
167
|
+
* state: editorState,
|
|
168
|
+
* attributes: { panelType: 'info' },
|
|
169
|
+
* });
|
|
170
|
+
* if (tr) {
|
|
171
|
+
* applyTransaction(tr);
|
|
172
|
+
* }
|
|
173
|
+
*/
|
|
174
|
+
function createPanelAction(_ref3) {
|
|
175
|
+
var state = _ref3.state,
|
|
176
|
+
attributes = _ref3.attributes;
|
|
177
|
+
var tr = createWrapSelectionTransaction({
|
|
178
|
+
state: state,
|
|
179
|
+
type: state.schema.nodes.panel,
|
|
180
|
+
nodeAttributes: attributes
|
|
181
|
+
});
|
|
182
|
+
if (tr) {
|
|
183
|
+
addAnalytics(state, tr, {
|
|
184
|
+
action: ACTION.INSERTED,
|
|
185
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
186
|
+
actionSubjectId: ACTION_SUBJECT_ID.PANEL,
|
|
187
|
+
attributes: {
|
|
188
|
+
inputMethod: INPUT_METHOD.QUICK_INSERT,
|
|
189
|
+
panelType: attributes.panelType
|
|
190
|
+
},
|
|
191
|
+
eventType: EVENT_TYPE.TRACK
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return tr;
|
|
195
|
+
}
|
|
158
196
|
export default panelPlugin;
|
|
@@ -31,6 +31,8 @@ export var insertItem = function insertItem(item) {
|
|
|
31
31
|
return insertSelectedItem(maybeNode, opts)(state, state.tr, state.selection.head);
|
|
32
32
|
};
|
|
33
33
|
var tr = item.action(insert, state);
|
|
34
|
+
|
|
35
|
+
/** @note There is no transaction when called without a search currently (different insert) */
|
|
34
36
|
if (tr && dispatch) {
|
|
35
37
|
dispatch(tr);
|
|
36
38
|
}
|
|
@@ -40,6 +40,10 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
40
40
|
name: item.value.name
|
|
41
41
|
}) || item.elemBefore;
|
|
42
42
|
},
|
|
43
|
+
/**
|
|
44
|
+
* @note This transformed items action is only used when a quick insert item has been
|
|
45
|
+
* called from the quick insert menu and a search has not been performed.
|
|
46
|
+
*/
|
|
43
47
|
action: function action() {
|
|
44
48
|
return onInsert({
|
|
45
49
|
item: item
|
|
@@ -62,6 +66,12 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
62
66
|
var getItems = useCallback(function (quickInsertState) {
|
|
63
67
|
return function (query, category) {
|
|
64
68
|
var result;
|
|
69
|
+
/**
|
|
70
|
+
* @warning The results if there is a query are not the same as the results if there is no query.
|
|
71
|
+
* For example: If you have a typed panel and then select the panel item then it will call a different action
|
|
72
|
+
* than is specified on the editor plugins quick insert
|
|
73
|
+
* @see above transform function for more details.
|
|
74
|
+
*/
|
|
65
75
|
if (query) {
|
|
66
76
|
result = searchQuickInsertItems(quickInsertState, {})(query, category);
|
|
67
77
|
} else {
|
package/dist/esm/version.json
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/// <reference path="../../../../../../../../typings/prosemirror.d.ts" />
|
|
2
|
+
/// <reference path="../../../../../../../../typings/prosemirror-state.d.ts" />
|
|
3
|
+
import { EditorState } from 'prosemirror-state';
|
|
4
|
+
import { NodeType } from 'prosemirror-model';
|
|
1
5
|
import { Command } from '../../../types';
|
|
2
6
|
import { HeadingLevelsAndNormalText } from '../types';
|
|
3
7
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
@@ -19,4 +23,25 @@ export declare function insertBlockType(name: string): Command;
|
|
|
19
23
|
* @returns - command that inserts block type
|
|
20
24
|
*/
|
|
21
25
|
export declare const insertBlockTypesWithAnalytics: (name: string, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
26
|
+
/**
|
|
27
|
+
* This function creates a new transaction that wraps the current selection
|
|
28
|
+
* in the specified node type if it results in a valid transaction.
|
|
29
|
+
* If not valid, it performs a safe insert operation.
|
|
30
|
+
*
|
|
31
|
+
* Example of when wrapping might not be valid is when attempting to wrap
|
|
32
|
+
* content that is already inside a panel with another panel
|
|
33
|
+
*/
|
|
34
|
+
export declare function createWrapSelectionTransaction({ state, type, nodeAttributes, }: {
|
|
35
|
+
state: EditorState;
|
|
36
|
+
type: NodeType;
|
|
37
|
+
nodeAttributes?: Record<string, any>;
|
|
38
|
+
}): import("prosemirror-state").Transaction;
|
|
39
|
+
/**
|
|
40
|
+
* This function creates a new transaction that inserts a code block,
|
|
41
|
+
* if there is text selected it will wrap the current selection if not it will
|
|
42
|
+
* append the codeblock to the end of the document.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createInsertCodeBlockTransaction({ state, }: {
|
|
45
|
+
state: EditorState;
|
|
46
|
+
}): import("prosemirror-state").Transaction;
|
|
22
47
|
export declare const cleanUpAtTheStartOfDocument: Command;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/// <reference path="../../../../../../../../typings/prosemirror.d.ts" />
|
|
2
|
+
/// <reference path="../../../../../../../../typings/prosemirror-state.d.ts" />
|
|
3
|
+
import { EditorState } from 'prosemirror-state';
|
|
4
|
+
import { NodeType } from 'prosemirror-model';
|
|
1
5
|
import { Command } from '../../../types';
|
|
2
6
|
import { HeadingLevelsAndNormalText } from '../types';
|
|
3
7
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
@@ -19,4 +23,25 @@ export declare function insertBlockType(name: string): Command;
|
|
|
19
23
|
* @returns - command that inserts block type
|
|
20
24
|
*/
|
|
21
25
|
export declare const insertBlockTypesWithAnalytics: (name: string, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
26
|
+
/**
|
|
27
|
+
* This function creates a new transaction that wraps the current selection
|
|
28
|
+
* in the specified node type if it results in a valid transaction.
|
|
29
|
+
* If not valid, it performs a safe insert operation.
|
|
30
|
+
*
|
|
31
|
+
* Example of when wrapping might not be valid is when attempting to wrap
|
|
32
|
+
* content that is already inside a panel with another panel
|
|
33
|
+
*/
|
|
34
|
+
export declare function createWrapSelectionTransaction({ state, type, nodeAttributes, }: {
|
|
35
|
+
state: EditorState;
|
|
36
|
+
type: NodeType;
|
|
37
|
+
nodeAttributes?: Record<string, any>;
|
|
38
|
+
}): import("prosemirror-state").Transaction;
|
|
39
|
+
/**
|
|
40
|
+
* This function creates a new transaction that inserts a code block,
|
|
41
|
+
* if there is text selected it will wrap the current selection if not it will
|
|
42
|
+
* append the codeblock to the end of the document.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createInsertCodeBlockTransaction({ state, }: {
|
|
45
|
+
state: EditorState;
|
|
46
|
+
}): import("prosemirror-state").Transaction;
|
|
22
47
|
export declare const cleanUpAtTheStartOfDocument: Command;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "185.12.
|
|
3
|
+
"version": "185.12.2",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@atlaskit/icon-object": "^6.3.0",
|
|
78
78
|
"@atlaskit/link-analytics": "^8.2.0",
|
|
79
79
|
"@atlaskit/link-datasource": "^0.28.0",
|
|
80
|
-
"@atlaskit/link-picker": "^1.
|
|
80
|
+
"@atlaskit/link-picker": "^1.27.0",
|
|
81
81
|
"@atlaskit/locale": "^2.5.0",
|
|
82
82
|
"@atlaskit/logo": "^13.14.0",
|
|
83
83
|
"@atlaskit/media-card": "^76.1.0",
|