@atlaskit/editor-core 191.0.7 → 191.0.9

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 (127) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/afm-cc/tsconfig.json +3 -3
  3. package/dist/cjs/plugins/index.js +0 -7
  4. package/dist/cjs/presets/universal.js +2 -1
  5. package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
  6. package/dist/cjs/ui/ContentStyles/index.js +1 -1
  7. package/dist/cjs/version-wrapper.js +1 -1
  8. package/dist/es2019/plugins/index.js +0 -1
  9. package/dist/es2019/presets/universal.js +2 -1
  10. package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
  11. package/dist/es2019/ui/ContentStyles/index.js +1 -1
  12. package/dist/es2019/version-wrapper.js +1 -1
  13. package/dist/esm/plugins/index.js +0 -1
  14. package/dist/esm/presets/universal.js +2 -1
  15. package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
  16. package/dist/esm/ui/ContentStyles/index.js +1 -1
  17. package/dist/esm/version-wrapper.js +1 -1
  18. package/dist/types/plugins/index.d.ts +0 -1
  19. package/dist/types/types/editor-props.d.ts +1 -1
  20. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  21. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  22. package/package.json +9 -9
  23. package/dist/cjs/plugins/find-replace/FindReplaceToolbarButtonWithState.js +0 -166
  24. package/dist/cjs/plugins/find-replace/actions.js +0 -19
  25. package/dist/cjs/plugins/find-replace/commands-with-analytics.js +0 -101
  26. package/dist/cjs/plugins/find-replace/commands.js +0 -255
  27. package/dist/cjs/plugins/find-replace/index.js +0 -94
  28. package/dist/cjs/plugins/find-replace/keymap.js +0 -24
  29. package/dist/cjs/plugins/find-replace/plugin-key.js +0 -8
  30. package/dist/cjs/plugins/find-replace/plugin.js +0 -138
  31. package/dist/cjs/plugins/find-replace/reducer.js +0 -61
  32. package/dist/cjs/plugins/find-replace/styles.js +0 -16
  33. package/dist/cjs/plugins/find-replace/types.js +0 -5
  34. package/dist/cjs/plugins/find-replace/ui/Find.js +0 -308
  35. package/dist/cjs/plugins/find-replace/ui/FindReplace.js +0 -103
  36. package/dist/cjs/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -132
  37. package/dist/cjs/plugins/find-replace/ui/FindReplaceTooltipButton.js +0 -76
  38. package/dist/cjs/plugins/find-replace/ui/Replace.js +0 -174
  39. package/dist/cjs/plugins/find-replace/ui/styles.js +0 -44
  40. package/dist/cjs/plugins/find-replace/utils/batch-decorations.js +0 -310
  41. package/dist/cjs/plugins/find-replace/utils/commands.js +0 -16
  42. package/dist/cjs/plugins/find-replace/utils/index.js +0 -290
  43. package/dist/cjs/utils/array.js +0 -13
  44. package/dist/es2019/plugins/find-replace/FindReplaceToolbarButtonWithState.js +0 -153
  45. package/dist/es2019/plugins/find-replace/actions.js +0 -13
  46. package/dist/es2019/plugins/find-replace/commands-with-analytics.js +0 -72
  47. package/dist/es2019/plugins/find-replace/commands.js +0 -240
  48. package/dist/es2019/plugins/find-replace/index.js +0 -89
  49. package/dist/es2019/plugins/find-replace/keymap.js +0 -16
  50. package/dist/es2019/plugins/find-replace/plugin-key.js +0 -2
  51. package/dist/es2019/plugins/find-replace/plugin.js +0 -117
  52. package/dist/es2019/plugins/find-replace/reducer.js +0 -56
  53. package/dist/es2019/plugins/find-replace/styles.js +0 -17
  54. package/dist/es2019/plugins/find-replace/types.js +0 -1
  55. package/dist/es2019/plugins/find-replace/ui/Find.js +0 -284
  56. package/dist/es2019/plugins/find-replace/ui/FindReplace.js +0 -78
  57. package/dist/es2019/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -122
  58. package/dist/es2019/plugins/find-replace/ui/FindReplaceTooltipButton.js +0 -50
  59. package/dist/es2019/plugins/find-replace/ui/Replace.js +0 -152
  60. package/dist/es2019/plugins/find-replace/ui/styles.js +0 -48
  61. package/dist/es2019/plugins/find-replace/utils/batch-decorations.js +0 -189
  62. package/dist/es2019/plugins/find-replace/utils/commands.js +0 -6
  63. package/dist/es2019/plugins/find-replace/utils/index.js +0 -249
  64. package/dist/es2019/utils/array.js +0 -3
  65. package/dist/esm/plugins/find-replace/FindReplaceToolbarButtonWithState.js +0 -157
  66. package/dist/esm/plugins/find-replace/actions.js +0 -13
  67. package/dist/esm/plugins/find-replace/commands-with-analytics.js +0 -95
  68. package/dist/esm/plugins/find-replace/commands.js +0 -248
  69. package/dist/esm/plugins/find-replace/index.js +0 -87
  70. package/dist/esm/plugins/find-replace/keymap.js +0 -18
  71. package/dist/esm/plugins/find-replace/plugin-key.js +0 -2
  72. package/dist/esm/plugins/find-replace/plugin.js +0 -133
  73. package/dist/esm/plugins/find-replace/reducer.js +0 -54
  74. package/dist/esm/plugins/find-replace/styles.js +0 -10
  75. package/dist/esm/plugins/find-replace/types.js +0 -1
  76. package/dist/esm/plugins/find-replace/ui/Find.js +0 -302
  77. package/dist/esm/plugins/find-replace/ui/FindReplace.js +0 -97
  78. package/dist/esm/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -126
  79. package/dist/esm/plugins/find-replace/ui/FindReplaceTooltipButton.js +0 -69
  80. package/dist/esm/plugins/find-replace/ui/Replace.js +0 -168
  81. package/dist/esm/plugins/find-replace/ui/styles.js +0 -37
  82. package/dist/esm/plugins/find-replace/utils/batch-decorations.js +0 -304
  83. package/dist/esm/plugins/find-replace/utils/commands.js +0 -10
  84. package/dist/esm/plugins/find-replace/utils/index.js +0 -280
  85. package/dist/esm/utils/array.js +0 -7
  86. package/dist/types/plugins/find-replace/FindReplaceToolbarButtonWithState.d.ts +0 -4
  87. package/dist/types/plugins/find-replace/actions.d.ts +0 -64
  88. package/dist/types/plugins/find-replace/commands-with-analytics.d.ts +0 -27
  89. package/dist/types/plugins/find-replace/commands.d.ts +0 -12
  90. package/dist/types/plugins/find-replace/index.d.ts +0 -3
  91. package/dist/types/plugins/find-replace/keymap.d.ts +0 -4
  92. package/dist/types/plugins/find-replace/plugin-key.d.ts +0 -3
  93. package/dist/types/plugins/find-replace/plugin.d.ts +0 -6
  94. package/dist/types/plugins/find-replace/reducer.d.ts +0 -4
  95. package/dist/types/plugins/find-replace/styles.d.ts +0 -3
  96. package/dist/types/plugins/find-replace/types.d.ts +0 -79
  97. package/dist/types/plugins/find-replace/ui/Find.d.ts +0 -71
  98. package/dist/types/plugins/find-replace/ui/FindReplace.d.ts +0 -43
  99. package/dist/types/plugins/find-replace/ui/FindReplaceToolbarButton.d.ts +0 -21
  100. package/dist/types/plugins/find-replace/ui/FindReplaceTooltipButton.d.ts +0 -18
  101. package/dist/types/plugins/find-replace/ui/Replace.d.ts +0 -27
  102. package/dist/types/plugins/find-replace/ui/styles.d.ts +0 -6
  103. package/dist/types/plugins/find-replace/utils/batch-decorations.d.ts +0 -36
  104. package/dist/types/plugins/find-replace/utils/commands.d.ts +0 -2
  105. package/dist/types/plugins/find-replace/utils/index.d.ts +0 -49
  106. package/dist/types/utils/array.d.ts +0 -1
  107. package/dist/types-ts4.5/plugins/find-replace/FindReplaceToolbarButtonWithState.d.ts +0 -4
  108. package/dist/types-ts4.5/plugins/find-replace/actions.d.ts +0 -64
  109. package/dist/types-ts4.5/plugins/find-replace/commands-with-analytics.d.ts +0 -27
  110. package/dist/types-ts4.5/plugins/find-replace/commands.d.ts +0 -12
  111. package/dist/types-ts4.5/plugins/find-replace/index.d.ts +0 -3
  112. package/dist/types-ts4.5/plugins/find-replace/keymap.d.ts +0 -4
  113. package/dist/types-ts4.5/plugins/find-replace/plugin-key.d.ts +0 -3
  114. package/dist/types-ts4.5/plugins/find-replace/plugin.d.ts +0 -6
  115. package/dist/types-ts4.5/plugins/find-replace/reducer.d.ts +0 -4
  116. package/dist/types-ts4.5/plugins/find-replace/styles.d.ts +0 -3
  117. package/dist/types-ts4.5/plugins/find-replace/types.d.ts +0 -79
  118. package/dist/types-ts4.5/plugins/find-replace/ui/Find.d.ts +0 -71
  119. package/dist/types-ts4.5/plugins/find-replace/ui/FindReplace.d.ts +0 -43
  120. package/dist/types-ts4.5/plugins/find-replace/ui/FindReplaceToolbarButton.d.ts +0 -21
  121. package/dist/types-ts4.5/plugins/find-replace/ui/FindReplaceTooltipButton.d.ts +0 -18
  122. package/dist/types-ts4.5/plugins/find-replace/ui/Replace.d.ts +0 -27
  123. package/dist/types-ts4.5/plugins/find-replace/ui/styles.d.ts +0 -6
  124. package/dist/types-ts4.5/plugins/find-replace/utils/batch-decorations.d.ts +0 -36
  125. package/dist/types-ts4.5/plugins/find-replace/utils/commands.d.ts +0 -2
  126. package/dist/types-ts4.5/plugins/find-replace/utils/index.d.ts +0 -49
  127. package/dist/types-ts4.5/utils/array.d.ts +0 -1
@@ -1,174 +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 _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
- var _react = _interopRequireDefault(require("react"));
16
- var _react2 = require("@emotion/react");
17
- var _standardButton = _interopRequireDefault(require("@atlaskit/button/standard-button"));
18
- var _reactIntlNext = require("react-intl-next");
19
- var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
20
- var _styles = require("./styles");
21
- var _analytics = require("@atlaskit/editor-common/analytics");
22
- 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); }; }
23
- 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; } } /** @jsx jsx */
24
- var messages = (0, _reactIntlNext.defineMessages)({
25
- replaceWith: {
26
- id: 'fabric.editor.replaceWith',
27
- defaultMessage: 'Replace with',
28
- description: 'The value that will replace the word or phrase that was searched for'
29
- },
30
- replace: {
31
- id: 'fabric.editor.replace',
32
- defaultMessage: 'Replace',
33
- description: 'Replace only the currently selected instance of the word or phrase'
34
- },
35
- replaceAll: {
36
- id: 'fabric.editor.replaceAll',
37
- defaultMessage: 'Replace all',
38
- description: 'Replace all instances of the word or phrase throughout the entire document'
39
- }
40
- });
41
- var Replace = /*#__PURE__*/function (_React$PureComponent) {
42
- (0, _inherits2.default)(Replace, _React$PureComponent);
43
- var _super = _createSuper(Replace);
44
- function Replace(props) {
45
- var _this;
46
- (0, _classCallCheck2.default)(this, Replace);
47
- _this = _super.call(this, props);
48
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "replaceTextfieldRef", /*#__PURE__*/_react.default.createRef());
49
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "skipWhileComposing", function (fn) {
50
- if (_this.state.isComposing) {
51
- return;
52
- }
53
- fn();
54
- });
55
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleReplaceClick", function () {
56
- return _this.skipWhileComposing(function () {
57
- _this.props.onReplace({
58
- triggerMethod: _analytics.TRIGGER_METHOD.BUTTON,
59
- replaceText: _this.state.replaceText
60
- });
61
- });
62
- });
63
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleReplaceChange", function (event) {
64
- return _this.skipWhileComposing(function () {
65
- _this.updateReplaceValue(event.target.value);
66
- });
67
- });
68
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateReplaceValue", function (replaceText) {
69
- var dispatchAnalyticsEvent = _this.props.dispatchAnalyticsEvent;
70
- if (dispatchAnalyticsEvent) {
71
- dispatchAnalyticsEvent({
72
- eventType: _analytics.EVENT_TYPE.TRACK,
73
- action: _analytics.ACTION.CHANGED_REPLACEMENT_TEXT,
74
- actionSubject: _analytics.ACTION_SUBJECT.FIND_REPLACE_DIALOG
75
- });
76
- }
77
- _this.setState({
78
- replaceText: replaceText
79
- });
80
- });
81
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleReplaceKeyDown", function (event) {
82
- return _this.skipWhileComposing(function () {
83
- if (event.key === 'Enter') {
84
- _this.props.onReplace({
85
- triggerMethod: _analytics.TRIGGER_METHOD.KEYBOARD,
86
- replaceText: _this.state.replaceText
87
- });
88
- } else if (event.key === 'ArrowUp') {
89
- // we want to move focus between find & replace texfields when user hits up/down arrows
90
- _this.props.onArrowUp();
91
- }
92
- });
93
- });
94
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleReplaceAllClick", function () {
95
- return _this.skipWhileComposing(function () {
96
- _this.props.onReplaceAll({
97
- replaceText: _this.state.replaceText
98
- });
99
- });
100
- });
101
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleCompositionStart", function () {
102
- _this.setState({
103
- isComposing: true
104
- });
105
- });
106
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleCompositionEnd", function (event) {
107
- _this.setState({
108
- isComposing: false
109
- });
110
- // type for React.CompositionEvent doesn't set type for target correctly
111
- _this.updateReplaceValue(event.target.value);
112
- });
113
- var _replaceText = props.replaceText,
114
- formatMessage = props.intl.formatMessage;
115
- _this.state = {
116
- replaceText: _replaceText || '',
117
- isComposing: false
118
- };
119
- _this.replaceWith = formatMessage(messages.replaceWith);
120
- _this.replace = formatMessage(messages.replace);
121
- _this.replaceAll = formatMessage(messages.replaceAll);
122
- return _this;
123
- }
124
- (0, _createClass2.default)(Replace, [{
125
- key: "componentDidMount",
126
- value: function componentDidMount() {
127
- this.props.onReplaceTextfieldRefSet(this.replaceTextfieldRef);
128
- }
129
- }, {
130
- key: "componentDidUpdate",
131
- value: function componentDidUpdate(_ref) {
132
- var prevReplaceText = _ref.replaceText;
133
- var replaceText = this.props.replaceText;
134
- if (replaceText && replaceText !== prevReplaceText) {
135
- this.setState({
136
- replaceText: replaceText,
137
- isComposing: false
138
- });
139
- }
140
- }
141
- }, {
142
- key: "render",
143
- value: function render() {
144
- var replaceText = this.state.replaceText;
145
- var canReplace = this.props.canReplace;
146
- return (0, _react2.jsx)("div", {
147
- css: _styles.sectionWrapperStyles
148
- }, (0, _react2.jsx)(_textfield.default, {
149
- name: "replace",
150
- appearance: "none",
151
- placeholder: this.replaceWith,
152
- defaultValue: replaceText,
153
- ref: this.replaceTextfieldRef,
154
- autoComplete: "off",
155
- onChange: this.handleReplaceChange,
156
- onKeyDown: this.handleReplaceKeyDown,
157
- onCompositionStart: this.handleCompositionStart,
158
- onCompositionEnd: this.handleCompositionEnd
159
- }), (0, _react2.jsx)(_standardButton.default, {
160
- css: _styles.replaceSectionButtonStyles,
161
- testId: this.replace,
162
- onClick: this.handleReplaceClick,
163
- isDisabled: !canReplace
164
- }, this.replace), (0, _react2.jsx)(_standardButton.default, {
165
- css: _styles.replaceSectionButtonStyles,
166
- testId: this.replaceAll,
167
- onClick: this.handleReplaceAllClick,
168
- isDisabled: !canReplace
169
- }, this.replaceAll));
170
- }
171
- }]);
172
- return Replace;
173
- }(_react.default.PureComponent);
174
- var _default = exports.default = (0, _reactIntlNext.injectIntl)(Replace);
@@ -1,44 +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.wrapperStyles = exports.sectionWrapperStyles = exports.ruleStyles = exports.replaceSectionButtonStyles = exports.countWrapperStyles = exports.countStyles = void 0;
8
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
- var _react = require("@emotion/react");
10
- var _colors = require("@atlaskit/theme/colors");
11
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
12
- var _templateObject;
13
- /** @jsx jsx */
14
- var replaceSectionButtonStyles = exports.replaceSectionButtonStyles = (0, _react.css)({
15
- marginLeft: "var(--ds-space-050, 4px)"
16
- });
17
- var ruleStyles = exports.ruleStyles = (0, _react.css)({
18
- width: '100%',
19
- border: 'none',
20
- backgroundColor: "".concat("var(--ds-border, ".concat(_colors.N30A, ")")),
21
- margin: "var(--ds-space-050, 4px)".concat(" 0px"),
22
- height: '1px',
23
- borderRadius: '1px'
24
- });
25
- var wrapperStyles = exports.wrapperStyles = (0, _react.css)({
26
- display: 'flex',
27
- flexDirection: 'column',
28
- '> *:not(#replace-hr-element)': {
29
- margin: "0px ".concat("var(--ds-space-050, 4px)")
30
- }
31
- });
32
- var sectionWrapperStyles = exports.sectionWrapperStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n\n & > * {\n display: inline-flex;\n height: 32px;\n flex: 0 0 auto;\n }\n\n & > [data-ds--text-field--container] {\n display: flex;\n flex: 1 1 auto;\n }\n"])));
33
- var countStyles = exports.countStyles = (0, _react.css)({
34
- color: "".concat("var(--ds-text-subtlest, ".concat(_colors.N60, ")")),
35
- fontSize: "".concat((0, _editorSharedStyles.relativeFontSizeToBase16)(12)),
36
- flex: '0 0 auto',
37
- justifyContent: 'center',
38
- alignItems: 'center',
39
- marginLeft: "var(--ds-space-050, 4px)",
40
- marginRight: "var(--ds-space-100, 8px)"
41
- });
42
- var countWrapperStyles = exports.countWrapperStyles = (0, _react.css)({
43
- alignItems: 'center'
44
- });
@@ -1,310 +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 _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
- var _index = require("./index");
13
- var _plugin = require("../plugin");
14
- // max number of decorations to apply at once
15
- var batchIncrement = 100;
16
- // position range to apply decorations between before alternating above or below viewport
17
- var posIncrement = 2000;
18
- /**
19
- * Provides support for applying search match highlight decorations in batches
20
- */
21
- var BatchDecorations = /*#__PURE__*/function () {
22
- function BatchDecorations() {
23
- (0, _classCallCheck2.default)(this, BatchDecorations);
24
- }
25
- (0, _createClass2.default)(BatchDecorations, [{
26
- key: "stop",
27
- value: function stop() {
28
- if (this.rafId) {
29
- cancelAnimationFrame(this.rafId);
30
- }
31
- }
32
-
33
- /**
34
- * Applies the decorations needed for the current search results
35
- * It does so async, splitting them up into batches to help with performance
36
- */
37
- }, {
38
- key: "applyAllSearchDecorations",
39
- value: function () {
40
- var _applyAllSearchDecorations = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(editorView, containerElement, addDecorations, removeDecorations) {
41
- var pmElement, positions, startPos, endPos, viewportStartPos, viewportEndPos, dir, before, after, diff;
42
- return _regenerator.default.wrap(function _callee$(_context) {
43
- while (1) switch (_context.prev = _context.next) {
44
- case 0:
45
- this.stop();
46
- this.addDecorations = addDecorations;
47
- this.removeDecorations = removeDecorations;
48
- if (containerElement) {
49
- _context.next = 5;
50
- break;
51
- }
52
- return _context.abrupt("return");
53
- case 5:
54
- pmElement = containerElement.querySelector('.ProseMirror');
55
- if (pmElement) {
56
- _context.next = 8;
57
- break;
58
- }
59
- return _context.abrupt("return");
60
- case 8:
61
- positions = this.calcDecorationPositions(editorView, containerElement, pmElement);
62
- startPos = positions.startPos, endPos = positions.endPos, viewportStartPos = positions.viewportStartPos, viewportEndPos = positions.viewportEndPos;
63
- dir = 0;
64
- before = viewportStartPos;
65
- after = viewportEndPos - posIncrement;
66
- _context.next = 15;
67
- return this.updateDecorationsBetween(editorView, viewportStartPos, viewportEndPos);
68
- case 15:
69
- if (!(before > startPos || after < endPos)) {
70
- _context.next = 28;
71
- break;
72
- }
73
- if (!(dir++ % 2 === 0 && before > startPos || after >= endPos)) {
74
- _context.next = 23;
75
- break;
76
- }
77
- diff = before - startPos;
78
- before = Math.max(before - posIncrement, startPos);
79
- _context.next = 21;
80
- return this.updateDecorationsBetween(editorView, before, before + Math.min(diff, posIncrement));
81
- case 21:
82
- _context.next = 26;
83
- break;
84
- case 23:
85
- after = Math.min(after + posIncrement, endPos);
86
- _context.next = 26;
87
- return this.updateDecorationsBetween(editorView, after, Math.min(after + posIncrement, endPos));
88
- case 26:
89
- _context.next = 15;
90
- break;
91
- case 28:
92
- case "end":
93
- return _context.stop();
94
- }
95
- }, _callee, this);
96
- }));
97
- function applyAllSearchDecorations(_x, _x2, _x3, _x4) {
98
- return _applyAllSearchDecorations.apply(this, arguments);
99
- }
100
- return applyAllSearchDecorations;
101
- }()
102
- }, {
103
- key: "updateDecorationsBetween",
104
- value: function () {
105
- var _updateDecorationsBetween = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(editorView, startPos, endPos) {
106
- return _regenerator.default.wrap(function _callee2$(_context2) {
107
- while (1) switch (_context2.prev = _context2.next) {
108
- case 0:
109
- _context2.next = 2;
110
- return this.removeDecorationsBetween(editorView, startPos, endPos);
111
- case 2:
112
- _context2.next = 4;
113
- return this.addDecorationsBetween(editorView, startPos, endPos);
114
- case 4:
115
- case "end":
116
- return _context2.stop();
117
- }
118
- }, _callee2, this);
119
- }));
120
- function updateDecorationsBetween(_x5, _x6, _x7) {
121
- return _updateDecorationsBetween.apply(this, arguments);
122
- }
123
- return updateDecorationsBetween;
124
- }()
125
- }, {
126
- key: "addDecorationsBetween",
127
- value: function () {
128
- var _addDecorationsBetween = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(editorView, startPos, endPos) {
129
- var _this = this;
130
- var selection, _getPluginState, matches, decorationSet, matchesBetween, selectionMatch, selectionIndex;
131
- return _regenerator.default.wrap(function _callee3$(_context3) {
132
- while (1) switch (_context3.prev = _context3.next) {
133
- case 0:
134
- selection = editorView.state.selection;
135
- _getPluginState = (0, _plugin.getPluginState)(editorView.state), matches = _getPluginState.matches, decorationSet = _getPluginState.decorationSet;
136
- if (!(matches.length === 0)) {
137
- _context3.next = 4;
138
- break;
139
- }
140
- return _context3.abrupt("return");
141
- case 4:
142
- matchesBetween = matches.filter(function (m) {
143
- return m.start >= startPos && (endPos === undefined || m.start < endPos);
144
- });
145
- selectionMatch = matches.find(function (match) {
146
- return match.start >= selection.from;
147
- });
148
- selectionIndex = matchesBetween.findIndex(function (match) {
149
- return match === selectionMatch;
150
- });
151
- _context3.next = 9;
152
- return this.batchRequests(function (counter) {
153
- var matchesToDecorate = matchesBetween.slice(counter, counter + batchIncrement);
154
- if (matchesToDecorate.length === 0) {
155
- return false;
156
- }
157
- var useSelectionIndex = selectionIndex >= counter && selectionIndex < counter + batchIncrement;
158
- if (selectionMatch && useSelectionIndex) {
159
- var selectionMatchDecoration = (0, _index.findDecorationFromMatch)(decorationSet, selectionMatch);
160
- if (selectionMatchDecoration) {
161
- matchesToDecorate.splice(selectionIndex % batchIncrement, 1);
162
- useSelectionIndex = false;
163
- }
164
- }
165
- if (_this.addDecorations) {
166
- _this.addDecorations((0, _index.createDecorations)(useSelectionIndex ? selectionIndex % batchIncrement : -1, matchesToDecorate));
167
- }
168
- }, {
169
- increment: batchIncrement,
170
- until: matchesBetween.length
171
- });
172
- case 9:
173
- return _context3.abrupt("return", _context3.sent);
174
- case 10:
175
- case "end":
176
- return _context3.stop();
177
- }
178
- }, _callee3, this);
179
- }));
180
- function addDecorationsBetween(_x8, _x9, _x10) {
181
- return _addDecorationsBetween.apply(this, arguments);
182
- }
183
- return addDecorationsBetween;
184
- }()
185
- }, {
186
- key: "removeDecorationsBetween",
187
- value: function () {
188
- var _removeDecorationsBetween = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(editorView, startPos, endPos) {
189
- var _this2 = this;
190
- var _getPluginState2, decorationSet, decorations;
191
- return _regenerator.default.wrap(function _callee4$(_context4) {
192
- while (1) switch (_context4.prev = _context4.next) {
193
- case 0:
194
- _getPluginState2 = (0, _plugin.getPluginState)(editorView.state), decorationSet = _getPluginState2.decorationSet;
195
- decorations = decorationSet.find(startPos, endPos);
196
- if (!(decorations.length === 0)) {
197
- _context4.next = 4;
198
- break;
199
- }
200
- return _context4.abrupt("return");
201
- case 4:
202
- _context4.next = 6;
203
- return this.batchRequests(function (counter) {
204
- var decorationsToRemove = decorations.slice(counter, counter + batchIncrement);
205
- if (decorationsToRemove.length === 0) {
206
- return false;
207
- }
208
- // only get those decorations whose from >= startPos
209
- for (var i = 0; i < decorationsToRemove.length; i++) {
210
- if (decorationsToRemove[i].from >= startPos) {
211
- break;
212
- }
213
- decorationsToRemove = decorationsToRemove.slice(1);
214
- }
215
- if (_this2.removeDecorations) {
216
- _this2.removeDecorations(decorationsToRemove);
217
- }
218
- }, {
219
- increment: batchIncrement,
220
- until: decorations.length
221
- });
222
- case 6:
223
- return _context4.abrupt("return", _context4.sent);
224
- case 7:
225
- case "end":
226
- return _context4.stop();
227
- }
228
- }, _callee4, this);
229
- }));
230
- function removeDecorationsBetween(_x11, _x12, _x13) {
231
- return _removeDecorationsBetween.apply(this, arguments);
232
- }
233
- return removeDecorationsBetween;
234
- }()
235
- /**
236
- * Calculates Prosemirror start and end positions we want to apply the decorations
237
- * between
238
- * Also calculates the positions the are the start and end of the user's viewport
239
- * so we can apply decorations there first and work outwards
240
- */
241
- }, {
242
- key: "calcDecorationPositions",
243
- value: function calcDecorationPositions(editorView, containerElement, pmElement) {
244
- var containerRect = containerElement.getBoundingClientRect();
245
- var pmRect = pmElement.getBoundingClientRect();
246
- var viewportStartPos = this.getStartPos(editorView, 0, pmRect.left);
247
- var viewportEndPos = this.getEndPos(editorView, containerRect.top + containerRect.height, pmRect.left);
248
- return {
249
- viewportStartPos: viewportStartPos,
250
- viewportEndPos: viewportEndPos,
251
- startPos: 1,
252
- endPos: editorView.state.doc.nodeSize
253
- };
254
- }
255
- }, {
256
- key: "getStartPos",
257
- value: function getStartPos(editorView, y, x) {
258
- var startPos = editorView.posAtCoords({
259
- top: y,
260
- left: x
261
- });
262
- return startPos ? startPos.pos : 1;
263
- }
264
- }, {
265
- key: "getEndPos",
266
- value: function getEndPos(editorView, y, x) {
267
- var maxPos = editorView.state.doc.nodeSize;
268
- var endPos = editorView.posAtCoords({
269
- top: y,
270
- left: x
271
- });
272
- return endPos ? endPos.pos : maxPos;
273
- }
274
-
275
- /**
276
- * Util to batch function calls by animation frames
277
- * A counter will start at 0 and increment by provided value until reaches limit
278
- * Passed in fn receives the counter as a param, return false to skip waiting
279
- * for the animation frame for the next call
280
- */
281
- }, {
282
- key: "batchRequests",
283
- value: function batchRequests(fn, opts) {
284
- var _this3 = this;
285
- var counter = 0;
286
- var increment = opts.increment,
287
- until = opts.until;
288
- return new Promise(function (resolve) {
289
- var batchedFn = function batchedFn() {
290
- var result = fn(counter);
291
- while (result === false && counter < until) {
292
- counter += increment;
293
- result = fn(counter);
294
- }
295
- if (counter < until) {
296
- counter += increment;
297
- _this3.rafId = requestAnimationFrame(batchedFn);
298
- } else {
299
- _this3.rafId = undefined;
300
- resolve();
301
- }
302
- };
303
- _this3.rafId = requestAnimationFrame(batchedFn);
304
- });
305
- }
306
- }]);
307
- return BatchDecorations;
308
- }();
309
- var batchDecorations = new BatchDecorations();
310
- var _default = exports.default = batchDecorations;
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.withScrollIntoView = void 0;
7
- var withScrollIntoView = exports.withScrollIntoView = function withScrollIntoView(command) {
8
- return function (state, dispatch, view) {
9
- return command(state, function (tr) {
10
- tr.scrollIntoView();
11
- if (dispatch) {
12
- dispatch(tr);
13
- }
14
- }, view);
15
- };
16
- };