@atlaskit/prosemirror-input-rules 2.1.1 → 2.1.2
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 +12 -0
- package/dist/cjs/plugin.js +3 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugin.js +3 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugin.js +3 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/plugin.d.ts +2 -2
- package/package.json +4 -3
- package/src/__tests__/unit/plugin.ts +3 -2
- package/src/plugin.ts +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/prosemirror-input-rules
|
|
2
2
|
|
|
3
|
+
## 2.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4e6fbaf5898`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4e6fbaf5898) - ED-14117 Change EditorState.apply type to receive readonly transaction
|
|
8
|
+
|
|
9
|
+
Transactions should not be mutated after being dispatched as it can lead to
|
|
10
|
+
unexpected behaviour. This change patches the relevant types declared in
|
|
11
|
+
prosemirror-state as a compile-time safeguard.
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 2.1.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -7,6 +7,8 @@ exports.createInputRulePlugin = createInputRulePlugin;
|
|
|
7
7
|
|
|
8
8
|
var _prosemirrorState = require("prosemirror-state");
|
|
9
9
|
|
|
10
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
|
+
|
|
10
12
|
var _constants = require("./constants");
|
|
11
13
|
|
|
12
14
|
var _handler = require("./handler");
|
|
@@ -24,7 +26,7 @@ function createInputRulePlugin(pluginName, rules) {
|
|
|
24
26
|
onInputEvent: onInputEvent,
|
|
25
27
|
onBeforeRegexMatch: onBeforeRegexMatch
|
|
26
28
|
});
|
|
27
|
-
var plugin = new
|
|
29
|
+
var plugin = new _safePlugin.SafePlugin({
|
|
28
30
|
key: pluginKey,
|
|
29
31
|
state: {
|
|
30
32
|
init: function init() {
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginKey, TextSelection } from 'prosemirror-state';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
3
|
import { TEXT_INPUT_RULE_TRANSACTION_KEY } from './constants';
|
|
3
4
|
import { createInputEventHandler } from './handler';
|
|
4
5
|
export function createInputRulePlugin(pluginName, rules, options = {}) {
|
|
@@ -13,7 +14,7 @@ export function createInputRulePlugin(pluginName, rules, options = {}) {
|
|
|
13
14
|
onInputEvent,
|
|
14
15
|
onBeforeRegexMatch
|
|
15
16
|
});
|
|
16
|
-
const plugin = new
|
|
17
|
+
const plugin = new SafePlugin({
|
|
17
18
|
key: pluginKey,
|
|
18
19
|
state: {
|
|
19
20
|
init() {
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/plugin.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginKey, TextSelection } from 'prosemirror-state';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
3
|
import { TEXT_INPUT_RULE_TRANSACTION_KEY } from './constants';
|
|
3
4
|
import { createInputEventHandler } from './handler';
|
|
4
5
|
export function createInputRulePlugin(pluginName, rules) {
|
|
@@ -14,7 +15,7 @@ export function createInputRulePlugin(pluginName, rules) {
|
|
|
14
15
|
onInputEvent: onInputEvent,
|
|
15
16
|
onBeforeRegexMatch: onBeforeRegexMatch
|
|
16
17
|
});
|
|
17
|
-
var plugin = new
|
|
18
|
+
var plugin = new SafePlugin({
|
|
18
19
|
key: pluginKey,
|
|
19
20
|
state: {
|
|
20
21
|
init: function init() {
|
package/dist/esm/version.json
CHANGED
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import type { InputRuleWrapper, OnBeforeRegexMatch, OnInputEvent } from './types';
|
|
3
3
|
declare type Options = {
|
|
4
4
|
allowInsertTextOnDocument?: boolean;
|
|
5
5
|
onInputEvent?: OnInputEvent;
|
|
6
6
|
onBeforeRegexMatch?: OnBeforeRegexMatch;
|
|
7
7
|
};
|
|
8
|
-
export declare function createInputRulePlugin(pluginName: string, rules: InputRuleWrapper[], options?: Options):
|
|
8
|
+
export declare function createInputRulePlugin(pluginName: string, rules: InputRuleWrapper[], options?: Options): SafePlugin;
|
|
9
9
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/prosemirror-input-rules",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "A package that contains helpers to create autoformatting rules for ProseMirror",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
"releaseModel": "scheduled"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"@atlaskit/editor-common": "^64.0.0",
|
|
22
23
|
"@babel/runtime": "^7.0.0",
|
|
23
24
|
"prosemirror-state": "1.3.4"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"@atlaskit/adf-schema": "^
|
|
27
|
-
"@atlaskit/editor-test-helpers": "^16.
|
|
27
|
+
"@atlaskit/adf-schema": "^22.0.0",
|
|
28
|
+
"@atlaskit/editor-test-helpers": "^16.1.0",
|
|
28
29
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
29
30
|
"@types/prosemirror-history": "^1.0.1",
|
|
30
31
|
"@types/prosemirror-model": "^1.11.0",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EditorState
|
|
1
|
+
import { EditorState } from 'prosemirror-state';
|
|
2
2
|
import { EditorView } from 'prosemirror-view';
|
|
3
3
|
|
|
4
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
5
|
import { createEditorState } from '@atlaskit/editor-test-helpers/create-editor-state';
|
|
5
6
|
import { doc, DocBuilder, p } from '@atlaskit/editor-test-helpers/doc-builder';
|
|
6
7
|
|
|
@@ -20,7 +21,7 @@ describe('input-tule/plugin/createInputRulePlugin', () => {
|
|
|
20
21
|
view.someProp('handleTextInput', (f) => f(view, $from.pos, $to.pos, text));
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
function createEditorView(lol: DocBuilder, customInputRule:
|
|
24
|
+
function createEditorView(lol: DocBuilder, customInputRule: SafePlugin) {
|
|
24
25
|
const editorState = createEditorState(lol, customInputRule);
|
|
25
26
|
|
|
26
27
|
return new EditorView(editorViewElement, {
|
package/src/plugin.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginKey, TextSelection } from 'prosemirror-state';
|
|
2
|
+
|
|
3
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
4
|
|
|
3
5
|
import { TEXT_INPUT_RULE_TRANSACTION_KEY } from './constants';
|
|
4
6
|
import { createInputEventHandler } from './handler';
|
|
@@ -19,7 +21,7 @@ export function createInputRulePlugin(
|
|
|
19
21
|
pluginName: string,
|
|
20
22
|
rules: InputRuleWrapper[],
|
|
21
23
|
options: Options = {},
|
|
22
|
-
):
|
|
24
|
+
): SafePlugin {
|
|
23
25
|
const onInputEvent = options?.onInputEvent;
|
|
24
26
|
const onBeforeRegexMatch = options?.onBeforeRegexMatch;
|
|
25
27
|
const allowInsertTextOnDocument = Boolean(options?.allowInsertTextOnDocument);
|
|
@@ -33,7 +35,7 @@ export function createInputRulePlugin(
|
|
|
33
35
|
onBeforeRegexMatch,
|
|
34
36
|
});
|
|
35
37
|
|
|
36
|
-
const plugin
|
|
38
|
+
const plugin = new SafePlugin<InputRulePluginState>({
|
|
37
39
|
key: pluginKey,
|
|
38
40
|
state: {
|
|
39
41
|
init() {
|