@atlaskit/editor-plugin-block-type 4.0.3 → 4.0.5

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-block-type
2
2
 
3
+ ## 4.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 4.0.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [#165097](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/165097)
14
+ [`0bca145c96b65`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0bca145c96b65) -
15
+ [ux] Adds test styles options to the Selection toolbar under Contextual toolbar experiment
16
+ - Updated dependencies
17
+
3
18
  ## 4.0.3
4
19
 
5
20
  ### Patch Changes
@@ -20,11 +20,13 @@ var _messages = require("@atlaskit/editor-common/messages");
20
20
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
21
21
  var _types = require("@atlaskit/editor-common/types");
22
22
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
23
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
23
24
  var _commands = require("./pm-plugins/commands");
24
25
  var _blockType = require("./pm-plugins/commands/block-type");
25
26
  var _inputRule = _interopRequireDefault(require("./pm-plugins/input-rule"));
26
27
  var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
27
28
  var _main = require("./pm-plugins/main");
29
+ var _FloatingToolbarComponent = require("./pm-plugins/ui/FloatingToolbarComponent");
28
30
  var _PrimaryToolbarComponent = require("./pm-plugins/ui/PrimaryToolbarComponent");
29
31
  var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editorAnalyticsApi) {
30
32
  var formatMessage = _ref.formatMessage;
@@ -201,6 +203,28 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
201
203
  },
202
204
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
203
205
  pluginsOptions: {
206
+ selectionToolbar: function selectionToolbar() {
207
+ if ((0, _experiments.editorExperiment)('contextual_formatting_toolbar', true)) {
208
+ var toolbarCustom = {
209
+ type: 'custom',
210
+ render: function render(view, _idx, _dispatchAnalyticsEvent) {
211
+ if (!view) {
212
+ return;
213
+ }
214
+ return /*#__PURE__*/_react.default.createElement(_FloatingToolbarComponent.FloatingToolbarComponent, {
215
+ api: api
216
+ });
217
+ },
218
+ fallback: []
219
+ };
220
+ return {
221
+ isToolbarAbove: true,
222
+ items: [toolbarCustom]
223
+ };
224
+ } else {
225
+ return undefined;
226
+ }
227
+ },
204
228
  quickInsert: function quickInsert(intl) {
205
229
  var _api$analytics5, _api$analytics6;
206
230
  var exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.FloatingToolbarComponent = FloatingToolbarComponent;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _analytics = require("@atlaskit/editor-common/analytics");
11
+ var _hooks = require("@atlaskit/editor-common/hooks");
12
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
13
+ var _ToolbarBlockType = _interopRequireDefault(require("./ToolbarBlockType"));
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ var FloatingToolbarSettings = {
17
+ isSmall: true,
18
+ disabled: false,
19
+ isToolbarReducedSpacing: true,
20
+ shouldUseDefaultRole: false
21
+ };
22
+ function FloatingToolbarComponent(_ref) {
23
+ var api = _ref.api;
24
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockType']),
25
+ blockTypeState = _useSharedPluginState.blockTypeState;
26
+ (0, _react.useEffect)(function () {
27
+ (0, _experiments.editorExperiment)('contextual_formatting_toolbar', true, {
28
+ exposure: true
29
+ });
30
+ }, []);
31
+ var boundSetBlockType = (0, _react.useCallback)(function (name) {
32
+ var _api$core, _api$blockType;
33
+ return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, _analytics.INPUT_METHOD.FLOATING_TB));
34
+ }, [api]);
35
+ return /*#__PURE__*/_react.default.createElement(_ToolbarBlockType.default, {
36
+ isSmall: FloatingToolbarSettings.isSmall,
37
+ isDisabled: FloatingToolbarSettings.disabled,
38
+ isReducedSpacing: FloatingToolbarSettings.isToolbarReducedSpacing,
39
+ setTextLevel: boundSetBlockType,
40
+ pluginState: blockTypeState,
41
+ shouldUseDefaultRole: FloatingToolbarSettings.shouldUseDefaultRole,
42
+ api: api
43
+ });
44
+ }
@@ -6,11 +6,13 @@ import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages'
6
6
  import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
7
7
  import { ToolbarSize } from '@atlaskit/editor-common/types';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
10
  import { setBlockTypeWithAnalytics } from './pm-plugins/commands';
10
11
  import { insertBlockQuoteWithAnalytics } from './pm-plugins/commands/block-type';
11
12
  import inputRulePlugin from './pm-plugins/input-rule';
12
13
  import keymapPlugin from './pm-plugins/keymap';
13
14
  import { createPlugin, pluginKey } from './pm-plugins/main';
15
+ import { FloatingToolbarComponent } from './pm-plugins/ui/FloatingToolbarComponent';
14
16
  import { PrimaryToolbarComponent } from './pm-plugins/ui/PrimaryToolbarComponent';
15
17
  const headingPluginOptions = ({
16
18
  formatMessage
@@ -186,6 +188,28 @@ const blockTypePlugin = ({
186
188
  },
187
189
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
188
190
  pluginsOptions: {
191
+ selectionToolbar: () => {
192
+ if (editorExperiment('contextual_formatting_toolbar', true)) {
193
+ const toolbarCustom = {
194
+ type: 'custom',
195
+ render: (view, _idx, _dispatchAnalyticsEvent) => {
196
+ if (!view) {
197
+ return;
198
+ }
199
+ return /*#__PURE__*/React.createElement(FloatingToolbarComponent, {
200
+ api: api
201
+ });
202
+ },
203
+ fallback: []
204
+ };
205
+ return {
206
+ isToolbarAbove: true,
207
+ items: [toolbarCustom]
208
+ };
209
+ } else {
210
+ return undefined;
211
+ }
212
+ },
189
213
  quickInsert: intl => {
190
214
  var _api$analytics5, _api$analytics6;
191
215
  const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
@@ -0,0 +1,36 @@
1
+ import React, { useCallback, useEffect } from 'react';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
+ import ToolbarBlockType from './ToolbarBlockType';
6
+ const FloatingToolbarSettings = {
7
+ isSmall: true,
8
+ disabled: false,
9
+ isToolbarReducedSpacing: true,
10
+ shouldUseDefaultRole: false
11
+ };
12
+ export function FloatingToolbarComponent({
13
+ api
14
+ }) {
15
+ const {
16
+ blockTypeState
17
+ } = useSharedPluginState(api, ['blockType']);
18
+ useEffect(() => {
19
+ editorExperiment('contextual_formatting_toolbar', true, {
20
+ exposure: true
21
+ });
22
+ }, []);
23
+ const boundSetBlockType = useCallback(name => {
24
+ var _api$core, _api$blockType, _api$blockType$comman;
25
+ return api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : (_api$blockType$comman = _api$blockType.commands) === null || _api$blockType$comman === void 0 ? void 0 : _api$blockType$comman.setTextLevel(name, INPUT_METHOD.FLOATING_TB));
26
+ }, [api]);
27
+ return /*#__PURE__*/React.createElement(ToolbarBlockType, {
28
+ isSmall: FloatingToolbarSettings.isSmall,
29
+ isDisabled: FloatingToolbarSettings.disabled,
30
+ isReducedSpacing: FloatingToolbarSettings.isToolbarReducedSpacing,
31
+ setTextLevel: boundSetBlockType,
32
+ pluginState: blockTypeState,
33
+ shouldUseDefaultRole: FloatingToolbarSettings.shouldUseDefaultRole,
34
+ api: api
35
+ });
36
+ }
@@ -7,11 +7,13 @@ import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages'
7
7
  import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
8
8
  import { ToolbarSize } from '@atlaskit/editor-common/types';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
11
  import { setBlockTypeWithAnalytics } from './pm-plugins/commands';
11
12
  import { insertBlockQuoteWithAnalytics } from './pm-plugins/commands/block-type';
12
13
  import inputRulePlugin from './pm-plugins/input-rule';
13
14
  import keymapPlugin from './pm-plugins/keymap';
14
15
  import { createPlugin, pluginKey } from './pm-plugins/main';
16
+ import { FloatingToolbarComponent } from './pm-plugins/ui/FloatingToolbarComponent';
15
17
  import { PrimaryToolbarComponent } from './pm-plugins/ui/PrimaryToolbarComponent';
16
18
  var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editorAnalyticsApi) {
17
19
  var formatMessage = _ref.formatMessage;
@@ -188,6 +190,28 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
188
190
  },
189
191
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
190
192
  pluginsOptions: {
193
+ selectionToolbar: function selectionToolbar() {
194
+ if (editorExperiment('contextual_formatting_toolbar', true)) {
195
+ var toolbarCustom = {
196
+ type: 'custom',
197
+ render: function render(view, _idx, _dispatchAnalyticsEvent) {
198
+ if (!view) {
199
+ return;
200
+ }
201
+ return /*#__PURE__*/React.createElement(FloatingToolbarComponent, {
202
+ api: api
203
+ });
204
+ },
205
+ fallback: []
206
+ };
207
+ return {
208
+ isToolbarAbove: true,
209
+ items: [toolbarCustom]
210
+ };
211
+ } else {
212
+ return undefined;
213
+ }
214
+ },
191
215
  quickInsert: function quickInsert(intl) {
192
216
  var _api$analytics5, _api$analytics6;
193
217
  var exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
@@ -0,0 +1,34 @@
1
+ import React, { useCallback, useEffect } from 'react';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
+ import ToolbarBlockType from './ToolbarBlockType';
6
+ var FloatingToolbarSettings = {
7
+ isSmall: true,
8
+ disabled: false,
9
+ isToolbarReducedSpacing: true,
10
+ shouldUseDefaultRole: false
11
+ };
12
+ export function FloatingToolbarComponent(_ref) {
13
+ var api = _ref.api;
14
+ var _useSharedPluginState = useSharedPluginState(api, ['blockType']),
15
+ blockTypeState = _useSharedPluginState.blockTypeState;
16
+ useEffect(function () {
17
+ editorExperiment('contextual_formatting_toolbar', true, {
18
+ exposure: true
19
+ });
20
+ }, []);
21
+ var boundSetBlockType = useCallback(function (name) {
22
+ var _api$core, _api$blockType;
23
+ return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, INPUT_METHOD.FLOATING_TB));
24
+ }, [api]);
25
+ return /*#__PURE__*/React.createElement(ToolbarBlockType, {
26
+ isSmall: FloatingToolbarSettings.isSmall,
27
+ isDisabled: FloatingToolbarSettings.disabled,
28
+ isReducedSpacing: FloatingToolbarSettings.isToolbarReducedSpacing,
29
+ setTextLevel: boundSetBlockType,
30
+ pluginState: blockTypeState,
31
+ shouldUseDefaultRole: FloatingToolbarSettings.shouldUseDefaultRole,
32
+ api: api
33
+ });
34
+ }
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { BlockTypePlugin } from '../../blockTypePluginType';
4
+ interface FloatingToolbarComponentProps {
5
+ api: ExtractInjectionAPI<BlockTypePlugin> | undefined;
6
+ }
7
+ export declare function FloatingToolbarComponent({ api }: FloatingToolbarComponentProps): JSX.Element;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { BlockTypePlugin } from '../../blockTypePluginType';
4
+ interface FloatingToolbarComponentProps {
5
+ api: ExtractInjectionAPI<BlockTypePlugin> | undefined;
6
+ }
7
+ export declare function FloatingToolbarComponent({ api }: FloatingToolbarComponentProps): JSX.Element;
8
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-type",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
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": "^44.2.0",
37
- "@atlaskit/editor-common": "^94.12.0",
37
+ "@atlaskit/editor-common": "^95.0.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
39
39
  "@atlaskit/editor-plugin-primary-toolbar": "^2.0.0",
40
40
  "@atlaskit/editor-prosemirror": "6.0.0",
@@ -42,11 +42,11 @@
42
42
  "@atlaskit/editor-tables": "^2.8.0",
43
43
  "@atlaskit/icon": "^22.24.0",
44
44
  "@atlaskit/platform-feature-flags": "^0.3.0",
45
- "@atlaskit/primitives": "^13.0.0",
45
+ "@atlaskit/primitives": "^13.2.0",
46
46
  "@atlaskit/prosemirror-input-rules": "^3.2.0",
47
47
  "@atlaskit/theme": "^14.0.0",
48
- "@atlaskit/tmp-editor-statsig": "^2.11.0",
49
- "@atlaskit/tokens": "^2.1.0",
48
+ "@atlaskit/tmp-editor-statsig": "^2.19.0",
49
+ "@atlaskit/tokens": "^2.3.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@emotion/react": "^11.7.1"
52
52
  },
@@ -58,7 +58,7 @@
58
58
  "devDependencies": {
59
59
  "@af/visual-regression": "*",
60
60
  "@atlaskit/analytics-next": "^10.1.0",
61
- "@atlaskit/editor-plugin-quick-insert": "^1.6.0",
61
+ "@atlaskit/editor-plugin-quick-insert": "^1.7.0",
62
62
  "@atlaskit/editor-plugin-type-ahead": "^1.10.0",
63
63
  "@atlaskit/ssr": "*",
64
64
  "@atlaskit/visual-regression": "*",