@atlaskit/editor-core 188.2.11 → 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.
Files changed (38) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/labs/next/presets/universal.js +2 -1
  3. package/dist/cjs/plugins/index.js +0 -7
  4. package/dist/cjs/version-wrapper.js +1 -1
  5. package/dist/es2019/labs/next/presets/universal.js +2 -1
  6. package/dist/es2019/plugins/index.js +0 -1
  7. package/dist/es2019/version-wrapper.js +1 -1
  8. package/dist/esm/labs/next/presets/universal.js +2 -1
  9. package/dist/esm/plugins/index.js +0 -1
  10. package/dist/esm/version-wrapper.js +1 -1
  11. package/dist/types/plugins/index.d.ts +0 -1
  12. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  13. package/package.json +2 -2
  14. package/dist/cjs/plugins/caption/index.js +0 -38
  15. package/dist/cjs/plugins/caption/nodeviews/index.js +0 -81
  16. package/dist/cjs/plugins/caption/pm-plugins/keymap.js +0 -72
  17. package/dist/cjs/plugins/caption/pm-plugins/main.js +0 -57
  18. package/dist/cjs/plugins/caption/pm-plugins/plugin-key.js +0 -8
  19. package/dist/es2019/plugins/caption/index.js +0 -31
  20. package/dist/es2019/plugins/caption/nodeviews/index.js +0 -47
  21. package/dist/es2019/plugins/caption/pm-plugins/keymap.js +0 -66
  22. package/dist/es2019/plugins/caption/pm-plugins/main.js +0 -50
  23. package/dist/es2019/plugins/caption/pm-plugins/plugin-key.js +0 -2
  24. package/dist/esm/plugins/caption/index.js +0 -31
  25. package/dist/esm/plugins/caption/nodeviews/index.js +0 -73
  26. package/dist/esm/plugins/caption/pm-plugins/keymap.js +0 -66
  27. package/dist/esm/plugins/caption/pm-plugins/main.js +0 -50
  28. package/dist/esm/plugins/caption/pm-plugins/plugin-key.js +0 -2
  29. package/dist/types/plugins/caption/index.d.ts +0 -3
  30. package/dist/types/plugins/caption/nodeviews/index.d.ts +0 -19
  31. package/dist/types/plugins/caption/pm-plugins/keymap.d.ts +0 -2
  32. package/dist/types/plugins/caption/pm-plugins/main.d.ts +0 -8
  33. package/dist/types/plugins/caption/pm-plugins/plugin-key.d.ts +0 -2
  34. package/dist/types-ts4.5/plugins/caption/index.d.ts +0 -3
  35. package/dist/types-ts4.5/plugins/caption/nodeviews/index.d.ts +0 -19
  36. package/dist/types-ts4.5/plugins/caption/pm-plugins/keymap.d.ts +0 -2
  37. package/dist/types-ts4.5/plugins/caption/pm-plugins/main.d.ts +0 -8
  38. package/dist/types-ts4.5/plugins/caption/pm-plugins/plugin-key.d.ts +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
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
+
3
13
  ## 188.2.11
4
14
 
5
15
  ### 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(_plugins.captionPlugin, function (plugin, builder) {
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);
@@ -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.2.11";
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, captionPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin, borderPlugin } from '../../../plugins';
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';
@@ -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';
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "188.2.11";
2
+ export const version = "188.3.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -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, captionPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin, borderPlugin } from '../../../plugins';
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';
@@ -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';
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "188.2.11";
2
+ export var version = "188.3.0";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -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.2.11",
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.1.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",
@@ -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,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.pluginKey = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- var pluginKey = exports.pluginKey = new _state.PluginKey('caption');
@@ -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,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export const pluginKey = new PluginKey('caption');
@@ -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,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export var pluginKey = new PluginKey('caption');
@@ -1,3 +0,0 @@
1
- import type { CaptionPlugin } from '@atlaskit/editor-plugin-caption';
2
- declare const captionPlugin: CaptionPlugin;
3
- export default captionPlugin;
@@ -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,2 +0,0 @@
1
- import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- export declare function captionKeymap(): SafePlugin;
@@ -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,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export declare const pluginKey: PluginKey<any>;
@@ -1,3 +0,0 @@
1
- import type { CaptionPlugin } from '@atlaskit/editor-plugin-caption';
2
- declare const captionPlugin: CaptionPlugin;
3
- export default captionPlugin;
@@ -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,2 +0,0 @@
1
- import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- export declare function captionKeymap(): SafePlugin;
@@ -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,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export declare const pluginKey: PluginKey<any>;