@atlaskit/editor-plugin-code-block 3.5.16 → 3.6.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 +14 -0
- package/dist/cjs/codeBlockPlugin.js +8 -0
- package/dist/cjs/pm-plugins/codeBlockCopySelectionPlugin.js +4 -2
- package/dist/es2019/codeBlockPlugin.js +9 -1
- package/dist/es2019/pm-plugins/codeBlockCopySelectionPlugin.js +4 -2
- package/dist/esm/codeBlockPlugin.js +9 -1
- package/dist/esm/pm-plugins/codeBlockCopySelectionPlugin.js +4 -2
- package/dist/types/codeBlockPluginType.d.ts +4 -0
- package/dist/types/pm-plugins/codeBlockCopySelectionPlugin.d.ts +2 -0
- package/dist/types/pm-plugins/main.d.ts +4 -0
- package/dist/types-ts4.5/codeBlockPluginType.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/codeBlockCopySelectionPlugin.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +4 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 3.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#103918](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103918)
|
|
8
|
+
[`29844093c6ab4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/29844093c6ab4) -
|
|
9
|
+
Expose new shared state for code block plugin which indicates the current node that the copy text
|
|
10
|
+
button is hovered for. Display highlight decorations for the copy text button in the advanced code
|
|
11
|
+
block plugin.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 3.5.16
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -36,6 +36,14 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
|
36
36
|
node: _adfSchema.codeBlock
|
|
37
37
|
}];
|
|
38
38
|
},
|
|
39
|
+
getSharedState: function getSharedState(state) {
|
|
40
|
+
if (!state) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
copyButtonHoverNode: _codeBlockCopySelectionPlugin.copySelectionPluginKey.getState(state).codeBlockNode
|
|
45
|
+
};
|
|
46
|
+
},
|
|
39
47
|
pmPlugins: function pmPlugins() {
|
|
40
48
|
return [{
|
|
41
49
|
name: 'codeBlock',
|
|
@@ -23,12 +23,14 @@ function getSelectionDecorationStartAndEnd(_ref) {
|
|
|
23
23
|
});
|
|
24
24
|
if (!codeBlockNode) {
|
|
25
25
|
return {
|
|
26
|
-
decorationStartAndEnd: undefined
|
|
26
|
+
decorationStartAndEnd: undefined,
|
|
27
|
+
codeBlockNode: undefined
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
var decorationStartAndEnd = [codeBlockNode.start, codeBlockNode.start + codeBlockNode.node.nodeSize];
|
|
30
31
|
return {
|
|
31
|
-
decorationStartAndEnd: decorationStartAndEnd
|
|
32
|
+
decorationStartAndEnd: decorationStartAndEnd,
|
|
33
|
+
codeBlockNode: codeBlockNode.node
|
|
32
34
|
};
|
|
33
35
|
}
|
|
34
36
|
function codeBlockCopySelectionPlugin() {
|
|
@@ -6,7 +6,7 @@ import { IconCode } from '@atlaskit/editor-common/quick-insert';
|
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { createInsertCodeBlockTransaction, insertCodeBlockWithAnalytics } from './editor-commands';
|
|
8
8
|
import { codeBlockAutoFullStopTransformPlugin } from './pm-plugins/codeBlockAutoFullStopTransformPlugin';
|
|
9
|
-
import { codeBlockCopySelectionPlugin } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
9
|
+
import { codeBlockCopySelectionPlugin, copySelectionPluginKey } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
10
10
|
import ideUX from './pm-plugins/ide-ux';
|
|
11
11
|
import { createCodeBlockInputRule } from './pm-plugins/input-rule';
|
|
12
12
|
import keymap from './pm-plugins/keymaps';
|
|
@@ -27,6 +27,14 @@ const codeBlockPlugin = ({
|
|
|
27
27
|
node: codeBlock
|
|
28
28
|
}];
|
|
29
29
|
},
|
|
30
|
+
getSharedState(state) {
|
|
31
|
+
if (!state) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
copyButtonHoverNode: copySelectionPluginKey.getState(state).codeBlockNode
|
|
36
|
+
};
|
|
37
|
+
},
|
|
30
38
|
pmPlugins() {
|
|
31
39
|
return [{
|
|
32
40
|
name: 'codeBlock',
|
|
@@ -13,12 +13,14 @@ function getSelectionDecorationStartAndEnd({
|
|
|
13
13
|
});
|
|
14
14
|
if (!codeBlockNode) {
|
|
15
15
|
return {
|
|
16
|
-
decorationStartAndEnd: undefined
|
|
16
|
+
decorationStartAndEnd: undefined,
|
|
17
|
+
codeBlockNode: undefined
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
const decorationStartAndEnd = [codeBlockNode.start, codeBlockNode.start + codeBlockNode.node.nodeSize];
|
|
20
21
|
return {
|
|
21
|
-
decorationStartAndEnd
|
|
22
|
+
decorationStartAndEnd,
|
|
23
|
+
codeBlockNode: codeBlockNode.node
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
26
|
export function codeBlockCopySelectionPlugin() {
|
|
@@ -9,7 +9,7 @@ import { IconCode } from '@atlaskit/editor-common/quick-insert';
|
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { createInsertCodeBlockTransaction, insertCodeBlockWithAnalytics } from './editor-commands';
|
|
11
11
|
import { codeBlockAutoFullStopTransformPlugin } from './pm-plugins/codeBlockAutoFullStopTransformPlugin';
|
|
12
|
-
import { codeBlockCopySelectionPlugin } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
12
|
+
import { codeBlockCopySelectionPlugin, copySelectionPluginKey } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
13
13
|
import ideUX from './pm-plugins/ide-ux';
|
|
14
14
|
import { createCodeBlockInputRule } from './pm-plugins/input-rule';
|
|
15
15
|
import keymap from './pm-plugins/keymaps';
|
|
@@ -29,6 +29,14 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
|
29
29
|
node: codeBlock
|
|
30
30
|
}];
|
|
31
31
|
},
|
|
32
|
+
getSharedState: function getSharedState(state) {
|
|
33
|
+
if (!state) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
copyButtonHoverNode: copySelectionPluginKey.getState(state).codeBlockNode
|
|
38
|
+
};
|
|
39
|
+
},
|
|
32
40
|
pmPlugins: function pmPlugins() {
|
|
33
41
|
return [{
|
|
34
42
|
name: 'codeBlock',
|
|
@@ -13,12 +13,14 @@ function getSelectionDecorationStartAndEnd(_ref) {
|
|
|
13
13
|
});
|
|
14
14
|
if (!codeBlockNode) {
|
|
15
15
|
return {
|
|
16
|
-
decorationStartAndEnd: undefined
|
|
16
|
+
decorationStartAndEnd: undefined,
|
|
17
|
+
codeBlockNode: undefined
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
var decorationStartAndEnd = [codeBlockNode.start, codeBlockNode.start + codeBlockNode.node.nodeSize];
|
|
20
21
|
return {
|
|
21
|
-
decorationStartAndEnd: decorationStartAndEnd
|
|
22
|
+
decorationStartAndEnd: decorationStartAndEnd,
|
|
23
|
+
codeBlockNode: codeBlockNode.node
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
26
|
export function codeBlockCopySelectionPlugin() {
|
|
@@ -5,6 +5,7 @@ import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
|
|
|
5
5
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
6
6
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
7
7
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
8
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
9
|
import type { CodeBlockOptions } from './types';
|
|
9
10
|
type CodeBlockDependencies = [
|
|
10
11
|
DecorationsPlugin,
|
|
@@ -16,6 +17,9 @@ type CodeBlockDependencies = [
|
|
|
16
17
|
export type CodeBlockPlugin = NextEditorPlugin<'codeBlock', {
|
|
17
18
|
pluginConfiguration: CodeBlockOptions | undefined;
|
|
18
19
|
dependencies: CodeBlockDependencies;
|
|
20
|
+
sharedState: {
|
|
21
|
+
copyButtonHoverNode: PMNode;
|
|
22
|
+
} | undefined;
|
|
19
23
|
actions: {
|
|
20
24
|
insertCodeBlock: (inputMethod: INPUT_METHOD) => Command;
|
|
21
25
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
export declare const copySelectionPluginKey: PluginKey<any>;
|
|
5
6
|
type CodeBlockCopySelectionPluginState = {
|
|
6
7
|
decorationStartAndEnd?: [start: number, end: number];
|
|
8
|
+
codeBlockNode?: PMNode;
|
|
7
9
|
};
|
|
8
10
|
export declare function codeBlockCopySelectionPlugin(): SafePlugin<CodeBlockCopySelectionPluginState>;
|
|
9
11
|
export declare function provideVisualFeedbackForCopyButton(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
6
|
import type { CodeBlockPlugin } from '../index';
|
|
6
7
|
import { type CodeBlockState } from './main-state';
|
|
@@ -36,6 +37,9 @@ export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompo
|
|
|
36
37
|
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
37
38
|
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
38
39
|
}, import("@atlaskit/editor-common/types").FeatureFlags>>];
|
|
40
|
+
sharedState: {
|
|
41
|
+
copyButtonHoverNode: PMNode;
|
|
42
|
+
} | undefined;
|
|
39
43
|
actions: {
|
|
40
44
|
insertCodeBlock: (inputMethod: import("@atlaskit/editor-common/analytics").INPUT_METHOD) => import("@atlaskit/editor-common/types").Command;
|
|
41
45
|
};
|
|
@@ -5,6 +5,7 @@ import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
|
|
|
5
5
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
6
6
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
7
7
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
8
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
9
|
import type { CodeBlockOptions } from './types';
|
|
9
10
|
type CodeBlockDependencies = [
|
|
10
11
|
DecorationsPlugin,
|
|
@@ -16,6 +17,9 @@ type CodeBlockDependencies = [
|
|
|
16
17
|
export type CodeBlockPlugin = NextEditorPlugin<'codeBlock', {
|
|
17
18
|
pluginConfiguration: CodeBlockOptions | undefined;
|
|
18
19
|
dependencies: CodeBlockDependencies;
|
|
20
|
+
sharedState: {
|
|
21
|
+
copyButtonHoverNode: PMNode;
|
|
22
|
+
} | undefined;
|
|
19
23
|
actions: {
|
|
20
24
|
insertCodeBlock: (inputMethod: INPUT_METHOD) => Command;
|
|
21
25
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
export declare const copySelectionPluginKey: PluginKey<any>;
|
|
@@ -7,6 +8,7 @@ type CodeBlockCopySelectionPluginState = {
|
|
|
7
8
|
start: number,
|
|
8
9
|
end: number
|
|
9
10
|
];
|
|
11
|
+
codeBlockNode?: PMNode;
|
|
10
12
|
};
|
|
11
13
|
export declare function codeBlockCopySelectionPlugin(): SafePlugin<CodeBlockCopySelectionPluginState>;
|
|
12
14
|
export declare function provideVisualFeedbackForCopyButton(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
6
|
import type { CodeBlockPlugin } from '../index';
|
|
6
7
|
import { type CodeBlockState } from './main-state';
|
|
@@ -44,6 +45,9 @@ export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompo
|
|
|
44
45
|
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
45
46
|
}, import("@atlaskit/editor-common/types").FeatureFlags>>
|
|
46
47
|
];
|
|
48
|
+
sharedState: {
|
|
49
|
+
copyButtonHoverNode: PMNode;
|
|
50
|
+
} | undefined;
|
|
47
51
|
actions: {
|
|
48
52
|
insertCodeBlock: (inputMethod: import("@atlaskit/editor-common/analytics").INPUT_METHOD) => import("@atlaskit/editor-common/types").Command;
|
|
49
53
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
35
|
"@atlaskit/code": "^15.6.0",
|
|
36
|
-
"@atlaskit/editor-common": "^99.
|
|
37
|
-
"@atlaskit/editor-plugin-analytics": "^1.
|
|
36
|
+
"@atlaskit/editor-common": "^99.5.0",
|
|
37
|
+
"@atlaskit/editor-plugin-analytics": "^1.11.0",
|
|
38
38
|
"@atlaskit/editor-plugin-composition": "^1.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-decorations": "^1.3.0",
|
|
40
40
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
42
|
-
"@atlaskit/icon": "^23.
|
|
42
|
+
"@atlaskit/icon": "^23.4.0",
|
|
43
43
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
44
44
|
"@atlaskit/prosemirror-input-rules": "^3.2.0",
|
|
45
45
|
"@babel/runtime": "^7.0.0"
|