@atlaskit/editor-plugin-text-formatting 1.2.3 → 1.3.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 +16 -0
- package/dist/cjs/plugin.js +2 -2
- package/dist/cjs/pm-plugins/main.js +26 -11
- package/dist/es2019/plugin.js +2 -2
- package/dist/es2019/pm-plugins/main.js +26 -11
- package/dist/esm/plugin.js +2 -2
- package/dist/esm/pm-plugins/main.js +26 -11
- package/package.json +4 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-formatting
|
|
2
2
|
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#82499](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/82499) [`cbd66fd38b62`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cbd66fd38b62) - Add option to disable strikethrough on text-formatting via disableStrikethrough.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 1.2.4
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#78492](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/78492) [`3b0b93acfd19`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3b0b93acfd19) - [ux] [CAMPTASKS-123] faulty formatting state for inline nodes
|
|
18
|
+
|
|
3
19
|
## 1.2.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -36,10 +36,10 @@ var textFormattingPlugin = exports.textFormattingPlugin = function textFormattin
|
|
|
36
36
|
}, {
|
|
37
37
|
name: 'strong',
|
|
38
38
|
mark: _adfSchema.strong
|
|
39
|
-
}
|
|
39
|
+
}].concat(options !== null && options !== void 0 && options.disableStrikethrough ? [] : {
|
|
40
40
|
name: 'strike',
|
|
41
41
|
mark: _adfSchema.strike
|
|
42
|
-
}
|
|
42
|
+
}).concat(options !== null && options !== void 0 && options.disableCode ? [] : {
|
|
43
43
|
name: 'code',
|
|
44
44
|
mark: _adfSchema.code
|
|
45
45
|
}).concat(options !== null && options !== void 0 && options.disableSuperscriptAndSubscript ? [] : {
|
|
@@ -16,6 +16,7 @@ var _mark = require("@atlaskit/editor-common/mark");
|
|
|
16
16
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
17
17
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
18
18
|
var _commands = require("@atlaskit/editor-prosemirror/commands");
|
|
19
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
19
20
|
var _textFormatting = _interopRequireWildcard(require("../commands/text-formatting"));
|
|
20
21
|
var commands = _textFormatting;
|
|
21
22
|
var _pluginKey = require("./plugin-key");
|
|
@@ -24,6 +25,24 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
24
25
|
// TODO: Ideally this should use the custom toggleMark function from @atlaskit/editor-common so we also disable the options when selecting inline nodes but it disables the marks when the selection is empty at this point in time which is undesirable
|
|
25
26
|
// import { toggleMark } from '@atlaskit/editor-common/mark';
|
|
26
27
|
|
|
28
|
+
var isSelectionInlineCursor = function isSelectionInlineCursor(selection) {
|
|
29
|
+
if (selection instanceof _state.NodeSelection) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
var checkNodeSelection = function checkNodeSelection(mark, editorState, type) {
|
|
35
|
+
var selection = editorState.selection;
|
|
36
|
+
if (isSelectionInlineCursor(selection)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (type !== null || type !== undefined) {
|
|
40
|
+
return (0, _commands.toggleMark)(mark, {
|
|
41
|
+
type: type
|
|
42
|
+
})(editorState);
|
|
43
|
+
}
|
|
44
|
+
return (0, _commands.toggleMark)(mark)(editorState);
|
|
45
|
+
};
|
|
27
46
|
var getTextFormattingState = function getTextFormattingState(editorState, editorAnalyticsAPI) {
|
|
28
47
|
var _editorState$schema$m = editorState.schema.marks,
|
|
29
48
|
em = _editorState$schema$m.em,
|
|
@@ -35,19 +54,19 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
|
|
|
35
54
|
var state = {};
|
|
36
55
|
if (code) {
|
|
37
56
|
state.codeActive = (0, _mark.anyMarkActive)(editorState, code.create());
|
|
38
|
-
state.codeDisabled = !(
|
|
57
|
+
state.codeDisabled = !checkNodeSelection(code, editorState);
|
|
39
58
|
}
|
|
40
59
|
if (em) {
|
|
41
60
|
state.emActive = (0, _mark.anyMarkActive)(editorState, em);
|
|
42
|
-
state.emDisabled = state.codeActive ? true : !(
|
|
61
|
+
state.emDisabled = state.codeActive ? true : !checkNodeSelection(em, editorState);
|
|
43
62
|
}
|
|
44
63
|
if (strike) {
|
|
45
64
|
state.strikeActive = (0, _mark.anyMarkActive)(editorState, strike);
|
|
46
|
-
state.strikeDisabled = state.codeActive ? true : !(
|
|
65
|
+
state.strikeDisabled = state.codeActive ? true : !checkNodeSelection(strike, editorState);
|
|
47
66
|
}
|
|
48
67
|
if (strong) {
|
|
49
68
|
state.strongActive = (0, _mark.anyMarkActive)(editorState, strong);
|
|
50
|
-
state.strongDisabled = state.codeActive ? true : !(
|
|
69
|
+
state.strongDisabled = state.codeActive ? true : !checkNodeSelection(strong, editorState);
|
|
51
70
|
}
|
|
52
71
|
if (subsup) {
|
|
53
72
|
var subMark = subsup.create({
|
|
@@ -57,17 +76,13 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
|
|
|
57
76
|
type: 'sup'
|
|
58
77
|
});
|
|
59
78
|
state.subscriptActive = (0, _mark.anyMarkActive)(editorState, subMark);
|
|
60
|
-
state.subscriptDisabled = state.codeActive ? true : !(
|
|
61
|
-
type: 'sub'
|
|
62
|
-
})(editorState);
|
|
79
|
+
state.subscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sub');
|
|
63
80
|
state.superscriptActive = (0, _mark.anyMarkActive)(editorState, supMark);
|
|
64
|
-
state.superscriptDisabled = state.codeActive ? true : !(
|
|
65
|
-
type: 'sup'
|
|
66
|
-
})(editorState);
|
|
81
|
+
state.superscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sup');
|
|
67
82
|
}
|
|
68
83
|
if (underline) {
|
|
69
84
|
state.underlineActive = (0, _mark.anyMarkActive)(editorState, underline);
|
|
70
|
-
state.underlineDisabled = state.codeActive ? true : !(
|
|
85
|
+
state.underlineDisabled = state.codeActive ? true : !checkNodeSelection(underline, editorState);
|
|
71
86
|
}
|
|
72
87
|
return state;
|
|
73
88
|
};
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -27,10 +27,10 @@ export const textFormattingPlugin = ({
|
|
|
27
27
|
}, {
|
|
28
28
|
name: 'strong',
|
|
29
29
|
mark: strong
|
|
30
|
-
}
|
|
30
|
+
}].concat(options !== null && options !== void 0 && options.disableStrikethrough ? [] : {
|
|
31
31
|
name: 'strike',
|
|
32
32
|
mark: strike
|
|
33
|
-
}
|
|
33
|
+
}).concat(options !== null && options !== void 0 && options.disableCode ? [] : {
|
|
34
34
|
name: 'code',
|
|
35
35
|
mark: code
|
|
36
36
|
}).concat(options !== null && options !== void 0 && options.disableSuperscriptAndSubscript ? [] : {
|
|
@@ -6,10 +6,29 @@ import { anyMarkActive } from '@atlaskit/editor-common/mark';
|
|
|
6
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
7
|
import { shallowEqual } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
|
|
9
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
10
|
import { createInlineCodeFromTextInputWithAnalytics } from '../commands/text-formatting';
|
|
10
11
|
import * as commands from '../commands/text-formatting';
|
|
11
12
|
import { pluginKey } from './plugin-key';
|
|
12
13
|
export { pluginKey };
|
|
14
|
+
const isSelectionInlineCursor = selection => {
|
|
15
|
+
if (selection instanceof NodeSelection) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
const checkNodeSelection = (mark, editorState, type) => {
|
|
21
|
+
const selection = editorState.selection;
|
|
22
|
+
if (isSelectionInlineCursor(selection)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (type !== null || type !== undefined) {
|
|
26
|
+
return toggleMark(mark, {
|
|
27
|
+
type: type
|
|
28
|
+
})(editorState);
|
|
29
|
+
}
|
|
30
|
+
return toggleMark(mark)(editorState);
|
|
31
|
+
};
|
|
13
32
|
const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
|
|
14
33
|
const {
|
|
15
34
|
em,
|
|
@@ -22,19 +41,19 @@ const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
|
|
|
22
41
|
const state = {};
|
|
23
42
|
if (code) {
|
|
24
43
|
state.codeActive = anyMarkActive(editorState, code.create());
|
|
25
|
-
state.codeDisabled = !
|
|
44
|
+
state.codeDisabled = !checkNodeSelection(code, editorState);
|
|
26
45
|
}
|
|
27
46
|
if (em) {
|
|
28
47
|
state.emActive = anyMarkActive(editorState, em);
|
|
29
|
-
state.emDisabled = state.codeActive ? true : !
|
|
48
|
+
state.emDisabled = state.codeActive ? true : !checkNodeSelection(em, editorState);
|
|
30
49
|
}
|
|
31
50
|
if (strike) {
|
|
32
51
|
state.strikeActive = anyMarkActive(editorState, strike);
|
|
33
|
-
state.strikeDisabled = state.codeActive ? true : !
|
|
52
|
+
state.strikeDisabled = state.codeActive ? true : !checkNodeSelection(strike, editorState);
|
|
34
53
|
}
|
|
35
54
|
if (strong) {
|
|
36
55
|
state.strongActive = anyMarkActive(editorState, strong);
|
|
37
|
-
state.strongDisabled = state.codeActive ? true : !
|
|
56
|
+
state.strongDisabled = state.codeActive ? true : !checkNodeSelection(strong, editorState);
|
|
38
57
|
}
|
|
39
58
|
if (subsup) {
|
|
40
59
|
const subMark = subsup.create({
|
|
@@ -44,17 +63,13 @@ const getTextFormattingState = (editorState, editorAnalyticsAPI) => {
|
|
|
44
63
|
type: 'sup'
|
|
45
64
|
});
|
|
46
65
|
state.subscriptActive = anyMarkActive(editorState, subMark);
|
|
47
|
-
state.subscriptDisabled = state.codeActive ? true : !
|
|
48
|
-
type: 'sub'
|
|
49
|
-
})(editorState);
|
|
66
|
+
state.subscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sub');
|
|
50
67
|
state.superscriptActive = anyMarkActive(editorState, supMark);
|
|
51
|
-
state.superscriptDisabled = state.codeActive ? true : !
|
|
52
|
-
type: 'sup'
|
|
53
|
-
})(editorState);
|
|
68
|
+
state.superscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sup');
|
|
54
69
|
}
|
|
55
70
|
if (underline) {
|
|
56
71
|
state.underlineActive = anyMarkActive(editorState, underline);
|
|
57
|
-
state.underlineDisabled = state.codeActive ? true : !
|
|
72
|
+
state.underlineDisabled = state.codeActive ? true : !checkNodeSelection(underline, editorState);
|
|
58
73
|
}
|
|
59
74
|
return state;
|
|
60
75
|
};
|
package/dist/esm/plugin.js
CHANGED
|
@@ -29,10 +29,10 @@ export var textFormattingPlugin = function textFormattingPlugin(_ref) {
|
|
|
29
29
|
}, {
|
|
30
30
|
name: 'strong',
|
|
31
31
|
mark: strong
|
|
32
|
-
}
|
|
32
|
+
}].concat(options !== null && options !== void 0 && options.disableStrikethrough ? [] : {
|
|
33
33
|
name: 'strike',
|
|
34
34
|
mark: strike
|
|
35
|
-
}
|
|
35
|
+
}).concat(options !== null && options !== void 0 && options.disableCode ? [] : {
|
|
36
36
|
name: 'code',
|
|
37
37
|
mark: code
|
|
38
38
|
}).concat(options !== null && options !== void 0 && options.disableSuperscriptAndSubscript ? [] : {
|
|
@@ -6,10 +6,29 @@ import { anyMarkActive } from '@atlaskit/editor-common/mark';
|
|
|
6
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
7
|
import { shallowEqual } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
|
|
9
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
10
|
import { createInlineCodeFromTextInputWithAnalytics } from '../commands/text-formatting';
|
|
10
11
|
import * as commands from '../commands/text-formatting';
|
|
11
12
|
import { pluginKey } from './plugin-key';
|
|
12
13
|
export { pluginKey };
|
|
14
|
+
var isSelectionInlineCursor = function isSelectionInlineCursor(selection) {
|
|
15
|
+
if (selection instanceof NodeSelection) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
var checkNodeSelection = function checkNodeSelection(mark, editorState, type) {
|
|
21
|
+
var selection = editorState.selection;
|
|
22
|
+
if (isSelectionInlineCursor(selection)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (type !== null || type !== undefined) {
|
|
26
|
+
return toggleMark(mark, {
|
|
27
|
+
type: type
|
|
28
|
+
})(editorState);
|
|
29
|
+
}
|
|
30
|
+
return toggleMark(mark)(editorState);
|
|
31
|
+
};
|
|
13
32
|
var getTextFormattingState = function getTextFormattingState(editorState, editorAnalyticsAPI) {
|
|
14
33
|
var _editorState$schema$m = editorState.schema.marks,
|
|
15
34
|
em = _editorState$schema$m.em,
|
|
@@ -21,19 +40,19 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
|
|
|
21
40
|
var state = {};
|
|
22
41
|
if (code) {
|
|
23
42
|
state.codeActive = anyMarkActive(editorState, code.create());
|
|
24
|
-
state.codeDisabled = !
|
|
43
|
+
state.codeDisabled = !checkNodeSelection(code, editorState);
|
|
25
44
|
}
|
|
26
45
|
if (em) {
|
|
27
46
|
state.emActive = anyMarkActive(editorState, em);
|
|
28
|
-
state.emDisabled = state.codeActive ? true : !
|
|
47
|
+
state.emDisabled = state.codeActive ? true : !checkNodeSelection(em, editorState);
|
|
29
48
|
}
|
|
30
49
|
if (strike) {
|
|
31
50
|
state.strikeActive = anyMarkActive(editorState, strike);
|
|
32
|
-
state.strikeDisabled = state.codeActive ? true : !
|
|
51
|
+
state.strikeDisabled = state.codeActive ? true : !checkNodeSelection(strike, editorState);
|
|
33
52
|
}
|
|
34
53
|
if (strong) {
|
|
35
54
|
state.strongActive = anyMarkActive(editorState, strong);
|
|
36
|
-
state.strongDisabled = state.codeActive ? true : !
|
|
55
|
+
state.strongDisabled = state.codeActive ? true : !checkNodeSelection(strong, editorState);
|
|
37
56
|
}
|
|
38
57
|
if (subsup) {
|
|
39
58
|
var subMark = subsup.create({
|
|
@@ -43,17 +62,13 @@ var getTextFormattingState = function getTextFormattingState(editorState, editor
|
|
|
43
62
|
type: 'sup'
|
|
44
63
|
});
|
|
45
64
|
state.subscriptActive = anyMarkActive(editorState, subMark);
|
|
46
|
-
state.subscriptDisabled = state.codeActive ? true : !
|
|
47
|
-
type: 'sub'
|
|
48
|
-
})(editorState);
|
|
65
|
+
state.subscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sub');
|
|
49
66
|
state.superscriptActive = anyMarkActive(editorState, supMark);
|
|
50
|
-
state.superscriptDisabled = state.codeActive ? true : !
|
|
51
|
-
type: 'sup'
|
|
52
|
-
})(editorState);
|
|
67
|
+
state.superscriptDisabled = state.codeActive ? true : !checkNodeSelection(subsup, editorState, 'sup');
|
|
53
68
|
}
|
|
54
69
|
if (underline) {
|
|
55
70
|
state.underlineActive = anyMarkActive(editorState, underline);
|
|
56
|
-
state.underlineDisabled = state.codeActive ? true : !
|
|
71
|
+
state.underlineDisabled = state.codeActive ? true : !checkNodeSelection(underline, editorState);
|
|
57
72
|
}
|
|
58
73
|
return state;
|
|
59
74
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-formatting",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Text-formatting plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/adf-schema": "^35.6.0",
|
|
36
|
-
"@atlaskit/editor-common": "^78.
|
|
36
|
+
"@atlaskit/editor-common": "^78.16.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
38
38
|
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
39
39
|
"@atlaskit/editor-shared-styles": "^2.9.0",
|
|
@@ -78,11 +78,9 @@
|
|
|
78
78
|
"ui-components": [
|
|
79
79
|
"lite-mode"
|
|
80
80
|
],
|
|
81
|
-
"deprecation":
|
|
82
|
-
"no-deprecated-imports"
|
|
83
|
-
],
|
|
81
|
+
"deprecation": "no-deprecated-imports",
|
|
84
82
|
"styling": [
|
|
85
|
-
"
|
|
83
|
+
"emotion",
|
|
86
84
|
"emotion"
|
|
87
85
|
],
|
|
88
86
|
"imports": [
|