@atlaskit/editor-plugin-block-controls 12.3.1 → 12.3.5
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 +27 -0
- package/dist/cjs/blockControlsPlugin.js +13 -3
- package/dist/es2019/blockControlsPlugin.js +13 -3
- package/dist/esm/blockControlsPlugin.js +13 -3
- package/dist/types/blockControlsPluginType.d.ts +10 -6
- package/dist/types-ts4.5/blockControlsPluginType.d.ts +10 -6
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 12.3.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 12.3.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 12.3.3
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`993241a125f8a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/993241a125f8a) -
|
|
20
|
+
[EDITOR-7652] Configure blockControl action getTextLength to return textLength and textContent and
|
|
21
|
+
renaming it to getTextInfo
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
24
|
+
## 12.3.2
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
|
|
3
30
|
## 12.3.1
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
|
@@ -39,21 +39,31 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
39
39
|
return {
|
|
40
40
|
name: 'blockControls',
|
|
41
41
|
actions: {
|
|
42
|
-
|
|
42
|
+
getTextInfo: function getTextInfo(editorView) {
|
|
43
43
|
var _api$blockControls, _blockControlsState$m;
|
|
44
44
|
var blockControlsState = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState();
|
|
45
45
|
var preservedSelection = blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.preservedSelection;
|
|
46
46
|
if (preservedSelection && preservedSelection.from !== preservedSelection.to) {
|
|
47
47
|
var from = preservedSelection.from,
|
|
48
48
|
to = preservedSelection.to;
|
|
49
|
-
|
|
49
|
+
var textContent = editorView.state.doc.textBetween(from, to, '\n');
|
|
50
|
+
return {
|
|
51
|
+
textLength: textContent.length,
|
|
52
|
+
textContent: textContent
|
|
53
|
+
};
|
|
50
54
|
}
|
|
51
55
|
var pos = blockControlsState === null || blockControlsState === void 0 || (_blockControlsState$m = blockControlsState.menuTriggerByNode) === null || _blockControlsState$m === void 0 ? void 0 : _blockControlsState$m.pos;
|
|
52
56
|
if (pos === null || pos === undefined) {
|
|
53
57
|
return null;
|
|
54
58
|
}
|
|
55
59
|
var node = editorView.state.doc.nodeAt(pos);
|
|
56
|
-
|
|
60
|
+
if (!node) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
textLength: node.textContent.length,
|
|
65
|
+
textContent: node.textContent
|
|
66
|
+
};
|
|
57
67
|
},
|
|
58
68
|
registerNodeDecoration: function registerNodeDecoration(factory) {
|
|
59
69
|
nodeDecorationRegistry.push(factory);
|
|
@@ -30,7 +30,7 @@ export const blockControlsPlugin = ({
|
|
|
30
30
|
return {
|
|
31
31
|
name: 'blockControls',
|
|
32
32
|
actions: {
|
|
33
|
-
|
|
33
|
+
getTextInfo: editorView => {
|
|
34
34
|
var _api$blockControls, _blockControlsState$m;
|
|
35
35
|
const blockControlsState = api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState();
|
|
36
36
|
const preservedSelection = blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.preservedSelection;
|
|
@@ -39,14 +39,24 @@ export const blockControlsPlugin = ({
|
|
|
39
39
|
from,
|
|
40
40
|
to
|
|
41
41
|
} = preservedSelection;
|
|
42
|
-
|
|
42
|
+
const textContent = editorView.state.doc.textBetween(from, to, '\n');
|
|
43
|
+
return {
|
|
44
|
+
textLength: textContent.length,
|
|
45
|
+
textContent
|
|
46
|
+
};
|
|
43
47
|
}
|
|
44
48
|
const pos = blockControlsState === null || blockControlsState === void 0 ? void 0 : (_blockControlsState$m = blockControlsState.menuTriggerByNode) === null || _blockControlsState$m === void 0 ? void 0 : _blockControlsState$m.pos;
|
|
45
49
|
if (pos === null || pos === undefined) {
|
|
46
50
|
return null;
|
|
47
51
|
}
|
|
48
52
|
const node = editorView.state.doc.nodeAt(pos);
|
|
49
|
-
|
|
53
|
+
if (!node) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
textLength: node.textContent.length,
|
|
58
|
+
textContent: node.textContent
|
|
59
|
+
};
|
|
50
60
|
},
|
|
51
61
|
registerNodeDecoration: factory => {
|
|
52
62
|
nodeDecorationRegistry.push(factory);
|
|
@@ -32,21 +32,31 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
32
32
|
return {
|
|
33
33
|
name: 'blockControls',
|
|
34
34
|
actions: {
|
|
35
|
-
|
|
35
|
+
getTextInfo: function getTextInfo(editorView) {
|
|
36
36
|
var _api$blockControls, _blockControlsState$m;
|
|
37
37
|
var blockControlsState = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState();
|
|
38
38
|
var preservedSelection = blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.preservedSelection;
|
|
39
39
|
if (preservedSelection && preservedSelection.from !== preservedSelection.to) {
|
|
40
40
|
var from = preservedSelection.from,
|
|
41
41
|
to = preservedSelection.to;
|
|
42
|
-
|
|
42
|
+
var textContent = editorView.state.doc.textBetween(from, to, '\n');
|
|
43
|
+
return {
|
|
44
|
+
textLength: textContent.length,
|
|
45
|
+
textContent: textContent
|
|
46
|
+
};
|
|
43
47
|
}
|
|
44
48
|
var pos = blockControlsState === null || blockControlsState === void 0 || (_blockControlsState$m = blockControlsState.menuTriggerByNode) === null || _blockControlsState$m === void 0 ? void 0 : _blockControlsState$m.pos;
|
|
45
49
|
if (pos === null || pos === undefined) {
|
|
46
50
|
return null;
|
|
47
51
|
}
|
|
48
52
|
var node = editorView.state.doc.nodeAt(pos);
|
|
49
|
-
|
|
53
|
+
if (!node) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
textLength: node.textContent.length,
|
|
58
|
+
textContent: node.textContent
|
|
59
|
+
};
|
|
50
60
|
},
|
|
51
61
|
registerNodeDecoration: function registerNodeDecoration(factory) {
|
|
52
62
|
nodeDecorationRegistry.push(factory);
|
|
@@ -162,16 +162,20 @@ export type BlockControlsPluginDependencies = [
|
|
|
162
162
|
export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
163
163
|
actions: {
|
|
164
164
|
/**
|
|
165
|
-
* Returns the text length of the block(s) that triggered
|
|
165
|
+
* Returns the text info (length and content) of the block(s) that triggered
|
|
166
|
+
* the block menu.
|
|
166
167
|
*
|
|
167
|
-
* When a preserved (multi-block) selection exists the
|
|
168
|
-
*
|
|
169
|
-
* is used.
|
|
168
|
+
* When a preserved (multi-block) selection exists the text spans all selected
|
|
169
|
+
* blocks; otherwise the single node at `menuTriggerByNode.pos` is used.
|
|
170
170
|
*
|
|
171
171
|
* @param editorView – the current editor view.
|
|
172
|
-
* @returns
|
|
172
|
+
* @returns An object with `textLength` and `textContent`, or `null` when the
|
|
173
|
+
* context cannot be determined.
|
|
173
174
|
*/
|
|
174
|
-
|
|
175
|
+
getTextInfo: (editorView: EditorView) => {
|
|
176
|
+
textContent: string;
|
|
177
|
+
textLength: number;
|
|
178
|
+
} | null;
|
|
175
179
|
registerNodeDecoration: (factory: NodeDecorationFactory) => void;
|
|
176
180
|
unregisterNodeDecoration: (type: string) => void;
|
|
177
181
|
};
|
|
@@ -164,16 +164,20 @@ export type BlockControlsPluginDependencies = [
|
|
|
164
164
|
export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
165
165
|
actions: {
|
|
166
166
|
/**
|
|
167
|
-
* Returns the text length of the block(s) that triggered
|
|
167
|
+
* Returns the text info (length and content) of the block(s) that triggered
|
|
168
|
+
* the block menu.
|
|
168
169
|
*
|
|
169
|
-
* When a preserved (multi-block) selection exists the
|
|
170
|
-
*
|
|
171
|
-
* is used.
|
|
170
|
+
* When a preserved (multi-block) selection exists the text spans all selected
|
|
171
|
+
* blocks; otherwise the single node at `menuTriggerByNode.pos` is used.
|
|
172
172
|
*
|
|
173
173
|
* @param editorView – the current editor view.
|
|
174
|
-
* @returns
|
|
174
|
+
* @returns An object with `textLength` and `textContent`, or `null` when the
|
|
175
|
+
* context cannot be determined.
|
|
175
176
|
*/
|
|
176
|
-
|
|
177
|
+
getTextInfo: (editorView: EditorView) => {
|
|
178
|
+
textContent: string;
|
|
179
|
+
textLength: number;
|
|
180
|
+
} | null;
|
|
177
181
|
registerNodeDecoration: (factory: NodeDecorationFactory) => void;
|
|
178
182
|
unregisterNodeDecoration: (type: string) => void;
|
|
179
183
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "12.3.
|
|
3
|
+
"version": "12.3.5",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@atlaskit/editor-plugin-quick-insert": "^11.1.0",
|
|
42
42
|
"@atlaskit/editor-plugin-selection": "^11.0.0",
|
|
43
43
|
"@atlaskit/editor-plugin-toolbar": "^8.0.0",
|
|
44
|
-
"@atlaskit/editor-plugin-type-ahead": "^11.
|
|
44
|
+
"@atlaskit/editor-plugin-type-ahead": "^11.3.0",
|
|
45
45
|
"@atlaskit/editor-plugin-user-intent": "^9.0.0",
|
|
46
46
|
"@atlaskit/editor-plugin-width": "^12.0.0",
|
|
47
47
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
|
|
57
57
|
"@atlaskit/primitives": "^19.0.0",
|
|
58
58
|
"@atlaskit/theme": "^25.0.0",
|
|
59
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
59
|
+
"@atlaskit/tmp-editor-statsig": "^99.0.0",
|
|
60
60
|
"@atlaskit/tokens": "^13.3.0",
|
|
61
61
|
"@atlaskit/tooltip": "^22.6.0",
|
|
62
62
|
"@babel/runtime": "^7.0.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"uuid": "^3.1.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@atlaskit/editor-common": "^115.
|
|
70
|
+
"@atlaskit/editor-common": "^115.13.0",
|
|
71
71
|
"react": "^18.2.0",
|
|
72
72
|
"react-dom": "^18.2.0",
|
|
73
73
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|