@atlaskit/editor-plugin-code-block-advanced 7.1.26 → 8.0.1

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/types/nodeviews/extensions/foldGutter.d.ts +2 -2
  3. package/dist/types/nodeviews/extensions/lineSeparator.d.ts +2 -1
  4. package/dist/types/nodeviews/extensions/prosemirrorDecorations.d.ts +2 -2
  5. package/dist/types/nodeviews/extensions/tripleClickExtension.d.ts +2 -1
  6. package/dist/types/nodeviews/lazyCodeBlockAdvanced.d.ts +2 -1
  7. package/dist/types/pm-plugins/main.d.ts +1 -1
  8. package/dist/types/ui/theme.d.ts +3 -2
  9. package/dist/types-ts4.5/nodeviews/extensions/foldGutter.d.ts +2 -2
  10. package/dist/types-ts4.5/nodeviews/extensions/lineSeparator.d.ts +2 -1
  11. package/dist/types-ts4.5/nodeviews/extensions/prosemirrorDecorations.d.ts +2 -2
  12. package/dist/types-ts4.5/nodeviews/extensions/tripleClickExtension.d.ts +2 -1
  13. package/dist/types-ts4.5/nodeviews/lazyCodeBlockAdvanced.d.ts +2 -1
  14. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  15. package/dist/types-ts4.5/ui/theme.d.ts +3 -2
  16. package/package.json +8 -8
  17. package/src/nodeviews/extensions/foldGutter.ts +2 -2
  18. package/src/nodeviews/extensions/lineSeparator.ts +2 -2
  19. package/src/nodeviews/extensions/prosemirrorDecorations.ts +5 -1
  20. package/src/nodeviews/extensions/tripleClickExtension.ts +2 -2
  21. package/src/nodeviews/languages/actionscript/languageSupport.ts +1 -1
  22. package/src/nodeviews/languages/actionscript/parser.ts +1 -1
  23. package/src/nodeviews/languages/getLanguageName.ts +1 -6
  24. package/src/nodeviews/languages/languageMap.ts +3 -1
  25. package/src/nodeviews/lazyCodeBlockAdvanced.ts +2 -2
  26. package/src/pm-plugins/main.ts +1 -1
  27. package/src/ui/syntaxHighlightingTheme.ts +1 -1
  28. package/src/ui/theme.ts +3 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-code-block-advanced
2
2
 
3
+ ## 8.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 8.0.0
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 7.1.26
4
16
 
5
17
  ### Patch Changes
@@ -1,10 +1,10 @@
1
- import { type StateEffect } from '@codemirror/state';
1
+ import { type Extension, type StateEffect } from '@codemirror/state';
2
2
  import type { EditorView as CodeMirror } from '@codemirror/view';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  export declare function foldGutterExtension({ selectNode, getNode, }: {
5
5
  getNode: () => PMNode;
6
6
  selectNode: () => void;
7
- }): import("@codemirror/state").Extension[];
7
+ }): Extension[];
8
8
  export declare function getCodeBlockFoldStateEffects({ node, cm, }: {
9
9
  cm: CodeMirror;
10
10
  node: PMNode;
@@ -1,5 +1,6 @@
1
+ import { type Extension } from '@codemirror/state';
1
2
  /**
2
3
  * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
3
4
  * we only consider \n for line separators.
4
5
  */
5
- export declare const lineSeparatorExtension: () => import("@codemirror/state").Extension;
6
+ export declare const lineSeparatorExtension: () => Extension;
@@ -15,6 +15,6 @@ import type { EditorView, DecorationSource } from '@atlaskit/editor-prosemirror/
15
15
  */
16
16
  export declare const prosemirrorDecorationPlugin: (updateDecorationsEffect: Facet<DecorationSource>, editorView: EditorView, getPos: () => number | undefined) => ViewPlugin<{
17
17
  decorations: DecorationSet;
18
- updateDecorations(view: CodeMirror): DecorationSet;
19
- update(update: ViewUpdate): void;
18
+ update: (update: ViewUpdate) => void;
19
+ updateDecorations: (view: CodeMirror) => DecorationSet;
20
20
  }>;
@@ -1,7 +1,8 @@
1
+ import { type Extension } from '@codemirror/state';
1
2
  /**
2
3
  * To have consistent behaviour with previous code block when a triple click occurs in the editor
3
4
  * we should select the entire code block rather than the line.
4
5
  *
5
6
  * @returns CodeMirror extension
6
7
  */
7
- export declare const tripleClickSelectAllExtension: () => import("@codemirror/state").Extension;
8
+ export declare const tripleClickSelectAllExtension: () => Extension;
@@ -1,5 +1,6 @@
1
1
  import { type Extension } from '@codemirror/state';
2
2
  import type { IntlShape } from 'react-intl-next';
3
+ import { type NodeViewConstructor } from '@atlaskit/editor-common/lazy-node-view';
3
4
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
5
  import type { CodeBlockAdvancedPlugin } from '../codeBlockAdvancedPluginType';
5
6
  interface Props {
@@ -8,5 +9,5 @@ interface Props {
8
9
  extensions: Extension[];
9
10
  getIntl: () => IntlShape;
10
11
  }
11
- export declare const lazyCodeBlockView: (props: Props) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor;
12
+ export declare const lazyCodeBlockView: (props: Props) => NodeViewConstructor;
12
13
  export {};
@@ -9,5 +9,5 @@ interface Props {
9
9
  extensions: Extension[];
10
10
  getIntl: () => IntlShape;
11
11
  }
12
- export declare const createPlugin: (props: Props) => SafePlugin<any>;
12
+ export declare const createPlugin: (props: Props) => SafePlugin;
13
13
  export {};
@@ -1,7 +1,8 @@
1
+ import type { Extension } from '@codemirror/state';
1
2
  import type { EditorContentMode } from '@atlaskit/editor-common/types';
2
3
  type ThemeOptions = {
3
4
  contentMode?: EditorContentMode;
4
5
  };
5
- export declare const cmTheme: (options?: ThemeOptions) => import("@codemirror/state").Extension;
6
- export declare const codeFoldingTheme: import("@codemirror/state").Extension;
6
+ export declare const cmTheme: (options?: ThemeOptions) => Extension;
7
+ export declare const codeFoldingTheme: Extension;
7
8
  export {};
@@ -1,10 +1,10 @@
1
- import { type StateEffect } from '@codemirror/state';
1
+ import { type Extension, type StateEffect } from '@codemirror/state';
2
2
  import type { EditorView as CodeMirror } from '@codemirror/view';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  export declare function foldGutterExtension({ selectNode, getNode, }: {
5
5
  getNode: () => PMNode;
6
6
  selectNode: () => void;
7
- }): import("@codemirror/state").Extension[];
7
+ }): Extension[];
8
8
  export declare function getCodeBlockFoldStateEffects({ node, cm, }: {
9
9
  cm: CodeMirror;
10
10
  node: PMNode;
@@ -1,5 +1,6 @@
1
+ import { type Extension } from '@codemirror/state';
1
2
  /**
2
3
  * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
3
4
  * we only consider \n for line separators.
4
5
  */
5
- export declare const lineSeparatorExtension: () => import("@codemirror/state").Extension;
6
+ export declare const lineSeparatorExtension: () => Extension;
@@ -15,6 +15,6 @@ import type { EditorView, DecorationSource } from '@atlaskit/editor-prosemirror/
15
15
  */
16
16
  export declare const prosemirrorDecorationPlugin: (updateDecorationsEffect: Facet<DecorationSource>, editorView: EditorView, getPos: () => number | undefined) => ViewPlugin<{
17
17
  decorations: DecorationSet;
18
- updateDecorations(view: CodeMirror): DecorationSet;
19
- update(update: ViewUpdate): void;
18
+ update: (update: ViewUpdate) => void;
19
+ updateDecorations: (view: CodeMirror) => DecorationSet;
20
20
  }>;
@@ -1,7 +1,8 @@
1
+ import { type Extension } from '@codemirror/state';
1
2
  /**
2
3
  * To have consistent behaviour with previous code block when a triple click occurs in the editor
3
4
  * we should select the entire code block rather than the line.
4
5
  *
5
6
  * @returns CodeMirror extension
6
7
  */
7
- export declare const tripleClickSelectAllExtension: () => import("@codemirror/state").Extension;
8
+ export declare const tripleClickSelectAllExtension: () => Extension;
@@ -1,5 +1,6 @@
1
1
  import { type Extension } from '@codemirror/state';
2
2
  import type { IntlShape } from 'react-intl-next';
3
+ import { type NodeViewConstructor } from '@atlaskit/editor-common/lazy-node-view';
3
4
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
5
  import type { CodeBlockAdvancedPlugin } from '../codeBlockAdvancedPluginType';
5
6
  interface Props {
@@ -8,5 +9,5 @@ interface Props {
8
9
  extensions: Extension[];
9
10
  getIntl: () => IntlShape;
10
11
  }
11
- export declare const lazyCodeBlockView: (props: Props) => import("@atlaskit/editor-common/lazy-node-view").NodeViewConstructor;
12
+ export declare const lazyCodeBlockView: (props: Props) => NodeViewConstructor;
12
13
  export {};
@@ -9,5 +9,5 @@ interface Props {
9
9
  extensions: Extension[];
10
10
  getIntl: () => IntlShape;
11
11
  }
12
- export declare const createPlugin: (props: Props) => SafePlugin<any>;
12
+ export declare const createPlugin: (props: Props) => SafePlugin;
13
13
  export {};
@@ -1,7 +1,8 @@
1
+ import type { Extension } from '@codemirror/state';
1
2
  import type { EditorContentMode } from '@atlaskit/editor-common/types';
2
3
  type ThemeOptions = {
3
4
  contentMode?: EditorContentMode;
4
5
  };
5
- export declare const cmTheme: (options?: ThemeOptions) => import("@codemirror/state").Extension;
6
- export declare const codeFoldingTheme: import("@codemirror/state").Extension;
6
+ export declare const cmTheme: (options?: ThemeOptions) => Extension;
7
+ export declare const codeFoldingTheme: Extension;
7
8
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block-advanced",
3
- "version": "7.1.26",
3
+ "version": "8.0.1",
4
4
  "description": "CodeBlockAdvanced plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -30,15 +30,15 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^52.2.0",
32
32
  "@atlaskit/code": "^17.4.0",
33
- "@atlaskit/editor-plugin-code-block": "^9.1.0",
34
- "@atlaskit/editor-plugin-editor-disabled": "^7.0.0",
35
- "@atlaskit/editor-plugin-find-replace": "^7.1.0",
36
- "@atlaskit/editor-plugin-selection": "^7.1.0",
37
- "@atlaskit/editor-plugin-selection-marker": "^7.0.0",
33
+ "@atlaskit/editor-plugin-code-block": "^10.0.0",
34
+ "@atlaskit/editor-plugin-editor-disabled": "^8.0.0",
35
+ "@atlaskit/editor-plugin-find-replace": "^8.0.0",
36
+ "@atlaskit/editor-plugin-selection": "^8.0.0",
37
+ "@atlaskit/editor-plugin-selection-marker": "^8.0.0",
38
38
  "@atlaskit/editor-prosemirror": "^7.3.0",
39
39
  "@atlaskit/platform-feature-flags": "^1.1.0",
40
40
  "@atlaskit/prosemirror-history": "^0.2.0",
41
- "@atlaskit/tmp-editor-statsig": "^35.7.0",
41
+ "@atlaskit/tmp-editor-statsig": "^36.0.0",
42
42
  "@atlaskit/tokens": "^11.1.0",
43
43
  "@babel/runtime": "^7.0.0",
44
44
  "@codemirror/autocomplete": "6.18.4",
@@ -55,7 +55,7 @@
55
55
  "codemirror-lang-elixir": "4.0.0"
56
56
  },
57
57
  "peerDependencies": {
58
- "@atlaskit/editor-common": "^111.34.0",
58
+ "@atlaskit/editor-common": "^112.0.0",
59
59
  "react": "^18.2.0",
60
60
  "react-intl-next": "npm:react-intl@^5.18.1"
61
61
  },
@@ -1,5 +1,5 @@
1
1
  import { foldGutter, codeFolding, foldState, foldEffect } from '@codemirror/language';
2
- import { type StateEffect } from '@codemirror/state';
2
+ import { type Extension, type StateEffect } from '@codemirror/state';
3
3
  import type { EditorView as CodeMirror } from '@codemirror/view';
4
4
 
5
5
  import {
@@ -62,7 +62,7 @@ export function foldGutterExtension({
62
62
  }: {
63
63
  getNode: () => PMNode;
64
64
  selectNode: () => void;
65
- }) {
65
+ }): Extension[] {
66
66
  return [
67
67
  foldGutter({
68
68
  foldingChanged: (update) => {
@@ -1,4 +1,4 @@
1
- import { EditorState as CodeMirrorState } from '@codemirror/state';
1
+ import { EditorState as CodeMirrorState, type Extension } from '@codemirror/state';
2
2
 
3
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
4
 
@@ -6,7 +6,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
6
  * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
7
7
  * we only consider \n for line separators.
8
8
  */
9
- export const lineSeparatorExtension = () => {
9
+ export const lineSeparatorExtension = (): Extension => {
10
10
  if (expValEquals('platform_editor_fix_advanced_codeblocks_crlf', 'isEnabled', true)) {
11
11
  return CodeMirrorState.lineSeparator.of('\n');
12
12
  }
@@ -108,7 +108,11 @@ export const prosemirrorDecorationPlugin = (
108
108
  updateDecorationsEffect: Facet<DecorationSource>,
109
109
  editorView: EditorView,
110
110
  getPos: () => number | undefined,
111
- ) =>
111
+ ): ViewPlugin<{
112
+ decorations: DecorationSet;
113
+ update: (update: ViewUpdate) => void;
114
+ updateDecorations: (view: CodeMirror) => DecorationSet;
115
+ }> =>
112
116
  ViewPlugin.fromClass(
113
117
  class {
114
118
  decorations: DecorationSet;
@@ -1,4 +1,4 @@
1
- import { EditorSelection } from '@codemirror/state';
1
+ import { EditorSelection, type Extension } from '@codemirror/state';
2
2
  import { EditorView as CodeMirror } from '@codemirror/view';
3
3
 
4
4
  /**
@@ -7,7 +7,7 @@ import { EditorView as CodeMirror } from '@codemirror/view';
7
7
  *
8
8
  * @returns CodeMirror extension
9
9
  */
10
- export const tripleClickSelectAllExtension = () =>
10
+ export const tripleClickSelectAllExtension = (): Extension =>
11
11
  CodeMirror.mouseSelectionStyle.of((view, event) => {
12
12
  // Check for a triple-click and avoid non-main "button" events
13
13
  // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
@@ -11,7 +11,7 @@ import { parser } from './parser';
11
11
  * import { actionscriptLanguageSupport } from './languageSupport';
12
12
  * const support = actionscriptLanguageSupport();
13
13
  */
14
- export function actionscriptLanguageSupport() {
14
+ export function actionscriptLanguageSupport(): LanguageSupport {
15
15
  // --- Syntax highlighting rules for ActionScript ---
16
16
  const actionScriptHighlight = styleTags({
17
17
  'var function': tags.controlKeyword,
@@ -2,7 +2,7 @@
2
2
  import { LRParser } from '@lezer/lr';
3
3
 
4
4
  const spec_Identifier = { __proto__: null, var: 8, function: 14 };
5
- export const parser = LRParser.deserialize({
5
+ export const parser: LRParser = LRParser.deserialize({
6
6
  version: 14,
7
7
  states:
8
8
  "$tQYQPOOOOQO'#Cl'#ClOOQO'#Ci'#CiOOQO'#Cd'#CdQYQPOOOkQPO'#CjOpQPO'#CnOuQPO'#CiOOQO-E6b-E6bOzQPO,59UO!SQPO,59YOOQO,59T,59TOOQO1G.p1G.pO!XQPO1G.pO!dQPO1G.tO!iQPO7+$[O!nQPO'#CpO!vQPO7+$`OOQO<<Gv<<GvO!{QPO'#CeO#QQPO,59[O#YQPO<<GzOOQO,59P,59POOQO-E6c-E6cO#_QPO'#CsOOQOAN=fAN=fOOQO,59_,59_O#fQPO,59_OOQO1G.y1G.y",
@@ -14,14 +14,9 @@ const getLanguageName = (languageValue: string): string | undefined => {
14
14
  }
15
15
 
16
16
  const language = (SUPPORTED_LANGUAGES as readonly Language[]).find((l) => {
17
- return (
18
- l.value === languageValue ||
19
- (l.alias && (l.alias as string[]).includes(languageValue))
20
- );
17
+ return l.value === languageValue || (l.alias && (l.alias as string[]).includes(languageValue));
21
18
  });
22
19
 
23
-
24
-
25
20
  return language ? language.name : undefined;
26
21
  };
27
22
 
@@ -6,7 +6,9 @@ import type { LanguageAlias } from '@atlaskit/code';
6
6
  type LanguageAliasValue = LanguageAlias[0];
7
7
 
8
8
  // getLanguageIdentifier defines `language.alias[0]`
9
- export const mapLanguageToCodeMirror = (language: LanguageAliasValue) => {
9
+ export const mapLanguageToCodeMirror = (
10
+ language: LanguageAliasValue,
11
+ ): LanguageDescription | undefined => {
10
12
  if (!language || language === 'none') {
11
13
  return undefined;
12
14
  }
@@ -1,7 +1,7 @@
1
1
  import { type Extension } from '@codemirror/state';
2
2
  import type { IntlShape } from 'react-intl-next';
3
3
 
4
- import { withLazyLoading } from '@atlaskit/editor-common/lazy-node-view';
4
+ import { withLazyLoading, type NodeViewConstructor } from '@atlaskit/editor-common/lazy-node-view';
5
5
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
6
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
7
7
  import type { EditorView, DecorationSource, Decoration } from '@atlaskit/editor-prosemirror/view';
@@ -15,7 +15,7 @@ interface Props {
15
15
  getIntl: () => IntlShape;
16
16
  }
17
17
 
18
- export const lazyCodeBlockView = (props: Props) => {
18
+ export const lazyCodeBlockView = (props: Props): NodeViewConstructor => {
19
19
  return withLazyLoading({
20
20
  nodeName: 'codeBlock',
21
21
  getNodeViewOptions: () => {},
@@ -17,7 +17,7 @@ interface Props {
17
17
  getIntl: () => IntlShape;
18
18
  }
19
19
 
20
- export const createPlugin = (props: Props) => {
20
+ export const createPlugin = (props: Props): SafePlugin => {
21
21
  return new SafePlugin({
22
22
  props: {
23
23
  nodeViews: {
@@ -4,7 +4,7 @@ import { tags } from '@lezer/highlight';
4
4
  import { token } from '@atlaskit/tokens';
5
5
 
6
6
  // Based on `platform/packages/design-system/code/src/internal/theme/styles.tsx`
7
- export const highlightStyle = HighlightStyle.define([
7
+ export const highlightStyle: HighlightStyle = HighlightStyle.define([
8
8
  { tag: tags.meta, color: token('color.text') },
9
9
  { tag: tags.link, textDecoration: 'underline' },
10
10
  {
package/src/ui/theme.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Extension } from '@codemirror/state';
1
2
  import { EditorView as CodeMirror } from '@codemirror/view';
2
3
 
3
4
  import type { EditorContentMode } from '@atlaskit/editor-common/types';
@@ -20,7 +21,7 @@ type ThemeOptions = {
20
21
  contentMode?: EditorContentMode;
21
22
  };
22
23
 
23
- export const cmTheme = (options?: ThemeOptions) =>
24
+ export const cmTheme = (options?: ThemeOptions): Extension =>
24
25
  CodeMirror.theme({
25
26
  '&': {
26
27
  backgroundColor: token('color.background.neutral'),
@@ -90,7 +91,7 @@ export const cmTheme = (options?: ThemeOptions) =>
90
91
  },
91
92
  });
92
93
 
93
- export const codeFoldingTheme = CodeMirror.theme({
94
+ export const codeFoldingTheme: Extension = CodeMirror.theme({
94
95
  '.cm-gutter': {
95
96
  paddingLeft: token('space.075'),
96
97
  paddingTop: token('space.100'),