@atlaskit/editor-core 189.1.11 → 189.1.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 +7 -0
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/types.d.ts +1 -1
- package/dist/types/types/editor-props.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +1 -1
- package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
- package/package.json +2 -1
- package/report.api.md +1 -10
- package/tmp/api-report-tmp.d.ts +1 -10
- package/dist/cjs/plugins/layout/actions.js +0 -345
- package/dist/cjs/plugins/layout/index.js +0 -91
- package/dist/cjs/plugins/layout/pm-plugins/main.js +0 -148
- package/dist/cjs/plugins/layout/pm-plugins/plugin-key.js +0 -8
- package/dist/cjs/plugins/layout/pm-plugins/types.js +0 -5
- package/dist/cjs/plugins/layout/toolbar-messages.js +0 -39
- package/dist/cjs/plugins/layout/toolbar.js +0 -116
- package/dist/cjs/plugins/layout/types.js +0 -5
- package/dist/es2019/plugins/layout/actions.js +0 -328
- package/dist/es2019/plugins/layout/index.js +0 -75
- package/dist/es2019/plugins/layout/pm-plugins/main.js +0 -142
- package/dist/es2019/plugins/layout/pm-plugins/plugin-key.js +0 -2
- package/dist/es2019/plugins/layout/pm-plugins/types.js +0 -1
- package/dist/es2019/plugins/layout/toolbar-messages.js +0 -33
- package/dist/es2019/plugins/layout/toolbar.js +0 -101
- package/dist/es2019/plugins/layout/types.js +0 -1
- package/dist/esm/plugins/layout/actions.js +0 -336
- package/dist/esm/plugins/layout/index.js +0 -79
- package/dist/esm/plugins/layout/pm-plugins/main.js +0 -141
- package/dist/esm/plugins/layout/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/layout/pm-plugins/types.js +0 -1
- package/dist/esm/plugins/layout/toolbar-messages.js +0 -33
- package/dist/esm/plugins/layout/toolbar.js +0 -109
- package/dist/esm/plugins/layout/types.js +0 -1
- package/dist/types/plugins/layout/actions.d.ts +0 -22
- package/dist/types/plugins/layout/index.d.ts +0 -15
- package/dist/types/plugins/layout/pm-plugins/main.d.ts +0 -6
- package/dist/types/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types/plugins/layout/pm-plugins/types.d.ts +0 -14
- package/dist/types/plugins/layout/toolbar-messages.d.ts +0 -32
- package/dist/types/plugins/layout/toolbar.d.ts +0 -6
- package/dist/types/plugins/layout/types.d.ts +0 -13
- package/dist/types-ts4.5/plugins/layout/actions.d.ts +0 -22
- package/dist/types-ts4.5/plugins/layout/index.d.ts +0 -18
- package/dist/types-ts4.5/plugins/layout/pm-plugins/main.d.ts +0 -6
- package/dist/types-ts4.5/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/layout/pm-plugins/types.d.ts +0 -14
- package/dist/types-ts4.5/plugins/layout/toolbar-messages.d.ts +0 -32
- package/dist/types-ts4.5/plugins/layout/toolbar.d.ts +0 -6
- package/dist/types-ts4.5/plugins/layout/types.d.ts +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 189.1.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#42505](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42505) [`48e5f1efdde`](https://bitbucket.org/atlassian/atlassian-frontend/commits/48e5f1efdde) - Extract layout plugin into new package @atlaskit/editor-plugin-layout.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 189.1.11
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -125,12 +125,6 @@ Object.defineProperty(exports, "jiraIssuePlugin", {
|
|
|
125
125
|
return _jiraIssue.default;
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
|
-
Object.defineProperty(exports, "layoutPlugin", {
|
|
129
|
-
enumerable: true,
|
|
130
|
-
get: function get() {
|
|
131
|
-
return _layout.layoutPlugin;
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
128
|
Object.defineProperty(exports, "macroPlugin", {
|
|
135
129
|
enumerable: true,
|
|
136
130
|
get: function get() {
|
|
@@ -203,7 +197,6 @@ var _collabEdit = _interopRequireDefault(require("./collab-edit"));
|
|
|
203
197
|
var _extension = _interopRequireDefault(require("./extension"));
|
|
204
198
|
var _insertBlock = _interopRequireDefault(require("./insert-block"));
|
|
205
199
|
var _jiraIssue = _interopRequireDefault(require("./jira-issue"));
|
|
206
|
-
var _layout = require("./layout");
|
|
207
200
|
var _toolbarListsIndentation = _interopRequireDefault(require("./toolbar-lists-indentation"));
|
|
208
201
|
var _macro = _interopRequireDefault(require("./macro"));
|
|
209
202
|
var _maxContentSize = _interopRequireDefault(require("./max-content-size"));
|
|
@@ -26,6 +26,7 @@ var _editorPluginGuideline = require("@atlaskit/editor-plugin-guideline");
|
|
|
26
26
|
var _editorPluginContextPanel = require("@atlaskit/editor-plugin-context-panel");
|
|
27
27
|
var _editorPluginGrid = require("@atlaskit/editor-plugin-grid");
|
|
28
28
|
var _editorPluginCard = require("@atlaskit/editor-plugin-card");
|
|
29
|
+
var _editorPluginLayout = require("@atlaskit/editor-plugin-layout");
|
|
29
30
|
var _editorPluginTable = require("@atlaskit/editor-plugin-table");
|
|
30
31
|
var _editorPluginContentInsertion = require("@atlaskit/editor-plugin-content-insertion");
|
|
31
32
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
@@ -293,7 +294,7 @@ function createUniversalPreset(appearance, props, featureFlags, prevAppearance,
|
|
|
293
294
|
return builder.add([plugin, options]);
|
|
294
295
|
}
|
|
295
296
|
return builder;
|
|
296
|
-
}).maybeAdd(
|
|
297
|
+
}).maybeAdd(_editorPluginLayout.layoutPlugin, function (plugin, builder) {
|
|
297
298
|
if (props.allowLayouts) {
|
|
298
299
|
var layoutOptions = (0, _typeof2.default)(props.allowLayouts) === 'object' ? props.allowLayouts : {};
|
|
299
300
|
return builder.add([plugin, _objectSpread(_objectSpread({}, layoutOptions), {}, {
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = exports.name = "@atlaskit/editor-core";
|
|
8
|
-
var version = exports.version = "189.1.
|
|
8
|
+
var version = exports.version = "189.1.12";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
|
@@ -4,7 +4,6 @@ export { default as collabEditPlugin } from './collab-edit';
|
|
|
4
4
|
export { default as extensionPlugin } from './extension';
|
|
5
5
|
export { default as insertBlockPlugin } from './insert-block';
|
|
6
6
|
export { default as jiraIssuePlugin } from './jira-issue';
|
|
7
|
-
export { layoutPlugin } from './layout';
|
|
8
7
|
export { default as toolbarListsIndentationPlugin } from './toolbar-lists-indentation';
|
|
9
8
|
export { default as macroPlugin } from './macro';
|
|
10
9
|
export { default as maxContentSizePlugin } from './max-content-size';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, insertBlockPlugin, jiraIssuePlugin,
|
|
1
|
+
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, insertBlockPlugin, jiraIssuePlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, panelPlugin, placeholderTextPlugin, tasksAndDecisionsPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, expandPlugin, isExpandInsertionEnabled, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../plugins';
|
|
2
2
|
import { textColorPlugin } from '@atlaskit/editor-plugin-text-color';
|
|
3
3
|
import { historyPlugin } from '@atlaskit/editor-plugin-history';
|
|
4
4
|
import { statusPlugin } from '@atlaskit/editor-plugin-status';
|
|
@@ -17,6 +17,7 @@ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
|
17
17
|
import { contextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
|
|
18
18
|
import { gridPlugin } from '@atlaskit/editor-plugin-grid';
|
|
19
19
|
import { cardPlugin } from '@atlaskit/editor-plugin-card';
|
|
20
|
+
import { layoutPlugin } from '@atlaskit/editor-plugin-layout';
|
|
20
21
|
import { tablesPlugin } from '@atlaskit/editor-plugin-table';
|
|
21
22
|
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
22
23
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
@@ -4,7 +4,6 @@ export { default as collabEditPlugin } from './collab-edit';
|
|
|
4
4
|
export { default as extensionPlugin } from './extension';
|
|
5
5
|
export { default as insertBlockPlugin } from './insert-block';
|
|
6
6
|
export { default as jiraIssuePlugin } from './jira-issue';
|
|
7
|
-
export { layoutPlugin } from './layout';
|
|
8
7
|
export { default as toolbarListsIndentationPlugin } from './toolbar-lists-indentation';
|
|
9
8
|
export { default as macroPlugin } from './macro';
|
|
10
9
|
export { default as maxContentSizePlugin } from './max-content-size';
|
|
@@ -2,7 +2,7 @@ import _typeof from "@babel/runtime/helpers/typeof";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, insertBlockPlugin, jiraIssuePlugin,
|
|
5
|
+
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, insertBlockPlugin, jiraIssuePlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, panelPlugin, placeholderTextPlugin, tasksAndDecisionsPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, expandPlugin, isExpandInsertionEnabled, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../plugins';
|
|
6
6
|
import { textColorPlugin } from '@atlaskit/editor-plugin-text-color';
|
|
7
7
|
import { historyPlugin } from '@atlaskit/editor-plugin-history';
|
|
8
8
|
import { statusPlugin } from '@atlaskit/editor-plugin-status';
|
|
@@ -21,6 +21,7 @@ import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
|
21
21
|
import { contextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
|
|
22
22
|
import { gridPlugin } from '@atlaskit/editor-plugin-grid';
|
|
23
23
|
import { cardPlugin } from '@atlaskit/editor-plugin-card';
|
|
24
|
+
import { layoutPlugin } from '@atlaskit/editor-plugin-layout';
|
|
24
25
|
import { tablesPlugin } from '@atlaskit/editor-plugin-table';
|
|
25
26
|
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
26
27
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
@@ -4,7 +4,6 @@ export { default as collabEditPlugin } from './collab-edit';
|
|
|
4
4
|
export { default as extensionPlugin } from './extension';
|
|
5
5
|
export { default as insertBlockPlugin } from './insert-block';
|
|
6
6
|
export { default as jiraIssuePlugin } from './jira-issue';
|
|
7
|
-
export { layoutPlugin } from './layout';
|
|
8
7
|
export { default as toolbarListsIndentationPlugin } from './toolbar-lists-indentation';
|
|
9
8
|
export { default as macroPlugin } from './macro';
|
|
10
9
|
export { default as maxContentSizePlugin } from './max-content-size';
|
|
@@ -10,7 +10,7 @@ import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
|
|
|
10
10
|
import type { BlockTypePlugin } from '@atlaskit/editor-plugin-block-type';
|
|
11
11
|
import type { CodeBlockPlugin } from '../code-block';
|
|
12
12
|
import type { PanelPlugin } from '../panel';
|
|
13
|
-
import type { LayoutPlugin } from '
|
|
13
|
+
import type { LayoutPlugin } from '@atlaskit/editor-plugin-layout';
|
|
14
14
|
import type { RulePlugin } from '@atlaskit/editor-plugin-rule';
|
|
15
15
|
import type { MediaPlugin } from '@atlaskit/editor-plugin-media';
|
|
16
16
|
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
@@ -18,7 +18,7 @@ import type { CodeBlockOptions } from '../plugins/code-block/types';
|
|
|
18
18
|
import type { CollabEditOptions } from '@atlaskit/editor-common/collab';
|
|
19
19
|
import type { DatePluginConfig } from '@atlaskit/editor-plugin-date';
|
|
20
20
|
import type { FindReplaceOptions } from '../plugins/find-replace/types';
|
|
21
|
-
import type { LayoutPluginOptions } from '
|
|
21
|
+
import type { LayoutPluginOptions } from '@atlaskit/editor-plugin-layout';
|
|
22
22
|
import type { MediaOptions, MediaState } from '@atlaskit/editor-plugin-media/types';
|
|
23
23
|
import type { MentionPluginConfig } from '@atlaskit/editor-plugin-mentions';
|
|
24
24
|
import type { PanelPluginConfig } from '../plugins/panel/types';
|
|
@@ -4,7 +4,6 @@ export { default as collabEditPlugin } from './collab-edit';
|
|
|
4
4
|
export { default as extensionPlugin } from './extension';
|
|
5
5
|
export { default as insertBlockPlugin } from './insert-block';
|
|
6
6
|
export { default as jiraIssuePlugin } from './jira-issue';
|
|
7
|
-
export { layoutPlugin } from './layout';
|
|
8
7
|
export { default as toolbarListsIndentationPlugin } from './toolbar-lists-indentation';
|
|
9
8
|
export { default as macroPlugin } from './macro';
|
|
10
9
|
export { default as maxContentSizePlugin } from './max-content-size';
|
|
@@ -10,7 +10,7 @@ import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
|
|
|
10
10
|
import type { BlockTypePlugin } from '@atlaskit/editor-plugin-block-type';
|
|
11
11
|
import type { CodeBlockPlugin } from '../code-block';
|
|
12
12
|
import type { PanelPlugin } from '../panel';
|
|
13
|
-
import type { LayoutPlugin } from '
|
|
13
|
+
import type { LayoutPlugin } from '@atlaskit/editor-plugin-layout';
|
|
14
14
|
import type { RulePlugin } from '@atlaskit/editor-plugin-rule';
|
|
15
15
|
import type { MediaPlugin } from '@atlaskit/editor-plugin-media';
|
|
16
16
|
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
@@ -18,7 +18,7 @@ import type { CodeBlockOptions } from '../plugins/code-block/types';
|
|
|
18
18
|
import type { CollabEditOptions } from '@atlaskit/editor-common/collab';
|
|
19
19
|
import type { DatePluginConfig } from '@atlaskit/editor-plugin-date';
|
|
20
20
|
import type { FindReplaceOptions } from '../plugins/find-replace/types';
|
|
21
|
-
import type { LayoutPluginOptions } from '
|
|
21
|
+
import type { LayoutPluginOptions } from '@atlaskit/editor-plugin-layout';
|
|
22
22
|
import type { MediaOptions, MediaState } from '@atlaskit/editor-plugin-media/types';
|
|
23
23
|
import type { MentionPluginConfig } from '@atlaskit/editor-plugin-mentions';
|
|
24
24
|
import type { PanelPluginConfig } from '../plugins/panel/types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "189.1.
|
|
3
|
+
"version": "189.1.12",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
"@atlaskit/editor-plugin-history": "^0.1.0",
|
|
85
85
|
"@atlaskit/editor-plugin-hyperlink": "^0.5.0",
|
|
86
86
|
"@atlaskit/editor-plugin-image-upload": "^0.2.0",
|
|
87
|
+
"@atlaskit/editor-plugin-layout": "^0.1.0",
|
|
87
88
|
"@atlaskit/editor-plugin-list": "^1.3.0",
|
|
88
89
|
"@atlaskit/editor-plugin-media": "^0.3.0",
|
|
89
90
|
"@atlaskit/editor-plugin-mentions": "^0.1.0",
|
package/report.api.md
CHANGED
|
@@ -49,6 +49,7 @@ import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
|
49
49
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
50
50
|
import { JSONDocNode } from '@atlaskit/editor-json-transformer/types';
|
|
51
51
|
import { jsx } from '@emotion/react';
|
|
52
|
+
import type { LayoutPluginOptions } from '@atlaskit/editor-plugin-layout';
|
|
52
53
|
import type { LinkingOptions } from '@atlaskit/editor-common/types';
|
|
53
54
|
import type { LongPressSelectionPluginOptions } from '@atlaskit/editor-common/types';
|
|
54
55
|
import { MacroAttributes } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -628,16 +629,6 @@ export type InlineCommentViewComponentProps = AnnotationComponentProps & {
|
|
|
628
629
|
|
|
629
630
|
export { INPUT_METHOD };
|
|
630
631
|
|
|
631
|
-
// @public (undocumented)
|
|
632
|
-
interface LayoutPluginOptions extends LongPressSelectionPluginOptions {
|
|
633
|
-
// (undocumented)
|
|
634
|
-
allowBreakout?: boolean;
|
|
635
|
-
// (undocumented)
|
|
636
|
-
UNSAFE_addSidebarLayouts?: boolean;
|
|
637
|
-
// (undocumented)
|
|
638
|
-
UNSAFE_allowSingleColumnLayout?: boolean;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
632
|
export { MacroAttributes };
|
|
642
633
|
|
|
643
634
|
export { MacroProvider };
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
|
38
38
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
39
39
|
import { JSONDocNode } from '@atlaskit/editor-json-transformer/types';
|
|
40
40
|
import { jsx } from '@emotion/react';
|
|
41
|
+
import type { LayoutPluginOptions } from '@atlaskit/editor-plugin-layout';
|
|
41
42
|
import type { LinkingOptions } from '@atlaskit/editor-common/types';
|
|
42
43
|
import type { LongPressSelectionPluginOptions } from '@atlaskit/editor-common/types';
|
|
43
44
|
import { MacroAttributes } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -576,16 +577,6 @@ export type InlineCommentViewComponentProps = AnnotationComponentProps & {
|
|
|
576
577
|
|
|
577
578
|
export { INPUT_METHOD }
|
|
578
579
|
|
|
579
|
-
// @public (undocumented)
|
|
580
|
-
interface LayoutPluginOptions extends LongPressSelectionPluginOptions {
|
|
581
|
-
// (undocumented)
|
|
582
|
-
allowBreakout?: boolean;
|
|
583
|
-
// (undocumented)
|
|
584
|
-
UNSAFE_addSidebarLayouts?: boolean;
|
|
585
|
-
// (undocumented)
|
|
586
|
-
UNSAFE_allowSingleColumnLayout?: boolean;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
580
|
export { MacroAttributes }
|
|
590
581
|
|
|
591
582
|
export { MacroProvider }
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.fixColumnStructure = exports.fixColumnSizes = exports.deleteActiveLayoutNode = exports.createDefaultLayoutSection = exports.TWO_COL_LAYOUTS = exports.THREE_COL_LAYOUTS = exports.ONE_COL_LAYOUTS = void 0;
|
|
8
|
-
exports.forceSectionToPresetLayout = forceSectionToPresetLayout;
|
|
9
|
-
exports.setPresetLayout = exports.insertLayoutColumnsWithAnalytics = exports.insertLayoutColumns = exports.getSelectedLayout = exports.getPresetLayout = void 0;
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
13
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
|
-
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
15
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
16
|
-
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
17
|
-
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
18
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
-
var ONE_COL_LAYOUTS = exports.ONE_COL_LAYOUTS = ['single'];
|
|
21
|
-
var TWO_COL_LAYOUTS = exports.TWO_COL_LAYOUTS = ['two_equal', 'two_left_sidebar', 'two_right_sidebar'];
|
|
22
|
-
var THREE_COL_LAYOUTS = exports.THREE_COL_LAYOUTS = ['three_equal', 'three_with_sidebars'];
|
|
23
|
-
var getWidthsForPreset = function getWidthsForPreset(presetLayout) {
|
|
24
|
-
switch (presetLayout) {
|
|
25
|
-
case 'single':
|
|
26
|
-
return [100];
|
|
27
|
-
case 'two_equal':
|
|
28
|
-
return [50, 50];
|
|
29
|
-
case 'three_equal':
|
|
30
|
-
return [33.33, 33.33, 33.33];
|
|
31
|
-
case 'two_left_sidebar':
|
|
32
|
-
return [33.33, 66.66];
|
|
33
|
-
case 'two_right_sidebar':
|
|
34
|
-
return [66.66, 33.33];
|
|
35
|
-
case 'three_with_sidebars':
|
|
36
|
-
return [25, 50, 25];
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Finds layout preset based on the width attrs of all the layoutColumn nodes
|
|
42
|
-
* inside the layoutSection node
|
|
43
|
-
*/
|
|
44
|
-
var getPresetLayout = exports.getPresetLayout = function getPresetLayout(section) {
|
|
45
|
-
var widths = (0, _utils2.mapChildren)(section, function (column) {
|
|
46
|
-
return column.attrs.width;
|
|
47
|
-
}).join(',');
|
|
48
|
-
switch (widths) {
|
|
49
|
-
case '100':
|
|
50
|
-
return 'single';
|
|
51
|
-
case '33.33,33.33,33.33':
|
|
52
|
-
return 'three_equal';
|
|
53
|
-
case '25,50,25':
|
|
54
|
-
return 'three_with_sidebars';
|
|
55
|
-
case '50,50':
|
|
56
|
-
return 'two_equal';
|
|
57
|
-
case '33.33,66.66':
|
|
58
|
-
return 'two_left_sidebar';
|
|
59
|
-
case '66.66,33.33':
|
|
60
|
-
return 'two_right_sidebar';
|
|
61
|
-
}
|
|
62
|
-
return;
|
|
63
|
-
};
|
|
64
|
-
var getSelectedLayout = exports.getSelectedLayout = function getSelectedLayout(maybeLayoutSection, current) {
|
|
65
|
-
if (maybeLayoutSection && getPresetLayout(maybeLayoutSection)) {
|
|
66
|
-
return getPresetLayout(maybeLayoutSection) || current;
|
|
67
|
-
}
|
|
68
|
-
return current;
|
|
69
|
-
};
|
|
70
|
-
var createDefaultLayoutSection = exports.createDefaultLayoutSection = function createDefaultLayoutSection(state) {
|
|
71
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
72
|
-
layoutSection = _state$schema$nodes.layoutSection,
|
|
73
|
-
layoutColumn = _state$schema$nodes.layoutColumn;
|
|
74
|
-
|
|
75
|
-
// create a 50-50 layout by default
|
|
76
|
-
var columns = _model.Fragment.fromArray([layoutColumn.createAndFill({
|
|
77
|
-
width: 50
|
|
78
|
-
}), layoutColumn.createAndFill({
|
|
79
|
-
width: 50
|
|
80
|
-
})]);
|
|
81
|
-
return layoutSection.createAndFill(undefined, columns);
|
|
82
|
-
};
|
|
83
|
-
var insertLayoutColumns = exports.insertLayoutColumns = function insertLayoutColumns(state, dispatch) {
|
|
84
|
-
if (dispatch) {
|
|
85
|
-
dispatch((0, _utils.safeInsert)(createDefaultLayoutSection(state))(state.tr));
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
};
|
|
89
|
-
var insertLayoutColumnsWithAnalytics = exports.insertLayoutColumnsWithAnalytics = function insertLayoutColumnsWithAnalytics(editorAnalyticsAPI) {
|
|
90
|
-
return function (inputMethod) {
|
|
91
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
92
|
-
action: _analytics.ACTION.INSERTED,
|
|
93
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
94
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.LAYOUT,
|
|
95
|
-
attributes: {
|
|
96
|
-
inputMethod: inputMethod
|
|
97
|
-
},
|
|
98
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
99
|
-
})(insertLayoutColumns);
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Add a column to the right of existing layout
|
|
105
|
-
*/
|
|
106
|
-
function addColumn(schema, pos) {
|
|
107
|
-
return function (tr) {
|
|
108
|
-
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill());
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function removeLastColumnInLayout(column, columnPos, insideRightEdgePos) {
|
|
112
|
-
return function (tr) {
|
|
113
|
-
if ((0, _utils2.isEmptyDocument)(column)) {
|
|
114
|
-
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(insideRightEdgePos), _model.Slice.empty);
|
|
115
|
-
} else {
|
|
116
|
-
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(columnPos + 1), _model.Slice.empty);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
var fromTwoColsToThree = addColumn;
|
|
121
|
-
var fromOneColToTwo = addColumn;
|
|
122
|
-
var fromTwoColsToOne = removeLastColumnInLayout;
|
|
123
|
-
var fromThreeColsToTwo = removeLastColumnInLayout;
|
|
124
|
-
var fromOneColToThree = function fromOneColToThree(schema, pos) {
|
|
125
|
-
return function (tr) {
|
|
126
|
-
addColumn(schema, pos)(tr);
|
|
127
|
-
addColumn(schema, pos)(tr);
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
var fromThreeColstoOne = function fromThreeColstoOne(node, tr, insideRightEdgePos) {
|
|
131
|
-
var thirdColumn = node.content.child(2);
|
|
132
|
-
fromThreeColsToTwo(thirdColumn, insideRightEdgePos - thirdColumn.nodeSize, insideRightEdgePos)(tr);
|
|
133
|
-
var secondColumn = node.content.child(1);
|
|
134
|
-
fromTwoColsToOne(secondColumn, insideRightEdgePos - thirdColumn.nodeSize - secondColumn.nodeSize, insideRightEdgePos)(tr);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Handles switching from 2 -> 3 cols, or 3 -> 2 cols
|
|
139
|
-
* Switching from 2 -> 3 just adds a new one at the end
|
|
140
|
-
* Switching from 3 -> 2 moves all the content of the third col inside the second before
|
|
141
|
-
* removing it
|
|
142
|
-
*/
|
|
143
|
-
function forceColumnStructure(state, node, pos, presetLayout) {
|
|
144
|
-
var tr = state.tr;
|
|
145
|
-
var insideRightEdgeOfLayoutSection = pos + node.nodeSize - 1;
|
|
146
|
-
var numCols = node.childCount;
|
|
147
|
-
|
|
148
|
-
// 3 columns -> 2 columns
|
|
149
|
-
if (TWO_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 3) {
|
|
150
|
-
var thirdColumn = node.content.child(2);
|
|
151
|
-
var columnPos = insideRightEdgeOfLayoutSection - thirdColumn.nodeSize;
|
|
152
|
-
fromThreeColsToTwo(thirdColumn, columnPos, insideRightEdgeOfLayoutSection)(tr);
|
|
153
|
-
|
|
154
|
-
// 2 columns -> 3 columns
|
|
155
|
-
} else if (THREE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 2) {
|
|
156
|
-
fromTwoColsToThree(state.schema, insideRightEdgeOfLayoutSection)(tr);
|
|
157
|
-
|
|
158
|
-
// 2 columns -> 1 column
|
|
159
|
-
} else if (ONE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 2) {
|
|
160
|
-
var secondColumn = node.content.child(1);
|
|
161
|
-
var _columnPos = insideRightEdgeOfLayoutSection - secondColumn.nodeSize;
|
|
162
|
-
fromTwoColsToOne(secondColumn, _columnPos, insideRightEdgeOfLayoutSection)(tr);
|
|
163
|
-
|
|
164
|
-
// 3 columns -> 1 column
|
|
165
|
-
} else if (ONE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 3) {
|
|
166
|
-
fromThreeColstoOne(node, tr, insideRightEdgeOfLayoutSection);
|
|
167
|
-
|
|
168
|
-
// 1 column -> 2 columns
|
|
169
|
-
} else if (TWO_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 1) {
|
|
170
|
-
fromOneColToTwo(state.schema, insideRightEdgeOfLayoutSection)(tr);
|
|
171
|
-
// 1 column -> 3 columns
|
|
172
|
-
} else if (THREE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 1) {
|
|
173
|
-
fromOneColToThree(state.schema, insideRightEdgeOfLayoutSection)(tr);
|
|
174
|
-
}
|
|
175
|
-
return tr;
|
|
176
|
-
}
|
|
177
|
-
function columnWidth(node, schema, widths) {
|
|
178
|
-
var layoutColumn = schema.nodes.layoutColumn;
|
|
179
|
-
var truncatedWidths = widths.map(function (w) {
|
|
180
|
-
return Number(w.toFixed(2));
|
|
181
|
-
});
|
|
182
|
-
return (0, _utils2.flatmap)(node.content, function (column, idx) {
|
|
183
|
-
if (column.type === layoutColumn) {
|
|
184
|
-
return layoutColumn.create(_objectSpread(_objectSpread({}, column.attrs), {}, {
|
|
185
|
-
width: truncatedWidths[idx]
|
|
186
|
-
}), column.content, column.marks);
|
|
187
|
-
} else {
|
|
188
|
-
return column;
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
function forceColumnWidths(state, tr, pos, presetLayout) {
|
|
193
|
-
var node = tr.doc.nodeAt(pos);
|
|
194
|
-
if (!node) {
|
|
195
|
-
return tr;
|
|
196
|
-
}
|
|
197
|
-
return tr.replaceWith(pos + 1, pos + node.nodeSize - 1, columnWidth(node, state.schema, getWidthsForPreset(presetLayout)));
|
|
198
|
-
}
|
|
199
|
-
function forceSectionToPresetLayout(state, node, pos, presetLayout) {
|
|
200
|
-
var tr = forceColumnStructure(state, node, pos, presetLayout);
|
|
201
|
-
|
|
202
|
-
// save the selection here, since forcing column widths causes a change over the
|
|
203
|
-
// entire layoutSection, which remaps selection to the end. not remapping here
|
|
204
|
-
// is safe because the structure is no longer changing.
|
|
205
|
-
var selection = tr.selection;
|
|
206
|
-
tr = forceColumnWidths(state, tr, pos, presetLayout);
|
|
207
|
-
var selectionPos$ = tr.doc.resolve(selection.$from.pos);
|
|
208
|
-
return tr.setSelection(state.selection instanceof _state.NodeSelection ? new _state.NodeSelection(selectionPos$) : new _state.TextSelection(selectionPos$));
|
|
209
|
-
}
|
|
210
|
-
var setPresetLayout = exports.setPresetLayout = function setPresetLayout(editorAnalyticsAPI) {
|
|
211
|
-
return function (layout) {
|
|
212
|
-
return function (state, dispatch) {
|
|
213
|
-
var _ref = _pluginKey.pluginKey.getState(state),
|
|
214
|
-
pos = _ref.pos,
|
|
215
|
-
selectedLayout = _ref.selectedLayout;
|
|
216
|
-
if (selectedLayout === layout || pos === null) {
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
var node = state.doc.nodeAt(pos);
|
|
220
|
-
if (!node) {
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
var tr = forceSectionToPresetLayout(state, node, pos, layout);
|
|
224
|
-
if (tr) {
|
|
225
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
226
|
-
action: _analytics.ACTION.CHANGED_LAYOUT,
|
|
227
|
-
actionSubject: _analytics.ACTION_SUBJECT.LAYOUT,
|
|
228
|
-
attributes: {
|
|
229
|
-
previousLayout: formatLayoutName(selectedLayout),
|
|
230
|
-
newLayout: formatLayoutName(layout)
|
|
231
|
-
},
|
|
232
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
233
|
-
})(tr);
|
|
234
|
-
tr.setMeta('scrollIntoView', false);
|
|
235
|
-
if (dispatch) {
|
|
236
|
-
dispatch(tr);
|
|
237
|
-
}
|
|
238
|
-
return true;
|
|
239
|
-
}
|
|
240
|
-
return false;
|
|
241
|
-
};
|
|
242
|
-
};
|
|
243
|
-
};
|
|
244
|
-
function layoutNeedChanges(node) {
|
|
245
|
-
return !getPresetLayout(node);
|
|
246
|
-
}
|
|
247
|
-
function getLayoutChange(node, pos, schema) {
|
|
248
|
-
if (node.type === schema.nodes.layoutSection) {
|
|
249
|
-
if (!layoutNeedChanges(node)) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
var presetLayout = node.childCount === 2 ? 'two_equal' : node.childCount === 3 ? 'three_equal' : 'single';
|
|
253
|
-
var fixedColumns = columnWidth(node, schema, getWidthsForPreset(presetLayout));
|
|
254
|
-
return {
|
|
255
|
-
from: pos + 1,
|
|
256
|
-
to: pos + node.nodeSize - 1,
|
|
257
|
-
slice: new _model.Slice(fixedColumns, 0, 0)
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
var fixColumnSizes = exports.fixColumnSizes = function fixColumnSizes(changedTr, state) {
|
|
262
|
-
var layoutSection = state.schema.nodes.layoutSection;
|
|
263
|
-
var change;
|
|
264
|
-
var range = (0, _utils2.getStepRange)(changedTr);
|
|
265
|
-
if (!range) {
|
|
266
|
-
return undefined;
|
|
267
|
-
}
|
|
268
|
-
changedTr.doc.nodesBetween(range.from, range.to, function (node, pos) {
|
|
269
|
-
if (node.type !== layoutSection) {
|
|
270
|
-
return true; // Check all internal nodes expect for layout section
|
|
271
|
-
}
|
|
272
|
-
// Node is a section
|
|
273
|
-
if (layoutNeedChanges(node)) {
|
|
274
|
-
change = getLayoutChange(node, pos, state.schema);
|
|
275
|
-
}
|
|
276
|
-
return false; // We dont go deep, We dont accept nested layouts
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
// Hack to prevent: https://product-fabric.atlassian.net/browse/ED-7523
|
|
280
|
-
// By default prosemirror try to recreate the node with the default attributes
|
|
281
|
-
// The default attribute is invalid adf though. when this happen the node after
|
|
282
|
-
// current position is a layout section
|
|
283
|
-
var $pos = changedTr.doc.resolve(range.to);
|
|
284
|
-
if ($pos.depth > 0) {
|
|
285
|
-
// 'range.to' position could resolve to doc, in this ResolvedPos.after will throws
|
|
286
|
-
var pos = $pos.after();
|
|
287
|
-
var node = changedTr.doc.nodeAt(pos);
|
|
288
|
-
if (node && node.type === layoutSection && layoutNeedChanges(node)) {
|
|
289
|
-
change = getLayoutChange(node, pos, state.schema);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return change;
|
|
293
|
-
};
|
|
294
|
-
var fixColumnStructure = exports.fixColumnStructure = function fixColumnStructure(state) {
|
|
295
|
-
var _ref2 = _pluginKey.pluginKey.getState(state),
|
|
296
|
-
pos = _ref2.pos,
|
|
297
|
-
selectedLayout = _ref2.selectedLayout;
|
|
298
|
-
if (pos !== null && selectedLayout) {
|
|
299
|
-
var node = state.doc.nodeAt(pos);
|
|
300
|
-
if (node && node.childCount !== getWidthsForPreset(selectedLayout).length) {
|
|
301
|
-
return forceSectionToPresetLayout(state, node, pos, selectedLayout);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return;
|
|
305
|
-
};
|
|
306
|
-
var deleteActiveLayoutNode = exports.deleteActiveLayoutNode = function deleteActiveLayoutNode(editorAnalyticsAPI) {
|
|
307
|
-
return function (state, dispatch) {
|
|
308
|
-
var _ref3 = _pluginKey.pluginKey.getState(state),
|
|
309
|
-
pos = _ref3.pos,
|
|
310
|
-
selectedLayout = _ref3.selectedLayout;
|
|
311
|
-
if (pos !== null) {
|
|
312
|
-
var node = state.doc.nodeAt(pos);
|
|
313
|
-
if (dispatch) {
|
|
314
|
-
var tr = state.tr.delete(pos, pos + node.nodeSize);
|
|
315
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
316
|
-
action: _analytics.ACTION.DELETED,
|
|
317
|
-
actionSubject: _analytics.ACTION_SUBJECT.LAYOUT,
|
|
318
|
-
attributes: {
|
|
319
|
-
layout: formatLayoutName(selectedLayout)
|
|
320
|
-
},
|
|
321
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
322
|
-
})(tr);
|
|
323
|
-
dispatch(tr);
|
|
324
|
-
}
|
|
325
|
-
return true;
|
|
326
|
-
}
|
|
327
|
-
return false;
|
|
328
|
-
};
|
|
329
|
-
};
|
|
330
|
-
var formatLayoutName = function formatLayoutName(layout) {
|
|
331
|
-
switch (layout) {
|
|
332
|
-
case 'single':
|
|
333
|
-
return _analytics.LAYOUT_TYPE.SINGLE_COL;
|
|
334
|
-
case 'two_equal':
|
|
335
|
-
return _analytics.LAYOUT_TYPE.TWO_COLS_EQUAL;
|
|
336
|
-
case 'three_equal':
|
|
337
|
-
return _analytics.LAYOUT_TYPE.THREE_COLS_EQUAL;
|
|
338
|
-
case 'two_left_sidebar':
|
|
339
|
-
return _analytics.LAYOUT_TYPE.LEFT_SIDEBAR;
|
|
340
|
-
case 'two_right_sidebar':
|
|
341
|
-
return _analytics.LAYOUT_TYPE.RIGHT_SIDEBAR;
|
|
342
|
-
case 'three_with_sidebars':
|
|
343
|
-
return _analytics.LAYOUT_TYPE.THREE_WITH_SIDEBARS;
|
|
344
|
-
}
|
|
345
|
-
};
|