@atlaskit/editor-core 188.11.1 → 188.11.3
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 +14 -0
- package/dist/cjs/labs/next/presets/default.js +2 -1
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/paste/index.js +8 -26
- package/dist/cjs/plugins/paste/plugin.js +31 -0
- package/dist/cjs/plugins/paste/pm-plugins/plugin-factory.js +2 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/labs/next/presets/default.js +2 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/paste/index.js +3 -27
- package/dist/es2019/plugins/paste/plugin.js +26 -0
- package/dist/es2019/plugins/paste/pm-plugins/plugin-factory.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/labs/next/presets/default.js +2 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/paste/index.js +3 -26
- package/dist/esm/plugins/paste/plugin.js +25 -0
- package/dist/esm/plugins/paste/pm-plugins/plugin-factory.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/paste/index.d.ts +3 -24
- package/dist/types/plugins/paste/plugin.d.ts +2 -0
- package/dist/types/plugins/paste/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/paste/pm-plugins/plugin-factory.d.ts +1 -1
- package/dist/types/plugins/paste/types.d.ts +1 -6
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/paste/index.d.ts +3 -24
- package/dist/types-ts4.5/plugins/paste/plugin.d.ts +2 -0
- package/dist/types-ts4.5/plugins/paste/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/paste/pm-plugins/plugin-factory.d.ts +1 -1
- package/dist/types-ts4.5/plugins/paste/types.d.ts +1 -6
- package/package.json +3 -1
- package/dist/cjs/plugins/better-type-history/index.js +0 -33
- package/dist/cjs/plugins/better-type-history/pm-plugins/main.js +0 -63
- package/dist/cjs/plugins/better-type-history/pm-plugins/plugin-key.js +0 -8
- package/dist/es2019/plugins/better-type-history/index.js +0 -24
- package/dist/es2019/plugins/better-type-history/pm-plugins/main.js +0 -57
- package/dist/es2019/plugins/better-type-history/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/better-type-history/index.js +0 -26
- package/dist/esm/plugins/better-type-history/pm-plugins/main.js +0 -57
- package/dist/esm/plugins/better-type-history/pm-plugins/plugin-key.js +0 -2
- package/dist/types/plugins/better-type-history/index.d.ts +0 -13
- package/dist/types/plugins/better-type-history/pm-plugins/main.d.ts +0 -3
- package/dist/types/plugins/better-type-history/pm-plugins/plugin-key.d.ts +0 -2
- package/dist/types-ts4.5/plugins/better-type-history/index.d.ts +0 -13
- package/dist/types-ts4.5/plugins/better-type-history/pm-plugins/main.d.ts +0 -3
- package/dist/types-ts4.5/plugins/better-type-history/pm-plugins/plugin-key.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 188.11.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#41862](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41862) [`668cb3bcd3a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/668cb3bcd3a) - [ED-20519] Extract Paste Plugin: Moving the plugin type to a new package
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 188.11.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#41783](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41783) [`60b12780695`](https://bitbucket.org/atlassian/atlassian-frontend/commits/60b12780695) - [ED-20519] Extract Better Type Plugin to help paste decoupling and extraction
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 188.11.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -11,6 +11,7 @@ var _editorPluginBlockType = require("@atlaskit/editor-plugin-block-type");
|
|
|
11
11
|
var _clearMarksOnChangeToEmptyDocument = _interopRequireDefault(require("../../../plugins/clear-marks-on-change-to-empty-document"));
|
|
12
12
|
var _editorPluginHyperlink = require("@atlaskit/editor-plugin-hyperlink");
|
|
13
13
|
var _editorPluginTextFormatting = require("@atlaskit/editor-plugin-text-formatting");
|
|
14
|
+
var _editorPluginBetterTypeHistory = require("@atlaskit/editor-plugin-better-type-history");
|
|
14
15
|
var _editorPluginWidth = require("@atlaskit/editor-plugin-width");
|
|
15
16
|
var _editorPluginUnsupportedContent = require("@atlaskit/editor-plugin-unsupported-content");
|
|
16
17
|
var _editorPluginBase = require("@atlaskit/editor-plugin-base");
|
|
@@ -63,7 +64,7 @@ function createDefaultPreset(options) {
|
|
|
63
64
|
}]);
|
|
64
65
|
}
|
|
65
66
|
return builder;
|
|
66
|
-
}).add([_paste.default, options.paste]).add(_editorPluginClipboard.clipboardPlugin).add(_editorPluginFocus.focusPlugin).add(_editorPluginComposition.compositionPlugin).add([_editorPluginBase.basePlugin, options.base]).add(_editorPluginDecorations.decorationsPlugin).maybeAdd(_undoRedo.default, function (p, builder) {
|
|
67
|
+
}).add(_editorPluginBetterTypeHistory.betterTypeHistoryPlugin).add([_paste.default, options.paste]).add(_editorPluginClipboard.clipboardPlugin).add(_editorPluginFocus.focusPlugin).add(_editorPluginComposition.compositionPlugin).add([_editorPluginBase.basePlugin, options.base]).add(_editorPluginDecorations.decorationsPlugin).maybeAdd(_undoRedo.default, function (p, builder) {
|
|
67
68
|
var _options$featureFlags;
|
|
68
69
|
// The undo redo plugin needs to be add before the blockTypePlugin
|
|
69
70
|
if ((_options$featureFlags = options.featureFlags) !== null && _options$featureFlags !== void 0 && _options$featureFlags.undoRedoButtons) {
|
|
@@ -35,12 +35,6 @@ Object.defineProperty(exports, "beforePrimaryToolbarPlugin", {
|
|
|
35
35
|
return _beforePrimaryToolbar.default;
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
-
Object.defineProperty(exports, "betterTypeHistoryPlugin", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function get() {
|
|
41
|
-
return _betterTypeHistory.default;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
38
|
Object.defineProperty(exports, "breakoutPlugin", {
|
|
45
39
|
enumerable: true,
|
|
46
40
|
get: function get() {
|
|
@@ -233,7 +227,6 @@ Object.defineProperty(exports, "viewUpdateSubscriptionPlugin", {
|
|
|
233
227
|
return _viewUpdateSubscription.default;
|
|
234
228
|
}
|
|
235
229
|
});
|
|
236
|
-
var _betterTypeHistory = _interopRequireDefault(require("./better-type-history"));
|
|
237
230
|
var _clearMarksOnChangeToEmptyDocument = _interopRequireDefault(require("./clear-marks-on-change-to-empty-document"));
|
|
238
231
|
var _codeBlock = _interopRequireDefault(require("./code-block"));
|
|
239
232
|
var _collabEdit = _interopRequireDefault(require("./collab-edit"));
|
|
@@ -4,29 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
16
|
-
return {
|
|
17
|
-
name: 'paste',
|
|
18
|
-
pmPlugins: function pmPlugins() {
|
|
19
|
-
return [{
|
|
20
|
-
name: 'paste',
|
|
21
|
-
plugin: function plugin(_ref3) {
|
|
22
|
-
var schema = _ref3.schema,
|
|
23
|
-
providerFactory = _ref3.providerFactory,
|
|
24
|
-
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent,
|
|
25
|
-
dispatch = _ref3.dispatch;
|
|
26
|
-
return (0, _main.createPlugin)(schema, dispatchAnalyticsEvent, dispatch, featureFlags, api, cardOptions, sanitizePrivateContent, providerFactory);
|
|
27
|
-
}
|
|
28
|
-
}];
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
var _default = exports.default = pastePlugin;
|
|
7
|
+
Object.defineProperty(exports, "pastePlugin", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _plugin.pastePlugin;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _plugin = require("./plugin");
|
|
14
|
+
var _default = exports.default = _plugin.pastePlugin;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.pastePlugin = void 0;
|
|
7
|
+
var _main = require("./pm-plugins/main");
|
|
8
|
+
var pastePlugin = exports.pastePlugin = function pastePlugin(_ref) {
|
|
9
|
+
var _api$featureFlags;
|
|
10
|
+
var config = _ref.config,
|
|
11
|
+
api = _ref.api;
|
|
12
|
+
var _ref2 = config !== null && config !== void 0 ? config : {},
|
|
13
|
+
cardOptions = _ref2.cardOptions,
|
|
14
|
+
sanitizePrivateContent = _ref2.sanitizePrivateContent;
|
|
15
|
+
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
16
|
+
return {
|
|
17
|
+
name: 'paste',
|
|
18
|
+
pmPlugins: function pmPlugins() {
|
|
19
|
+
return [{
|
|
20
|
+
name: 'paste',
|
|
21
|
+
plugin: function plugin(_ref3) {
|
|
22
|
+
var schema = _ref3.schema,
|
|
23
|
+
providerFactory = _ref3.providerFactory,
|
|
24
|
+
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent,
|
|
25
|
+
dispatch = _ref3.dispatch;
|
|
26
|
+
return (0, _main.createPlugin)(schema, dispatchAnalyticsEvent, dispatch, featureFlags, api, cardOptions, sanitizePrivateContent, providerFactory);
|
|
27
|
+
}
|
|
28
|
+
}];
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -8,12 +8,12 @@ exports.pluginKey = exports.getPluginState = exports.createPluginState = exports
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
-
var
|
|
11
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
12
|
var _reducer = require("../reducer");
|
|
13
13
|
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; }
|
|
14
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
15
|
var pluginKey = exports.pluginKey = new _state.PluginKey('pastePlugin');
|
|
16
|
-
var _pluginFactory = (0,
|
|
16
|
+
var _pluginFactory = (0, _utils.pluginFactory)(pluginKey, _reducer.reducer, {
|
|
17
17
|
mapping: function mapping(tr, pluginState) {
|
|
18
18
|
if (tr.docChanged) {
|
|
19
19
|
var atLeastOnePositionChanged = false;
|
|
@@ -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.11.
|
|
8
|
+
var version = exports.version = "188.11.3";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
|
@@ -5,6 +5,7 @@ import { blockTypePlugin } from '@atlaskit/editor-plugin-block-type';
|
|
|
5
5
|
import clearMarksOnChangeToEmptyDocumentPlugin from '../../../plugins/clear-marks-on-change-to-empty-document';
|
|
6
6
|
import { hyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
|
|
7
7
|
import { textFormattingPlugin } from '@atlaskit/editor-plugin-text-formatting';
|
|
8
|
+
import { betterTypeHistoryPlugin } from '@atlaskit/editor-plugin-better-type-history';
|
|
8
9
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
9
10
|
import { unsupportedContentPlugin } from '@atlaskit/editor-plugin-unsupported-content';
|
|
10
11
|
import { basePlugin } from '@atlaskit/editor-plugin-base';
|
|
@@ -59,7 +60,7 @@ export function createDefaultPreset(options) {
|
|
|
59
60
|
}]);
|
|
60
61
|
}
|
|
61
62
|
return builder;
|
|
62
|
-
}).add([pastePlugin, options.paste]).add(clipboardPlugin).add(focusPlugin).add(compositionPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, (p, builder) => {
|
|
63
|
+
}).add(betterTypeHistoryPlugin).add([pastePlugin, options.paste]).add(clipboardPlugin).add(focusPlugin).add(compositionPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, (p, builder) => {
|
|
63
64
|
var _options$featureFlags;
|
|
64
65
|
// The undo redo plugin needs to be add before the blockTypePlugin
|
|
65
66
|
if ((_options$featureFlags = options.featureFlags) !== null && _options$featureFlags !== void 0 && _options$featureFlags.undoRedoButtons) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { default as betterTypeHistoryPlugin } from './better-type-history';
|
|
2
1
|
export { default as clearMarksOnChangeToEmptyDocumentPlugin } from './clear-marks-on-change-to-empty-document';
|
|
3
2
|
export { default as codeBlockPlugin } from './code-block';
|
|
4
3
|
export { default as collabEditPlugin } from './collab-edit';
|
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
api
|
|
5
|
-
}) => {
|
|
6
|
-
var _api$featureFlags;
|
|
7
|
-
const {
|
|
8
|
-
cardOptions,
|
|
9
|
-
sanitizePrivateContent
|
|
10
|
-
} = config !== null && config !== void 0 ? config : {};
|
|
11
|
-
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
12
|
-
return {
|
|
13
|
-
name: 'paste',
|
|
14
|
-
pmPlugins() {
|
|
15
|
-
return [{
|
|
16
|
-
name: 'paste',
|
|
17
|
-
plugin: ({
|
|
18
|
-
schema,
|
|
19
|
-
providerFactory,
|
|
20
|
-
dispatchAnalyticsEvent,
|
|
21
|
-
dispatch
|
|
22
|
-
}) => createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, api, cardOptions, sanitizePrivateContent, providerFactory)
|
|
23
|
-
}];
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export default pastePlugin;
|
|
1
|
+
import { pastePlugin } from './plugin';
|
|
2
|
+
export default pastePlugin;
|
|
3
|
+
export { pastePlugin };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createPlugin } from './pm-plugins/main';
|
|
2
|
+
export const pastePlugin = ({
|
|
3
|
+
config,
|
|
4
|
+
api
|
|
5
|
+
}) => {
|
|
6
|
+
var _api$featureFlags;
|
|
7
|
+
const {
|
|
8
|
+
cardOptions,
|
|
9
|
+
sanitizePrivateContent
|
|
10
|
+
} = config !== null && config !== void 0 ? config : {};
|
|
11
|
+
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
12
|
+
return {
|
|
13
|
+
name: 'paste',
|
|
14
|
+
pmPlugins() {
|
|
15
|
+
return [{
|
|
16
|
+
name: 'paste',
|
|
17
|
+
plugin: ({
|
|
18
|
+
schema,
|
|
19
|
+
providerFactory,
|
|
20
|
+
dispatchAnalyticsEvent,
|
|
21
|
+
dispatch
|
|
22
|
+
}) => createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, api, cardOptions, sanitizePrivateContent, providerFactory)
|
|
23
|
+
}];
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { pluginFactory } from '
|
|
2
|
+
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { reducer } from '../reducer';
|
|
4
4
|
export const pluginKey = new PluginKey('pastePlugin');
|
|
5
5
|
export const {
|
|
@@ -5,6 +5,7 @@ import { blockTypePlugin } from '@atlaskit/editor-plugin-block-type';
|
|
|
5
5
|
import clearMarksOnChangeToEmptyDocumentPlugin from '../../../plugins/clear-marks-on-change-to-empty-document';
|
|
6
6
|
import { hyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
|
|
7
7
|
import { textFormattingPlugin } from '@atlaskit/editor-plugin-text-formatting';
|
|
8
|
+
import { betterTypeHistoryPlugin } from '@atlaskit/editor-plugin-better-type-history';
|
|
8
9
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
9
10
|
import { unsupportedContentPlugin } from '@atlaskit/editor-plugin-unsupported-content';
|
|
10
11
|
import { basePlugin } from '@atlaskit/editor-plugin-base';
|
|
@@ -55,7 +56,7 @@ export function createDefaultPreset(options) {
|
|
|
55
56
|
}]);
|
|
56
57
|
}
|
|
57
58
|
return builder;
|
|
58
|
-
}).add([pastePlugin, options.paste]).add(clipboardPlugin).add(focusPlugin).add(compositionPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, function (p, builder) {
|
|
59
|
+
}).add(betterTypeHistoryPlugin).add([pastePlugin, options.paste]).add(clipboardPlugin).add(focusPlugin).add(compositionPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, function (p, builder) {
|
|
59
60
|
var _options$featureFlags;
|
|
60
61
|
// The undo redo plugin needs to be add before the blockTypePlugin
|
|
61
62
|
if ((_options$featureFlags = options.featureFlags) !== null && _options$featureFlags !== void 0 && _options$featureFlags.undoRedoButtons) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { default as betterTypeHistoryPlugin } from './better-type-history';
|
|
2
1
|
export { default as clearMarksOnChangeToEmptyDocumentPlugin } from './clear-marks-on-change-to-empty-document';
|
|
3
2
|
export { default as codeBlockPlugin } from './code-block';
|
|
4
3
|
export { default as collabEditPlugin } from './collab-edit';
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var config = _ref.config,
|
|
5
|
-
api = _ref.api;
|
|
6
|
-
var _ref2 = config !== null && config !== void 0 ? config : {},
|
|
7
|
-
cardOptions = _ref2.cardOptions,
|
|
8
|
-
sanitizePrivateContent = _ref2.sanitizePrivateContent;
|
|
9
|
-
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
10
|
-
return {
|
|
11
|
-
name: 'paste',
|
|
12
|
-
pmPlugins: function pmPlugins() {
|
|
13
|
-
return [{
|
|
14
|
-
name: 'paste',
|
|
15
|
-
plugin: function plugin(_ref3) {
|
|
16
|
-
var schema = _ref3.schema,
|
|
17
|
-
providerFactory = _ref3.providerFactory,
|
|
18
|
-
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent,
|
|
19
|
-
dispatch = _ref3.dispatch;
|
|
20
|
-
return createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, api, cardOptions, sanitizePrivateContent, providerFactory);
|
|
21
|
-
}
|
|
22
|
-
}];
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export default pastePlugin;
|
|
1
|
+
import { pastePlugin } from './plugin';
|
|
2
|
+
export default pastePlugin;
|
|
3
|
+
export { pastePlugin };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createPlugin } from './pm-plugins/main';
|
|
2
|
+
export var pastePlugin = function pastePlugin(_ref) {
|
|
3
|
+
var _api$featureFlags;
|
|
4
|
+
var config = _ref.config,
|
|
5
|
+
api = _ref.api;
|
|
6
|
+
var _ref2 = config !== null && config !== void 0 ? config : {},
|
|
7
|
+
cardOptions = _ref2.cardOptions,
|
|
8
|
+
sanitizePrivateContent = _ref2.sanitizePrivateContent;
|
|
9
|
+
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
10
|
+
return {
|
|
11
|
+
name: 'paste',
|
|
12
|
+
pmPlugins: function pmPlugins() {
|
|
13
|
+
return [{
|
|
14
|
+
name: 'paste',
|
|
15
|
+
plugin: function plugin(_ref3) {
|
|
16
|
+
var schema = _ref3.schema,
|
|
17
|
+
providerFactory = _ref3.providerFactory,
|
|
18
|
+
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent,
|
|
19
|
+
dispatch = _ref3.dispatch;
|
|
20
|
+
return createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, api, cardOptions, sanitizePrivateContent, providerFactory);
|
|
21
|
+
}
|
|
22
|
+
}];
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
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 { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
-
import { pluginFactory } from '
|
|
6
|
+
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { reducer } from '../reducer';
|
|
8
8
|
export var pluginKey = new PluginKey('pastePlugin');
|
|
9
9
|
var _pluginFactory = pluginFactory(pluginKey, reducer, {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { default as betterTypeHistoryPlugin } from './better-type-history';
|
|
2
1
|
export { default as clearMarksOnChangeToEmptyDocumentPlugin } from './clear-marks-on-change-to-empty-document';
|
|
3
2
|
export { default as codeBlockPlugin } from './code-block';
|
|
4
3
|
export { default as collabEditPlugin } from './collab-edit';
|
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
4
|
-
import type { cardPlugin } from '@atlaskit/editor-plugin-card';
|
|
5
|
-
import type betterTypeHistoryPlugin from '../better-type-history';
|
|
6
|
-
import type { listPlugin } from '@atlaskit/editor-plugin-list';
|
|
7
|
-
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
8
|
-
import type { MediaPlugin } from '@atlaskit/editor-plugin-media';
|
|
9
|
-
export type PastePluginOptions = {
|
|
10
|
-
cardOptions?: CardOptions;
|
|
11
|
-
sanitizePrivateContent?: boolean;
|
|
12
|
-
};
|
|
13
|
-
export type PastePlugin = NextEditorPlugin<'paste', {
|
|
14
|
-
pluginConfiguration: PastePluginOptions;
|
|
15
|
-
dependencies: [
|
|
16
|
-
FeatureFlagsPlugin,
|
|
17
|
-
OptionalPlugin<typeof listPlugin>,
|
|
18
|
-
typeof betterTypeHistoryPlugin,
|
|
19
|
-
OptionalPlugin<typeof cardPlugin>,
|
|
20
|
-
OptionalPlugin<typeof analyticsPlugin>,
|
|
21
|
-
OptionalPlugin<MediaPlugin>
|
|
22
|
-
];
|
|
23
|
-
}>;
|
|
24
|
-
declare const pastePlugin: PastePlugin;
|
|
1
|
+
import { pastePlugin } from './plugin';
|
|
2
|
+
export type { PastePlugin, PastePluginOptions } from './types';
|
|
25
3
|
export default pastePlugin;
|
|
4
|
+
export { pastePlugin };
|
|
@@ -7,4 +7,4 @@ export { pluginKey as stateKey } from './plugin-factory';
|
|
|
7
7
|
import type { Dispatch } from '../../../event-dispatcher';
|
|
8
8
|
import type { FeatureFlags, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
9
9
|
import type { PastePlugin } from '../';
|
|
10
|
-
export declare function createPlugin(schema: Schema, dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, featureFlags: FeatureFlags, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, cardOptions?: CardOptions, sanitizePrivateContent?: boolean, providerFactory?: ProviderFactory): SafePlugin<import("
|
|
10
|
+
export declare function createPlugin(schema: Schema, dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, featureFlags: FeatureFlags, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, cardOptions?: CardOptions, sanitizePrivateContent?: boolean, providerFactory?: ProviderFactory): SafePlugin<import("@atlaskit/editor-plugin-paste").PastePluginState>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export declare const pluginKey: PluginKey<any>;
|
|
3
|
-
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: import("
|
|
3
|
+
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: import("@atlaskit/editor-plugin-paste").PastePluginState | ((state: import("prosemirror-state").EditorState) => import("@atlaskit/editor-plugin-paste").PastePluginState)) => import("prosemirror-state").SafeStateField<import("@atlaskit/editor-plugin-paste").PastePluginState>, createCommand: <A = import("../actions").PastePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => import("@atlaskit/editor-plugin-paste").PastePluginState;
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
/** map of pasted macro link positions that will to be mapped through incoming transactions */
|
|
3
|
-
pastedMacroPositions: {
|
|
4
|
-
[key: string]: number;
|
|
5
|
-
};
|
|
6
|
-
}
|
|
1
|
+
export type { PastePlugin, PastePluginOptions, PastePluginState, } from '@atlaskit/editor-plugin-paste';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { default as betterTypeHistoryPlugin } from './better-type-history';
|
|
2
1
|
export { default as clearMarksOnChangeToEmptyDocumentPlugin } from './clear-marks-on-change-to-empty-document';
|
|
3
2
|
export { default as codeBlockPlugin } from './code-block';
|
|
4
3
|
export { default as collabEditPlugin } from './collab-edit';
|
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
4
|
-
import type { cardPlugin } from '@atlaskit/editor-plugin-card';
|
|
5
|
-
import type betterTypeHistoryPlugin from '../better-type-history';
|
|
6
|
-
import type { listPlugin } from '@atlaskit/editor-plugin-list';
|
|
7
|
-
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
8
|
-
import type { MediaPlugin } from '@atlaskit/editor-plugin-media';
|
|
9
|
-
export type PastePluginOptions = {
|
|
10
|
-
cardOptions?: CardOptions;
|
|
11
|
-
sanitizePrivateContent?: boolean;
|
|
12
|
-
};
|
|
13
|
-
export type PastePlugin = NextEditorPlugin<'paste', {
|
|
14
|
-
pluginConfiguration: PastePluginOptions;
|
|
15
|
-
dependencies: [
|
|
16
|
-
FeatureFlagsPlugin,
|
|
17
|
-
OptionalPlugin<typeof listPlugin>,
|
|
18
|
-
typeof betterTypeHistoryPlugin,
|
|
19
|
-
OptionalPlugin<typeof cardPlugin>,
|
|
20
|
-
OptionalPlugin<typeof analyticsPlugin>,
|
|
21
|
-
OptionalPlugin<MediaPlugin>
|
|
22
|
-
];
|
|
23
|
-
}>;
|
|
24
|
-
declare const pastePlugin: PastePlugin;
|
|
1
|
+
import { pastePlugin } from './plugin';
|
|
2
|
+
export type { PastePlugin, PastePluginOptions } from './types';
|
|
25
3
|
export default pastePlugin;
|
|
4
|
+
export { pastePlugin };
|
|
@@ -7,4 +7,4 @@ export { pluginKey as stateKey } from './plugin-factory';
|
|
|
7
7
|
import type { Dispatch } from '../../../event-dispatcher';
|
|
8
8
|
import type { FeatureFlags, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
9
9
|
import type { PastePlugin } from '../';
|
|
10
|
-
export declare function createPlugin(schema: Schema, dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, featureFlags: FeatureFlags, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, cardOptions?: CardOptions, sanitizePrivateContent?: boolean, providerFactory?: ProviderFactory): SafePlugin<import("
|
|
10
|
+
export declare function createPlugin(schema: Schema, dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, featureFlags: FeatureFlags, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, cardOptions?: CardOptions, sanitizePrivateContent?: boolean, providerFactory?: ProviderFactory): SafePlugin<import("@atlaskit/editor-plugin-paste").PastePluginState>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export declare const pluginKey: PluginKey<any>;
|
|
3
|
-
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: import("
|
|
3
|
+
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: import("@atlaskit/editor-plugin-paste").PastePluginState | ((state: import("prosemirror-state").EditorState) => import("@atlaskit/editor-plugin-paste").PastePluginState)) => import("prosemirror-state").SafeStateField<import("@atlaskit/editor-plugin-paste").PastePluginState>, createCommand: <A = import("../actions").PastePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => import("@atlaskit/editor-plugin-paste").PastePluginState;
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
/** map of pasted macro link positions that will to be mapped through incoming transactions */
|
|
3
|
-
pastedMacroPositions: {
|
|
4
|
-
[key: string]: number;
|
|
5
|
-
};
|
|
6
|
-
}
|
|
1
|
+
export type { PastePlugin, PastePluginOptions, PastePluginState, } from '@atlaskit/editor-plugin-paste';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "188.11.
|
|
3
|
+
"version": "188.11.3",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@atlaskit/editor-palette": "1.5.1",
|
|
60
60
|
"@atlaskit/editor-plugin-analytics": "^0.2.0",
|
|
61
61
|
"@atlaskit/editor-plugin-base": "^0.2.0",
|
|
62
|
+
"@atlaskit/editor-plugin-better-type-history": "^0.1.0",
|
|
62
63
|
"@atlaskit/editor-plugin-block-type": "^2.0.0",
|
|
63
64
|
"@atlaskit/editor-plugin-border": "^0.1.0",
|
|
64
65
|
"@atlaskit/editor-plugin-caption": "^0.2.0",
|
|
@@ -84,6 +85,7 @@
|
|
|
84
85
|
"@atlaskit/editor-plugin-list": "^1.3.0",
|
|
85
86
|
"@atlaskit/editor-plugin-media": "^0.3.0",
|
|
86
87
|
"@atlaskit/editor-plugin-mentions": "^0.1.0",
|
|
88
|
+
"@atlaskit/editor-plugin-paste": "^0.0.1",
|
|
87
89
|
"@atlaskit/editor-plugin-placeholder": "^0.1.0",
|
|
88
90
|
"@atlaskit/editor-plugin-quick-insert": "^0.2.0",
|
|
89
91
|
"@atlaskit/editor-plugin-rule": "^0.1.0",
|
|
@@ -1,33 +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 _main = _interopRequireDefault(require("./pm-plugins/main"));
|
|
9
|
-
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
10
|
-
/**
|
|
11
|
-
* This plugin is aiming to improve undo behaviour for some of our more custom applications, very specific text
|
|
12
|
-
* paste events, splitting blocks of text, new lines.
|
|
13
|
-
*/
|
|
14
|
-
var betterTypeHistory = function betterTypeHistory() {
|
|
15
|
-
return {
|
|
16
|
-
name: 'betterTypeHistory',
|
|
17
|
-
actions: {
|
|
18
|
-
flagPasteEvent: function flagPasteEvent(tr) {
|
|
19
|
-
tr.setMeta(_pluginKey.pluginKey, true);
|
|
20
|
-
return tr;
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
pmPlugins: function pmPlugins() {
|
|
24
|
-
return [{
|
|
25
|
-
name: 'betterTypeHistory',
|
|
26
|
-
plugin: function plugin() {
|
|
27
|
-
return (0, _main.default)();
|
|
28
|
-
}
|
|
29
|
-
}];
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
var _default = exports.default = betterTypeHistory;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
|
-
var _history = require("@atlaskit/editor-prosemirror/history");
|
|
11
|
-
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
12
|
-
var _step = require("../../../utils/step");
|
|
13
|
-
var _pluginKey = require("./plugin-key");
|
|
14
|
-
var getEnterKeyboardActionStep = function getEnterKeyboardActionStep(trs) {
|
|
15
|
-
var firstTr = trs.length === 1 && trs[0];
|
|
16
|
-
if (!firstTr || !firstTr.docChanged || !firstTr.isGeneric || !(firstTr.selection instanceof _state.TextSelection)) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
var selection = firstTr.selection,
|
|
20
|
-
steps = firstTr.steps;
|
|
21
|
-
var replaceSteps = steps.filter(function (step) {
|
|
22
|
-
return step instanceof _transform.ReplaceStep || step instanceof _transform.ReplaceAroundStep;
|
|
23
|
-
});
|
|
24
|
-
if (!selection.$cursor || replaceSteps.length !== 1) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
return replaceSteps[0];
|
|
28
|
-
};
|
|
29
|
-
var isSliceSplittingBlockNode = function isSliceSplittingBlockNode(slice) {
|
|
30
|
-
var hasOnlyTwoChildren = slice.size > 1 && slice.content.childCount === 2;
|
|
31
|
-
if (!hasOnlyTwoChildren) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
var firstNode = slice.content.child(0);
|
|
35
|
-
var secondNode = slice.content.child(1);
|
|
36
|
-
return firstNode && secondNode && firstNode.type === secondNode.type;
|
|
37
|
-
};
|
|
38
|
-
var isSliceAddingNewlineChar = function isSliceAddingNewlineChar(slice, schema) {
|
|
39
|
-
var newLine = _model.Fragment.from(schema.text('\n'));
|
|
40
|
-
return slice.content.eq(newLine);
|
|
41
|
-
};
|
|
42
|
-
var _default = exports.default = function _default() {
|
|
43
|
-
return new _safePlugin.SafePlugin({
|
|
44
|
-
key: _pluginKey.pluginKey,
|
|
45
|
-
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
46
|
-
var hasHandlePasteMeta = transactions.find(function (tran) {
|
|
47
|
-
return tran.getMeta(_pluginKey.pluginKey);
|
|
48
|
-
});
|
|
49
|
-
if (hasHandlePasteMeta) {
|
|
50
|
-
return (0, _history.closeHistory)(newState.tr);
|
|
51
|
-
}
|
|
52
|
-
var enterStep = getEnterKeyboardActionStep(transactions);
|
|
53
|
-
if (!enterStep) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
var slice = (0, _step.extractSliceFromStep)(enterStep);
|
|
57
|
-
var schema = newState.schema;
|
|
58
|
-
if (slice && (isSliceSplittingBlockNode(slice) || isSliceAddingNewlineChar(slice, schema))) {
|
|
59
|
-
return (0, _history.closeHistory)(newState.tr);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import createPlugin from './pm-plugins/main';
|
|
2
|
-
import { pluginKey } from './pm-plugins/plugin-key';
|
|
3
|
-
/**
|
|
4
|
-
* This plugin is aiming to improve undo behaviour for some of our more custom applications, very specific text
|
|
5
|
-
* paste events, splitting blocks of text, new lines.
|
|
6
|
-
*/
|
|
7
|
-
const betterTypeHistory = () => {
|
|
8
|
-
return {
|
|
9
|
-
name: 'betterTypeHistory',
|
|
10
|
-
actions: {
|
|
11
|
-
flagPasteEvent(tr) {
|
|
12
|
-
tr.setMeta(pluginKey, true);
|
|
13
|
-
return tr;
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
pmPlugins() {
|
|
17
|
-
return [{
|
|
18
|
-
name: 'betterTypeHistory',
|
|
19
|
-
plugin: () => createPlugin()
|
|
20
|
-
}];
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export default betterTypeHistory;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
5
|
-
import { ReplaceStep, ReplaceAroundStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
|
-
import { extractSliceFromStep } from '../../../utils/step';
|
|
7
|
-
import { pluginKey } from './plugin-key';
|
|
8
|
-
const getEnterKeyboardActionStep = trs => {
|
|
9
|
-
const firstTr = trs.length === 1 && trs[0];
|
|
10
|
-
if (!firstTr || !firstTr.docChanged || !firstTr.isGeneric || !(firstTr.selection instanceof TextSelection)) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const {
|
|
14
|
-
selection,
|
|
15
|
-
steps
|
|
16
|
-
} = firstTr;
|
|
17
|
-
const replaceSteps = steps.filter(step => step instanceof ReplaceStep || step instanceof ReplaceAroundStep);
|
|
18
|
-
if (!selection.$cursor || replaceSteps.length !== 1) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return replaceSteps[0];
|
|
22
|
-
};
|
|
23
|
-
const isSliceSplittingBlockNode = slice => {
|
|
24
|
-
const hasOnlyTwoChildren = slice.size > 1 && slice.content.childCount === 2;
|
|
25
|
-
if (!hasOnlyTwoChildren) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
const firstNode = slice.content.child(0);
|
|
29
|
-
const secondNode = slice.content.child(1);
|
|
30
|
-
return firstNode && secondNode && firstNode.type === secondNode.type;
|
|
31
|
-
};
|
|
32
|
-
const isSliceAddingNewlineChar = (slice, schema) => {
|
|
33
|
-
const newLine = Fragment.from(schema.text('\n'));
|
|
34
|
-
return slice.content.eq(newLine);
|
|
35
|
-
};
|
|
36
|
-
export default (() => {
|
|
37
|
-
return new SafePlugin({
|
|
38
|
-
key: pluginKey,
|
|
39
|
-
appendTransaction: (transactions, oldState, newState) => {
|
|
40
|
-
const hasHandlePasteMeta = transactions.find(tran => tran.getMeta(pluginKey));
|
|
41
|
-
if (hasHandlePasteMeta) {
|
|
42
|
-
return closeHistory(newState.tr);
|
|
43
|
-
}
|
|
44
|
-
const enterStep = getEnterKeyboardActionStep(transactions);
|
|
45
|
-
if (!enterStep) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const slice = extractSliceFromStep(enterStep);
|
|
49
|
-
const {
|
|
50
|
-
schema
|
|
51
|
-
} = newState;
|
|
52
|
-
if (slice && (isSliceSplittingBlockNode(slice) || isSliceAddingNewlineChar(slice, schema))) {
|
|
53
|
-
return closeHistory(newState.tr);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import createPlugin from './pm-plugins/main';
|
|
2
|
-
import { pluginKey } from './pm-plugins/plugin-key';
|
|
3
|
-
/**
|
|
4
|
-
* This plugin is aiming to improve undo behaviour for some of our more custom applications, very specific text
|
|
5
|
-
* paste events, splitting blocks of text, new lines.
|
|
6
|
-
*/
|
|
7
|
-
var betterTypeHistory = function betterTypeHistory() {
|
|
8
|
-
return {
|
|
9
|
-
name: 'betterTypeHistory',
|
|
10
|
-
actions: {
|
|
11
|
-
flagPasteEvent: function flagPasteEvent(tr) {
|
|
12
|
-
tr.setMeta(pluginKey, true);
|
|
13
|
-
return tr;
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
pmPlugins: function pmPlugins() {
|
|
17
|
-
return [{
|
|
18
|
-
name: 'betterTypeHistory',
|
|
19
|
-
plugin: function plugin() {
|
|
20
|
-
return createPlugin();
|
|
21
|
-
}
|
|
22
|
-
}];
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export default betterTypeHistory;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
5
|
-
import { ReplaceStep, ReplaceAroundStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
|
-
import { extractSliceFromStep } from '../../../utils/step';
|
|
7
|
-
import { pluginKey } from './plugin-key';
|
|
8
|
-
var getEnterKeyboardActionStep = function getEnterKeyboardActionStep(trs) {
|
|
9
|
-
var firstTr = trs.length === 1 && trs[0];
|
|
10
|
-
if (!firstTr || !firstTr.docChanged || !firstTr.isGeneric || !(firstTr.selection instanceof TextSelection)) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
var selection = firstTr.selection,
|
|
14
|
-
steps = firstTr.steps;
|
|
15
|
-
var replaceSteps = steps.filter(function (step) {
|
|
16
|
-
return step instanceof ReplaceStep || step instanceof ReplaceAroundStep;
|
|
17
|
-
});
|
|
18
|
-
if (!selection.$cursor || replaceSteps.length !== 1) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return replaceSteps[0];
|
|
22
|
-
};
|
|
23
|
-
var isSliceSplittingBlockNode = function isSliceSplittingBlockNode(slice) {
|
|
24
|
-
var hasOnlyTwoChildren = slice.size > 1 && slice.content.childCount === 2;
|
|
25
|
-
if (!hasOnlyTwoChildren) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
var firstNode = slice.content.child(0);
|
|
29
|
-
var secondNode = slice.content.child(1);
|
|
30
|
-
return firstNode && secondNode && firstNode.type === secondNode.type;
|
|
31
|
-
};
|
|
32
|
-
var isSliceAddingNewlineChar = function isSliceAddingNewlineChar(slice, schema) {
|
|
33
|
-
var newLine = Fragment.from(schema.text('\n'));
|
|
34
|
-
return slice.content.eq(newLine);
|
|
35
|
-
};
|
|
36
|
-
export default (function () {
|
|
37
|
-
return new SafePlugin({
|
|
38
|
-
key: pluginKey,
|
|
39
|
-
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
40
|
-
var hasHandlePasteMeta = transactions.find(function (tran) {
|
|
41
|
-
return tran.getMeta(pluginKey);
|
|
42
|
-
});
|
|
43
|
-
if (hasHandlePasteMeta) {
|
|
44
|
-
return closeHistory(newState.tr);
|
|
45
|
-
}
|
|
46
|
-
var enterStep = getEnterKeyboardActionStep(transactions);
|
|
47
|
-
if (!enterStep) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
var slice = extractSliceFromStep(enterStep);
|
|
51
|
-
var schema = newState.schema;
|
|
52
|
-
if (slice && (isSliceSplittingBlockNode(slice) || isSliceAddingNewlineChar(slice, schema))) {
|
|
53
|
-
return closeHistory(newState.tr);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
-
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
export type BetterTypeHistoryAPI = {
|
|
4
|
-
flagPasteEvent: (transaction: Transaction) => Transaction;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* This plugin is aiming to improve undo behaviour for some of our more custom applications, very specific text
|
|
8
|
-
* paste events, splitting blocks of text, new lines.
|
|
9
|
-
*/
|
|
10
|
-
declare const betterTypeHistory: NextEditorPlugin<'betterTypeHistory', {
|
|
11
|
-
actions: BetterTypeHistoryAPI;
|
|
12
|
-
}>;
|
|
13
|
-
export default betterTypeHistory;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
-
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
export type BetterTypeHistoryAPI = {
|
|
4
|
-
flagPasteEvent: (transaction: Transaction) => Transaction;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* This plugin is aiming to improve undo behaviour for some of our more custom applications, very specific text
|
|
8
|
-
* paste events, splitting blocks of text, new lines.
|
|
9
|
-
*/
|
|
10
|
-
declare const betterTypeHistory: NextEditorPlugin<'betterTypeHistory', {
|
|
11
|
-
actions: BetterTypeHistoryAPI;
|
|
12
|
-
}>;
|
|
13
|
-
export default betterTypeHistory;
|