@atlaskit/editor-plugin-code-block 5.0.7 → 5.0.9

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-code-block
2
2
 
3
+ ## 5.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 5.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - [#199487](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/199487)
14
+ [`9146513a60d45`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9146513a60d45) -
15
+ Add a new experiment for code folding in the editor.
16
+ - Updated dependencies
17
+
3
18
  ## 5.0.7
4
19
 
5
20
  ### Patch Changes
@@ -15,6 +15,7 @@ var _transforms = require("@atlaskit/editor-common/transforms");
15
15
  var _state = require("@atlaskit/editor-prosemirror/state");
16
16
  var _view = require("@atlaskit/editor-prosemirror/view");
17
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
18
19
  var _editorCommands = require("../editor-commands");
19
20
  var _codeBlock2 = require("../nodeviews/code-block");
20
21
  var _classNames = require("../ui/class-names");
@@ -84,7 +85,12 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
84
85
  state: {
85
86
  init: function init(_, state) {
86
87
  var node = (0, _transforms.findCodeBlock)(state, state.selection);
87
- var initialDecorations = (0, _decorators.generateInitialDecorations)(state);
88
+ var initialDecorations =
89
+ // Disabled when using advanced code block advanced since it interfers with styling
90
+ // Long term we will deprecate the code block plugin and move all the related logic to
91
+ // the advanced plugin
92
+ // @ts-expect-error Code block advanced cannot depend on code block
93
+ (api === null || api === void 0 ? void 0 : api.codeBlockAdvanced) !== undefined && (0, _expValEquals.expValEquals)('platform_editor_code_block_fold_gutter', 'isEnabled', true) ? [] : (0, _decorators.generateInitialDecorations)(state);
88
94
  return {
89
95
  pos: node ? node.pos : null,
90
96
  contentCopied: false,
@@ -9,6 +9,7 @@ import { findCodeBlock } from '@atlaskit/editor-common/transforms';
9
9
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
10
10
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
11
11
  import { fg } from '@atlaskit/platform-feature-flags';
12
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
13
  import { ignoreFollowingMutations, resetShouldIgnoreFollowingMutations } from '../editor-commands';
13
14
  import { codeBlockNodeView } from '../nodeviews/code-block';
14
15
  import { codeBlockClassNames } from '../ui/class-names';
@@ -73,7 +74,12 @@ export const createPlugin = ({
73
74
  state: {
74
75
  init(_, state) {
75
76
  const node = findCodeBlock(state, state.selection);
76
- const initialDecorations = generateInitialDecorations(state);
77
+ const initialDecorations =
78
+ // Disabled when using advanced code block advanced since it interfers with styling
79
+ // Long term we will deprecate the code block plugin and move all the related logic to
80
+ // the advanced plugin
81
+ // @ts-expect-error Code block advanced cannot depend on code block
82
+ (api === null || api === void 0 ? void 0 : api.codeBlockAdvanced) !== undefined && expValEquals('platform_editor_code_block_fold_gutter', 'isEnabled', true) ? [] : generateInitialDecorations(state);
77
83
  return {
78
84
  pos: node ? node.pos : null,
79
85
  contentCopied: false,
@@ -12,6 +12,7 @@ import { findCodeBlock } from '@atlaskit/editor-common/transforms';
12
12
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
13
13
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
15
16
  import { ignoreFollowingMutations, resetShouldIgnoreFollowingMutations } from '../editor-commands';
16
17
  import { codeBlockNodeView } from '../nodeviews/code-block';
17
18
  import { codeBlockClassNames } from '../ui/class-names';
@@ -79,7 +80,12 @@ export var createPlugin = function createPlugin(_ref) {
79
80
  state: {
80
81
  init: function init(_, state) {
81
82
  var node = findCodeBlock(state, state.selection);
82
- var initialDecorations = generateInitialDecorations(state);
83
+ var initialDecorations =
84
+ // Disabled when using advanced code block advanced since it interfers with styling
85
+ // Long term we will deprecate the code block plugin and move all the related logic to
86
+ // the advanced plugin
87
+ // @ts-expect-error Code block advanced cannot depend on code block
88
+ (api === null || api === void 0 ? void 0 : api.codeBlockAdvanced) !== undefined && expValEquals('platform_editor_code_block_fold_gutter', 'isEnabled', true) ? [] : generateInitialDecorations(state);
83
89
  return {
84
90
  pos: node ? node.pos : null,
85
91
  contentCopied: false,
@@ -318,6 +318,10 @@ export declare const DEFAULT_LANGUAGES: ({
318
318
  readonly name: "Protocol Buffers";
319
319
  readonly alias: readonly ["protobuf", "proto"];
320
320
  readonly value: "protobuf";
321
+ } | {
322
+ readonly name: "TOML";
323
+ readonly alias: readonly ["toml"];
324
+ readonly value: "toml";
321
325
  } | {
322
326
  readonly name: "Handlebars";
323
327
  readonly alias: readonly ["handlebars", "mustache"];
@@ -656,6 +660,10 @@ export declare function findMatchedLanguage(supportedLanguages: Language[], lang
656
660
  readonly name: "Protocol Buffers";
657
661
  readonly alias: readonly ["protobuf", "proto"];
658
662
  readonly value: "protobuf";
663
+ } | {
664
+ readonly name: "TOML";
665
+ readonly alias: readonly ["toml"];
666
+ readonly value: "toml";
659
667
  } | {
660
668
  readonly name: "Handlebars";
661
669
  readonly alias: readonly ["handlebars", "mustache"];
@@ -995,6 +1003,10 @@ export declare function createLanguageList(supportedLanguages: Language[]): ({
995
1003
  readonly name: "Protocol Buffers";
996
1004
  readonly alias: readonly ["protobuf", "proto"];
997
1005
  readonly value: "protobuf";
1006
+ } | {
1007
+ readonly name: "TOML";
1008
+ readonly alias: readonly ["toml"];
1009
+ readonly value: "toml";
998
1010
  } | {
999
1011
  readonly name: "Handlebars";
1000
1012
  readonly alias: readonly ["handlebars", "mustache"];
@@ -1,61 +1,13 @@
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';
5
4
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
5
  import type { CodeBlockPlugin } from '../index';
7
6
  import { type CodeBlockState } from './main-state';
8
7
  export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompositionInputOverride, api, }: {
9
- useLongPressSelection?: boolean | undefined;
8
+ useLongPressSelection?: boolean;
10
9
  getIntl: () => IntlShape;
11
- allowCompositionInputOverride?: boolean | undefined;
12
- api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"codeBlock", {
13
- pluginConfiguration: import("../types").CodeBlockPluginOptions | undefined;
14
- dependencies: [import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"decorations", {
15
- sharedState: import("@atlaskit/editor-plugin-decorations").DecorationState;
16
- actions: {
17
- hoverDecoration: (nodeType: import("prosemirror-model").NodeType | import("prosemirror-model").NodeType[], add: boolean, className?: string | undefined) => import("@atlaskit/editor-common/types").Command;
18
- removeDecoration: import("@atlaskit/editor-common/types").Command;
19
- };
20
- }, undefined>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"composition", {
21
- sharedState: import("@atlaskit/editor-plugin-composition").CompositionState;
22
- }, undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
23
- pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
24
- sharedState: {
25
- createAnalyticsEvent: import("packages/analytics/analytics-next/dist/types").CreateUIAnalyticsEvent | null;
26
- attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
27
- performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
28
- };
29
- dependencies: [import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
30
- pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
31
- sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
32
- }, import("@atlaskit/editor-common/types").FeatureFlags>>];
33
- actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
34
- }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorDisabled", {
35
- sharedState: import("@atlaskit/editor-plugin-editor-disabled").EditorDisabledPluginState;
36
- pluginConfiguration: import("@atlaskit/editor-plugin-editor-disabled").EditorDisabledPluginOptions | undefined;
37
- }, import("@atlaskit/editor-plugin-editor-disabled").EditorDisabledPluginOptions | undefined>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
38
- pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
39
- sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
40
- }, import("@atlaskit/editor-common/types").FeatureFlags>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"interaction", {
41
- sharedState: import("@atlaskit/editor-plugin-interaction").SharedInteractionState;
42
- commands: {
43
- handleInteraction: import("@atlaskit/editor-common/types").EditorCommand;
44
- };
45
- }, undefined>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorViewMode", {
46
- sharedState: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginState | null;
47
- dependencies: [];
48
- pluginConfiguration?: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginOptions | undefined;
49
- commands: {
50
- updateViewMode: (mode: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode) => import("@atlaskit/editor-common/types").EditorCommand;
51
- };
52
- }, import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginOptions | undefined>>];
53
- sharedState: {
54
- copyButtonHoverNode: PMNode;
55
- } | undefined;
56
- actions: {
57
- insertCodeBlock: (inputMethod: import("@atlaskit/editor-common/analytics").INPUT_METHOD) => import("@atlaskit/editor-common/types").Command;
58
- };
59
- }> | undefined;
60
- decorations?: DecorationSet | undefined;
10
+ allowCompositionInputOverride?: boolean;
11
+ api?: ExtractInjectionAPI<CodeBlockPlugin>;
12
+ decorations?: DecorationSet;
61
13
  }) => SafePlugin<CodeBlockState>;
@@ -1,7 +1,7 @@
1
1
  import type { ExtractInjectionAPI, FloatingToolbarHandler, SelectOption } from '@atlaskit/editor-common/types';
2
2
  import type { CodeBlockPlugin } from '../index';
3
3
  import { type Language } from './language-list';
4
- export declare const getToolbarConfig: (allowCopyToClipboard: boolean | undefined, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined, overrideLanguageName?: ((name: Language['name']) => string) | undefined) => FloatingToolbarHandler;
4
+ export declare const getToolbarConfig: (allowCopyToClipboard: boolean | undefined, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined, overrideLanguageName?: ((name: Language["name"]) => string) | undefined) => FloatingToolbarHandler;
5
5
  /**
6
6
  * Filters language list based on both name and alias properties.
7
7
  * @param option
@@ -560,6 +560,12 @@ export declare const DEFAULT_LANGUAGES: ({
560
560
  "proto"
561
561
  ];
562
562
  readonly value: "protobuf";
563
+ } | {
564
+ readonly name: "TOML";
565
+ readonly alias: readonly [
566
+ "toml"
567
+ ];
568
+ readonly value: "toml";
563
569
  } | {
564
570
  readonly name: "Handlebars";
565
571
  readonly alias: readonly [
@@ -1148,6 +1154,12 @@ export declare function findMatchedLanguage(supportedLanguages: Language[], lang
1148
1154
  "proto"
1149
1155
  ];
1150
1156
  readonly value: "protobuf";
1157
+ } | {
1158
+ readonly name: "TOML";
1159
+ readonly alias: readonly [
1160
+ "toml"
1161
+ ];
1162
+ readonly value: "toml";
1151
1163
  } | {
1152
1164
  readonly name: "Handlebars";
1153
1165
  readonly alias: readonly [
@@ -1737,6 +1749,12 @@ export declare function createLanguageList(supportedLanguages: Language[]): ({
1737
1749
  "proto"
1738
1750
  ];
1739
1751
  readonly value: "protobuf";
1752
+ } | {
1753
+ readonly name: "TOML";
1754
+ readonly alias: readonly [
1755
+ "toml"
1756
+ ];
1757
+ readonly value: "toml";
1740
1758
  } | {
1741
1759
  readonly name: "Handlebars";
1742
1760
  readonly alias: readonly [
@@ -1,72 +1,13 @@
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';
5
4
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
5
  import type { CodeBlockPlugin } from '../index';
7
6
  import { type CodeBlockState } from './main-state';
8
7
  export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompositionInputOverride, api, }: {
9
- useLongPressSelection?: boolean | undefined;
8
+ useLongPressSelection?: boolean;
10
9
  getIntl: () => IntlShape;
11
- allowCompositionInputOverride?: boolean | undefined;
12
- api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"codeBlock", {
13
- pluginConfiguration: import("../types").CodeBlockPluginOptions | undefined;
14
- dependencies: [
15
- import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"decorations", {
16
- sharedState: import("@atlaskit/editor-plugin-decorations").DecorationState;
17
- actions: {
18
- hoverDecoration: (nodeType: import("prosemirror-model").NodeType | import("prosemirror-model").NodeType[], add: boolean, className?: string | undefined) => import("@atlaskit/editor-common/types").Command;
19
- removeDecoration: import("@atlaskit/editor-common/types").Command;
20
- };
21
- }, undefined>,
22
- import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"composition", {
23
- sharedState: import("@atlaskit/editor-plugin-composition").CompositionState;
24
- }, undefined>,
25
- import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
26
- pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
27
- sharedState: {
28
- createAnalyticsEvent: import("packages/analytics/analytics-next/dist/types").CreateUIAnalyticsEvent | null;
29
- attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
30
- performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
31
- };
32
- dependencies: [
33
- import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
34
- pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
35
- sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
36
- }, import("@atlaskit/editor-common/types").FeatureFlags>>
37
- ];
38
- actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
39
- }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>,
40
- import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorDisabled", {
41
- sharedState: import("@atlaskit/editor-plugin-editor-disabled").EditorDisabledPluginState;
42
- pluginConfiguration: import("@atlaskit/editor-plugin-editor-disabled").EditorDisabledPluginOptions | undefined;
43
- }, import("@atlaskit/editor-plugin-editor-disabled").EditorDisabledPluginOptions | undefined>>,
44
- import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
45
- pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
46
- sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
47
- }, import("@atlaskit/editor-common/types").FeatureFlags>>,
48
- import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"interaction", {
49
- sharedState: import("@atlaskit/editor-plugin-interaction").SharedInteractionState;
50
- commands: {
51
- handleInteraction: import("@atlaskit/editor-common/types").EditorCommand;
52
- };
53
- }, undefined>>,
54
- import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorViewMode", {
55
- sharedState: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginState | null;
56
- dependencies: [
57
- ];
58
- pluginConfiguration?: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginOptions | undefined;
59
- commands: {
60
- updateViewMode: (mode: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode) => import("@atlaskit/editor-common/types").EditorCommand;
61
- };
62
- }, import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginOptions | undefined>>
63
- ];
64
- sharedState: {
65
- copyButtonHoverNode: PMNode;
66
- } | undefined;
67
- actions: {
68
- insertCodeBlock: (inputMethod: import("@atlaskit/editor-common/analytics").INPUT_METHOD) => import("@atlaskit/editor-common/types").Command;
69
- };
70
- }> | undefined;
71
- decorations?: DecorationSet | undefined;
10
+ allowCompositionInputOverride?: boolean;
11
+ api?: ExtractInjectionAPI<CodeBlockPlugin>;
12
+ decorations?: DecorationSet;
72
13
  }) => SafePlugin<CodeBlockState>;
@@ -1,7 +1,7 @@
1
1
  import type { ExtractInjectionAPI, FloatingToolbarHandler, SelectOption } from '@atlaskit/editor-common/types';
2
2
  import type { CodeBlockPlugin } from '../index';
3
3
  import { type Language } from './language-list';
4
- export declare const getToolbarConfig: (allowCopyToClipboard: boolean | undefined, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined, overrideLanguageName?: ((name: Language['name']) => string) | undefined) => FloatingToolbarHandler;
4
+ export declare const getToolbarConfig: (allowCopyToClipboard: boolean | undefined, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined, overrideLanguageName?: ((name: Language["name"]) => string) | undefined) => FloatingToolbarHandler;
5
5
  /**
6
6
  * Filters language list based on both name and alias properties.
7
7
  * @param option
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block",
3
- "version": "5.0.7",
3
+ "version": "5.0.9",
4
4
  "description": "Code block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -39,20 +39,17 @@
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^5.0.0",
40
40
  "@atlaskit/editor-plugin-interaction": "^5.0.0",
41
41
  "@atlaskit/editor-prosemirror": "7.0.0",
42
- "@atlaskit/icon": "^27.9.0",
42
+ "@atlaskit/icon": "^27.12.0",
43
43
  "@atlaskit/platform-feature-flags": "^1.1.0",
44
- "@atlaskit/prosemirror-input-rules": "^3.3.0",
45
- "@atlaskit/tmp-editor-statsig": "^9.22.0",
44
+ "@atlaskit/prosemirror-input-rules": "^3.4.0",
45
+ "@atlaskit/tmp-editor-statsig": "^10.0.0",
46
46
  "@babel/runtime": "^7.0.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@atlaskit/editor-common": "^107.16.0",
49
+ "@atlaskit/editor-common": "^107.25.0",
50
50
  "react": "^18.2.0",
51
51
  "react-intl-next": "npm:react-intl@^5.18.1"
52
52
  },
53
- "devDependencies": {
54
- "typescript": "~5.4.2"
55
- },
56
53
  "techstack": {
57
54
  "@atlassian/frontend": {
58
55
  "code-structure": [