@atlaskit/editor-plugin-selection-marker 1.1.3 → 1.2.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 +6 -0
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/cjs/ui/selection-decoration.js +20 -4
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/es2019/ui/selection-decoration.js +20 -4
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/esm/ui/selection-decoration.js +20 -4
- package/dist/types/ui/selection-decoration.d.ts +2 -1
- package/dist/types-ts4.5/ui/selection-decoration.d.ts +2 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-marker
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#90866](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/90866) [`519e3bd71a35`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/519e3bd71a35) - [ux] [ED-22985] - Limit selection-marker plugin to only decorate text nodes
|
|
8
|
+
|
|
3
9
|
## 1.1.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -21,9 +21,9 @@ function getDecorations(tr, type) {
|
|
|
21
21
|
case 'none':
|
|
22
22
|
return _view.DecorationSet.empty;
|
|
23
23
|
case 'highlight':
|
|
24
|
-
return _view.DecorationSet.create(tr.doc, [].concat((0, _toConsumableArray2.default)((0, _widgetDecoration.createWidgetDecoration)(selection.$anchor, 'anchor', selection, true)),
|
|
24
|
+
return _view.DecorationSet.create(tr.doc, [].concat((0, _toConsumableArray2.default)((0, _widgetDecoration.createWidgetDecoration)(selection.$anchor, 'anchor', selection, true)), (0, _toConsumableArray2.default)((0, _selectionDecoration.selectionDecoration)(tr.doc, selection, true)), (0, _toConsumableArray2.default)((0, _widgetDecoration.createWidgetDecoration)(selection.$head, 'head', selection, true))));
|
|
25
25
|
case 'blur':
|
|
26
|
-
return _view.DecorationSet.create(tr.doc, [].concat((0, _toConsumableArray2.default)((0, _widgetDecoration.createWidgetDecoration)(selection.$anchor, 'anchor', selection, false)),
|
|
26
|
+
return _view.DecorationSet.create(tr.doc, [].concat((0, _toConsumableArray2.default)((0, _widgetDecoration.createWidgetDecoration)(selection.$anchor, 'anchor', selection, false)), (0, _toConsumableArray2.default)((0, _selectionDecoration.selectionDecoration)(tr.doc, selection, false))));
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
function getDecorationType(tr, forceHide, shouldHideDecorations) {
|
|
@@ -7,9 +7,25 @@ exports.selectionDecoration = void 0;
|
|
|
7
7
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
8
8
|
var decorationStyle = "\n background-color: ".concat("var(--ds-background-accent-gray-subtler, #DCDFE4)", ";\n ");
|
|
9
9
|
var decorationHighlightStyle = "\n background-color: ".concat("var(--ds-background-accent-blue-subtlest, #E9F2FF)", ";\n border-bottom: 2px solid ", "var(--ds-background-accent-blue-subtler, #cce0ff)", ";\n ");
|
|
10
|
-
var selectionDecoration = exports.selectionDecoration = function selectionDecoration(selection, isHighlight) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
var selectionDecoration = exports.selectionDecoration = function selectionDecoration(doc, selection, isHighlight) {
|
|
11
|
+
var selectionDecorations = [];
|
|
12
|
+
doc.nodesBetween(selection.from, selection.to, function (currentNode, nodePos) {
|
|
13
|
+
if (!currentNode.isText) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
var decorationFrom = selection.from;
|
|
17
|
+
var decorationTo = selection.to;
|
|
18
|
+
if (nodePos > selection.from) {
|
|
19
|
+
decorationFrom = nodePos;
|
|
20
|
+
}
|
|
21
|
+
if (nodePos + currentNode.nodeSize < selection.to) {
|
|
22
|
+
decorationTo = nodePos + currentNode.nodeSize;
|
|
23
|
+
}
|
|
24
|
+
selectionDecorations.push(_view.Decoration.inline(decorationFrom, decorationTo, {
|
|
25
|
+
style: isHighlight ? decorationHighlightStyle : decorationStyle,
|
|
26
|
+
'data-testid': 'selection-marker-selection'
|
|
27
|
+
}));
|
|
28
|
+
return true;
|
|
14
29
|
});
|
|
30
|
+
return selectionDecorations;
|
|
15
31
|
};
|
|
@@ -13,9 +13,9 @@ function getDecorations(tr, type) {
|
|
|
13
13
|
case 'none':
|
|
14
14
|
return DecorationSet.empty;
|
|
15
15
|
case 'highlight':
|
|
16
|
-
return DecorationSet.create(tr.doc, [...createWidgetDecoration(selection.$anchor, 'anchor', selection, true), selectionDecoration(selection, true), ...createWidgetDecoration(selection.$head, 'head', selection, true)]);
|
|
16
|
+
return DecorationSet.create(tr.doc, [...createWidgetDecoration(selection.$anchor, 'anchor', selection, true), ...selectionDecoration(tr.doc, selection, true), ...createWidgetDecoration(selection.$head, 'head', selection, true)]);
|
|
17
17
|
case 'blur':
|
|
18
|
-
return DecorationSet.create(tr.doc, [...createWidgetDecoration(selection.$anchor, 'anchor', selection, false), selectionDecoration(selection, false)]);
|
|
18
|
+
return DecorationSet.create(tr.doc, [...createWidgetDecoration(selection.$anchor, 'anchor', selection, false), ...selectionDecoration(tr.doc, selection, false)]);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
function getDecorationType(tr, forceHide, shouldHideDecorations) {
|
|
@@ -6,9 +6,25 @@ const decorationHighlightStyle = `
|
|
|
6
6
|
background-color: ${"var(--ds-background-accent-blue-subtlest, #E9F2FF)"};
|
|
7
7
|
border-bottom: 2px solid ${"var(--ds-background-accent-blue-subtler, #cce0ff)"};
|
|
8
8
|
`;
|
|
9
|
-
export const selectionDecoration = (selection, isHighlight) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export const selectionDecoration = (doc, selection, isHighlight) => {
|
|
10
|
+
const selectionDecorations = [];
|
|
11
|
+
doc.nodesBetween(selection.from, selection.to, (currentNode, nodePos) => {
|
|
12
|
+
if (!currentNode.isText) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
let decorationFrom = selection.from;
|
|
16
|
+
let decorationTo = selection.to;
|
|
17
|
+
if (nodePos > selection.from) {
|
|
18
|
+
decorationFrom = nodePos;
|
|
19
|
+
}
|
|
20
|
+
if (nodePos + currentNode.nodeSize < selection.to) {
|
|
21
|
+
decorationTo = nodePos + currentNode.nodeSize;
|
|
22
|
+
}
|
|
23
|
+
selectionDecorations.push(Decoration.inline(decorationFrom, decorationTo, {
|
|
24
|
+
style: isHighlight ? decorationHighlightStyle : decorationStyle,
|
|
25
|
+
'data-testid': 'selection-marker-selection'
|
|
26
|
+
}));
|
|
27
|
+
return true;
|
|
13
28
|
});
|
|
29
|
+
return selectionDecorations;
|
|
14
30
|
};
|
|
@@ -12,9 +12,9 @@ function getDecorations(tr, type) {
|
|
|
12
12
|
case 'none':
|
|
13
13
|
return DecorationSet.empty;
|
|
14
14
|
case 'highlight':
|
|
15
|
-
return DecorationSet.create(tr.doc, [].concat(_toConsumableArray(createWidgetDecoration(selection.$anchor, 'anchor', selection, true)),
|
|
15
|
+
return DecorationSet.create(tr.doc, [].concat(_toConsumableArray(createWidgetDecoration(selection.$anchor, 'anchor', selection, true)), _toConsumableArray(selectionDecoration(tr.doc, selection, true)), _toConsumableArray(createWidgetDecoration(selection.$head, 'head', selection, true))));
|
|
16
16
|
case 'blur':
|
|
17
|
-
return DecorationSet.create(tr.doc, [].concat(_toConsumableArray(createWidgetDecoration(selection.$anchor, 'anchor', selection, false)),
|
|
17
|
+
return DecorationSet.create(tr.doc, [].concat(_toConsumableArray(createWidgetDecoration(selection.$anchor, 'anchor', selection, false)), _toConsumableArray(selectionDecoration(tr.doc, selection, false))));
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
function getDecorationType(tr, forceHide, shouldHideDecorations) {
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
var decorationStyle = "\n background-color: ".concat("var(--ds-background-accent-gray-subtler, #DCDFE4)", ";\n ");
|
|
3
3
|
var decorationHighlightStyle = "\n background-color: ".concat("var(--ds-background-accent-blue-subtlest, #E9F2FF)", ";\n border-bottom: 2px solid ", "var(--ds-background-accent-blue-subtler, #cce0ff)", ";\n ");
|
|
4
|
-
export var selectionDecoration = function selectionDecoration(selection, isHighlight) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export var selectionDecoration = function selectionDecoration(doc, selection, isHighlight) {
|
|
5
|
+
var selectionDecorations = [];
|
|
6
|
+
doc.nodesBetween(selection.from, selection.to, function (currentNode, nodePos) {
|
|
7
|
+
if (!currentNode.isText) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
var decorationFrom = selection.from;
|
|
11
|
+
var decorationTo = selection.to;
|
|
12
|
+
if (nodePos > selection.from) {
|
|
13
|
+
decorationFrom = nodePos;
|
|
14
|
+
}
|
|
15
|
+
if (nodePos + currentNode.nodeSize < selection.to) {
|
|
16
|
+
decorationTo = nodePos + currentNode.nodeSize;
|
|
17
|
+
}
|
|
18
|
+
selectionDecorations.push(Decoration.inline(decorationFrom, decorationTo, {
|
|
19
|
+
style: isHighlight ? decorationHighlightStyle : decorationStyle,
|
|
20
|
+
'data-testid': 'selection-marker-selection'
|
|
21
|
+
}));
|
|
22
|
+
return true;
|
|
8
23
|
});
|
|
24
|
+
return selectionDecorations;
|
|
9
25
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
1
2
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
3
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
export declare const selectionDecoration: (selection: Selection, isHighlight: boolean) => Decoration;
|
|
4
|
+
export declare const selectionDecoration: (doc: PMNode, selection: Selection, isHighlight: boolean) => Decoration[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
1
2
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
3
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
export declare const selectionDecoration: (selection: Selection, isHighlight: boolean) => Decoration;
|
|
4
|
+
export declare const selectionDecoration: (doc: PMNode, selection: Selection, isHighlight: boolean) => Decoration[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-marker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Selection marker plugin for @atlaskit/editor-core.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/editor-common": "^78.
|
|
34
|
+
"@atlaskit/editor-common": "^78.28.0",
|
|
35
35
|
"@atlaskit/editor-plugin-focus": "^1.1.0",
|
|
36
36
|
"@atlaskit/editor-plugin-type-ahead": "^1.0.2",
|
|
37
37
|
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
38
|
-
"@atlaskit/primitives": "^5.
|
|
39
|
-
"@atlaskit/theme": "^12.
|
|
40
|
-
"@atlaskit/tokens": "^1.
|
|
38
|
+
"@atlaskit/primitives": "^5.5.0",
|
|
39
|
+
"@atlaskit/theme": "^12.7.0",
|
|
40
|
+
"@atlaskit/tokens": "^1.43.0",
|
|
41
41
|
"@babel/runtime": "^7.0.0",
|
|
42
42
|
"@emotion/react": "^11.7.1"
|
|
43
43
|
},
|