@atlaskit/editor-plugin-highlight 5.3.0 → 5.3.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 +14 -0
- package/dist/cjs/highlightPlugin.js +12 -1
- package/dist/cjs/pm-plugins/highlight-padding/add-padding-decorations.js +63 -0
- package/dist/cjs/pm-plugins/highlight-padding/index.js +65 -0
- package/dist/cjs/pm-plugins/highlight-padding/update-padding-decorations.js +31 -0
- package/dist/cjs/pm-plugins/highlight-padding/utils.js +47 -0
- package/dist/cjs/ui/HighlightColorMenuItem.js +1 -1
- package/dist/es2019/highlightPlugin.js +22 -11
- package/dist/es2019/pm-plugins/highlight-padding/add-padding-decorations.js +59 -0
- package/dist/es2019/pm-plugins/highlight-padding/index.js +59 -0
- package/dist/es2019/pm-plugins/highlight-padding/update-padding-decorations.js +26 -0
- package/dist/es2019/pm-plugins/highlight-padding/utils.js +41 -0
- package/dist/es2019/ui/HighlightColorMenuItem.js +1 -1
- package/dist/esm/highlightPlugin.js +12 -1
- package/dist/esm/pm-plugins/highlight-padding/add-padding-decorations.js +57 -0
- package/dist/esm/pm-plugins/highlight-padding/index.js +59 -0
- package/dist/esm/pm-plugins/highlight-padding/update-padding-decorations.js +25 -0
- package/dist/esm/pm-plugins/highlight-padding/utils.js +41 -0
- package/dist/esm/ui/HighlightColorMenuItem.js +1 -1
- package/dist/types/pm-plugins/highlight-padding/add-padding-decorations.d.ts +14 -0
- package/dist/types/pm-plugins/highlight-padding/index.d.ts +16 -0
- package/dist/types/pm-plugins/highlight-padding/update-padding-decorations.d.ts +13 -0
- package/dist/types/pm-plugins/highlight-padding/utils.d.ts +14 -0
- package/dist/types-ts4.5/pm-plugins/highlight-padding/add-padding-decorations.d.ts +14 -0
- package/dist/types-ts4.5/pm-plugins/highlight-padding/index.d.ts +16 -0
- package/dist/types-ts4.5/pm-plugins/highlight-padding/update-padding-decorations.d.ts +13 -0
- package/dist/types-ts4.5/pm-plugins/highlight-padding/utils.d.ts +14 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-highlight
|
|
2
2
|
|
|
3
|
+
## 5.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6af30673f7cee`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6af30673f7cee) -
|
|
8
|
+
[ux] Adding padding to the left and right side of highlighted text
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 5.3.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 5.3.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -8,8 +8,10 @@ exports.highlightPlugin = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
11
12
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
13
|
var _changeColor = require("./editor-commands/change-color");
|
|
14
|
+
var _highlightPadding = require("./pm-plugins/highlight-padding");
|
|
13
15
|
var _keymap = require("./pm-plugins/keymap");
|
|
14
16
|
var _main = require("./pm-plugins/main");
|
|
15
17
|
var _FloatingToolbarHighlightColor = require("./ui/FloatingToolbarHighlightColor");
|
|
@@ -65,7 +67,7 @@ var highlightPlugin = exports.highlightPlugin = function highlightPlugin(_ref) {
|
|
|
65
67
|
changeColor: (0, _changeColor.changeColor)(editorAnalyticsAPI)
|
|
66
68
|
},
|
|
67
69
|
pmPlugins: function pmPlugins() {
|
|
68
|
-
|
|
70
|
+
var plugins = [{
|
|
69
71
|
name: 'highlight',
|
|
70
72
|
plugin: function plugin() {
|
|
71
73
|
return (0, _main.createPlugin)({
|
|
@@ -80,6 +82,15 @@ var highlightPlugin = exports.highlightPlugin = function highlightPlugin(_ref) {
|
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
84
|
}];
|
|
85
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_text_highlight_padding', 'isEnabled', true)) {
|
|
86
|
+
plugins.push({
|
|
87
|
+
name: 'highlightPadding',
|
|
88
|
+
plugin: function plugin() {
|
|
89
|
+
return (0, _highlightPadding.createHighlightPaddingPlugin)();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return plugins;
|
|
83
94
|
},
|
|
84
95
|
getSharedState: function getSharedState(editorState) {
|
|
85
96
|
if (!editorState) {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.addPaddingDecorations = void 0;
|
|
7
|
+
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
8
|
+
var _utils = require("./utils");
|
|
9
|
+
var createPaddingDecoration = function createPaddingDecoration(_ref) {
|
|
10
|
+
var pos = _ref.pos,
|
|
11
|
+
node = _ref.node,
|
|
12
|
+
padLeft = _ref.padLeft,
|
|
13
|
+
padRight = _ref.padRight;
|
|
14
|
+
var classes = [];
|
|
15
|
+
var baseClass = 'background-color';
|
|
16
|
+
var padLeftClass = "".concat(baseClass, "-padding-left");
|
|
17
|
+
var padRightClass = "".concat(baseClass, "-padding-right");
|
|
18
|
+
if (padLeft) {
|
|
19
|
+
classes.push(padLeftClass);
|
|
20
|
+
}
|
|
21
|
+
if (padRight) {
|
|
22
|
+
classes.push(padRightClass);
|
|
23
|
+
}
|
|
24
|
+
return _view.Decoration.inline(pos, pos + node.nodeSize, {
|
|
25
|
+
class: classes.join(' ')
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Adds padding decorations to highlighted text
|
|
30
|
+
* within the specified range.
|
|
31
|
+
*/
|
|
32
|
+
var addPaddingDecorations = exports.addPaddingDecorations = function addPaddingDecorations(_ref2) {
|
|
33
|
+
var decorationSet = _ref2.decorationSet,
|
|
34
|
+
state = _ref2.state,
|
|
35
|
+
from = _ref2.from,
|
|
36
|
+
to = _ref2.to;
|
|
37
|
+
var newDecorationSet = decorationSet;
|
|
38
|
+
state.doc.nodesBetween(from, to, function (node, pos) {
|
|
39
|
+
if (!(0, _utils.isHighlightedTextNode)(node)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
var nodeStart = pos;
|
|
43
|
+
var nodeEnd = pos + node.nodeSize;
|
|
44
|
+
var padLeft = (0, _utils.shouldPadLeft)({
|
|
45
|
+
state: state,
|
|
46
|
+
nodeStart: nodeStart
|
|
47
|
+
});
|
|
48
|
+
var padRight = (0, _utils.shouldPadRight)({
|
|
49
|
+
state: state,
|
|
50
|
+
nodeEnd: nodeEnd
|
|
51
|
+
});
|
|
52
|
+
if (padLeft && padRight) {
|
|
53
|
+
var newDecoration = createPaddingDecoration({
|
|
54
|
+
pos: nodeStart,
|
|
55
|
+
node: node,
|
|
56
|
+
padLeft: padLeft,
|
|
57
|
+
padRight: padRight
|
|
58
|
+
});
|
|
59
|
+
newDecorationSet = newDecorationSet.add(state.doc, [newDecoration]);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return newDecorationSet;
|
|
63
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.highlightPaddingPluginKey = exports.createHighlightPaddingPlugin = void 0;
|
|
7
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
+
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
10
|
+
var _addPaddingDecorations = require("./add-padding-decorations");
|
|
11
|
+
var _updatePaddingDecorations = require("./update-padding-decorations");
|
|
12
|
+
var highlightPaddingPluginKey = exports.highlightPaddingPluginKey = new _state.PluginKey('highlightPaddingPluginKey');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Plugin to add padding decorations around highlighted text.
|
|
16
|
+
*
|
|
17
|
+
* Padding is added to the left and/or right of highlighted text
|
|
18
|
+
* only when it is at the start or end of a block, or when it is adjacent
|
|
19
|
+
* to whitespace.
|
|
20
|
+
*/
|
|
21
|
+
var createHighlightPaddingPlugin = exports.createHighlightPaddingPlugin = function createHighlightPaddingPlugin() {
|
|
22
|
+
return new _safePlugin.SafePlugin({
|
|
23
|
+
key: highlightPaddingPluginKey,
|
|
24
|
+
state: {
|
|
25
|
+
init: function init(_, state) {
|
|
26
|
+
// Initially scan the entire doc to create all highlight padding decorations
|
|
27
|
+
// after which updates will only apply to changed ranges
|
|
28
|
+
var initialDecorationSet = _view.DecorationSet.empty;
|
|
29
|
+
var decorationSet = (0, _addPaddingDecorations.addPaddingDecorations)({
|
|
30
|
+
decorationSet: initialDecorationSet,
|
|
31
|
+
state: state,
|
|
32
|
+
from: 0,
|
|
33
|
+
to: state.doc.content.size
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
decorationSet: decorationSet
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
apply: function apply(tr, pluginState, _oldState, state) {
|
|
40
|
+
if (!tr.docChanged) {
|
|
41
|
+
return pluginState;
|
|
42
|
+
}
|
|
43
|
+
var decorationSet = pluginState.decorationSet.map(tr.mapping, tr.doc);
|
|
44
|
+
tr.mapping.maps.forEach(function (stepMap) {
|
|
45
|
+
stepMap.forEach(function (_oldStart, _oldEnd, start, end) {
|
|
46
|
+
decorationSet = (0, _updatePaddingDecorations.updatePaddingDecorations)({
|
|
47
|
+
decorationSet: decorationSet,
|
|
48
|
+
state: state,
|
|
49
|
+
start: start,
|
|
50
|
+
end: end
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
decorationSet: decorationSet
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
props: {
|
|
60
|
+
decorations: function decorations(state) {
|
|
61
|
+
return highlightPaddingPluginKey.getState(state).decorationSet;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updatePaddingDecorations = void 0;
|
|
7
|
+
var _addPaddingDecorations = require("./add-padding-decorations");
|
|
8
|
+
/**
|
|
9
|
+
* Updates padding decorations in the specified range.
|
|
10
|
+
*/
|
|
11
|
+
var updatePaddingDecorations = exports.updatePaddingDecorations = function updatePaddingDecorations(_ref) {
|
|
12
|
+
var prevDecorationSet = _ref.decorationSet,
|
|
13
|
+
state = _ref.state,
|
|
14
|
+
start = _ref.start,
|
|
15
|
+
end = _ref.end;
|
|
16
|
+
// First remove any decorations within the range
|
|
17
|
+
// Note that it finds all decorations in the set which touch the given range (including decorations that start or end directly at the boundaries)
|
|
18
|
+
var toRemove = prevDecorationSet.find(start, end);
|
|
19
|
+
var decorationSet = prevDecorationSet.remove(toRemove);
|
|
20
|
+
|
|
21
|
+
// Expand the range by 1 on each side to catch adjacent text nodes
|
|
22
|
+
// that may need padding decorations added/removed
|
|
23
|
+
var from = Math.max(0, start - 1);
|
|
24
|
+
var to = Math.min(state.doc.content.size, end + 1);
|
|
25
|
+
return (0, _addPaddingDecorations.addPaddingDecorations)({
|
|
26
|
+
decorationSet: decorationSet,
|
|
27
|
+
state: state,
|
|
28
|
+
from: from,
|
|
29
|
+
to: to
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shouldPadRight = exports.shouldPadLeft = exports.isHighlightedTextNode = void 0;
|
|
7
|
+
var isHighlightedTextNode = exports.isHighlightedTextNode = function isHighlightedTextNode(node) {
|
|
8
|
+
return node.isText && node.marks.some(function (mark) {
|
|
9
|
+
return mark.type.name === 'backgroundColor';
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var shouldPadLeft = exports.shouldPadLeft = function shouldPadLeft(_ref) {
|
|
13
|
+
var state = _ref.state,
|
|
14
|
+
nodeStart = _ref.nodeStart;
|
|
15
|
+
var $pos = state.doc.resolve(nodeStart);
|
|
16
|
+
var isAtBlockStart = $pos.parentOffset === 0;
|
|
17
|
+
if (isAtBlockStart) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
var isAtDocStart = nodeStart === 0;
|
|
21
|
+
if (isAtDocStart) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
var isPrevCharSpace = state.doc.textBetween(nodeStart - 1, nodeStart) === ' ';
|
|
25
|
+
if (isPrevCharSpace) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
};
|
|
30
|
+
var shouldPadRight = exports.shouldPadRight = function shouldPadRight(_ref2) {
|
|
31
|
+
var state = _ref2.state,
|
|
32
|
+
nodeEnd = _ref2.nodeEnd;
|
|
33
|
+
var $pos = state.doc.resolve(nodeEnd);
|
|
34
|
+
var isAtBlockEnd = $pos.parentOffset === $pos.parent.content.size;
|
|
35
|
+
if (isAtBlockEnd) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
var isAtDocEnd = nodeEnd === state.doc.content.size;
|
|
39
|
+
if (isAtDocEnd) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
var isNextCharSpace = state.doc.textBetween(nodeEnd, nodeEnd + 1) === ' ';
|
|
43
|
+
if (isNextCharSpace) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { backgroundColor } from '@atlaskit/adf-schema';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
import { changeColor } from './editor-commands/change-color';
|
|
7
|
+
import { createHighlightPaddingPlugin } from './pm-plugins/highlight-padding';
|
|
6
8
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
7
9
|
import { createPlugin, highlightPluginKey } from './pm-plugins/main';
|
|
8
10
|
import { FloatingToolbarHighlightColorWithIntl as FloatingToolbarHighlightColor } from './ui/FloatingToolbarHighlightColor';
|
|
@@ -59,17 +61,26 @@ export const highlightPlugin = ({
|
|
|
59
61
|
commands: {
|
|
60
62
|
changeColor: changeColor(editorAnalyticsAPI)
|
|
61
63
|
},
|
|
62
|
-
pmPlugins: () =>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
pmPlugins: () => {
|
|
65
|
+
const plugins = [{
|
|
66
|
+
name: 'highlight',
|
|
67
|
+
plugin: () => createPlugin({
|
|
68
|
+
api
|
|
69
|
+
})
|
|
70
|
+
}, {
|
|
71
|
+
name: 'highlightKeymap',
|
|
72
|
+
plugin: () => keymapPlugin({
|
|
73
|
+
api
|
|
74
|
+
})
|
|
75
|
+
}];
|
|
76
|
+
if (expValEquals('platform_editor_text_highlight_padding', 'isEnabled', true)) {
|
|
77
|
+
plugins.push({
|
|
78
|
+
name: 'highlightPadding',
|
|
79
|
+
plugin: () => createHighlightPaddingPlugin()
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return plugins;
|
|
83
|
+
},
|
|
73
84
|
getSharedState(editorState) {
|
|
74
85
|
if (!editorState) {
|
|
75
86
|
return;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import { isHighlightedTextNode, shouldPadLeft, shouldPadRight } from './utils';
|
|
3
|
+
const createPaddingDecoration = ({
|
|
4
|
+
pos,
|
|
5
|
+
node,
|
|
6
|
+
padLeft,
|
|
7
|
+
padRight
|
|
8
|
+
}) => {
|
|
9
|
+
const classes = [];
|
|
10
|
+
const baseClass = 'background-color';
|
|
11
|
+
const padLeftClass = `${baseClass}-padding-left`;
|
|
12
|
+
const padRightClass = `${baseClass}-padding-right`;
|
|
13
|
+
if (padLeft) {
|
|
14
|
+
classes.push(padLeftClass);
|
|
15
|
+
}
|
|
16
|
+
if (padRight) {
|
|
17
|
+
classes.push(padRightClass);
|
|
18
|
+
}
|
|
19
|
+
return Decoration.inline(pos, pos + node.nodeSize, {
|
|
20
|
+
class: classes.join(' ')
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Adds padding decorations to highlighted text
|
|
25
|
+
* within the specified range.
|
|
26
|
+
*/
|
|
27
|
+
export const addPaddingDecorations = ({
|
|
28
|
+
decorationSet,
|
|
29
|
+
state,
|
|
30
|
+
from,
|
|
31
|
+
to
|
|
32
|
+
}) => {
|
|
33
|
+
let newDecorationSet = decorationSet;
|
|
34
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
35
|
+
if (!isHighlightedTextNode(node)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const nodeStart = pos;
|
|
39
|
+
const nodeEnd = pos + node.nodeSize;
|
|
40
|
+
const padLeft = shouldPadLeft({
|
|
41
|
+
state,
|
|
42
|
+
nodeStart
|
|
43
|
+
});
|
|
44
|
+
const padRight = shouldPadRight({
|
|
45
|
+
state,
|
|
46
|
+
nodeEnd
|
|
47
|
+
});
|
|
48
|
+
if (padLeft && padRight) {
|
|
49
|
+
const newDecoration = createPaddingDecoration({
|
|
50
|
+
pos: nodeStart,
|
|
51
|
+
node,
|
|
52
|
+
padLeft,
|
|
53
|
+
padRight
|
|
54
|
+
});
|
|
55
|
+
newDecorationSet = newDecorationSet.add(state.doc, [newDecoration]);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return newDecorationSet;
|
|
59
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import { addPaddingDecorations } from './add-padding-decorations';
|
|
5
|
+
import { updatePaddingDecorations } from './update-padding-decorations';
|
|
6
|
+
export const highlightPaddingPluginKey = new PluginKey('highlightPaddingPluginKey');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Plugin to add padding decorations around highlighted text.
|
|
10
|
+
*
|
|
11
|
+
* Padding is added to the left and/or right of highlighted text
|
|
12
|
+
* only when it is at the start or end of a block, or when it is adjacent
|
|
13
|
+
* to whitespace.
|
|
14
|
+
*/
|
|
15
|
+
export const createHighlightPaddingPlugin = () => {
|
|
16
|
+
return new SafePlugin({
|
|
17
|
+
key: highlightPaddingPluginKey,
|
|
18
|
+
state: {
|
|
19
|
+
init: (_, state) => {
|
|
20
|
+
// Initially scan the entire doc to create all highlight padding decorations
|
|
21
|
+
// after which updates will only apply to changed ranges
|
|
22
|
+
const initialDecorationSet = DecorationSet.empty;
|
|
23
|
+
const decorationSet = addPaddingDecorations({
|
|
24
|
+
decorationSet: initialDecorationSet,
|
|
25
|
+
state,
|
|
26
|
+
from: 0,
|
|
27
|
+
to: state.doc.content.size
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
decorationSet
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
apply: (tr, pluginState, _oldState, state) => {
|
|
34
|
+
if (!tr.docChanged) {
|
|
35
|
+
return pluginState;
|
|
36
|
+
}
|
|
37
|
+
let decorationSet = pluginState.decorationSet.map(tr.mapping, tr.doc);
|
|
38
|
+
tr.mapping.maps.forEach(stepMap => {
|
|
39
|
+
stepMap.forEach((_oldStart, _oldEnd, start, end) => {
|
|
40
|
+
decorationSet = updatePaddingDecorations({
|
|
41
|
+
decorationSet,
|
|
42
|
+
state,
|
|
43
|
+
start,
|
|
44
|
+
end
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
decorationSet
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
props: {
|
|
54
|
+
decorations: state => {
|
|
55
|
+
return highlightPaddingPluginKey.getState(state).decorationSet;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { addPaddingDecorations } from './add-padding-decorations';
|
|
2
|
+
/**
|
|
3
|
+
* Updates padding decorations in the specified range.
|
|
4
|
+
*/
|
|
5
|
+
export const updatePaddingDecorations = ({
|
|
6
|
+
decorationSet: prevDecorationSet,
|
|
7
|
+
state,
|
|
8
|
+
start,
|
|
9
|
+
end
|
|
10
|
+
}) => {
|
|
11
|
+
// First remove any decorations within the range
|
|
12
|
+
// Note that it finds all decorations in the set which touch the given range (including decorations that start or end directly at the boundaries)
|
|
13
|
+
const toRemove = prevDecorationSet.find(start, end);
|
|
14
|
+
const decorationSet = prevDecorationSet.remove(toRemove);
|
|
15
|
+
|
|
16
|
+
// Expand the range by 1 on each side to catch adjacent text nodes
|
|
17
|
+
// that may need padding decorations added/removed
|
|
18
|
+
const from = Math.max(0, start - 1);
|
|
19
|
+
const to = Math.min(state.doc.content.size, end + 1);
|
|
20
|
+
return addPaddingDecorations({
|
|
21
|
+
decorationSet,
|
|
22
|
+
state,
|
|
23
|
+
from,
|
|
24
|
+
to
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const isHighlightedTextNode = node => {
|
|
2
|
+
return node.isText && node.marks.some(mark => mark.type.name === 'backgroundColor');
|
|
3
|
+
};
|
|
4
|
+
export const shouldPadLeft = ({
|
|
5
|
+
state,
|
|
6
|
+
nodeStart
|
|
7
|
+
}) => {
|
|
8
|
+
const $pos = state.doc.resolve(nodeStart);
|
|
9
|
+
const isAtBlockStart = $pos.parentOffset === 0;
|
|
10
|
+
if (isAtBlockStart) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
const isAtDocStart = nodeStart === 0;
|
|
14
|
+
if (isAtDocStart) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
const isPrevCharSpace = state.doc.textBetween(nodeStart - 1, nodeStart) === ' ';
|
|
18
|
+
if (isPrevCharSpace) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
};
|
|
23
|
+
export const shouldPadRight = ({
|
|
24
|
+
state,
|
|
25
|
+
nodeEnd
|
|
26
|
+
}) => {
|
|
27
|
+
const $pos = state.doc.resolve(nodeEnd);
|
|
28
|
+
const isAtBlockEnd = $pos.parentOffset === $pos.parent.content.size;
|
|
29
|
+
if (isAtBlockEnd) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
const isAtDocEnd = nodeEnd === state.doc.content.size;
|
|
33
|
+
if (isAtDocEnd) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
const isNextCharSpace = state.doc.textBetween(nodeEnd, nodeEnd + 1) === ' ';
|
|
37
|
+
if (isNextCharSpace) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* HighlightColorMenuItem.tsx generated by @compiled/babel-plugin v0.
|
|
1
|
+
/* HighlightColorMenuItem.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
2
|
import "./HighlightColorMenuItem.compiled.css";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { backgroundColor } from '@atlaskit/adf-schema';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
import { changeColor } from './editor-commands/change-color';
|
|
7
|
+
import { createHighlightPaddingPlugin } from './pm-plugins/highlight-padding';
|
|
6
8
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
7
9
|
import { createPlugin, highlightPluginKey } from './pm-plugins/main';
|
|
8
10
|
import { FloatingToolbarHighlightColorWithIntl as FloatingToolbarHighlightColor } from './ui/FloatingToolbarHighlightColor';
|
|
@@ -58,7 +60,7 @@ export var highlightPlugin = function highlightPlugin(_ref) {
|
|
|
58
60
|
changeColor: changeColor(editorAnalyticsAPI)
|
|
59
61
|
},
|
|
60
62
|
pmPlugins: function pmPlugins() {
|
|
61
|
-
|
|
63
|
+
var plugins = [{
|
|
62
64
|
name: 'highlight',
|
|
63
65
|
plugin: function plugin() {
|
|
64
66
|
return createPlugin({
|
|
@@ -73,6 +75,15 @@ export var highlightPlugin = function highlightPlugin(_ref) {
|
|
|
73
75
|
});
|
|
74
76
|
}
|
|
75
77
|
}];
|
|
78
|
+
if (expValEquals('platform_editor_text_highlight_padding', 'isEnabled', true)) {
|
|
79
|
+
plugins.push({
|
|
80
|
+
name: 'highlightPadding',
|
|
81
|
+
plugin: function plugin() {
|
|
82
|
+
return createHighlightPaddingPlugin();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return plugins;
|
|
76
87
|
},
|
|
77
88
|
getSharedState: function getSharedState(editorState) {
|
|
78
89
|
if (!editorState) {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import { isHighlightedTextNode, shouldPadLeft, shouldPadRight } from './utils';
|
|
3
|
+
var createPaddingDecoration = function createPaddingDecoration(_ref) {
|
|
4
|
+
var pos = _ref.pos,
|
|
5
|
+
node = _ref.node,
|
|
6
|
+
padLeft = _ref.padLeft,
|
|
7
|
+
padRight = _ref.padRight;
|
|
8
|
+
var classes = [];
|
|
9
|
+
var baseClass = 'background-color';
|
|
10
|
+
var padLeftClass = "".concat(baseClass, "-padding-left");
|
|
11
|
+
var padRightClass = "".concat(baseClass, "-padding-right");
|
|
12
|
+
if (padLeft) {
|
|
13
|
+
classes.push(padLeftClass);
|
|
14
|
+
}
|
|
15
|
+
if (padRight) {
|
|
16
|
+
classes.push(padRightClass);
|
|
17
|
+
}
|
|
18
|
+
return Decoration.inline(pos, pos + node.nodeSize, {
|
|
19
|
+
class: classes.join(' ')
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Adds padding decorations to highlighted text
|
|
24
|
+
* within the specified range.
|
|
25
|
+
*/
|
|
26
|
+
export var addPaddingDecorations = function addPaddingDecorations(_ref2) {
|
|
27
|
+
var decorationSet = _ref2.decorationSet,
|
|
28
|
+
state = _ref2.state,
|
|
29
|
+
from = _ref2.from,
|
|
30
|
+
to = _ref2.to;
|
|
31
|
+
var newDecorationSet = decorationSet;
|
|
32
|
+
state.doc.nodesBetween(from, to, function (node, pos) {
|
|
33
|
+
if (!isHighlightedTextNode(node)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
var nodeStart = pos;
|
|
37
|
+
var nodeEnd = pos + node.nodeSize;
|
|
38
|
+
var padLeft = shouldPadLeft({
|
|
39
|
+
state: state,
|
|
40
|
+
nodeStart: nodeStart
|
|
41
|
+
});
|
|
42
|
+
var padRight = shouldPadRight({
|
|
43
|
+
state: state,
|
|
44
|
+
nodeEnd: nodeEnd
|
|
45
|
+
});
|
|
46
|
+
if (padLeft && padRight) {
|
|
47
|
+
var newDecoration = createPaddingDecoration({
|
|
48
|
+
pos: nodeStart,
|
|
49
|
+
node: node,
|
|
50
|
+
padLeft: padLeft,
|
|
51
|
+
padRight: padRight
|
|
52
|
+
});
|
|
53
|
+
newDecorationSet = newDecorationSet.add(state.doc, [newDecoration]);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return newDecorationSet;
|
|
57
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import { addPaddingDecorations } from './add-padding-decorations';
|
|
5
|
+
import { updatePaddingDecorations } from './update-padding-decorations';
|
|
6
|
+
export var highlightPaddingPluginKey = new PluginKey('highlightPaddingPluginKey');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Plugin to add padding decorations around highlighted text.
|
|
10
|
+
*
|
|
11
|
+
* Padding is added to the left and/or right of highlighted text
|
|
12
|
+
* only when it is at the start or end of a block, or when it is adjacent
|
|
13
|
+
* to whitespace.
|
|
14
|
+
*/
|
|
15
|
+
export var createHighlightPaddingPlugin = function createHighlightPaddingPlugin() {
|
|
16
|
+
return new SafePlugin({
|
|
17
|
+
key: highlightPaddingPluginKey,
|
|
18
|
+
state: {
|
|
19
|
+
init: function init(_, state) {
|
|
20
|
+
// Initially scan the entire doc to create all highlight padding decorations
|
|
21
|
+
// after which updates will only apply to changed ranges
|
|
22
|
+
var initialDecorationSet = DecorationSet.empty;
|
|
23
|
+
var decorationSet = addPaddingDecorations({
|
|
24
|
+
decorationSet: initialDecorationSet,
|
|
25
|
+
state: state,
|
|
26
|
+
from: 0,
|
|
27
|
+
to: state.doc.content.size
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
decorationSet: decorationSet
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
apply: function apply(tr, pluginState, _oldState, state) {
|
|
34
|
+
if (!tr.docChanged) {
|
|
35
|
+
return pluginState;
|
|
36
|
+
}
|
|
37
|
+
var decorationSet = pluginState.decorationSet.map(tr.mapping, tr.doc);
|
|
38
|
+
tr.mapping.maps.forEach(function (stepMap) {
|
|
39
|
+
stepMap.forEach(function (_oldStart, _oldEnd, start, end) {
|
|
40
|
+
decorationSet = updatePaddingDecorations({
|
|
41
|
+
decorationSet: decorationSet,
|
|
42
|
+
state: state,
|
|
43
|
+
start: start,
|
|
44
|
+
end: end
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
decorationSet: decorationSet
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
props: {
|
|
54
|
+
decorations: function decorations(state) {
|
|
55
|
+
return highlightPaddingPluginKey.getState(state).decorationSet;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { addPaddingDecorations } from './add-padding-decorations';
|
|
2
|
+
/**
|
|
3
|
+
* Updates padding decorations in the specified range.
|
|
4
|
+
*/
|
|
5
|
+
export var updatePaddingDecorations = function updatePaddingDecorations(_ref) {
|
|
6
|
+
var prevDecorationSet = _ref.decorationSet,
|
|
7
|
+
state = _ref.state,
|
|
8
|
+
start = _ref.start,
|
|
9
|
+
end = _ref.end;
|
|
10
|
+
// First remove any decorations within the range
|
|
11
|
+
// Note that it finds all decorations in the set which touch the given range (including decorations that start or end directly at the boundaries)
|
|
12
|
+
var toRemove = prevDecorationSet.find(start, end);
|
|
13
|
+
var decorationSet = prevDecorationSet.remove(toRemove);
|
|
14
|
+
|
|
15
|
+
// Expand the range by 1 on each side to catch adjacent text nodes
|
|
16
|
+
// that may need padding decorations added/removed
|
|
17
|
+
var from = Math.max(0, start - 1);
|
|
18
|
+
var to = Math.min(state.doc.content.size, end + 1);
|
|
19
|
+
return addPaddingDecorations({
|
|
20
|
+
decorationSet: decorationSet,
|
|
21
|
+
state: state,
|
|
22
|
+
from: from,
|
|
23
|
+
to: to
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export var isHighlightedTextNode = function isHighlightedTextNode(node) {
|
|
2
|
+
return node.isText && node.marks.some(function (mark) {
|
|
3
|
+
return mark.type.name === 'backgroundColor';
|
|
4
|
+
});
|
|
5
|
+
};
|
|
6
|
+
export var shouldPadLeft = function shouldPadLeft(_ref) {
|
|
7
|
+
var state = _ref.state,
|
|
8
|
+
nodeStart = _ref.nodeStart;
|
|
9
|
+
var $pos = state.doc.resolve(nodeStart);
|
|
10
|
+
var isAtBlockStart = $pos.parentOffset === 0;
|
|
11
|
+
if (isAtBlockStart) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
var isAtDocStart = nodeStart === 0;
|
|
15
|
+
if (isAtDocStart) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
var isPrevCharSpace = state.doc.textBetween(nodeStart - 1, nodeStart) === ' ';
|
|
19
|
+
if (isPrevCharSpace) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
};
|
|
24
|
+
export var shouldPadRight = function shouldPadRight(_ref2) {
|
|
25
|
+
var state = _ref2.state,
|
|
26
|
+
nodeEnd = _ref2.nodeEnd;
|
|
27
|
+
var $pos = state.doc.resolve(nodeEnd);
|
|
28
|
+
var isAtBlockEnd = $pos.parentOffset === $pos.parent.content.size;
|
|
29
|
+
if (isAtBlockEnd) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
var isAtDocEnd = nodeEnd === state.doc.content.size;
|
|
33
|
+
if (isAtDocEnd) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
var isNextCharSpace = state.doc.textBetween(nodeEnd, nodeEnd + 1) === ' ';
|
|
37
|
+
if (isNextCharSpace) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* HighlightColorMenuItem.tsx generated by @compiled/babel-plugin v0.
|
|
1
|
+
/* HighlightColorMenuItem.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import "./HighlightColorMenuItem.compiled.css";
|
|
4
4
|
import * as React from 'react';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { type DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
type AddPaddingDecorationsOptions = {
|
|
4
|
+
decorationSet: DecorationSet;
|
|
5
|
+
from: number;
|
|
6
|
+
state: EditorState;
|
|
7
|
+
to: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Adds padding decorations to highlighted text
|
|
11
|
+
* within the specified range.
|
|
12
|
+
*/
|
|
13
|
+
export declare const addPaddingDecorations: ({ decorationSet, state, from, to, }: AddPaddingDecorationsOptions) => DecorationSet;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
type HighlightPaddingPluginState = {
|
|
5
|
+
decorationSet: DecorationSet;
|
|
6
|
+
};
|
|
7
|
+
export declare const highlightPaddingPluginKey: PluginKey<any>;
|
|
8
|
+
/**
|
|
9
|
+
* Plugin to add padding decorations around highlighted text.
|
|
10
|
+
*
|
|
11
|
+
* Padding is added to the left and/or right of highlighted text
|
|
12
|
+
* only when it is at the start or end of a block, or when it is adjacent
|
|
13
|
+
* to whitespace.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createHighlightPaddingPlugin: () => SafePlugin<HighlightPaddingPluginState>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { type DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
type UpdatePaddingDecorationsOptions = {
|
|
4
|
+
decorationSet: DecorationSet;
|
|
5
|
+
end: number;
|
|
6
|
+
start: number;
|
|
7
|
+
state: EditorState;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Updates padding decorations in the specified range.
|
|
11
|
+
*/
|
|
12
|
+
export declare const updatePaddingDecorations: ({ decorationSet: prevDecorationSet, state, start, end, }: UpdatePaddingDecorationsOptions) => DecorationSet;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export declare const isHighlightedTextNode: (node: PMNode) => boolean;
|
|
4
|
+
type ShouldPadLeftOptions = {
|
|
5
|
+
nodeStart: number;
|
|
6
|
+
state: EditorState;
|
|
7
|
+
};
|
|
8
|
+
export declare const shouldPadLeft: ({ state, nodeStart }: ShouldPadLeftOptions) => boolean;
|
|
9
|
+
type ShouldPadRightOptions = {
|
|
10
|
+
nodeEnd: number;
|
|
11
|
+
state: EditorState;
|
|
12
|
+
};
|
|
13
|
+
export declare const shouldPadRight: ({ state, nodeEnd }: ShouldPadRightOptions) => boolean;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { type DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
type AddPaddingDecorationsOptions = {
|
|
4
|
+
decorationSet: DecorationSet;
|
|
5
|
+
from: number;
|
|
6
|
+
state: EditorState;
|
|
7
|
+
to: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Adds padding decorations to highlighted text
|
|
11
|
+
* within the specified range.
|
|
12
|
+
*/
|
|
13
|
+
export declare const addPaddingDecorations: ({ decorationSet, state, from, to, }: AddPaddingDecorationsOptions) => DecorationSet;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
type HighlightPaddingPluginState = {
|
|
5
|
+
decorationSet: DecorationSet;
|
|
6
|
+
};
|
|
7
|
+
export declare const highlightPaddingPluginKey: PluginKey<any>;
|
|
8
|
+
/**
|
|
9
|
+
* Plugin to add padding decorations around highlighted text.
|
|
10
|
+
*
|
|
11
|
+
* Padding is added to the left and/or right of highlighted text
|
|
12
|
+
* only when it is at the start or end of a block, or when it is adjacent
|
|
13
|
+
* to whitespace.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createHighlightPaddingPlugin: () => SafePlugin<HighlightPaddingPluginState>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { type DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
type UpdatePaddingDecorationsOptions = {
|
|
4
|
+
decorationSet: DecorationSet;
|
|
5
|
+
end: number;
|
|
6
|
+
start: number;
|
|
7
|
+
state: EditorState;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Updates padding decorations in the specified range.
|
|
11
|
+
*/
|
|
12
|
+
export declare const updatePaddingDecorations: ({ decorationSet: prevDecorationSet, state, start, end, }: UpdatePaddingDecorationsOptions) => DecorationSet;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export declare const isHighlightedTextNode: (node: PMNode) => boolean;
|
|
4
|
+
type ShouldPadLeftOptions = {
|
|
5
|
+
nodeStart: number;
|
|
6
|
+
state: EditorState;
|
|
7
|
+
};
|
|
8
|
+
export declare const shouldPadLeft: ({ state, nodeStart }: ShouldPadLeftOptions) => boolean;
|
|
9
|
+
type ShouldPadRightOptions = {
|
|
10
|
+
nodeEnd: number;
|
|
11
|
+
state: EditorState;
|
|
12
|
+
};
|
|
13
|
+
export declare const shouldPadRight: ({ state, nodeEnd }: ShouldPadRightOptions) => boolean;
|
|
14
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-highlight",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.2",
|
|
4
4
|
"description": "Highlight plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,19 +44,19 @@
|
|
|
44
44
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
45
45
|
"@atlaskit/editor-shared-styles": "^3.6.0",
|
|
46
46
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
47
|
-
"@atlaskit/editor-toolbar": "^0.
|
|
47
|
+
"@atlaskit/editor-toolbar": "^0.9.0",
|
|
48
48
|
"@atlaskit/editor-toolbar-model": "^0.2.0",
|
|
49
49
|
"@atlaskit/heading": "^5.2.0",
|
|
50
|
-
"@atlaskit/icon": "^28.
|
|
50
|
+
"@atlaskit/icon": "^28.2.0",
|
|
51
51
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
52
|
-
"@atlaskit/primitives": "^14.
|
|
53
|
-
"@atlaskit/tmp-editor-statsig": "^12.
|
|
52
|
+
"@atlaskit/primitives": "^14.15.0",
|
|
53
|
+
"@atlaskit/tmp-editor-statsig": "^12.28.0",
|
|
54
54
|
"@atlaskit/tokens": "^6.3.0",
|
|
55
55
|
"@babel/runtime": "^7.0.0",
|
|
56
56
|
"@emotion/react": "^11.7.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@atlaskit/editor-common": "^109.
|
|
59
|
+
"@atlaskit/editor-common": "^109.11.0",
|
|
60
60
|
"react": "^18.2.0",
|
|
61
61
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
62
62
|
},
|