@atlaskit/editor-plugin-code-block 1.1.9 → 1.1.11

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,17 @@
1
1
  # @atlaskit/editor-plugin-code-block
2
2
 
3
+ ## 1.1.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [#91461](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91461) [`1b353cb06cc8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1b353cb06cc8) - [ED-23042] Disable editing in code blocks and expand nodes when editorDisabled state is true
8
+
9
+ ## 1.1.10
10
+
11
+ ### Patch Changes
12
+
13
+ - [#92426](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92426) [`32c76c7c225c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/32c76c7c225c) - Bump adf-schema to 35.9.2 to support table alignment options
14
+
3
15
  ## 1.1.9
4
16
 
5
17
  ### Patch Changes
@@ -12,11 +12,12 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
12
12
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
13
13
  var _utils = require("@atlaskit/editor-common/utils");
14
14
  var _model = require("@atlaskit/editor-prosemirror/model");
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
16
  var _actions = require("../actions");
16
17
  var _mainState = require("../pm-plugins/main-state");
17
18
  var _classNames = require("../ui/class-names");
18
19
  var MATCH_NEWLINES = new RegExp('\n', 'g');
19
- var toDOM = function toDOM(node) {
20
+ var toDOM = function toDOM(node, contentEditable) {
20
21
  return ['div', {
21
22
  class: 'code-block'
22
23
  }, ['div', {
@@ -32,7 +33,7 @@ var toDOM = function toDOM(node) {
32
33
  }, ['code', {
33
34
  'data-language': node.attrs.language || '',
34
35
  spellcheck: 'false',
35
- contenteditable: 'true',
36
+ contenteditable: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : 'true',
36
37
  'data-testid': 'code-block--code'
37
38
  }, 0]]], ['div', {
38
39
  class: _classNames.codeBlockClassNames.end,
@@ -40,8 +41,9 @@ var toDOM = function toDOM(node) {
40
41
  }]];
41
42
  };
42
43
  var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
43
- function CodeBlockView(_node, view, getPos) {
44
- var _this = this;
44
+ function CodeBlockView(_node, view, getPos, api, cleanupEditorDisabledListener) {
45
+ var _this = this,
46
+ _api$editorDisabled;
45
47
  (0, _classCallCheck2.default)(this, CodeBlockView);
46
48
  (0, _defineProperty2.default)(this, "ensureLineNumbers", (0, _rafSchd.default)(function () {
47
49
  var lines = 1;
@@ -58,7 +60,8 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
58
60
  _this.lineNumberGutter.removeChild(_this.lineNumberGutter.lastChild);
59
61
  }
60
62
  }));
61
- var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(_node)),
63
+ this.cleanupEditorDisabledListener = cleanupEditorDisabledListener;
64
+ var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled !== void 0 && _api$editorDisabled.editorDisabled))),
62
65
  dom = _DOMSerializer$render.dom,
63
66
  contentDOM = _DOMSerializer$render.contentDOM;
64
67
  this.getPos = getPos;
@@ -67,9 +70,24 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
67
70
  this.dom = dom;
68
71
  this.contentDOM = contentDOM;
69
72
  this.lineNumberGutter = this.dom.querySelector(".".concat(_classNames.codeBlockClassNames.gutter));
73
+ this.api = api;
70
74
  this.ensureLineNumbers();
75
+ this.handleEditorDisabledChanged();
71
76
  }
72
77
  (0, _createClass2.default)(CodeBlockView, [{
78
+ key: "handleEditorDisabledChanged",
79
+ value: function handleEditorDisabledChanged() {
80
+ var _this$api,
81
+ _this2 = this;
82
+ if ((_this$api = this.api) !== null && _this$api !== void 0 && _this$api.editorDisabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
83
+ this.cleanupEditorDisabledListener = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
84
+ if (_this2.contentDOM) {
85
+ _this2.contentDOM.setAttribute('contenteditable', sharedState.nextSharedState.editorDisabled ? 'false' : 'true');
86
+ }
87
+ });
88
+ }
89
+ }
90
+ }, {
73
91
  key: "updateDOMAndSelection",
74
92
  value: function updateDOMAndSelection(savedInnerHTML, newCursorPosition) {
75
93
  var _this$dom;
@@ -145,9 +163,17 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
145
163
  // Ensure updating the line-number gutter doesn't trigger reparsing the codeblock
146
164
  return record.target === this.lineNumberGutter || record.target.parentNode === this.lineNumberGutter;
147
165
  }
166
+ }, {
167
+ key: "destroy",
168
+ value: function destroy() {
169
+ if (this.cleanupEditorDisabledListener) {
170
+ this.cleanupEditorDisabledListener();
171
+ }
172
+ this.cleanupEditorDisabledListener = undefined;
173
+ }
148
174
  }]);
149
175
  return CodeBlockView;
150
176
  }();
151
- var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos) {
152
- return new CodeBlockView(node, view, getPos);
177
+ var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, api) {
178
+ return new CodeBlockView(node, view, getPos, api);
153
179
  };
@@ -40,7 +40,8 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
40
40
  var getIntl = _ref2.getIntl;
41
41
  return (0, _main.createPlugin)(_objectSpread(_objectSpread({}, options), {}, {
42
42
  getIntl: getIntl,
43
- appearance: (_options$appearance = options === null || options === void 0 ? void 0 : options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : 'comment'
43
+ appearance: (_options$appearance = options === null || options === void 0 ? void 0 : options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : 'comment',
44
+ api: api
44
45
  }));
45
46
  }
46
47
  }, {
@@ -24,7 +24,8 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
24
24
  getIntl = _ref.getIntl,
25
25
  appearance = _ref.appearance,
26
26
  _ref$allowComposition = _ref.allowCompositionInputOverride,
27
- allowCompositionInputOverride = _ref$allowComposition === void 0 ? false : _ref$allowComposition;
27
+ allowCompositionInputOverride = _ref$allowComposition === void 0 ? false : _ref$allowComposition,
28
+ api = _ref.api;
28
29
  var handleDOMEvents = {};
29
30
 
30
31
  // ME-1599: Composition on mobile was causing the DOM observer to mutate the code block
@@ -101,7 +102,9 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
101
102
  key: _pluginKey.pluginKey,
102
103
  props: {
103
104
  nodeViews: {
104
- codeBlock: _codeBlock.codeBlockNodeView
105
+ codeBlock: function codeBlock(node, view, getPos) {
106
+ return (0, _codeBlock.codeBlockNodeView)(node, view, getPos, api);
107
+ }
105
108
  },
106
109
  handleClickOn: (0, _selection.createSelectionClickHandler)(['codeBlock'], function (target) {
107
110
  return !!(target.closest(".".concat(_classNames.codeBlockClassNames.gutter)) || target.classList.contains(_classNames.codeBlockClassNames.content));
@@ -2,11 +2,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import rafSchedule from 'raf-schd';
3
3
  import { browser } from '@atlaskit/editor-common/utils';
4
4
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
5
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
6
  import { resetShouldIgnoreFollowingMutations } from '../actions';
6
7
  import { getPluginState } from '../pm-plugins/main-state';
7
8
  import { codeBlockClassNames } from '../ui/class-names';
8
9
  const MATCH_NEWLINES = new RegExp('\n', 'g');
9
- const toDOM = node => ['div', {
10
+ const toDOM = (node, contentEditable) => ['div', {
10
11
  class: 'code-block'
11
12
  }, ['div', {
12
13
  class: codeBlockClassNames.start,
@@ -21,14 +22,15 @@ const toDOM = node => ['div', {
21
22
  }, ['code', {
22
23
  'data-language': node.attrs.language || '',
23
24
  spellcheck: 'false',
24
- contenteditable: 'true',
25
+ contenteditable: getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : 'true',
25
26
  'data-testid': 'code-block--code'
26
27
  }, 0]]], ['div', {
27
28
  class: codeBlockClassNames.end,
28
29
  contenteditable: 'false'
29
30
  }]];
30
31
  export class CodeBlockView {
31
- constructor(_node, view, getPos) {
32
+ constructor(_node, view, getPos, api, cleanupEditorDisabledListener) {
33
+ var _api$editorDisabled, _api$editorDisabled$s;
32
34
  _defineProperty(this, "ensureLineNumbers", rafSchedule(() => {
33
35
  let lines = 1;
34
36
  this.node.forEach(node => {
@@ -44,17 +46,30 @@ export class CodeBlockView {
44
46
  this.lineNumberGutter.removeChild(this.lineNumberGutter.lastChild);
45
47
  }
46
48
  }));
49
+ this.cleanupEditorDisabledListener = cleanupEditorDisabledListener;
47
50
  const {
48
51
  dom,
49
52
  contentDOM
50
- } = DOMSerializer.renderSpec(document, toDOM(_node));
53
+ } = DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled$s = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled$s !== void 0 && _api$editorDisabled$s.editorDisabled)));
51
54
  this.getPos = getPos;
52
55
  this.view = view;
53
56
  this.node = _node;
54
57
  this.dom = dom;
55
58
  this.contentDOM = contentDOM;
56
59
  this.lineNumberGutter = this.dom.querySelector(`.${codeBlockClassNames.gutter}`);
60
+ this.api = api;
57
61
  this.ensureLineNumbers();
62
+ this.handleEditorDisabledChanged();
63
+ }
64
+ handleEditorDisabledChanged() {
65
+ var _this$api;
66
+ if ((_this$api = this.api) !== null && _this$api !== void 0 && _this$api.editorDisabled && getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
67
+ this.cleanupEditorDisabledListener = this.api.editorDisabled.sharedState.onChange(sharedState => {
68
+ if (this.contentDOM) {
69
+ this.contentDOM.setAttribute('contenteditable', sharedState.nextSharedState.editorDisabled ? 'false' : 'true');
70
+ }
71
+ });
72
+ }
58
73
  }
59
74
  updateDOMAndSelection(savedInnerHTML, newCursorPosition) {
60
75
  var _this$dom;
@@ -122,5 +137,11 @@ export class CodeBlockView {
122
137
  // Ensure updating the line-number gutter doesn't trigger reparsing the codeblock
123
138
  return record.target === this.lineNumberGutter || record.target.parentNode === this.lineNumberGutter;
124
139
  }
140
+ destroy() {
141
+ if (this.cleanupEditorDisabledListener) {
142
+ this.cleanupEditorDisabledListener();
143
+ }
144
+ this.cleanupEditorDisabledListener = undefined;
145
+ }
125
146
  }
126
- export const codeBlockNodeView = (node, view, getPos) => new CodeBlockView(node, view, getPos);
147
+ export const codeBlockNodeView = (node, view, getPos, api) => new CodeBlockView(node, view, getPos, api);
@@ -32,7 +32,8 @@ const codeBlockPlugin = ({
32
32
  return createPlugin({
33
33
  ...options,
34
34
  getIntl,
35
- appearance: (_options$appearance = options === null || options === void 0 ? void 0 : options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : 'comment'
35
+ appearance: (_options$appearance = options === null || options === void 0 ? void 0 : options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : 'comment',
36
+ api
36
37
  });
37
38
  }
38
39
  }, {
@@ -12,7 +12,8 @@ export const createPlugin = ({
12
12
  useLongPressSelection = false,
13
13
  getIntl,
14
14
  appearance,
15
- allowCompositionInputOverride = false
15
+ allowCompositionInputOverride = false,
16
+ api
16
17
  }) => {
17
18
  const handleDOMEvents = {};
18
19
 
@@ -91,7 +92,7 @@ export const createPlugin = ({
91
92
  key: pluginKey,
92
93
  props: {
93
94
  nodeViews: {
94
- codeBlock: codeBlockNodeView
95
+ codeBlock: (node, view, getPos) => codeBlockNodeView(node, view, getPos, api)
95
96
  },
96
97
  handleClickOn: createSelectionClickHandler(['codeBlock'], target => !!(target.closest(`.${codeBlockClassNames.gutter}`) || target.classList.contains(codeBlockClassNames.content)), {
97
98
  useLongPressSelection
@@ -5,11 +5,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
5
  import rafSchedule from 'raf-schd';
6
6
  import { browser } from '@atlaskit/editor-common/utils';
7
7
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
8
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { resetShouldIgnoreFollowingMutations } from '../actions';
9
10
  import { getPluginState } from '../pm-plugins/main-state';
10
11
  import { codeBlockClassNames } from '../ui/class-names';
11
12
  var MATCH_NEWLINES = new RegExp('\n', 'g');
12
- var toDOM = function toDOM(node) {
13
+ var toDOM = function toDOM(node, contentEditable) {
13
14
  return ['div', {
14
15
  class: 'code-block'
15
16
  }, ['div', {
@@ -25,7 +26,7 @@ var toDOM = function toDOM(node) {
25
26
  }, ['code', {
26
27
  'data-language': node.attrs.language || '',
27
28
  spellcheck: 'false',
28
- contenteditable: 'true',
29
+ contenteditable: getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : 'true',
29
30
  'data-testid': 'code-block--code'
30
31
  }, 0]]], ['div', {
31
32
  class: codeBlockClassNames.end,
@@ -33,8 +34,9 @@ var toDOM = function toDOM(node) {
33
34
  }]];
34
35
  };
35
36
  export var CodeBlockView = /*#__PURE__*/function () {
36
- function CodeBlockView(_node, view, getPos) {
37
- var _this = this;
37
+ function CodeBlockView(_node, view, getPos, api, cleanupEditorDisabledListener) {
38
+ var _this = this,
39
+ _api$editorDisabled;
38
40
  _classCallCheck(this, CodeBlockView);
39
41
  _defineProperty(this, "ensureLineNumbers", rafSchedule(function () {
40
42
  var lines = 1;
@@ -51,7 +53,8 @@ export var CodeBlockView = /*#__PURE__*/function () {
51
53
  _this.lineNumberGutter.removeChild(_this.lineNumberGutter.lastChild);
52
54
  }
53
55
  }));
54
- var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(_node)),
56
+ this.cleanupEditorDisabledListener = cleanupEditorDisabledListener;
57
+ var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled !== void 0 && _api$editorDisabled.editorDisabled))),
55
58
  dom = _DOMSerializer$render.dom,
56
59
  contentDOM = _DOMSerializer$render.contentDOM;
57
60
  this.getPos = getPos;
@@ -60,9 +63,24 @@ export var CodeBlockView = /*#__PURE__*/function () {
60
63
  this.dom = dom;
61
64
  this.contentDOM = contentDOM;
62
65
  this.lineNumberGutter = this.dom.querySelector(".".concat(codeBlockClassNames.gutter));
66
+ this.api = api;
63
67
  this.ensureLineNumbers();
68
+ this.handleEditorDisabledChanged();
64
69
  }
65
70
  _createClass(CodeBlockView, [{
71
+ key: "handleEditorDisabledChanged",
72
+ value: function handleEditorDisabledChanged() {
73
+ var _this$api,
74
+ _this2 = this;
75
+ if ((_this$api = this.api) !== null && _this$api !== void 0 && _this$api.editorDisabled && getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
76
+ this.cleanupEditorDisabledListener = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
77
+ if (_this2.contentDOM) {
78
+ _this2.contentDOM.setAttribute('contenteditable', sharedState.nextSharedState.editorDisabled ? 'false' : 'true');
79
+ }
80
+ });
81
+ }
82
+ }
83
+ }, {
66
84
  key: "updateDOMAndSelection",
67
85
  value: function updateDOMAndSelection(savedInnerHTML, newCursorPosition) {
68
86
  var _this$dom;
@@ -138,9 +156,17 @@ export var CodeBlockView = /*#__PURE__*/function () {
138
156
  // Ensure updating the line-number gutter doesn't trigger reparsing the codeblock
139
157
  return record.target === this.lineNumberGutter || record.target.parentNode === this.lineNumberGutter;
140
158
  }
159
+ }, {
160
+ key: "destroy",
161
+ value: function destroy() {
162
+ if (this.cleanupEditorDisabledListener) {
163
+ this.cleanupEditorDisabledListener();
164
+ }
165
+ this.cleanupEditorDisabledListener = undefined;
166
+ }
141
167
  }]);
142
168
  return CodeBlockView;
143
169
  }();
144
- export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos) {
145
- return new CodeBlockView(node, view, getPos);
170
+ export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, api) {
171
+ return new CodeBlockView(node, view, getPos, api);
146
172
  };
@@ -33,7 +33,8 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
33
33
  var getIntl = _ref2.getIntl;
34
34
  return createPlugin(_objectSpread(_objectSpread({}, options), {}, {
35
35
  getIntl: getIntl,
36
- appearance: (_options$appearance = options === null || options === void 0 ? void 0 : options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : 'comment'
36
+ appearance: (_options$appearance = options === null || options === void 0 ? void 0 : options.appearance) !== null && _options$appearance !== void 0 ? _options$appearance : 'comment',
37
+ api: api
37
38
  }));
38
39
  }
39
40
  }, {
@@ -17,7 +17,8 @@ export var createPlugin = function createPlugin(_ref) {
17
17
  getIntl = _ref.getIntl,
18
18
  appearance = _ref.appearance,
19
19
  _ref$allowComposition = _ref.allowCompositionInputOverride,
20
- allowCompositionInputOverride = _ref$allowComposition === void 0 ? false : _ref$allowComposition;
20
+ allowCompositionInputOverride = _ref$allowComposition === void 0 ? false : _ref$allowComposition,
21
+ api = _ref.api;
21
22
  var handleDOMEvents = {};
22
23
 
23
24
  // ME-1599: Composition on mobile was causing the DOM observer to mutate the code block
@@ -94,7 +95,9 @@ export var createPlugin = function createPlugin(_ref) {
94
95
  key: pluginKey,
95
96
  props: {
96
97
  nodeViews: {
97
- codeBlock: codeBlockNodeView
98
+ codeBlock: function codeBlock(node, view, getPos) {
99
+ return codeBlockNodeView(node, view, getPos, api);
100
+ }
98
101
  },
99
102
  handleClickOn: createSelectionClickHandler(['codeBlock'], function (target) {
100
103
  return !!(target.closest(".".concat(codeBlockClassNames.gutter)) || target.classList.contains(codeBlockClassNames.content));
@@ -1,14 +1,18 @@
1
- import type { getPosHandler, getPosHandlerNode } from '@atlaskit/editor-common/types';
1
+ import type { ExtractInjectionAPI, getPosHandler, getPosHandlerNode } from '@atlaskit/editor-common/types';
2
2
  import type { Node } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { CodeBlockPlugin } from '../plugin';
4
5
  export declare class CodeBlockView {
6
+ private cleanupEditorDisabledListener?;
5
7
  node: Node;
6
8
  dom: HTMLElement;
7
9
  contentDOM: HTMLElement;
8
10
  lineNumberGutter: HTMLElement;
9
11
  getPos: getPosHandlerNode;
10
12
  view: EditorView;
11
- constructor(node: Node, view: EditorView, getPos: getPosHandlerNode);
13
+ api?: ExtractInjectionAPI<CodeBlockPlugin>;
14
+ constructor(node: Node, view: EditorView, getPos: getPosHandlerNode, api?: ExtractInjectionAPI<CodeBlockPlugin>, cleanupEditorDisabledListener?: (() => void) | undefined);
15
+ handleEditorDisabledChanged(): void;
12
16
  updateDOMAndSelection(savedInnerHTML: string, newCursorPosition: number): void;
13
17
  coalesceDOMElements(): void;
14
18
  private ensureLineNumbers;
@@ -17,5 +21,6 @@ export declare class CodeBlockView {
17
21
  type: 'selection';
18
22
  target: Element;
19
23
  }): boolean;
24
+ destroy(): void;
20
25
  }
21
- export declare const codeBlockNodeView: (node: Node, view: EditorView, getPos: getPosHandler) => CodeBlockView;
26
+ export declare const codeBlockNodeView: (node: Node, view: EditorView, getPos: getPosHandler, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined) => CodeBlockView;
@@ -3,13 +3,15 @@ import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
4
  import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
5
5
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
6
+ import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
6
7
  import type { CodeBlockOptions } from './types';
7
8
  export type CodeBlockPlugin = NextEditorPlugin<'codeBlock', {
8
9
  pluginConfiguration: CodeBlockOptions | undefined;
9
10
  dependencies: [
10
11
  DecorationsPlugin,
11
12
  CompositionPlugin,
12
- OptionalPlugin<AnalyticsPlugin>
13
+ OptionalPlugin<AnalyticsPlugin>,
14
+ OptionalPlugin<EditorDisabledPlugin>
13
15
  ];
14
16
  actions: {
15
17
  insertCodeBlock: (inputMethod: INPUT_METHOD) => Command;
@@ -1,10 +1,62 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import type { EditorAppearance } from '@atlaskit/editor-common/types';
3
+ import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
+ import type { CodeBlockPlugin } from '../index';
4
5
  import type { CodeBlockState } from './main-state';
5
- export declare const createPlugin: ({ useLongPressSelection, getIntl, appearance, allowCompositionInputOverride, }: {
6
+ export declare const createPlugin: ({ useLongPressSelection, getIntl, appearance, allowCompositionInputOverride, api, }: {
6
7
  useLongPressSelection?: boolean | undefined;
7
8
  getIntl: () => IntlShape;
8
9
  appearance: EditorAppearance;
9
10
  allowCompositionInputOverride?: boolean | undefined;
11
+ api?: import("@atlaskit/editor-common/types").PublicPluginAPI<[import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"codeBlock", {
12
+ pluginConfiguration: import("../types").CodeBlockOptions | undefined;
13
+ dependencies: [import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"decorations", {
14
+ sharedState: import("@atlaskit/editor-plugin-decorations").DecorationState;
15
+ actions: {
16
+ hoverDecoration: (nodeType: import("prosemirror-model").NodeType | import("prosemirror-model").NodeType[], add: boolean, className?: string | undefined) => import("@atlaskit/editor-common/types").Command;
17
+ removeDecoration: import("@atlaskit/editor-common/types").Command;
18
+ };
19
+ }, undefined>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"composition", {
20
+ sharedState: import("@atlaskit/editor-plugin-composition").CompositionState;
21
+ }, undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
22
+ pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
23
+ sharedState: {
24
+ createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | null;
25
+ attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
26
+ performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
27
+ };
28
+ dependencies: [import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
29
+ pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
30
+ sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
31
+ }, import("@atlaskit/editor-common/types").FeatureFlags>>];
32
+ actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
33
+ }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorDisabled", {
34
+ sharedState: import("@atlaskit/editor-plugin-editor-disabled").EditorDisabledPluginState;
35
+ }, undefined>>];
36
+ actions: {
37
+ insertCodeBlock: (inputMethod: import("@atlaskit/editor-common/analytics").INPUT_METHOD) => import("@atlaskit/editor-common/types").Command;
38
+ };
39
+ }, import("../types").CodeBlockOptions | undefined>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"decorations", {
40
+ sharedState: import("@atlaskit/editor-plugin-decorations").DecorationState;
41
+ actions: {
42
+ hoverDecoration: (nodeType: import("prosemirror-model").NodeType | import("prosemirror-model").NodeType[], add: boolean, className?: string | undefined) => import("@atlaskit/editor-common/types").Command;
43
+ removeDecoration: import("@atlaskit/editor-common/types").Command;
44
+ };
45
+ }, undefined>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"composition", {
46
+ sharedState: import("@atlaskit/editor-plugin-composition").CompositionState;
47
+ }, undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
48
+ pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
49
+ sharedState: {
50
+ createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | null;
51
+ attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
52
+ performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
53
+ };
54
+ dependencies: [import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
55
+ pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
56
+ sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
57
+ }, import("@atlaskit/editor-common/types").FeatureFlags>>];
58
+ actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
59
+ }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorDisabled", {
60
+ sharedState: import("@atlaskit/editor-plugin-editor-disabled").EditorDisabledPluginState;
61
+ }, undefined>>]> | undefined;
10
62
  }) => SafePlugin<CodeBlockState>;
@@ -1,14 +1,18 @@
1
- import type { getPosHandler, getPosHandlerNode } from '@atlaskit/editor-common/types';
1
+ import type { ExtractInjectionAPI, getPosHandler, getPosHandlerNode } from '@atlaskit/editor-common/types';
2
2
  import type { Node } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { CodeBlockPlugin } from '../plugin';
4
5
  export declare class CodeBlockView {
6
+ private cleanupEditorDisabledListener?;
5
7
  node: Node;
6
8
  dom: HTMLElement;
7
9
  contentDOM: HTMLElement;
8
10
  lineNumberGutter: HTMLElement;
9
11
  getPos: getPosHandlerNode;
10
12
  view: EditorView;
11
- constructor(node: Node, view: EditorView, getPos: getPosHandlerNode);
13
+ api?: ExtractInjectionAPI<CodeBlockPlugin>;
14
+ constructor(node: Node, view: EditorView, getPos: getPosHandlerNode, api?: ExtractInjectionAPI<CodeBlockPlugin>, cleanupEditorDisabledListener?: (() => void) | undefined);
15
+ handleEditorDisabledChanged(): void;
12
16
  updateDOMAndSelection(savedInnerHTML: string, newCursorPosition: number): void;
13
17
  coalesceDOMElements(): void;
14
18
  private ensureLineNumbers;
@@ -17,5 +21,6 @@ export declare class CodeBlockView {
17
21
  type: 'selection';
18
22
  target: Element;
19
23
  }): boolean;
24
+ destroy(): void;
20
25
  }
21
- export declare const codeBlockNodeView: (node: Node, view: EditorView, getPos: getPosHandler) => CodeBlockView;
26
+ export declare const codeBlockNodeView: (node: Node, view: EditorView, getPos: getPosHandler, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined) => CodeBlockView;
@@ -3,13 +3,15 @@ import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
4
  import type { CompositionPlugin } from '@atlaskit/editor-plugin-composition';
5
5
  import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
6
+ import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
6
7
  import type { CodeBlockOptions } from './types';
7
8
  export type CodeBlockPlugin = NextEditorPlugin<'codeBlock', {
8
9
  pluginConfiguration: CodeBlockOptions | undefined;
9
10
  dependencies: [
10
11
  DecorationsPlugin,
11
12
  CompositionPlugin,
12
- OptionalPlugin<AnalyticsPlugin>
13
+ OptionalPlugin<AnalyticsPlugin>,
14
+ OptionalPlugin<EditorDisabledPlugin>
13
15
  ];
14
16
  actions: {
15
17
  insertCodeBlock: (inputMethod: INPUT_METHOD) => Command;
@@ -1,10 +1,77 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import type { EditorAppearance } from '@atlaskit/editor-common/types';
3
+ import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
+ import type { CodeBlockPlugin } from '../index';
4
5
  import type { CodeBlockState } from './main-state';
5
- export declare const createPlugin: ({ useLongPressSelection, getIntl, appearance, allowCompositionInputOverride, }: {
6
+ export declare const createPlugin: ({ useLongPressSelection, getIntl, appearance, allowCompositionInputOverride, api, }: {
6
7
  useLongPressSelection?: boolean | undefined;
7
8
  getIntl: () => IntlShape;
8
9
  appearance: EditorAppearance;
9
10
  allowCompositionInputOverride?: boolean | undefined;
11
+ api?: import("@atlaskit/editor-common/types").PublicPluginAPI<[
12
+ import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"codeBlock", {
13
+ pluginConfiguration: import("../types").CodeBlockOptions | 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("@atlaskit/analytics-next").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
+ }, undefined>>
43
+ ];
44
+ actions: {
45
+ insertCodeBlock: (inputMethod: import("@atlaskit/editor-common/analytics").INPUT_METHOD) => import("@atlaskit/editor-common/types").Command;
46
+ };
47
+ }, import("../types").CodeBlockOptions | undefined>,
48
+ import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"decorations", {
49
+ sharedState: import("@atlaskit/editor-plugin-decorations").DecorationState;
50
+ actions: {
51
+ hoverDecoration: (nodeType: import("prosemirror-model").NodeType | import("prosemirror-model").NodeType[], add: boolean, className?: string | undefined) => import("@atlaskit/editor-common/types").Command;
52
+ removeDecoration: import("@atlaskit/editor-common/types").Command;
53
+ };
54
+ }, undefined>,
55
+ import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"composition", {
56
+ sharedState: import("@atlaskit/editor-plugin-composition").CompositionState;
57
+ }, undefined>,
58
+ import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
59
+ pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
60
+ sharedState: {
61
+ createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | null;
62
+ attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
63
+ performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
64
+ };
65
+ dependencies: [
66
+ import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
67
+ pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
68
+ sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
69
+ }, import("@atlaskit/editor-common/types").FeatureFlags>>
70
+ ];
71
+ actions: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI;
72
+ }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>,
73
+ import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorDisabled", {
74
+ sharedState: import("@atlaskit/editor-plugin-editor-disabled").EditorDisabledPluginState;
75
+ }, undefined>>
76
+ ]> | undefined;
10
77
  }) => SafePlugin<CodeBlockState>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "Code block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,14 +33,16 @@
33
33
  ".": "./src/index.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/adf-schema": "^35.9.0",
36
+ "@atlaskit/adf-schema": "^35.9.2",
37
37
  "@atlaskit/code": "^15.1.0",
38
- "@atlaskit/editor-common": "^78.28.0",
38
+ "@atlaskit/editor-common": "^78.30.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
40
40
  "@atlaskit/editor-plugin-composition": "^1.0.0",
41
41
  "@atlaskit/editor-plugin-decorations": "^1.0.0",
42
+ "@atlaskit/editor-plugin-editor-disabled": "^1.0.0",
42
43
  "@atlaskit/editor-prosemirror": "3.0.0",
43
44
  "@atlaskit/icon": "^22.1.0",
45
+ "@atlaskit/platform-feature-flags": "^0.2.0",
44
46
  "@atlaskit/prosemirror-input-rules": "^3.0.0",
45
47
  "@babel/runtime": "^7.0.0",
46
48
  "raf-schd": "^4.0.3"
@@ -91,5 +93,10 @@
91
93
  "no-unused-dependencies": {
92
94
  "checkDevDependencies": true
93
95
  }
96
+ },
97
+ "platform-feature-flags": {
98
+ "platform.editor.live-view.disable-editing-in-view-mode_fi1rx": {
99
+ "type": "boolean"
100
+ }
94
101
  }
95
102
  }