@atlaskit/editor-plugin-block-type 3.0.24 → 3.0.26
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 +37 -0
- package/dist/cjs/plugin/commands/delete-block-content.js +6 -2
- package/dist/cjs/plugin/pm-plugins/input-rule.js +5 -4
- package/dist/cjs/plugin/utils.js +1 -2
- package/dist/es2019/plugin/commands/delete-block-content.js +6 -2
- package/dist/es2019/plugin/pm-plugins/input-rule.js +5 -4
- package/dist/es2019/plugin/utils.js +1 -2
- package/dist/esm/plugin/commands/delete-block-content.js +6 -2
- package/dist/esm/plugin/pm-plugins/input-rule.js +5 -4
- package/dist/esm/plugin/utils.js +1 -2
- package/dist/types/plugin/pm-plugins/input-rule.d.ts +1 -1
- package/dist/types/plugin/utils.d.ts +1 -1
- package/dist/types-ts4.5/plugin/pm-plugins/input-rule.d.ts +1 -1
- package/dist/types-ts4.5/plugin/utils.d.ts +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-type
|
|
2
2
|
|
|
3
|
+
## 3.0.26
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#76093](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/76093) [`fc113e0c416f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fc113e0c416f) - ED-22243 handling of backspace for mediaGroup node nested in panel
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 3.0.25
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#75482](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75482) [`18b5a6fb910a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/18b5a6fb910a) - # MAJOR CHANGE to `@atlaskit/prosemirror-input-rules` package.
|
|
15
|
+
|
|
16
|
+
## WHY?
|
|
17
|
+
|
|
18
|
+
Removing editor-common dependencies from prosemirror-input-rules package.
|
|
19
|
+
|
|
20
|
+
This makes it easier for editor updates because it simplifies our dependency graph.
|
|
21
|
+
|
|
22
|
+
## WHAT and HOW?
|
|
23
|
+
|
|
24
|
+
These are no longer available via `@atlaskit/prosemirror-input-rules` but are available from `@atlaskit/editor-common/types`:
|
|
25
|
+
|
|
26
|
+
- InputRuleWrapper
|
|
27
|
+
- InputRuleHandler
|
|
28
|
+
- OnHandlerApply
|
|
29
|
+
- createRule
|
|
30
|
+
|
|
31
|
+
These have changed from a `SafePlugin` to a `SafePluginSpec`. In order to update your code you need to instantiate a `SafePlugin` (ie. `new SafePlugin(createPlugin( ... ))`).
|
|
32
|
+
|
|
33
|
+
`SafePlugin` exists in `@atlaskit/editor-common/safe-plugin`.
|
|
34
|
+
|
|
35
|
+
- createPlugin
|
|
36
|
+
- createInputRulePlugin
|
|
37
|
+
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
|
|
3
40
|
## 3.0.24
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -16,6 +16,9 @@ var isSelectedNodeSoleDecisionItem = function isSelectedNodeSoleDecisionItem(sta
|
|
|
16
16
|
var decisionList = (_findParentNodeOfType = (0, _utils.findParentNodeOfType)([state.schema.nodes.decisionList])(state.selection)) === null || _findParentNodeOfType === void 0 ? void 0 : _findParentNodeOfType.node;
|
|
17
17
|
return (decisionList === null || decisionList === void 0 ? void 0 : decisionList.childCount) === 1;
|
|
18
18
|
};
|
|
19
|
+
var isSelectedNodeMediaGroup = function isSelectedNodeMediaGroup(state) {
|
|
20
|
+
return Boolean(state.selection instanceof _state.NodeSelection && state.selection.node.type.name === 'media' && state.selection.$head.parent.type.name === 'mediaGroup');
|
|
21
|
+
};
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
24
|
* Prevent removing the block when deleting block content
|
|
@@ -46,11 +49,12 @@ function deleteBlockContent(isNodeAWrappingBlockNode) {
|
|
|
46
49
|
if (!selectionCrossesWrappingBlockNode) {
|
|
47
50
|
return false;
|
|
48
51
|
}
|
|
49
|
-
var
|
|
52
|
+
var isParentNodeOfTypePanel = (0, _utils.hasParentNodeOfType)([state.schema.nodes.panel])(state.selection);
|
|
50
53
|
|
|
51
54
|
// If decision is inside panel and the decision list have only one decision item which is selected,
|
|
52
55
|
// delete the whole decision list.
|
|
53
|
-
if
|
|
56
|
+
// Also, checks if selection is a mediaGroup node within a panel
|
|
57
|
+
if (isParentNodeOfTypePanel && (isSelectedNodeSoleDecisionItem(state) || isSelectedNodeMediaGroup(state))) {
|
|
54
58
|
tr.setSelection(new _state.TextSelection(tr.doc.resolve($from.before()))).delete($from.before(), $from.after());
|
|
55
59
|
} else {
|
|
56
60
|
tr.delete($from.pos, $to.pos);
|
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
10
|
var _commands = require("@atlaskit/editor-common/commands");
|
|
11
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
13
|
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
13
14
|
var _utils2 = require("../utils");
|
|
@@ -37,7 +38,7 @@ function blockQuoteRule(nodeType) {
|
|
|
37
38
|
function getHeadingRules(editorAnalyticsAPI, schema) {
|
|
38
39
|
// '# ' for h1, '## ' for h2 and etc
|
|
39
40
|
var hashRule = headingRule(schema.nodes.heading, MAX_HEADING_LEVEL);
|
|
40
|
-
var leftNodeReplacementHashRule = (0,
|
|
41
|
+
var leftNodeReplacementHashRule = (0, _utils.createRule)(new RegExp("".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, "(#{1,6})\\s$")), function (state, match, start, end) {
|
|
41
42
|
var level = match[1].length;
|
|
42
43
|
return (0, _commands.insertBlock)(state, schema.nodes.heading, start, end, {
|
|
43
44
|
level: level
|
|
@@ -69,7 +70,7 @@ function getHeadingRules(editorAnalyticsAPI, schema) {
|
|
|
69
70
|
function getBlockQuoteRules(editorAnalyticsAPI, schema) {
|
|
70
71
|
// '> ' for blockquote
|
|
71
72
|
var greatherThanRule = blockQuoteRule(schema.nodes.blockquote);
|
|
72
|
-
var leftNodeReplacementGreatherRule = (0,
|
|
73
|
+
var leftNodeReplacementGreatherRule = (0, _utils.createRule)(new RegExp("".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, "\\s*>\\s$")), function (state, _match, start, end) {
|
|
73
74
|
return (0, _commands.insertBlock)(state, schema.nodes.blockquote, start, end);
|
|
74
75
|
});
|
|
75
76
|
|
|
@@ -94,9 +95,9 @@ function inputRulePlugin(editorAnalyticsAPI, schema, featureFlags) {
|
|
|
94
95
|
rules.push.apply(rules, (0, _toConsumableArray2.default)(getBlockQuoteRules(editorAnalyticsAPI, schema)));
|
|
95
96
|
}
|
|
96
97
|
if (rules.length !== 0) {
|
|
97
|
-
return (0, _prosemirrorInputRules.createPlugin)('block-type', rules, {
|
|
98
|
+
return new _safePlugin.SafePlugin((0, _prosemirrorInputRules.createPlugin)('block-type', rules, {
|
|
98
99
|
isBlockNodeRule: true
|
|
99
|
-
});
|
|
100
|
+
}));
|
|
100
101
|
}
|
|
101
102
|
return;
|
|
102
103
|
}
|
package/dist/cjs/plugin/utils.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.areBlockTypesDisabled = areBlockTypesDisabled;
|
|
7
7
|
exports.isNodeAWrappingBlockNode = exports.createWrappingTextBlockRule = exports.createJoinNodesRule = void 0;
|
|
8
8
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
|
-
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
10
9
|
var _blockTypes = require("./block-types");
|
|
11
10
|
var isNodeAWrappingBlockNode = exports.isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
|
|
12
11
|
if (!node) {
|
|
@@ -40,7 +39,7 @@ var createWrappingTextBlockRule = exports.createWrappingTextBlockRule = function
|
|
|
40
39
|
}
|
|
41
40
|
return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
|
|
42
41
|
};
|
|
43
|
-
return (0,
|
|
42
|
+
return (0, _utils.createRule)(match, handler);
|
|
44
43
|
};
|
|
45
44
|
|
|
46
45
|
/**
|
|
@@ -11,6 +11,9 @@ const isSelectedNodeSoleDecisionItem = state => {
|
|
|
11
11
|
const decisionList = (_findParentNodeOfType = findParentNodeOfType([state.schema.nodes.decisionList])(state.selection)) === null || _findParentNodeOfType === void 0 ? void 0 : _findParentNodeOfType.node;
|
|
12
12
|
return (decisionList === null || decisionList === void 0 ? void 0 : decisionList.childCount) === 1;
|
|
13
13
|
};
|
|
14
|
+
const isSelectedNodeMediaGroup = state => {
|
|
15
|
+
return Boolean(state.selection instanceof NodeSelection && state.selection.node.type.name === 'media' && state.selection.$head.parent.type.name === 'mediaGroup');
|
|
16
|
+
};
|
|
14
17
|
|
|
15
18
|
/**
|
|
16
19
|
* Prevent removing the block when deleting block content
|
|
@@ -44,11 +47,12 @@ export function deleteBlockContent(isNodeAWrappingBlockNode) {
|
|
|
44
47
|
if (!selectionCrossesWrappingBlockNode) {
|
|
45
48
|
return false;
|
|
46
49
|
}
|
|
47
|
-
const
|
|
50
|
+
const isParentNodeOfTypePanel = hasParentNodeOfType([state.schema.nodes.panel])(state.selection);
|
|
48
51
|
|
|
49
52
|
// If decision is inside panel and the decision list have only one decision item which is selected,
|
|
50
53
|
// delete the whole decision list.
|
|
51
|
-
if
|
|
54
|
+
// Also, checks if selection is a mediaGroup node within a panel
|
|
55
|
+
if (isParentNodeOfTypePanel && (isSelectedNodeSoleDecisionItem(state) || isSelectedNodeMediaGroup(state))) {
|
|
52
56
|
tr.setSelection(new TextSelection(tr.doc.resolve($from.before()))).delete($from.before(), $from.after());
|
|
53
57
|
} else {
|
|
54
58
|
tr.delete($from.pos, $to.pos);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { insertBlock } from '@atlaskit/editor-common/commands';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import { createRule, inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
5
|
+
import { createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
5
6
|
import { createJoinNodesRule, createWrappingTextBlockRule } from '../utils';
|
|
6
7
|
const MAX_HEADING_LEVEL = 6;
|
|
7
8
|
function getHeadingLevel(match) {
|
|
@@ -84,9 +85,9 @@ function inputRulePlugin(editorAnalyticsAPI, schema, featureFlags) {
|
|
|
84
85
|
rules.push(...getBlockQuoteRules(editorAnalyticsAPI, schema));
|
|
85
86
|
}
|
|
86
87
|
if (rules.length !== 0) {
|
|
87
|
-
return createPlugin('block-type', rules, {
|
|
88
|
+
return new SafePlugin(createPlugin('block-type', rules, {
|
|
88
89
|
isBlockNodeRule: true
|
|
89
|
-
});
|
|
90
|
+
}));
|
|
90
91
|
}
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createWrappingJoinRule } from '@atlaskit/editor-common/utils';
|
|
2
|
-
import { createRule } from '@atlaskit/prosemirror-input-rules';
|
|
1
|
+
import { createRule, createWrappingJoinRule } from '@atlaskit/editor-common/utils';
|
|
3
2
|
import { WRAPPER_BLOCK_TYPES } from './block-types';
|
|
4
3
|
export const isNodeAWrappingBlockNode = node => {
|
|
5
4
|
if (!node) {
|
|
@@ -11,6 +11,9 @@ var isSelectedNodeSoleDecisionItem = function isSelectedNodeSoleDecisionItem(sta
|
|
|
11
11
|
var decisionList = (_findParentNodeOfType = findParentNodeOfType([state.schema.nodes.decisionList])(state.selection)) === null || _findParentNodeOfType === void 0 ? void 0 : _findParentNodeOfType.node;
|
|
12
12
|
return (decisionList === null || decisionList === void 0 ? void 0 : decisionList.childCount) === 1;
|
|
13
13
|
};
|
|
14
|
+
var isSelectedNodeMediaGroup = function isSelectedNodeMediaGroup(state) {
|
|
15
|
+
return Boolean(state.selection instanceof NodeSelection && state.selection.node.type.name === 'media' && state.selection.$head.parent.type.name === 'mediaGroup');
|
|
16
|
+
};
|
|
14
17
|
|
|
15
18
|
/**
|
|
16
19
|
* Prevent removing the block when deleting block content
|
|
@@ -41,11 +44,12 @@ export function deleteBlockContent(isNodeAWrappingBlockNode) {
|
|
|
41
44
|
if (!selectionCrossesWrappingBlockNode) {
|
|
42
45
|
return false;
|
|
43
46
|
}
|
|
44
|
-
var
|
|
47
|
+
var isParentNodeOfTypePanel = hasParentNodeOfType([state.schema.nodes.panel])(state.selection);
|
|
45
48
|
|
|
46
49
|
// If decision is inside panel and the decision list have only one decision item which is selected,
|
|
47
50
|
// delete the whole decision list.
|
|
48
|
-
if
|
|
51
|
+
// Also, checks if selection is a mediaGroup node within a panel
|
|
52
|
+
if (isParentNodeOfTypePanel && (isSelectedNodeSoleDecisionItem(state) || isSelectedNodeMediaGroup(state))) {
|
|
49
53
|
tr.setSelection(new TextSelection(tr.doc.resolve($from.before()))).delete($from.before(), $from.after());
|
|
50
54
|
} else {
|
|
51
55
|
tr.delete($from.pos, $to.pos);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { insertBlock } from '@atlaskit/editor-common/commands';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
+
import { createRule, inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
6
7
|
import { createJoinNodesRule, createWrappingTextBlockRule } from '../utils';
|
|
7
8
|
var MAX_HEADING_LEVEL = 6;
|
|
8
9
|
function getHeadingLevel(match) {
|
|
@@ -87,9 +88,9 @@ function inputRulePlugin(editorAnalyticsAPI, schema, featureFlags) {
|
|
|
87
88
|
rules.push.apply(rules, _toConsumableArray(getBlockQuoteRules(editorAnalyticsAPI, schema)));
|
|
88
89
|
}
|
|
89
90
|
if (rules.length !== 0) {
|
|
90
|
-
return createPlugin('block-type', rules, {
|
|
91
|
+
return new SafePlugin(createPlugin('block-type', rules, {
|
|
91
92
|
isBlockNodeRule: true
|
|
92
|
-
});
|
|
93
|
+
}));
|
|
93
94
|
}
|
|
94
95
|
return;
|
|
95
96
|
}
|
package/dist/esm/plugin/utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createWrappingJoinRule } from '@atlaskit/editor-common/utils';
|
|
2
|
-
import { createRule } from '@atlaskit/prosemirror-input-rules';
|
|
1
|
+
import { createRule, createWrappingJoinRule } from '@atlaskit/editor-common/utils';
|
|
3
2
|
import { WRAPPER_BLOCK_TYPES } from './block-types';
|
|
4
3
|
export var isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
|
|
5
4
|
if (!node) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
declare function inputRulePlugin(editorAnalyticsAPI: EditorAnalyticsAPI | undefined, schema: Schema, featureFlags: FeatureFlags): SafePlugin | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { InputRuleWrapper } from '@atlaskit/editor-common/types';
|
|
1
2
|
import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { InputRuleWrapper } from '@atlaskit/prosemirror-input-rules';
|
|
4
4
|
export declare const isNodeAWrappingBlockNode: (node?: PMNode | null) => boolean;
|
|
5
5
|
export declare const createJoinNodesRule: (match: RegExp, nodeType: NodeType) => InputRuleWrapper;
|
|
6
6
|
type WrappingTextRuleProps = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
declare function inputRulePlugin(editorAnalyticsAPI: EditorAnalyticsAPI | undefined, schema: Schema, featureFlags: FeatureFlags): SafePlugin | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { InputRuleWrapper } from '@atlaskit/editor-common/types';
|
|
1
2
|
import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { InputRuleWrapper } from '@atlaskit/prosemirror-input-rules';
|
|
4
4
|
export declare const isNodeAWrappingBlockNode: (node?: PMNode | null) => boolean;
|
|
5
5
|
export declare const createJoinNodesRule: (match: RegExp, nodeType: NodeType) => InputRuleWrapper;
|
|
6
6
|
type WrappingTextRuleProps = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-type",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.26",
|
|
4
4
|
"description": "BlockType plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@atlaskit/adf-schema": "^35.5.1",
|
|
39
|
-
"@atlaskit/editor-common": "^78.
|
|
39
|
+
"@atlaskit/editor-common": "^78.5.0",
|
|
40
40
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^2.9.0",
|
|
43
43
|
"@atlaskit/editor-tables": "^2.5.0",
|
|
44
|
-
"@atlaskit/icon": "^22.
|
|
44
|
+
"@atlaskit/icon": "^22.1.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.2.5",
|
|
46
|
-
"@atlaskit/prosemirror-input-rules": "^
|
|
46
|
+
"@atlaskit/prosemirror-input-rules": "^3.0.0",
|
|
47
47
|
"@atlaskit/theme": "^12.6.0",
|
|
48
|
-
"@atlaskit/tokens": "^1.
|
|
48
|
+
"@atlaskit/tokens": "^1.38.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0",
|
|
50
50
|
"@emotion/react": "^11.7.1"
|
|
51
51
|
},
|