@atlaskit/editor-core 188.2.9 → 188.3.0
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 +17 -0
- package/dist/cjs/labs/next/presets/universal.js +3 -1
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/labs/next/presets/universal.js +3 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/labs/next/presets/universal.js +3 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/package.json +7 -9
- package/dist/cjs/plugins/caption/index.js +0 -38
- package/dist/cjs/plugins/caption/nodeviews/index.js +0 -81
- package/dist/cjs/plugins/caption/pm-plugins/keymap.js +0 -72
- package/dist/cjs/plugins/caption/pm-plugins/main.js +0 -57
- package/dist/cjs/plugins/caption/pm-plugins/plugin-key.js +0 -8
- package/dist/es2019/plugins/caption/index.js +0 -31
- package/dist/es2019/plugins/caption/nodeviews/index.js +0 -47
- package/dist/es2019/plugins/caption/pm-plugins/keymap.js +0 -66
- package/dist/es2019/plugins/caption/pm-plugins/main.js +0 -50
- package/dist/es2019/plugins/caption/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/caption/index.js +0 -31
- package/dist/esm/plugins/caption/nodeviews/index.js +0 -73
- package/dist/esm/plugins/caption/pm-plugins/keymap.js +0 -66
- package/dist/esm/plugins/caption/pm-plugins/main.js +0 -50
- package/dist/esm/plugins/caption/pm-plugins/plugin-key.js +0 -2
- package/dist/types/plugins/caption/index.d.ts +0 -3
- package/dist/types/plugins/caption/nodeviews/index.d.ts +0 -19
- package/dist/types/plugins/caption/pm-plugins/keymap.d.ts +0 -2
- package/dist/types/plugins/caption/pm-plugins/main.d.ts +0 -8
- package/dist/types/plugins/caption/pm-plugins/plugin-key.d.ts +0 -2
- package/dist/types-ts4.5/plugins/caption/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/caption/nodeviews/index.d.ts +0 -19
- package/dist/types-ts4.5/plugins/caption/pm-plugins/keymap.d.ts +0 -2
- package/dist/types-ts4.5/plugins/caption/pm-plugins/main.d.ts +0 -8
- package/dist/types-ts4.5/plugins/caption/pm-plugins/plugin-key.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 188.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#41239](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41239) [`7d70b962986`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7d70b962986) - Extract Caption Plugin from Editor Core
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 188.2.11
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#41224](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41224) [`6818e578fd6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6818e578fd6) - Added new Tables toggle option for enabling Drag and Drop
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 188.2.9
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -9,6 +9,7 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _api = require("../../../selection-api/api");
|
|
11
11
|
var _plugins = require("../../../plugins");
|
|
12
|
+
var _editorPluginCaption = require("@atlaskit/editor-plugin-caption");
|
|
12
13
|
var _editorPluginHelpDialog = require("@atlaskit/editor-plugin-help-dialog");
|
|
13
14
|
var _editorPluginRule = require("@atlaskit/editor-plugin-rule");
|
|
14
15
|
var _editorPluginEmoji = require("@atlaskit/editor-plugin-emoji");
|
|
@@ -129,7 +130,7 @@ function createUniversalPreset(appearance, props, featureFlags, prevAppearance,
|
|
|
129
130
|
})]);
|
|
130
131
|
}
|
|
131
132
|
return builder;
|
|
132
|
-
}).maybeAdd(
|
|
133
|
+
}).maybeAdd(_editorPluginCaption.captionPlugin, function (plugin, builder) {
|
|
133
134
|
// EDM-799: inside caption plugin we do the feature flag in enabling the plugin
|
|
134
135
|
if (props.media && (props.media.allowCaptions || (0, _mediaCommon.getMediaFeatureFlag)('captions', props.media.featureFlags))) {
|
|
135
136
|
return builder.add(plugin);
|
|
@@ -159,6 +160,7 @@ function createUniversalPreset(appearance, props, featureFlags, prevAppearance,
|
|
|
159
160
|
// tableResizingEnabled will replace breakoutEnabled once FF is 100% rolled out,
|
|
160
161
|
// logic below is to help codemod during cleanup
|
|
161
162
|
tableResizingEnabled: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') && ['full-page', 'full-width'].includes(appearance || ''),
|
|
163
|
+
dragAndDropEnabled: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.drag-and-drop') && isFullPage,
|
|
162
164
|
breakoutEnabled: appearance === 'full-page',
|
|
163
165
|
allowContextualMenu: !isMobile,
|
|
164
166
|
fullWidthEnabled: appearance === 'full-width',
|
|
@@ -53,12 +53,6 @@ Object.defineProperty(exports, "breakoutPlugin", {
|
|
|
53
53
|
return _breakout.default;
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
|
-
Object.defineProperty(exports, "captionPlugin", {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function get() {
|
|
59
|
-
return _caption.default;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
56
|
Object.defineProperty(exports, "clearMarksOnChangeToEmptyDocumentPlugin", {
|
|
63
57
|
enumerable: true,
|
|
64
58
|
get: function get() {
|
|
@@ -327,7 +321,6 @@ var _analytics = _interopRequireDefault(require("./analytics"));
|
|
|
327
321
|
var _customAutoformat = _interopRequireDefault(require("./custom-autoformat"));
|
|
328
322
|
var _feedbackDialog = _interopRequireDefault(require("./feedback-dialog"));
|
|
329
323
|
var _history = _interopRequireDefault(require("./history"));
|
|
330
|
-
var _caption = _interopRequireDefault(require("./caption"));
|
|
331
324
|
var _expand = _interopRequireWildcard(require("./expand"));
|
|
332
325
|
var _scrollIntoView = _interopRequireDefault(require("./scroll-into-view"));
|
|
333
326
|
var _mobileDimensions = _interopRequireDefault(require("./mobile-dimensions"));
|
|
@@ -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 = "188.
|
|
8
|
+
var version = exports.version = "188.3.0";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createEditorSelectionAPI } from '../../../selection-api/api';
|
|
2
|
-
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, mediaPlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, saveOnEnterPlugin, tasksAndDecisionsPlugin, textColorPlugin, statusPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin,
|
|
2
|
+
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, mediaPlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, saveOnEnterPlugin, tasksAndDecisionsPlugin, textColorPlugin, statusPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin, borderPlugin } from '../../../plugins';
|
|
3
|
+
import { captionPlugin } from '@atlaskit/editor-plugin-caption';
|
|
3
4
|
import { helpDialogPlugin } from '@atlaskit/editor-plugin-help-dialog';
|
|
4
5
|
import { rulePlugin } from '@atlaskit/editor-plugin-rule';
|
|
5
6
|
import { emojiPlugin } from '@atlaskit/editor-plugin-emoji';
|
|
@@ -148,6 +149,7 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
|
|
|
148
149
|
// tableResizingEnabled will replace breakoutEnabled once FF is 100% rolled out,
|
|
149
150
|
// logic below is to help codemod during cleanup
|
|
150
151
|
tableResizingEnabled: getBooleanFF('platform.editor.custom-table-width') && ['full-page', 'full-width'].includes(appearance || ''),
|
|
152
|
+
dragAndDropEnabled: getBooleanFF('platform.editor.table.drag-and-drop') && isFullPage,
|
|
151
153
|
breakoutEnabled: appearance === 'full-page',
|
|
152
154
|
allowContextualMenu: !isMobile,
|
|
153
155
|
fullWidthEnabled: appearance === 'full-width',
|
|
@@ -32,7 +32,6 @@ export { default as analyticsPlugin } from './analytics';
|
|
|
32
32
|
export { default as customAutoformatPlugin } from './custom-autoformat';
|
|
33
33
|
export { default as feedbackDialogPlugin } from './feedback-dialog';
|
|
34
34
|
export { default as historyPlugin } from './history';
|
|
35
|
-
export { default as captionPlugin } from './caption';
|
|
36
35
|
export { default as expandPlugin, isExpandInsertionEnabled } from './expand';
|
|
37
36
|
export { default as scrollIntoViewPlugin } from './scroll-into-view';
|
|
38
37
|
export { default as mobileDimensionsPlugin } from './mobile-dimensions';
|
|
@@ -3,7 +3,8 @@ 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
5
|
import { createEditorSelectionAPI } from '../../../selection-api/api';
|
|
6
|
-
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, mediaPlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, saveOnEnterPlugin, tasksAndDecisionsPlugin, textColorPlugin, statusPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin,
|
|
6
|
+
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, mediaPlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, saveOnEnterPlugin, tasksAndDecisionsPlugin, textColorPlugin, statusPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin, borderPlugin } from '../../../plugins';
|
|
7
|
+
import { captionPlugin } from '@atlaskit/editor-plugin-caption';
|
|
7
8
|
import { helpDialogPlugin } from '@atlaskit/editor-plugin-help-dialog';
|
|
8
9
|
import { rulePlugin } from '@atlaskit/editor-plugin-rule';
|
|
9
10
|
import { emojiPlugin } from '@atlaskit/editor-plugin-emoji';
|
|
@@ -152,6 +153,7 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
|
|
|
152
153
|
// tableResizingEnabled will replace breakoutEnabled once FF is 100% rolled out,
|
|
153
154
|
// logic below is to help codemod during cleanup
|
|
154
155
|
tableResizingEnabled: getBooleanFF('platform.editor.custom-table-width') && ['full-page', 'full-width'].includes(appearance || ''),
|
|
156
|
+
dragAndDropEnabled: getBooleanFF('platform.editor.table.drag-and-drop') && isFullPage,
|
|
155
157
|
breakoutEnabled: appearance === 'full-page',
|
|
156
158
|
allowContextualMenu: !isMobile,
|
|
157
159
|
fullWidthEnabled: appearance === 'full-width',
|
|
@@ -32,7 +32,6 @@ export { default as analyticsPlugin } from './analytics';
|
|
|
32
32
|
export { default as customAutoformatPlugin } from './custom-autoformat';
|
|
33
33
|
export { default as feedbackDialogPlugin } from './feedback-dialog';
|
|
34
34
|
export { default as historyPlugin } from './history';
|
|
35
|
-
export { default as captionPlugin } from './caption';
|
|
36
35
|
export { default as expandPlugin, isExpandInsertionEnabled } from './expand';
|
|
37
36
|
export { default as scrollIntoViewPlugin } from './scroll-into-view';
|
|
38
37
|
export { default as mobileDimensionsPlugin } from './mobile-dimensions';
|
|
@@ -32,7 +32,6 @@ export { default as analyticsPlugin } from './analytics';
|
|
|
32
32
|
export { default as customAutoformatPlugin } from './custom-autoformat';
|
|
33
33
|
export { default as feedbackDialogPlugin } from './feedback-dialog';
|
|
34
34
|
export { default as historyPlugin } from './history';
|
|
35
|
-
export { default as captionPlugin } from './caption';
|
|
36
35
|
export { default as expandPlugin, isExpandInsertionEnabled } from './expand';
|
|
37
36
|
export { default as scrollIntoViewPlugin } from './scroll-into-view';
|
|
38
37
|
export { default as mobileDimensionsPlugin } from './mobile-dimensions';
|
|
@@ -32,7 +32,6 @@ export { default as analyticsPlugin } from './analytics';
|
|
|
32
32
|
export { default as customAutoformatPlugin } from './custom-autoformat';
|
|
33
33
|
export { default as feedbackDialogPlugin } from './feedback-dialog';
|
|
34
34
|
export { default as historyPlugin } from './history';
|
|
35
|
-
export { default as captionPlugin } from './caption';
|
|
36
35
|
export { default as expandPlugin, isExpandInsertionEnabled } from './expand';
|
|
37
36
|
export { default as scrollIntoViewPlugin } from './scroll-into-view';
|
|
38
37
|
export { default as mobileDimensionsPlugin } from './mobile-dimensions';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "188.
|
|
3
|
+
"version": "188.3.0",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@atlaskit/editor-plugin-analytics": "^0.2.0",
|
|
63
63
|
"@atlaskit/editor-plugin-base": "^0.2.0",
|
|
64
64
|
"@atlaskit/editor-plugin-block-type": "^2.0.0",
|
|
65
|
-
"@atlaskit/editor-plugin-caption": "^0.
|
|
65
|
+
"@atlaskit/editor-plugin-caption": "^0.2.0",
|
|
66
66
|
"@atlaskit/editor-plugin-card": "^0.9.0",
|
|
67
67
|
"@atlaskit/editor-plugin-clipboard": "^0.1.0",
|
|
68
68
|
"@atlaskit/editor-plugin-composition": "^0.1.0",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@atlaskit/editor-plugin-placeholder": "^0.1.0",
|
|
87
87
|
"@atlaskit/editor-plugin-quick-insert": "^0.1.0",
|
|
88
88
|
"@atlaskit/editor-plugin-rule": "^0.1.0",
|
|
89
|
-
"@atlaskit/editor-plugin-table": "^4.
|
|
89
|
+
"@atlaskit/editor-plugin-table": "^4.1.0",
|
|
90
90
|
"@atlaskit/editor-plugin-text-formatting": "^0.4.0",
|
|
91
91
|
"@atlaskit/editor-plugin-type-ahead": "^0.4.0",
|
|
92
92
|
"@atlaskit/editor-plugin-unsupported-content": "^0.2.0",
|
|
@@ -157,10 +157,9 @@
|
|
|
157
157
|
"@af/integration-testing": "*",
|
|
158
158
|
"@af/visual-regression": "*",
|
|
159
159
|
"@atlaskit/code": "^14.6.0",
|
|
160
|
-
"@atlaskit/collab-provider": "9.15.
|
|
160
|
+
"@atlaskit/collab-provider": "9.15.1",
|
|
161
161
|
"@atlaskit/dropdown-menu": "^11.14.0",
|
|
162
162
|
"@atlaskit/editor-extension-dropbox": "^0.4.0",
|
|
163
|
-
"@atlaskit/editor-plugin-table": "^4.0.0",
|
|
164
163
|
"@atlaskit/flag": "^15.2.0",
|
|
165
164
|
"@atlaskit/icon-object": "^6.3.0",
|
|
166
165
|
"@atlaskit/inline-dialog": "^13.6.0",
|
|
@@ -174,11 +173,7 @@
|
|
|
174
173
|
"@atlaskit/modal-dialog": "^12.8.0",
|
|
175
174
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
176
175
|
"@atlaskit/renderer": "^108.15.0",
|
|
177
|
-
"@atlaskit/section-message": "^6.4.0",
|
|
178
|
-
"@atlaskit/smart-user-picker": "^6.3.0",
|
|
179
176
|
"@atlaskit/synchrony-test-helpers": "^2.3.0",
|
|
180
|
-
"@atlaskit/textarea": "^4.7.0",
|
|
181
|
-
"@atlaskit/toggle": "^12.6.0",
|
|
182
177
|
"@atlaskit/ufo": "^0.2.0",
|
|
183
178
|
"@atlaskit/util-data-test": "^17.8.0",
|
|
184
179
|
"@atlaskit/visual-regression": "*",
|
|
@@ -294,6 +289,9 @@
|
|
|
294
289
|
"type": "boolean",
|
|
295
290
|
"referenceOnly": "true"
|
|
296
291
|
},
|
|
292
|
+
"platform.editor.table.drag-and-drop": {
|
|
293
|
+
"type": "boolean"
|
|
294
|
+
},
|
|
297
295
|
"platform.editor.table.overflow-state-analytics": {
|
|
298
296
|
"type": "boolean",
|
|
299
297
|
"referenceOnly": "true"
|
|
@@ -1,38 +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.default = void 0;
|
|
8
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
9
|
-
var _main = _interopRequireDefault(require("./pm-plugins/main"));
|
|
10
|
-
var _keymap = require("./pm-plugins/keymap");
|
|
11
|
-
var captionPlugin = function captionPlugin(_ref) {
|
|
12
|
-
var api = _ref.api;
|
|
13
|
-
return {
|
|
14
|
-
name: 'caption',
|
|
15
|
-
nodes: function nodes() {
|
|
16
|
-
return [{
|
|
17
|
-
name: 'caption',
|
|
18
|
-
node: _adfSchema.caption
|
|
19
|
-
}];
|
|
20
|
-
},
|
|
21
|
-
pmPlugins: function pmPlugins() {
|
|
22
|
-
return [{
|
|
23
|
-
name: 'caption',
|
|
24
|
-
plugin: function plugin(_ref2) {
|
|
25
|
-
var portalProviderAPI = _ref2.portalProviderAPI,
|
|
26
|
-
providerFactory = _ref2.providerFactory,
|
|
27
|
-
eventDispatcher = _ref2.eventDispatcher,
|
|
28
|
-
dispatch = _ref2.dispatch;
|
|
29
|
-
return (0, _main.default)(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api);
|
|
30
|
-
}
|
|
31
|
-
}, {
|
|
32
|
-
name: 'captionKeymap',
|
|
33
|
-
plugin: _keymap.captionKeymap
|
|
34
|
-
}];
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
var _default = exports.default = captionPlugin;
|
|
@@ -1,81 +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.CaptionNodeView = void 0;
|
|
8
|
-
exports.default = captionNodeView;
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
18
|
-
var _selectionBasedNodeView = require("@atlaskit/editor-common/selection-based-node-view");
|
|
19
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
20
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
-
var CaptionNodeView = exports.CaptionNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
22
|
-
(0, _inherits2.default)(CaptionNodeView, _SelectionBasedNodeVi);
|
|
23
|
-
var _super = _createSuper(CaptionNodeView);
|
|
24
|
-
function CaptionNodeView() {
|
|
25
|
-
var _this;
|
|
26
|
-
(0, _classCallCheck2.default)(this, CaptionNodeView);
|
|
27
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
28
|
-
args[_key] = arguments[_key];
|
|
29
|
-
}
|
|
30
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
31
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selected", _this.insideSelection());
|
|
32
|
-
return _this;
|
|
33
|
-
}
|
|
34
|
-
(0, _createClass2.default)(CaptionNodeView, [{
|
|
35
|
-
key: "createDomRef",
|
|
36
|
-
value: function createDomRef() {
|
|
37
|
-
var domRef = document.createElement('figcaption');
|
|
38
|
-
domRef.setAttribute('data-caption', 'true');
|
|
39
|
-
return domRef;
|
|
40
|
-
}
|
|
41
|
-
}, {
|
|
42
|
-
key: "getContentDOM",
|
|
43
|
-
value: function getContentDOM() {
|
|
44
|
-
var dom = document.createElement('div');
|
|
45
|
-
// setting a className prevents PM/Chrome mutation observer from
|
|
46
|
-
// incorrectly deleting nodes
|
|
47
|
-
dom.className = 'caption-wrapper';
|
|
48
|
-
return {
|
|
49
|
-
dom: dom
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
key: "render",
|
|
54
|
-
value: function render(_props, forwardRef) {
|
|
55
|
-
return /*#__PURE__*/_react.default.createElement(_ui.Caption, {
|
|
56
|
-
selected: this.insideSelection(),
|
|
57
|
-
hasContent: this.node.content.childCount > 0
|
|
58
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
59
|
-
ref: forwardRef
|
|
60
|
-
}));
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
key: "viewShouldUpdate",
|
|
64
|
-
value: function viewShouldUpdate(nextNode) {
|
|
65
|
-
if (this.node.childCount !== nextNode.childCount) {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
var newSelected = this.insideSelection();
|
|
69
|
-
var selectedStateChange = this.selected !== newSelected;
|
|
70
|
-
this.selected = newSelected;
|
|
71
|
-
return selectedStateChange;
|
|
72
|
-
}
|
|
73
|
-
}]);
|
|
74
|
-
return CaptionNodeView;
|
|
75
|
-
}(_selectionBasedNodeView.SelectionBasedNodeView);
|
|
76
|
-
function captionNodeView(portalProviderAPI, eventDispatcher, pluginInjectionApi) {
|
|
77
|
-
return function (node, view, getPos) {
|
|
78
|
-
var hasIntlContext = true;
|
|
79
|
-
return new CaptionNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {}, undefined, undefined, undefined, hasIntlContext).init();
|
|
80
|
-
};
|
|
81
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.captionKeymap = captionKeymap;
|
|
7
|
-
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
8
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
-
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
10
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
|
-
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
12
|
-
var _selection = require("@atlaskit/editor-common/selection");
|
|
13
|
-
function captionKeymap() {
|
|
14
|
-
var list = {};
|
|
15
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveDown.common, createNewParagraphBelowCaption, list);
|
|
16
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.enter.common, createNewParagraphBelowCaption, list);
|
|
17
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveDown.common, getOutOfCaption, list);
|
|
18
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.enter.common, getOutOfCaption, list);
|
|
19
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveUp.common, selectParentMediaSingle, list);
|
|
20
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.shiftTab.common, selectParentMediaSingle, list);
|
|
21
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.tab.common, getOutOfCaption, list);
|
|
22
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveLeft.common, gapCursorSelectLeftParentMediaSingle, list);
|
|
23
|
-
return (0, _keymap.keymap)(list);
|
|
24
|
-
}
|
|
25
|
-
var createNewParagraphBelowCaption = function createNewParagraphBelowCaption(state, dispatch) {
|
|
26
|
-
var caption = (0, _utils.findParentNodeOfType)(state.schema.nodes.caption)(state.selection);
|
|
27
|
-
if (caption) {
|
|
28
|
-
return (0, _utils2.createNewParagraphBelow)(state, dispatch);
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
};
|
|
32
|
-
var getOutOfCaption = function getOutOfCaption(state, dispatch) {
|
|
33
|
-
var caption = (0, _utils.findParentNodeOfType)(state.schema.nodes.caption)(state.selection);
|
|
34
|
-
if (caption) {
|
|
35
|
-
if (dispatch) {
|
|
36
|
-
var tr = state.tr.setSelection(_state.Selection.near(state.tr.doc.resolve(caption.pos + caption.node.nodeSize)));
|
|
37
|
-
dispatch(tr);
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
};
|
|
43
|
-
var selectParentMediaSingle = function selectParentMediaSingle(state, dispatch) {
|
|
44
|
-
if ((0, _utils.findParentNodeOfType)(state.schema.nodes.caption)(state.selection)) {
|
|
45
|
-
var mediaSingleParent = (0, _utils.findParentNodeOfType)(state.schema.nodes.mediaSingle)(state.selection);
|
|
46
|
-
if (mediaSingleParent) {
|
|
47
|
-
if (dispatch) {
|
|
48
|
-
var tr = state.tr.setSelection(_state.Selection.near(state.tr.doc.resolve(mediaSingleParent.pos)));
|
|
49
|
-
dispatch(tr);
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
};
|
|
56
|
-
var gapCursorSelectLeftParentMediaSingle = function gapCursorSelectLeftParentMediaSingle(state, dispatch) {
|
|
57
|
-
var caption = (0, _utils.findParentNodeOfType)(state.schema.nodes.caption)(state.selection);
|
|
58
|
-
if (caption) {
|
|
59
|
-
var mediaSingleParent = (0, _utils.findParentNodeOfType)(state.schema.nodes.mediaSingle)(state.selection);
|
|
60
|
-
if (mediaSingleParent && state.selection.empty && state.tr.doc.resolve(state.selection.from).parentOffset === 0) {
|
|
61
|
-
var gapCursorSelection = _selection.GapCursorSelection.findFrom(state.tr.doc.resolve(mediaSingleParent.pos), 0, false);
|
|
62
|
-
if (gapCursorSelection) {
|
|
63
|
-
if (dispatch) {
|
|
64
|
-
var tr = state.tr.setSelection(gapCursorSelection);
|
|
65
|
-
dispatch(tr);
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return false;
|
|
72
|
-
};
|
|
@@ -1,57 +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.default = void 0;
|
|
8
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
|
-
var _pluginKey = require("./plugin-key");
|
|
11
|
-
var _nodeviews = _interopRequireDefault(require("./../nodeviews"));
|
|
12
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
-
var fireAnalytics = function fireAnalytics(tr, action, analyticsApi) {
|
|
14
|
-
analyticsApi === null || analyticsApi === void 0 || analyticsApi.attachAnalyticsEvent({
|
|
15
|
-
action: action,
|
|
16
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
17
|
-
actionSubject: _analytics.ACTION_SUBJECT.MEDIA_SINGLE,
|
|
18
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.CAPTION
|
|
19
|
-
})(tr);
|
|
20
|
-
};
|
|
21
|
-
var _default = exports.default = function _default(portalProviderAPI, eventDispatcher, providerFactory, dispatch, pluginInjectionApi) {
|
|
22
|
-
var _pluginInjectionApi$a;
|
|
23
|
-
var analyticsApi = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
24
|
-
return new _safePlugin.SafePlugin({
|
|
25
|
-
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
26
|
-
// only run for transactions that change selection
|
|
27
|
-
if (!transactions.find(function (tr) {
|
|
28
|
-
return tr.selectionSet;
|
|
29
|
-
})) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
var newSelection = !newState.selection.eq(oldState.selection);
|
|
33
|
-
var findCaption = (0, _utils.findParentNodeOfType)(oldState.schema.nodes.caption);
|
|
34
|
-
var oldSelectionCaption = findCaption(oldState.selection);
|
|
35
|
-
var tr = newState.tr;
|
|
36
|
-
|
|
37
|
-
// if selecting away from caption, or selecting a different caption
|
|
38
|
-
if (newSelection && oldSelectionCaption) {
|
|
39
|
-
if (oldSelectionCaption.node.childCount === 0) {
|
|
40
|
-
tr.delete(oldSelectionCaption.start - 1, oldSelectionCaption.start);
|
|
41
|
-
tr.setMeta('scrollIntoView', false);
|
|
42
|
-
fireAnalytics(tr, _analytics.ACTION.DELETED, analyticsApi);
|
|
43
|
-
return tr;
|
|
44
|
-
} else {
|
|
45
|
-
fireAnalytics(tr, _analytics.ACTION.EDITED, analyticsApi);
|
|
46
|
-
return tr;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
key: _pluginKey.pluginKey,
|
|
51
|
-
props: {
|
|
52
|
-
nodeViews: {
|
|
53
|
-
caption: (0, _nodeviews.default)(portalProviderAPI, eventDispatcher, pluginInjectionApi)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { caption } from '@atlaskit/adf-schema';
|
|
2
|
-
import { default as createCaptionPlugin } from './pm-plugins/main';
|
|
3
|
-
import { captionKeymap } from './pm-plugins/keymap';
|
|
4
|
-
const captionPlugin = ({
|
|
5
|
-
api
|
|
6
|
-
}) => {
|
|
7
|
-
return {
|
|
8
|
-
name: 'caption',
|
|
9
|
-
nodes() {
|
|
10
|
-
return [{
|
|
11
|
-
name: 'caption',
|
|
12
|
-
node: caption
|
|
13
|
-
}];
|
|
14
|
-
},
|
|
15
|
-
pmPlugins() {
|
|
16
|
-
return [{
|
|
17
|
-
name: 'caption',
|
|
18
|
-
plugin: ({
|
|
19
|
-
portalProviderAPI,
|
|
20
|
-
providerFactory,
|
|
21
|
-
eventDispatcher,
|
|
22
|
-
dispatch
|
|
23
|
-
}) => createCaptionPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api)
|
|
24
|
-
}, {
|
|
25
|
-
name: 'captionKeymap',
|
|
26
|
-
plugin: captionKeymap
|
|
27
|
-
}];
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
export default captionPlugin;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Caption } from '@atlaskit/editor-common/ui';
|
|
4
|
-
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
5
|
-
export class CaptionNodeView extends SelectionBasedNodeView {
|
|
6
|
-
constructor(...args) {
|
|
7
|
-
super(...args);
|
|
8
|
-
_defineProperty(this, "selected", this.insideSelection());
|
|
9
|
-
}
|
|
10
|
-
createDomRef() {
|
|
11
|
-
const domRef = document.createElement('figcaption');
|
|
12
|
-
domRef.setAttribute('data-caption', 'true');
|
|
13
|
-
return domRef;
|
|
14
|
-
}
|
|
15
|
-
getContentDOM() {
|
|
16
|
-
const dom = document.createElement('div');
|
|
17
|
-
// setting a className prevents PM/Chrome mutation observer from
|
|
18
|
-
// incorrectly deleting nodes
|
|
19
|
-
dom.className = 'caption-wrapper';
|
|
20
|
-
return {
|
|
21
|
-
dom
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
render(_props, forwardRef) {
|
|
25
|
-
return /*#__PURE__*/React.createElement(Caption, {
|
|
26
|
-
selected: this.insideSelection(),
|
|
27
|
-
hasContent: this.node.content.childCount > 0
|
|
28
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
29
|
-
ref: forwardRef
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
viewShouldUpdate(nextNode) {
|
|
33
|
-
if (this.node.childCount !== nextNode.childCount) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
const newSelected = this.insideSelection();
|
|
37
|
-
const selectedStateChange = this.selected !== newSelected;
|
|
38
|
-
this.selected = newSelected;
|
|
39
|
-
return selectedStateChange;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export default function captionNodeView(portalProviderAPI, eventDispatcher, pluginInjectionApi) {
|
|
43
|
-
return (node, view, getPos) => {
|
|
44
|
-
const hasIntlContext = true;
|
|
45
|
-
return new CaptionNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {}, undefined, undefined, undefined, hasIntlContext).init();
|
|
46
|
-
};
|
|
47
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { bindKeymapWithCommand, moveDown, enter, moveUp, shiftTab, tab, moveLeft } from '@atlaskit/editor-common/keymaps';
|
|
4
|
-
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { createNewParagraphBelow } from '@atlaskit/editor-common/utils';
|
|
6
|
-
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
7
|
-
export function captionKeymap() {
|
|
8
|
-
const list = {};
|
|
9
|
-
bindKeymapWithCommand(moveDown.common, createNewParagraphBelowCaption, list);
|
|
10
|
-
bindKeymapWithCommand(enter.common, createNewParagraphBelowCaption, list);
|
|
11
|
-
bindKeymapWithCommand(moveDown.common, getOutOfCaption, list);
|
|
12
|
-
bindKeymapWithCommand(enter.common, getOutOfCaption, list);
|
|
13
|
-
bindKeymapWithCommand(moveUp.common, selectParentMediaSingle, list);
|
|
14
|
-
bindKeymapWithCommand(shiftTab.common, selectParentMediaSingle, list);
|
|
15
|
-
bindKeymapWithCommand(tab.common, getOutOfCaption, list);
|
|
16
|
-
bindKeymapWithCommand(moveLeft.common, gapCursorSelectLeftParentMediaSingle, list);
|
|
17
|
-
return keymap(list);
|
|
18
|
-
}
|
|
19
|
-
const createNewParagraphBelowCaption = (state, dispatch) => {
|
|
20
|
-
const caption = findParentNodeOfType(state.schema.nodes.caption)(state.selection);
|
|
21
|
-
if (caption) {
|
|
22
|
-
return createNewParagraphBelow(state, dispatch);
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
};
|
|
26
|
-
const getOutOfCaption = (state, dispatch) => {
|
|
27
|
-
const caption = findParentNodeOfType(state.schema.nodes.caption)(state.selection);
|
|
28
|
-
if (caption) {
|
|
29
|
-
if (dispatch) {
|
|
30
|
-
const tr = state.tr.setSelection(Selection.near(state.tr.doc.resolve(caption.pos + caption.node.nodeSize)));
|
|
31
|
-
dispatch(tr);
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
};
|
|
37
|
-
const selectParentMediaSingle = (state, dispatch) => {
|
|
38
|
-
if (findParentNodeOfType(state.schema.nodes.caption)(state.selection)) {
|
|
39
|
-
const mediaSingleParent = findParentNodeOfType(state.schema.nodes.mediaSingle)(state.selection);
|
|
40
|
-
if (mediaSingleParent) {
|
|
41
|
-
if (dispatch) {
|
|
42
|
-
const tr = state.tr.setSelection(Selection.near(state.tr.doc.resolve(mediaSingleParent.pos)));
|
|
43
|
-
dispatch(tr);
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
};
|
|
50
|
-
const gapCursorSelectLeftParentMediaSingle = (state, dispatch) => {
|
|
51
|
-
const caption = findParentNodeOfType(state.schema.nodes.caption)(state.selection);
|
|
52
|
-
if (caption) {
|
|
53
|
-
const mediaSingleParent = findParentNodeOfType(state.schema.nodes.mediaSingle)(state.selection);
|
|
54
|
-
if (mediaSingleParent && state.selection.empty && state.tr.doc.resolve(state.selection.from).parentOffset === 0) {
|
|
55
|
-
const gapCursorSelection = GapCursorSelection.findFrom(state.tr.doc.resolve(mediaSingleParent.pos), 0, false);
|
|
56
|
-
if (gapCursorSelection) {
|
|
57
|
-
if (dispatch) {
|
|
58
|
-
const tr = state.tr.setSelection(gapCursorSelection);
|
|
59
|
-
dispatch(tr);
|
|
60
|
-
}
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
-
import { pluginKey } from './plugin-key';
|
|
4
|
-
import captionNodeView from './../nodeviews';
|
|
5
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
const fireAnalytics = (tr, action, analyticsApi) => {
|
|
7
|
-
analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent({
|
|
8
|
-
action,
|
|
9
|
-
eventType: EVENT_TYPE.TRACK,
|
|
10
|
-
actionSubject: ACTION_SUBJECT.MEDIA_SINGLE,
|
|
11
|
-
actionSubjectId: ACTION_SUBJECT_ID.CAPTION
|
|
12
|
-
})(tr);
|
|
13
|
-
};
|
|
14
|
-
export default ((portalProviderAPI, eventDispatcher, providerFactory, dispatch, pluginInjectionApi) => {
|
|
15
|
-
var _pluginInjectionApi$a;
|
|
16
|
-
const analyticsApi = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
17
|
-
return new SafePlugin({
|
|
18
|
-
appendTransaction(transactions, oldState, newState) {
|
|
19
|
-
// only run for transactions that change selection
|
|
20
|
-
if (!transactions.find(tr => tr.selectionSet)) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const newSelection = !newState.selection.eq(oldState.selection);
|
|
24
|
-
const findCaption = findParentNodeOfType(oldState.schema.nodes.caption);
|
|
25
|
-
const oldSelectionCaption = findCaption(oldState.selection);
|
|
26
|
-
const {
|
|
27
|
-
tr
|
|
28
|
-
} = newState;
|
|
29
|
-
|
|
30
|
-
// if selecting away from caption, or selecting a different caption
|
|
31
|
-
if (newSelection && oldSelectionCaption) {
|
|
32
|
-
if (oldSelectionCaption.node.childCount === 0) {
|
|
33
|
-
tr.delete(oldSelectionCaption.start - 1, oldSelectionCaption.start);
|
|
34
|
-
tr.setMeta('scrollIntoView', false);
|
|
35
|
-
fireAnalytics(tr, ACTION.DELETED, analyticsApi);
|
|
36
|
-
return tr;
|
|
37
|
-
} else {
|
|
38
|
-
fireAnalytics(tr, ACTION.EDITED, analyticsApi);
|
|
39
|
-
return tr;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
key: pluginKey,
|
|
44
|
-
props: {
|
|
45
|
-
nodeViews: {
|
|
46
|
-
caption: captionNodeView(portalProviderAPI, eventDispatcher, pluginInjectionApi)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { caption } from '@atlaskit/adf-schema';
|
|
2
|
-
import { default as createCaptionPlugin } from './pm-plugins/main';
|
|
3
|
-
import { captionKeymap } from './pm-plugins/keymap';
|
|
4
|
-
var captionPlugin = function captionPlugin(_ref) {
|
|
5
|
-
var api = _ref.api;
|
|
6
|
-
return {
|
|
7
|
-
name: 'caption',
|
|
8
|
-
nodes: function nodes() {
|
|
9
|
-
return [{
|
|
10
|
-
name: 'caption',
|
|
11
|
-
node: caption
|
|
12
|
-
}];
|
|
13
|
-
},
|
|
14
|
-
pmPlugins: function pmPlugins() {
|
|
15
|
-
return [{
|
|
16
|
-
name: 'caption',
|
|
17
|
-
plugin: function plugin(_ref2) {
|
|
18
|
-
var portalProviderAPI = _ref2.portalProviderAPI,
|
|
19
|
-
providerFactory = _ref2.providerFactory,
|
|
20
|
-
eventDispatcher = _ref2.eventDispatcher,
|
|
21
|
-
dispatch = _ref2.dispatch;
|
|
22
|
-
return createCaptionPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api);
|
|
23
|
-
}
|
|
24
|
-
}, {
|
|
25
|
-
name: 'captionKeymap',
|
|
26
|
-
plugin: captionKeymap
|
|
27
|
-
}];
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
export default captionPlugin;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import { Caption } from '@atlaskit/editor-common/ui';
|
|
12
|
-
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
13
|
-
export var CaptionNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
14
|
-
_inherits(CaptionNodeView, _SelectionBasedNodeVi);
|
|
15
|
-
var _super = _createSuper(CaptionNodeView);
|
|
16
|
-
function CaptionNodeView() {
|
|
17
|
-
var _this;
|
|
18
|
-
_classCallCheck(this, CaptionNodeView);
|
|
19
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
|
-
args[_key] = arguments[_key];
|
|
21
|
-
}
|
|
22
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
23
|
-
_defineProperty(_assertThisInitialized(_this), "selected", _this.insideSelection());
|
|
24
|
-
return _this;
|
|
25
|
-
}
|
|
26
|
-
_createClass(CaptionNodeView, [{
|
|
27
|
-
key: "createDomRef",
|
|
28
|
-
value: function createDomRef() {
|
|
29
|
-
var domRef = document.createElement('figcaption');
|
|
30
|
-
domRef.setAttribute('data-caption', 'true');
|
|
31
|
-
return domRef;
|
|
32
|
-
}
|
|
33
|
-
}, {
|
|
34
|
-
key: "getContentDOM",
|
|
35
|
-
value: function getContentDOM() {
|
|
36
|
-
var dom = document.createElement('div');
|
|
37
|
-
// setting a className prevents PM/Chrome mutation observer from
|
|
38
|
-
// incorrectly deleting nodes
|
|
39
|
-
dom.className = 'caption-wrapper';
|
|
40
|
-
return {
|
|
41
|
-
dom: dom
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}, {
|
|
45
|
-
key: "render",
|
|
46
|
-
value: function render(_props, forwardRef) {
|
|
47
|
-
return /*#__PURE__*/React.createElement(Caption, {
|
|
48
|
-
selected: this.insideSelection(),
|
|
49
|
-
hasContent: this.node.content.childCount > 0
|
|
50
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
51
|
-
ref: forwardRef
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "viewShouldUpdate",
|
|
56
|
-
value: function viewShouldUpdate(nextNode) {
|
|
57
|
-
if (this.node.childCount !== nextNode.childCount) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
var newSelected = this.insideSelection();
|
|
61
|
-
var selectedStateChange = this.selected !== newSelected;
|
|
62
|
-
this.selected = newSelected;
|
|
63
|
-
return selectedStateChange;
|
|
64
|
-
}
|
|
65
|
-
}]);
|
|
66
|
-
return CaptionNodeView;
|
|
67
|
-
}(SelectionBasedNodeView);
|
|
68
|
-
export default function captionNodeView(portalProviderAPI, eventDispatcher, pluginInjectionApi) {
|
|
69
|
-
return function (node, view, getPos) {
|
|
70
|
-
var hasIntlContext = true;
|
|
71
|
-
return new CaptionNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {}, undefined, undefined, undefined, hasIntlContext).init();
|
|
72
|
-
};
|
|
73
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { bindKeymapWithCommand, moveDown, enter, moveUp, shiftTab, tab, moveLeft } from '@atlaskit/editor-common/keymaps';
|
|
4
|
-
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { createNewParagraphBelow } from '@atlaskit/editor-common/utils';
|
|
6
|
-
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
7
|
-
export function captionKeymap() {
|
|
8
|
-
var list = {};
|
|
9
|
-
bindKeymapWithCommand(moveDown.common, createNewParagraphBelowCaption, list);
|
|
10
|
-
bindKeymapWithCommand(enter.common, createNewParagraphBelowCaption, list);
|
|
11
|
-
bindKeymapWithCommand(moveDown.common, getOutOfCaption, list);
|
|
12
|
-
bindKeymapWithCommand(enter.common, getOutOfCaption, list);
|
|
13
|
-
bindKeymapWithCommand(moveUp.common, selectParentMediaSingle, list);
|
|
14
|
-
bindKeymapWithCommand(shiftTab.common, selectParentMediaSingle, list);
|
|
15
|
-
bindKeymapWithCommand(tab.common, getOutOfCaption, list);
|
|
16
|
-
bindKeymapWithCommand(moveLeft.common, gapCursorSelectLeftParentMediaSingle, list);
|
|
17
|
-
return keymap(list);
|
|
18
|
-
}
|
|
19
|
-
var createNewParagraphBelowCaption = function createNewParagraphBelowCaption(state, dispatch) {
|
|
20
|
-
var caption = findParentNodeOfType(state.schema.nodes.caption)(state.selection);
|
|
21
|
-
if (caption) {
|
|
22
|
-
return createNewParagraphBelow(state, dispatch);
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
};
|
|
26
|
-
var getOutOfCaption = function getOutOfCaption(state, dispatch) {
|
|
27
|
-
var caption = findParentNodeOfType(state.schema.nodes.caption)(state.selection);
|
|
28
|
-
if (caption) {
|
|
29
|
-
if (dispatch) {
|
|
30
|
-
var tr = state.tr.setSelection(Selection.near(state.tr.doc.resolve(caption.pos + caption.node.nodeSize)));
|
|
31
|
-
dispatch(tr);
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
};
|
|
37
|
-
var selectParentMediaSingle = function selectParentMediaSingle(state, dispatch) {
|
|
38
|
-
if (findParentNodeOfType(state.schema.nodes.caption)(state.selection)) {
|
|
39
|
-
var mediaSingleParent = findParentNodeOfType(state.schema.nodes.mediaSingle)(state.selection);
|
|
40
|
-
if (mediaSingleParent) {
|
|
41
|
-
if (dispatch) {
|
|
42
|
-
var tr = state.tr.setSelection(Selection.near(state.tr.doc.resolve(mediaSingleParent.pos)));
|
|
43
|
-
dispatch(tr);
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
};
|
|
50
|
-
var gapCursorSelectLeftParentMediaSingle = function gapCursorSelectLeftParentMediaSingle(state, dispatch) {
|
|
51
|
-
var caption = findParentNodeOfType(state.schema.nodes.caption)(state.selection);
|
|
52
|
-
if (caption) {
|
|
53
|
-
var mediaSingleParent = findParentNodeOfType(state.schema.nodes.mediaSingle)(state.selection);
|
|
54
|
-
if (mediaSingleParent && state.selection.empty && state.tr.doc.resolve(state.selection.from).parentOffset === 0) {
|
|
55
|
-
var gapCursorSelection = GapCursorSelection.findFrom(state.tr.doc.resolve(mediaSingleParent.pos), 0, false);
|
|
56
|
-
if (gapCursorSelection) {
|
|
57
|
-
if (dispatch) {
|
|
58
|
-
var tr = state.tr.setSelection(gapCursorSelection);
|
|
59
|
-
dispatch(tr);
|
|
60
|
-
}
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
-
import { pluginKey } from './plugin-key';
|
|
4
|
-
import captionNodeView from './../nodeviews';
|
|
5
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
var fireAnalytics = function fireAnalytics(tr, action, analyticsApi) {
|
|
7
|
-
analyticsApi === null || analyticsApi === void 0 || analyticsApi.attachAnalyticsEvent({
|
|
8
|
-
action: action,
|
|
9
|
-
eventType: EVENT_TYPE.TRACK,
|
|
10
|
-
actionSubject: ACTION_SUBJECT.MEDIA_SINGLE,
|
|
11
|
-
actionSubjectId: ACTION_SUBJECT_ID.CAPTION
|
|
12
|
-
})(tr);
|
|
13
|
-
};
|
|
14
|
-
export default (function (portalProviderAPI, eventDispatcher, providerFactory, dispatch, pluginInjectionApi) {
|
|
15
|
-
var _pluginInjectionApi$a;
|
|
16
|
-
var analyticsApi = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
17
|
-
return new SafePlugin({
|
|
18
|
-
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
19
|
-
// only run for transactions that change selection
|
|
20
|
-
if (!transactions.find(function (tr) {
|
|
21
|
-
return tr.selectionSet;
|
|
22
|
-
})) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
var newSelection = !newState.selection.eq(oldState.selection);
|
|
26
|
-
var findCaption = findParentNodeOfType(oldState.schema.nodes.caption);
|
|
27
|
-
var oldSelectionCaption = findCaption(oldState.selection);
|
|
28
|
-
var tr = newState.tr;
|
|
29
|
-
|
|
30
|
-
// if selecting away from caption, or selecting a different caption
|
|
31
|
-
if (newSelection && oldSelectionCaption) {
|
|
32
|
-
if (oldSelectionCaption.node.childCount === 0) {
|
|
33
|
-
tr.delete(oldSelectionCaption.start - 1, oldSelectionCaption.start);
|
|
34
|
-
tr.setMeta('scrollIntoView', false);
|
|
35
|
-
fireAnalytics(tr, ACTION.DELETED, analyticsApi);
|
|
36
|
-
return tr;
|
|
37
|
-
} else {
|
|
38
|
-
fireAnalytics(tr, ACTION.EDITED, analyticsApi);
|
|
39
|
-
return tr;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
key: pluginKey,
|
|
44
|
-
props: {
|
|
45
|
-
nodeViews: {
|
|
46
|
-
caption: captionNodeView(portalProviderAPI, eventDispatcher, pluginInjectionApi)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import type { ExtractInjectionAPI, getPosHandler } from '@atlaskit/editor-common/types';
|
|
5
|
-
import type { ForwardRef } from '@atlaskit/editor-common/react-node-view';
|
|
6
|
-
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
7
|
-
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
8
|
-
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
9
|
-
import type captionPlugin from '../index';
|
|
10
|
-
export declare class CaptionNodeView extends SelectionBasedNodeView {
|
|
11
|
-
private selected;
|
|
12
|
-
createDomRef(): HTMLElement;
|
|
13
|
-
getContentDOM(): {
|
|
14
|
-
dom: HTMLDivElement;
|
|
15
|
-
};
|
|
16
|
-
render(_props: never, forwardRef: ForwardRef): JSX.Element;
|
|
17
|
-
viewShouldUpdate(nextNode: PMNode): boolean;
|
|
18
|
-
}
|
|
19
|
-
export default function captionNodeView(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginInjectionApi: ExtractInjectionAPI<typeof captionPlugin> | undefined): (node: PMNode, view: EditorView, getPos: getPosHandler) => CaptionNodeView;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
3
|
-
import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
4
|
-
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
5
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
6
|
-
import type captionPlugin from '../index';
|
|
7
|
-
declare const _default: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, dispatch: Dispatch, pluginInjectionApi: ExtractInjectionAPI<typeof captionPlugin> | undefined) => SafePlugin<any>;
|
|
8
|
-
export default _default;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import type { ExtractInjectionAPI, getPosHandler } from '@atlaskit/editor-common/types';
|
|
5
|
-
import type { ForwardRef } from '@atlaskit/editor-common/react-node-view';
|
|
6
|
-
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
7
|
-
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
8
|
-
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
9
|
-
import type captionPlugin from '../index';
|
|
10
|
-
export declare class CaptionNodeView extends SelectionBasedNodeView {
|
|
11
|
-
private selected;
|
|
12
|
-
createDomRef(): HTMLElement;
|
|
13
|
-
getContentDOM(): {
|
|
14
|
-
dom: HTMLDivElement;
|
|
15
|
-
};
|
|
16
|
-
render(_props: never, forwardRef: ForwardRef): JSX.Element;
|
|
17
|
-
viewShouldUpdate(nextNode: PMNode): boolean;
|
|
18
|
-
}
|
|
19
|
-
export default function captionNodeView(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginInjectionApi: ExtractInjectionAPI<typeof captionPlugin> | undefined): (node: PMNode, view: EditorView, getPos: getPosHandler) => CaptionNodeView;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
3
|
-
import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
4
|
-
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
5
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
6
|
-
import type captionPlugin from '../index';
|
|
7
|
-
declare const _default: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, dispatch: Dispatch, pluginInjectionApi: ExtractInjectionAPI<typeof captionPlugin> | undefined) => SafePlugin<any>;
|
|
8
|
-
export default _default;
|