@atlaskit/editor-plugin-block-type 6.0.5 → 6.0.6
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 +10 -0
- package/dist/cjs/pm-plugins/commands/block-type.js +36 -7
- package/dist/cjs/pm-plugins/ui/FloatingToolbarComponent.js +2 -2
- package/dist/es2019/pm-plugins/commands/block-type.js +37 -8
- package/dist/es2019/pm-plugins/ui/FloatingToolbarComponent.js +2 -2
- package/dist/esm/pm-plugins/commands/block-type.js +37 -8
- package/dist/esm/pm-plugins/ui/FloatingToolbarComponent.js +2 -2
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-type
|
|
2
2
|
|
|
3
|
+
## 6.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#188518](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/188518)
|
|
8
|
+
[`713b78fb27820`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/713b78fb27820) -
|
|
9
|
+
Fixed block quote not changing to normal text and splitting tables when normal text is selected in
|
|
10
|
+
toolbar
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 6.0.5
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -17,7 +17,9 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
17
17
|
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
18
18
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
19
19
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
20
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
20
21
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
22
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
23
|
var _blockTypes = require("../block-types");
|
|
22
24
|
var _clearFormatting = require("./clear-formatting");
|
|
23
25
|
var _wrapSelectionIn = require("./wrapSelectionIn");
|
|
@@ -56,12 +58,28 @@ function setHeading(level, fromBlockQuote) {
|
|
|
56
58
|
if (!range) {
|
|
57
59
|
return;
|
|
58
60
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_bugfix_remove_block_quote')) {
|
|
62
|
+
// First, lift the content out of the blockquote
|
|
63
|
+
var targetLiftDepth = (0, _transform.liftTarget)(range);
|
|
64
|
+
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
65
|
+
tr.lift(range, targetLiftDepth);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Then apply the heading block type to the lifted content
|
|
69
|
+
// We need to recalculate positions after the lift operation
|
|
70
|
+
var newFrom = tr.mapping.map($from.pos);
|
|
71
|
+
var newTo = tr.mapping.map($to.pos);
|
|
72
|
+
tr.setBlockType(newFrom, newTo, schema.nodes.heading, {
|
|
73
|
+
level: level
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
var content = $from.node().content;
|
|
77
|
+
var headingNode = schema.nodes.heading.createChecked({
|
|
78
|
+
level: level
|
|
79
|
+
}, content);
|
|
80
|
+
var slice = new _model.Slice(_model.Fragment.from(headingNode), 0, 0);
|
|
81
|
+
tr.replaceRange(range.start, range.end, slice);
|
|
82
|
+
}
|
|
65
83
|
} else {
|
|
66
84
|
tr.setBlockType($from.pos, $to.pos, schema.nodes.heading, {
|
|
67
85
|
level: level
|
|
@@ -103,7 +121,18 @@ function setNormalText(fromBlockQuote) {
|
|
|
103
121
|
if (!range) {
|
|
104
122
|
return;
|
|
105
123
|
}
|
|
106
|
-
|
|
124
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_bugfix_remove_block_quote')) {
|
|
125
|
+
// First, lift the content out of the blockquote
|
|
126
|
+
var targetLiftDepth = (0, _transform.liftTarget)(range);
|
|
127
|
+
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
128
|
+
tr.lift(range, targetLiftDepth);
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
tr.lift(range, 0);
|
|
132
|
+
}
|
|
133
|
+
var newFrom = tr.mapping.map($from.pos);
|
|
134
|
+
var newTo = tr.mapping.map($to.pos);
|
|
135
|
+
tr.setBlockType(newFrom, newTo, schema.nodes.paragraph, {});
|
|
107
136
|
} else {
|
|
108
137
|
tr.setBlockType($from.pos, $to.pos, schema.nodes.paragraph);
|
|
109
138
|
}
|
|
@@ -60,9 +60,9 @@ function FloatingToolbarComponent(_ref) {
|
|
|
60
60
|
availableBlockTypes = _useFloatingToolbarCo.availableBlockTypes,
|
|
61
61
|
availableBlockTypesInDropdown = _useFloatingToolbarCo.availableBlockTypesInDropdown,
|
|
62
62
|
formattingIsPresent = _useFloatingToolbarCo.formattingIsPresent;
|
|
63
|
-
var boundSetBlockType = (0, _react.useCallback)(function (name) {
|
|
63
|
+
var boundSetBlockType = (0, _react.useCallback)(function (name, fromBlockQuote) {
|
|
64
64
|
var _api$core, _api$blockType;
|
|
65
|
-
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, _analytics.INPUT_METHOD.FLOATING_TB));
|
|
65
|
+
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, _analytics.INPUT_METHOD.FLOATING_TB, fromBlockQuote));
|
|
66
66
|
}, [api]);
|
|
67
67
|
var wrapBlockQuote = (0, _react.useCallback)(function () {
|
|
68
68
|
var _api$core2, _api$blockType2;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
3
3
|
import { filterChildrenBetween, wrapSelectionIn } from '@atlaskit/editor-common/utils';
|
|
4
|
-
import {
|
|
4
|
+
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
|
|
5
6
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
8
|
import { HEADINGS_BY_NAME, NORMAL_TEXT } from '../block-types';
|
|
7
9
|
import { FORMATTING_NODE_TYPES, FORMATTING_MARK_TYPES, cellSelectionNodesBetween, formatTypes, clearNodeFormattingOnSelection } from './clear-formatting';
|
|
8
10
|
import { wrapSelectionInBlockType } from './wrapSelectionIn';
|
|
@@ -49,12 +51,28 @@ export function setHeading(level, fromBlockQuote) {
|
|
|
49
51
|
if (!range) {
|
|
50
52
|
return;
|
|
51
53
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
if (fg('platform_editor_bugfix_remove_block_quote')) {
|
|
55
|
+
// First, lift the content out of the blockquote
|
|
56
|
+
const targetLiftDepth = liftTarget(range);
|
|
57
|
+
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
58
|
+
tr.lift(range, targetLiftDepth);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Then apply the heading block type to the lifted content
|
|
62
|
+
// We need to recalculate positions after the lift operation
|
|
63
|
+
const newFrom = tr.mapping.map($from.pos);
|
|
64
|
+
const newTo = tr.mapping.map($to.pos);
|
|
65
|
+
tr.setBlockType(newFrom, newTo, schema.nodes.heading, {
|
|
66
|
+
level
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
const content = $from.node().content;
|
|
70
|
+
const headingNode = schema.nodes.heading.createChecked({
|
|
71
|
+
level
|
|
72
|
+
}, content);
|
|
73
|
+
const slice = new Slice(Fragment.from(headingNode), 0, 0);
|
|
74
|
+
tr.replaceRange(range.start, range.end, slice);
|
|
75
|
+
}
|
|
58
76
|
} else {
|
|
59
77
|
tr.setBlockType($from.pos, $to.pos, schema.nodes.heading, {
|
|
60
78
|
level
|
|
@@ -107,7 +125,18 @@ export function setNormalText(fromBlockQuote) {
|
|
|
107
125
|
if (!range) {
|
|
108
126
|
return;
|
|
109
127
|
}
|
|
110
|
-
|
|
128
|
+
if (fg('platform_editor_bugfix_remove_block_quote')) {
|
|
129
|
+
// First, lift the content out of the blockquote
|
|
130
|
+
const targetLiftDepth = liftTarget(range);
|
|
131
|
+
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
132
|
+
tr.lift(range, targetLiftDepth);
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
tr.lift(range, 0);
|
|
136
|
+
}
|
|
137
|
+
const newFrom = tr.mapping.map($from.pos);
|
|
138
|
+
const newTo = tr.mapping.map($to.pos);
|
|
139
|
+
tr.setBlockType(newFrom, newTo, schema.nodes.paragraph, {});
|
|
111
140
|
} else {
|
|
112
141
|
tr.setBlockType($from.pos, $to.pos, schema.nodes.paragraph);
|
|
113
142
|
}
|
|
@@ -55,9 +55,9 @@ export function FloatingToolbarComponent({
|
|
|
55
55
|
availableBlockTypesInDropdown,
|
|
56
56
|
formattingIsPresent
|
|
57
57
|
} = useFloatingToolbarComponentPluginState(api);
|
|
58
|
-
const boundSetBlockType = useCallback(name => {
|
|
58
|
+
const boundSetBlockType = useCallback((name, fromBlockQuote) => {
|
|
59
59
|
var _api$core, _api$blockType, _api$blockType$comman;
|
|
60
|
-
return api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : (_api$blockType$comman = _api$blockType.commands) === null || _api$blockType$comman === void 0 ? void 0 : _api$blockType$comman.setTextLevel(name, INPUT_METHOD.FLOATING_TB));
|
|
60
|
+
return api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : (_api$blockType$comman = _api$blockType.commands) === null || _api$blockType$comman === void 0 ? void 0 : _api$blockType$comman.setTextLevel(name, INPUT_METHOD.FLOATING_TB, fromBlockQuote));
|
|
61
61
|
}, [api]);
|
|
62
62
|
const wrapBlockQuote = useCallback(() => {
|
|
63
63
|
var _api$core2, _api$blockType2, _api$blockType2$comma;
|
|
@@ -4,8 +4,10 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
6
6
|
import { filterChildrenBetween, wrapSelectionIn } from '@atlaskit/editor-common/utils';
|
|
7
|
-
import {
|
|
7
|
+
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
+
import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
|
|
8
9
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
11
|
import { HEADINGS_BY_NAME, NORMAL_TEXT } from '../block-types';
|
|
10
12
|
import { FORMATTING_NODE_TYPES, FORMATTING_MARK_TYPES, cellSelectionNodesBetween, formatTypes, clearNodeFormattingOnSelection } from './clear-formatting';
|
|
11
13
|
import { wrapSelectionInBlockType } from './wrapSelectionIn';
|
|
@@ -41,12 +43,28 @@ export function setHeading(level, fromBlockQuote) {
|
|
|
41
43
|
if (!range) {
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
if (fg('platform_editor_bugfix_remove_block_quote')) {
|
|
47
|
+
// First, lift the content out of the blockquote
|
|
48
|
+
var targetLiftDepth = liftTarget(range);
|
|
49
|
+
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
50
|
+
tr.lift(range, targetLiftDepth);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Then apply the heading block type to the lifted content
|
|
54
|
+
// We need to recalculate positions after the lift operation
|
|
55
|
+
var newFrom = tr.mapping.map($from.pos);
|
|
56
|
+
var newTo = tr.mapping.map($to.pos);
|
|
57
|
+
tr.setBlockType(newFrom, newTo, schema.nodes.heading, {
|
|
58
|
+
level: level
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
var content = $from.node().content;
|
|
62
|
+
var headingNode = schema.nodes.heading.createChecked({
|
|
63
|
+
level: level
|
|
64
|
+
}, content);
|
|
65
|
+
var slice = new Slice(Fragment.from(headingNode), 0, 0);
|
|
66
|
+
tr.replaceRange(range.start, range.end, slice);
|
|
67
|
+
}
|
|
50
68
|
} else {
|
|
51
69
|
tr.setBlockType($from.pos, $to.pos, schema.nodes.heading, {
|
|
52
70
|
level: level
|
|
@@ -88,7 +106,18 @@ export function setNormalText(fromBlockQuote) {
|
|
|
88
106
|
if (!range) {
|
|
89
107
|
return;
|
|
90
108
|
}
|
|
91
|
-
|
|
109
|
+
if (fg('platform_editor_bugfix_remove_block_quote')) {
|
|
110
|
+
// First, lift the content out of the blockquote
|
|
111
|
+
var targetLiftDepth = liftTarget(range);
|
|
112
|
+
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
113
|
+
tr.lift(range, targetLiftDepth);
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
tr.lift(range, 0);
|
|
117
|
+
}
|
|
118
|
+
var newFrom = tr.mapping.map($from.pos);
|
|
119
|
+
var newTo = tr.mapping.map($to.pos);
|
|
120
|
+
tr.setBlockType(newFrom, newTo, schema.nodes.paragraph, {});
|
|
92
121
|
} else {
|
|
93
122
|
tr.setBlockType($from.pos, $to.pos, schema.nodes.paragraph);
|
|
94
123
|
}
|
|
@@ -51,9 +51,9 @@ export function FloatingToolbarComponent(_ref) {
|
|
|
51
51
|
availableBlockTypes = _useFloatingToolbarCo.availableBlockTypes,
|
|
52
52
|
availableBlockTypesInDropdown = _useFloatingToolbarCo.availableBlockTypesInDropdown,
|
|
53
53
|
formattingIsPresent = _useFloatingToolbarCo.formattingIsPresent;
|
|
54
|
-
var boundSetBlockType = useCallback(function (name) {
|
|
54
|
+
var boundSetBlockType = useCallback(function (name, fromBlockQuote) {
|
|
55
55
|
var _api$core, _api$blockType;
|
|
56
|
-
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, INPUT_METHOD.FLOATING_TB));
|
|
56
|
+
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, INPUT_METHOD.FLOATING_TB, fromBlockQuote));
|
|
57
57
|
}, [api]);
|
|
58
58
|
var wrapBlockQuote = useCallback(function () {
|
|
59
59
|
var _api$core2, _api$blockType2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-type",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.6",
|
|
4
4
|
"description": "BlockType plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^3.5.0",
|
|
43
43
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
44
|
-
"@atlaskit/icon": "^27.
|
|
45
|
-
"@atlaskit/icon-lab": "^5.
|
|
44
|
+
"@atlaskit/icon": "^27.5.0",
|
|
45
|
+
"@atlaskit/icon-lab": "^5.2.0",
|
|
46
46
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
47
47
|
"@atlaskit/primitives": "^14.10.0",
|
|
48
48
|
"@atlaskit/prosemirror-input-rules": "^3.3.0",
|
|
49
49
|
"@atlaskit/theme": "^19.0.0",
|
|
50
50
|
"@atlaskit/tmp-editor-statsig": "^9.8.0",
|
|
51
|
-
"@atlaskit/tokens": "^5.
|
|
51
|
+
"@atlaskit/tokens": "^5.6.0",
|
|
52
52
|
"@babel/runtime": "^7.0.0",
|
|
53
53
|
"@emotion/react": "^11.7.1"
|
|
54
54
|
},
|
|
@@ -115,6 +115,9 @@
|
|
|
115
115
|
},
|
|
116
116
|
"platform_editor_use_preferences_plugin": {
|
|
117
117
|
"type": "boolean"
|
|
118
|
+
},
|
|
119
|
+
"platform_editor_bugfix_remove_block_quote": {
|
|
120
|
+
"type": "boolean"
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
}
|