@atlaskit/editor-plugin-block-type 3.14.8 → 3.14.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,15 @@
1
1
  # @atlaskit/editor-plugin-block-type
2
2
 
3
+ ## 3.14.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#141778](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/141778)
8
+ [`1c6f578277694`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1c6f578277694) -
9
+ ED-24870 & ED-24864 - Add the logic to gate the nested media in quotes functionality behind the
10
+ nest-media-and-codeblock-in-quote experiment. Also adjust the logic so the nested expands are now
11
+ behind the nested-expand-in-expand experiment.
12
+
3
13
  ## 3.14.8
4
14
 
5
15
  ### Patch Changes
@@ -4,12 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.pluginKey = exports.createPlugin = void 0;
7
+ exports.pluginKey = exports.handleBlockQuoteDND = exports.createPlugin = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _browser = require("@atlaskit/editor-common/browser");
11
11
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
12
  var _state = require("@atlaskit/editor-prosemirror/state");
13
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
13
14
  var _blockTypes = require("../block-types");
14
15
  var _commands = require("../commands");
15
16
  var _consts = require("../consts");
@@ -145,7 +146,44 @@ var createPlugin = exports.createPlugin = function createPlugin(editorAPI, dispa
145
146
  altKeyLocation = 0;
146
147
  }
147
148
  return false;
149
+ },
150
+ handleDrop: function handleDrop(view, event, slice, moved) {
151
+ return handleBlockQuoteDND(view, event, slice);
148
152
  }
149
153
  }
150
154
  });
155
+ };
156
+ var handleBlockQuoteDND = exports.handleBlockQuoteDND = function handleBlockQuoteDND(view, event, slice) {
157
+ // Throwaway code for the sake of the expiriment. handleDrop can be removed after experiment complete.
158
+ if ((0, _experiments.editorExperiment)('nest-media-and-codeblock-in-quote', false)) {
159
+ var sliceContainsCodeBlockOrMedia = false;
160
+ slice.content.forEach(function (node) {
161
+ if (node.type === view.state.schema.nodes.codeBlock) {
162
+ sliceContainsCodeBlockOrMedia = true;
163
+ } else if (node.type === view.state.schema.nodes.mediaSingle) {
164
+ sliceContainsCodeBlockOrMedia = true;
165
+ } else if (node.type === view.state.schema.nodes.mediaGroup) {
166
+ sliceContainsCodeBlockOrMedia = true;
167
+ }
168
+ });
169
+ if (sliceContainsCodeBlockOrMedia) {
170
+ var state = view.state;
171
+ var schema = state.schema;
172
+ var dropPos = view.posAtCoords({
173
+ left: event.clientX,
174
+ top: event.clientY
175
+ });
176
+ if (!dropPos) {
177
+ return false;
178
+ }
179
+ var resolvedPos = state.doc.resolve(dropPos.pos);
180
+ var dropLocationNodeType = resolvedPos.node().type;
181
+ var dropLocationParentNodeType = resolvedPos.depth > 0 ? resolvedPos.node(resolvedPos.depth - 1).type : dropLocationNodeType;
182
+ if (dropLocationNodeType === schema.nodes.blockquote || dropLocationParentNodeType === schema.nodes.blockquote) {
183
+ event.preventDefault();
184
+ return true;
185
+ }
186
+ }
187
+ }
188
+ return false;
151
189
  };
@@ -2,6 +2,7 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { browser } from '@atlaskit/editor-common/browser';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
6
  import { BLOCK_QUOTE, CODE_BLOCK, HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6, HEADINGS_BY_LEVEL, NORMAL_TEXT, OTHER, PANEL, TEXT_BLOCK_TYPES, WRAPPER_BLOCK_TYPES } from '../block-types';
6
7
  import { setHeadingWithAnalytics, setNormalTextWithAnalytics } from '../commands';
7
8
  import { HEADING_KEYS } from '../consts';
@@ -133,7 +134,48 @@ export const createPlugin = (editorAPI, dispatch, lastNodeMustBeParagraph) => {
133
134
  altKeyLocation = 0;
134
135
  }
135
136
  return false;
137
+ },
138
+ handleDrop(view, event, slice, moved) {
139
+ return handleBlockQuoteDND(view, event, slice);
136
140
  }
137
141
  }
138
142
  });
143
+ };
144
+ export const handleBlockQuoteDND = (view, event, slice) => {
145
+ // Throwaway code for the sake of the expiriment. handleDrop can be removed after experiment complete.
146
+ if (editorExperiment('nest-media-and-codeblock-in-quote', false)) {
147
+ let sliceContainsCodeBlockOrMedia = false;
148
+ slice.content.forEach(node => {
149
+ if (node.type === view.state.schema.nodes.codeBlock) {
150
+ sliceContainsCodeBlockOrMedia = true;
151
+ } else if (node.type === view.state.schema.nodes.mediaSingle) {
152
+ sliceContainsCodeBlockOrMedia = true;
153
+ } else if (node.type === view.state.schema.nodes.mediaGroup) {
154
+ sliceContainsCodeBlockOrMedia = true;
155
+ }
156
+ });
157
+ if (sliceContainsCodeBlockOrMedia) {
158
+ const {
159
+ state
160
+ } = view;
161
+ const {
162
+ schema
163
+ } = state;
164
+ const dropPos = view.posAtCoords({
165
+ left: event.clientX,
166
+ top: event.clientY
167
+ });
168
+ if (!dropPos) {
169
+ return false;
170
+ }
171
+ const resolvedPos = state.doc.resolve(dropPos.pos);
172
+ const dropLocationNodeType = resolvedPos.node().type;
173
+ const dropLocationParentNodeType = resolvedPos.depth > 0 ? resolvedPos.node(resolvedPos.depth - 1).type : dropLocationNodeType;
174
+ if (dropLocationNodeType === schema.nodes.blockquote || dropLocationParentNodeType === schema.nodes.blockquote) {
175
+ event.preventDefault();
176
+ return true;
177
+ }
178
+ }
179
+ }
180
+ return false;
139
181
  };
@@ -5,6 +5,7 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
5
  import { browser } from '@atlaskit/editor-common/browser';
6
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
9
  import { BLOCK_QUOTE, CODE_BLOCK, HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6, HEADINGS_BY_LEVEL, NORMAL_TEXT, OTHER, PANEL, TEXT_BLOCK_TYPES, WRAPPER_BLOCK_TYPES } from '../block-types';
9
10
  import { setHeadingWithAnalytics, setNormalTextWithAnalytics } from '../commands';
10
11
  import { HEADING_KEYS } from '../consts';
@@ -138,7 +139,44 @@ export var createPlugin = function createPlugin(editorAPI, dispatch, lastNodeMus
138
139
  altKeyLocation = 0;
139
140
  }
140
141
  return false;
142
+ },
143
+ handleDrop: function handleDrop(view, event, slice, moved) {
144
+ return handleBlockQuoteDND(view, event, slice);
141
145
  }
142
146
  }
143
147
  });
148
+ };
149
+ export var handleBlockQuoteDND = function handleBlockQuoteDND(view, event, slice) {
150
+ // Throwaway code for the sake of the expiriment. handleDrop can be removed after experiment complete.
151
+ if (editorExperiment('nest-media-and-codeblock-in-quote', false)) {
152
+ var sliceContainsCodeBlockOrMedia = false;
153
+ slice.content.forEach(function (node) {
154
+ if (node.type === view.state.schema.nodes.codeBlock) {
155
+ sliceContainsCodeBlockOrMedia = true;
156
+ } else if (node.type === view.state.schema.nodes.mediaSingle) {
157
+ sliceContainsCodeBlockOrMedia = true;
158
+ } else if (node.type === view.state.schema.nodes.mediaGroup) {
159
+ sliceContainsCodeBlockOrMedia = true;
160
+ }
161
+ });
162
+ if (sliceContainsCodeBlockOrMedia) {
163
+ var state = view.state;
164
+ var schema = state.schema;
165
+ var dropPos = view.posAtCoords({
166
+ left: event.clientX,
167
+ top: event.clientY
168
+ });
169
+ if (!dropPos) {
170
+ return false;
171
+ }
172
+ var resolvedPos = state.doc.resolve(dropPos.pos);
173
+ var dropLocationNodeType = resolvedPos.node().type;
174
+ var dropLocationParentNodeType = resolvedPos.depth > 0 ? resolvedPos.node(resolvedPos.depth - 1).type : dropLocationNodeType;
175
+ if (dropLocationNodeType === schema.nodes.blockquote || dropLocationParentNodeType === schema.nodes.blockquote) {
176
+ event.preventDefault();
177
+ return true;
178
+ }
179
+ }
180
+ }
181
+ return false;
144
182
  };
@@ -1,6 +1,8 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { Slice } from '@atlaskit/editor-prosemirror/model';
3
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
6
  import type { BlockTypePlugin } from '../index';
5
7
  import type { BlockType } from '../types';
6
8
  export type BlockTypeState = {
@@ -16,3 +18,4 @@ export declare const createPlugin: (editorAPI: ExtractInjectionAPI<BlockTypePlug
16
18
  availableBlockTypes: BlockType[];
17
19
  availableWrapperBlockTypes: BlockType[];
18
20
  }>;
21
+ export declare const handleBlockQuoteDND: (view: EditorView, event: DragEvent, slice: Slice) => boolean;
@@ -1,6 +1,8 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { Slice } from '@atlaskit/editor-prosemirror/model';
3
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
6
  import type { BlockTypePlugin } from '../index';
5
7
  import type { BlockType } from '../types';
6
8
  export type BlockTypeState = {
@@ -16,3 +18,4 @@ export declare const createPlugin: (editorAPI: ExtractInjectionAPI<BlockTypePlug
16
18
  availableBlockTypes: BlockType[];
17
19
  availableWrapperBlockTypes: BlockType[];
18
20
  }>;
21
+ export declare const handleBlockQuoteDND: (view: EditorView, event: DragEvent, slice: Slice) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-type",
3
- "version": "3.14.8",
3
+ "version": "3.14.9",
4
4
  "description": "BlockType plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^40.9.0",
37
- "@atlaskit/editor-common": "^89.2.0",
37
+ "@atlaskit/editor-common": "^89.3.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
39
39
  "@atlaskit/editor-plugin-primary-toolbar": "^2.0.0",
40
40
  "@atlaskit/editor-prosemirror": "6.0.0",