@atlaskit/editor-plugin-code-block-advanced 2.2.10 → 2.2.12

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-advanced
2
2
 
3
+ ## 2.2.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 2.2.11
10
+
11
+ ### Patch Changes
12
+
13
+ - [#158523](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/158523)
14
+ [`3fe5dff3f49a5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3fe5dff3f49a5) -
15
+ Triple click should select entire code block.
16
+ - Updated dependencies
17
+
3
18
  ## 2.2.10
4
19
 
5
20
  ### Patch Changes
@@ -24,6 +24,7 @@ var _updateCMSelection = require("./codemirrorSync/updateCMSelection");
24
24
  var _keymap = require("./extensions/keymap");
25
25
  var _manageSelectionMarker = require("./extensions/manageSelectionMarker");
26
26
  var _prosemirrorDecorations = require("./extensions/prosemirrorDecorations");
27
+ var _tripleClickExtension = require("./extensions/tripleClickExtension");
27
28
  var _loader = require("./languages/loader");
28
29
  // Based on: https://prosemirror.net/examples/codemirror/
29
30
  var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
@@ -82,7 +83,7 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
82
83
  contentEditable: "".concat(this.view.editable)
83
84
  })]), (0, _autocomplete.closeBrackets)(), _view.EditorView.editorAttributes.of({
84
85
  class: 'code-block'
85
- }), (0, _manageSelectionMarker.manageSelectionMarker)(config.api), (0, _prosemirrorDecorations.prosemirrorDecorationPlugin)(this.pmFacet, view, getPos)])
86
+ }), (0, _manageSelectionMarker.manageSelectionMarker)(config.api), (0, _prosemirrorDecorations.prosemirrorDecorationPlugin)(this.pmFacet, view, getPos), (0, _tripleClickExtension.tripleClickSelectAllExtension)()])
86
87
  });
87
88
 
88
89
  // We append an additional element that fixes a selection bug on chrome if the code block
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.tripleClickSelectAllExtension = void 0;
7
+ var _state = require("@codemirror/state");
8
+ var _view = require("@codemirror/view");
9
+ /**
10
+ * To have consistent behaviour with previous code block when a triple click occurs in the editor
11
+ * we should select the entire code block rather than the line.
12
+ *
13
+ * @returns CodeMirror extension
14
+ */
15
+ var tripleClickSelectAllExtension = exports.tripleClickSelectAllExtension = function tripleClickSelectAllExtension() {
16
+ return _view.EditorView.mouseSelectionStyle.of(function (view, event) {
17
+ // Check for a triple-click and avoid non-main "button" events
18
+ // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
19
+ // https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
20
+ if (event.detail !== 3 || event.button !== 0) {
21
+ return null;
22
+ }
23
+ return {
24
+ // Select the entire document
25
+ get: function get() {
26
+ return _state.EditorSelection.single(0, view.state.doc.length);
27
+ },
28
+ update: function update() {}
29
+ };
30
+ });
31
+ };
@@ -14,6 +14,7 @@ import { getCMSelectionChanges } from './codemirrorSync/updateCMSelection';
14
14
  import { keymapExtension } from './extensions/keymap';
15
15
  import { manageSelectionMarker } from './extensions/manageSelectionMarker';
16
16
  import { prosemirrorDecorationPlugin } from './extensions/prosemirrorDecorations';
17
+ import { tripleClickSelectAllExtension } from './extensions/tripleClickExtension';
17
18
  import { LanguageLoader } from './languages/loader';
18
19
  // Based on: https://prosemirror.net/examples/codemirror/
19
20
  class CodeBlockAdvancedNodeView {
@@ -60,7 +61,7 @@ class CodeBlockAdvancedNodeView {
60
61
  contentEditable: `${this.view.editable}`
61
62
  })]), closeBrackets(), CodeMirror.editorAttributes.of({
62
63
  class: 'code-block'
63
- }), manageSelectionMarker(config.api), prosemirrorDecorationPlugin(this.pmFacet, view, getPos)]
64
+ }), manageSelectionMarker(config.api), prosemirrorDecorationPlugin(this.pmFacet, view, getPos), tripleClickSelectAllExtension()]
64
65
  });
65
66
 
66
67
  // We append an additional element that fixes a selection bug on chrome if the code block
@@ -0,0 +1,24 @@
1
+ import { EditorSelection } from '@codemirror/state';
2
+ import { EditorView as CodeMirror } from '@codemirror/view';
3
+
4
+ /**
5
+ * To have consistent behaviour with previous code block when a triple click occurs in the editor
6
+ * we should select the entire code block rather than the line.
7
+ *
8
+ * @returns CodeMirror extension
9
+ */
10
+ export const tripleClickSelectAllExtension = () => CodeMirror.mouseSelectionStyle.of((view, event) => {
11
+ // Check for a triple-click and avoid non-main "button" events
12
+ // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
13
+ // https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
14
+ if (event.detail !== 3 || event.button !== 0) {
15
+ return null;
16
+ }
17
+ return {
18
+ // Select the entire document
19
+ get() {
20
+ return EditorSelection.single(0, view.state.doc.length);
21
+ },
22
+ update() {}
23
+ };
24
+ });
@@ -17,6 +17,7 @@ import { getCMSelectionChanges } from './codemirrorSync/updateCMSelection';
17
17
  import { keymapExtension } from './extensions/keymap';
18
18
  import { manageSelectionMarker } from './extensions/manageSelectionMarker';
19
19
  import { prosemirrorDecorationPlugin } from './extensions/prosemirrorDecorations';
20
+ import { tripleClickSelectAllExtension } from './extensions/tripleClickExtension';
20
21
  import { LanguageLoader } from './languages/loader';
21
22
  // Based on: https://prosemirror.net/examples/codemirror/
22
23
  var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
@@ -75,7 +76,7 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
75
76
  contentEditable: "".concat(this.view.editable)
76
77
  })]), closeBrackets(), CodeMirror.editorAttributes.of({
77
78
  class: 'code-block'
78
- }), manageSelectionMarker(config.api), prosemirrorDecorationPlugin(this.pmFacet, view, getPos)])
79
+ }), manageSelectionMarker(config.api), prosemirrorDecorationPlugin(this.pmFacet, view, getPos), tripleClickSelectAllExtension()])
79
80
  });
80
81
 
81
82
  // We append an additional element that fixes a selection bug on chrome if the code block
@@ -0,0 +1,26 @@
1
+ import { EditorSelection } from '@codemirror/state';
2
+ import { EditorView as CodeMirror } from '@codemirror/view';
3
+
4
+ /**
5
+ * To have consistent behaviour with previous code block when a triple click occurs in the editor
6
+ * we should select the entire code block rather than the line.
7
+ *
8
+ * @returns CodeMirror extension
9
+ */
10
+ export var tripleClickSelectAllExtension = function tripleClickSelectAllExtension() {
11
+ return CodeMirror.mouseSelectionStyle.of(function (view, event) {
12
+ // Check for a triple-click and avoid non-main "button" events
13
+ // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
14
+ // https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
15
+ if (event.detail !== 3 || event.button !== 0) {
16
+ return null;
17
+ }
18
+ return {
19
+ // Select the entire document
20
+ get: function get() {
21
+ return EditorSelection.single(0, view.state.doc.length);
22
+ },
23
+ update: function update() {}
24
+ };
25
+ });
26
+ };
@@ -1,4 +1,4 @@
1
- import { ChangeSpec } from '@codemirror/state';
1
+ import type { ChangeSpec } from '@codemirror/state';
2
2
  /**
3
3
  *
4
4
  * Compares the updated text with the current to determine the transaction to fire
@@ -1,5 +1,5 @@
1
1
  import { Facet } from '@codemirror/state';
2
- import { ViewPlugin, EditorView as CodeMirror, DecorationSet, ViewUpdate } from '@codemirror/view';
2
+ import { ViewPlugin, EditorView as CodeMirror, type DecorationSet, ViewUpdate } from '@codemirror/view';
3
3
  import type { EditorView, DecorationSource } from '@atlaskit/editor-prosemirror/view';
4
4
  /**
5
5
  * Creates CodeMirror versions of the decorations provided by ProseMirror.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * To have consistent behaviour with previous code block when a triple click occurs in the editor
3
+ * we should select the entire code block rather than the line.
4
+ *
5
+ * @returns CodeMirror extension
6
+ */
7
+ export declare const tripleClickSelectAllExtension: () => import("@codemirror/state").Extension;
@@ -1,4 +1,4 @@
1
- import { ChangeSpec } from '@codemirror/state';
1
+ import type { ChangeSpec } from '@codemirror/state';
2
2
  /**
3
3
  *
4
4
  * Compares the updated text with the current to determine the transaction to fire
@@ -1,5 +1,5 @@
1
1
  import { Facet } from '@codemirror/state';
2
- import { ViewPlugin, EditorView as CodeMirror, DecorationSet, ViewUpdate } from '@codemirror/view';
2
+ import { ViewPlugin, EditorView as CodeMirror, type DecorationSet, ViewUpdate } from '@codemirror/view';
3
3
  import type { EditorView, DecorationSource } from '@atlaskit/editor-prosemirror/view';
4
4
  /**
5
5
  * Creates CodeMirror versions of the decorations provided by ProseMirror.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * To have consistent behaviour with previous code block when a triple click occurs in the editor
3
+ * we should select the entire code block rather than the line.
4
+ *
5
+ * @returns CodeMirror extension
6
+ */
7
+ export declare const tripleClickSelectAllExtension: () => import("@codemirror/state").Extension;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block-advanced",
3
- "version": "2.2.10",
3
+ "version": "2.2.12",
4
4
  "description": "CodeBlockAdvanced plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,12 +33,12 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@atlaskit/adf-schema": "^47.6.0",
36
- "@atlaskit/editor-common": "^105.6.0",
36
+ "@atlaskit/editor-common": "^106.0.0",
37
37
  "@atlaskit/editor-plugin-code-block": "^4.4.0",
38
38
  "@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
39
39
  "@atlaskit/editor-plugin-find-replace": "^2.2.0",
40
40
  "@atlaskit/editor-plugin-selection": "^2.2.0",
41
- "@atlaskit/editor-plugin-selection-marker": "^2.3.0",
41
+ "@atlaskit/editor-plugin-selection-marker": "^2.4.0",
42
42
  "@atlaskit/editor-prosemirror": "7.0.0",
43
43
  "@atlaskit/tokens": "^4.9.0",
44
44
  "@babel/runtime": "^7.0.0",
@@ -38,6 +38,7 @@ import { getCMSelectionChanges } from './codemirrorSync/updateCMSelection';
38
38
  import { keymapExtension } from './extensions/keymap';
39
39
  import { manageSelectionMarker } from './extensions/manageSelectionMarker';
40
40
  import { prosemirrorDecorationPlugin } from './extensions/prosemirrorDecorations';
41
+ import { tripleClickSelectAllExtension } from './extensions/tripleClickExtension';
41
42
  import { LanguageLoader } from './languages/loader';
42
43
 
43
44
  interface ConfigProps {
@@ -120,6 +121,7 @@ class CodeBlockAdvancedNodeView implements NodeView {
120
121
  CodeMirror.editorAttributes.of({ class: 'code-block' }),
121
122
  manageSelectionMarker(config.api),
122
123
  prosemirrorDecorationPlugin(this.pmFacet, view, getPos),
124
+ tripleClickSelectAllExtension(),
123
125
  ],
124
126
  });
125
127
 
@@ -1,4 +1,4 @@
1
- import { ChangeSpec } from '@codemirror/state';
1
+ import type { ChangeSpec } from '@codemirror/state';
2
2
 
3
3
  /**
4
4
  *
@@ -4,7 +4,7 @@ import {
4
4
  WidgetType,
5
5
  Decoration as CodeMirrorDecoration,
6
6
  EditorView as CodeMirror,
7
- DecorationSet,
7
+ type DecorationSet,
8
8
  ViewUpdate,
9
9
  } from '@codemirror/view';
10
10
 
@@ -0,0 +1,25 @@
1
+ import { EditorSelection } from '@codemirror/state';
2
+ import { EditorView as CodeMirror } from '@codemirror/view';
3
+
4
+ /**
5
+ * To have consistent behaviour with previous code block when a triple click occurs in the editor
6
+ * we should select the entire code block rather than the line.
7
+ *
8
+ * @returns CodeMirror extension
9
+ */
10
+ export const tripleClickSelectAllExtension = () =>
11
+ CodeMirror.mouseSelectionStyle.of((view, event) => {
12
+ // Check for a triple-click and avoid non-main "button" events
13
+ // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
14
+ // https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
15
+ if (event.detail !== 3 || event.button !== 0) {
16
+ return null;
17
+ }
18
+ return {
19
+ // Select the entire document
20
+ get() {
21
+ return EditorSelection.single(0, view.state.doc.length);
22
+ },
23
+ update() {},
24
+ };
25
+ });
@@ -39,11 +39,12 @@ export const highlightStyle = HighlightStyle.define([
39
39
  },
40
40
  {
41
41
  tag: tags.inserted,
42
- color: token('color.text.accent.green')
42
+ color: token('color.text.accent.green'),
43
43
  },
44
44
  { tag: [tags.string], color: token('color.text.accent.green') },
45
45
  {
46
- tag: [tags.deleted], color: token('color.text.accent.red')
46
+ tag: [tags.deleted],
47
+ color: token('color.text.accent.red'),
47
48
  },
48
49
  {
49
50
  tag: [tags.special(tags.string)],