@atlaskit/prosemirror-input-rules 2.2.0 → 2.2.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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/prosemirror-input-rules
2
2
 
3
+ ## 2.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a142ba1aa28`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a142ba1aa28) - [ED17172] Bump prosemirror-model to 1.16.0 and prosemirror-view to 1.23.7 and removed work-arounds for fixed issues
8
+ - Updated dependencies
9
+
10
+ ## 2.2.1
11
+
12
+ ### Patch Changes
13
+
14
+ - [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
15
+
3
16
  ## 2.2.0
4
17
 
5
18
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-input-rules",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-input-rules",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-input-rules",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,6 @@
1
1
  import type { PluginKey } from 'prosemirror-state';
2
2
  import type { HandleInputEvent, InputRuleWrapper, OnBeforeRegexMatch, OnInputEvent } from './types';
3
- declare type Options = {
3
+ type Options = {
4
4
  pluginKey: PluginKey;
5
5
  rules: InputRuleWrapper[];
6
6
  allowInsertTextOnDocument: boolean;
@@ -1,6 +1,6 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { InputRuleWrapper, OnBeforeRegexMatch, OnInputEvent } from './types';
3
- declare type Options = {
3
+ type Options = {
4
4
  allowInsertTextOnDocument?: boolean;
5
5
  onInputEvent?: OnInputEvent;
6
6
  onBeforeRegexMatch?: OnBeforeRegexMatch;
@@ -1,30 +1,30 @@
1
1
  import type { EditorState, Transaction } from 'prosemirror-state';
2
2
  import type { EditorView } from 'prosemirror-view';
3
- export declare type InputRuleHandler = (state: EditorState, matchResult: RegExpExecArray, start: number, end: number) => Transaction | null;
4
- export declare type HandleInputEvent = (props: {
3
+ export type InputRuleHandler = (state: EditorState, matchResult: RegExpExecArray, start: number, end: number) => Transaction | null;
4
+ export type HandleInputEvent = (props: {
5
5
  view: EditorView;
6
6
  from: number;
7
7
  to: number;
8
8
  text: string;
9
9
  }) => boolean;
10
- export declare type InputRulePluginState = {
10
+ export type InputRulePluginState = {
11
11
  matchedRule: MatchedRule;
12
12
  from: number;
13
13
  to: number;
14
14
  textInserted: string;
15
15
  } | null;
16
- export declare type OnHandlerApply = (state: EditorState, tr: Transaction, matchResult: RegExpExecArray) => void;
16
+ export type OnHandlerApply = (state: EditorState, tr: Transaction, matchResult: RegExpExecArray) => void;
17
17
  export interface InputRuleWrapper {
18
18
  match: RegExp;
19
19
  handler: InputRuleHandler;
20
20
  onHandlerApply?: OnHandlerApply;
21
21
  }
22
- export declare type MatchedRule = InputRuleWrapper & {
22
+ export type MatchedRule = InputRuleWrapper & {
23
23
  result: RegExpExecArray;
24
24
  };
25
- export declare type OnInputEvent = (props: {
25
+ export type OnInputEvent = (props: {
26
26
  state: EditorState;
27
27
  from: number;
28
28
  to: number;
29
29
  }) => boolean;
30
- export declare type OnBeforeRegexMatch = (tr: Transaction) => void;
30
+ export type OnBeforeRegexMatch = (tr: Transaction) => void;
@@ -0,0 +1,3 @@
1
+ export declare const leafNodeReplacementCharacter = "\uFFFC";
2
+ export declare const TEXT_INPUT_RULE_TRANSACTION_KEY = "input_rule_plugin_transaction";
3
+ export declare const MAX_REGEX_MATCH = 500;
@@ -0,0 +1,11 @@
1
+ import type { PluginKey } from 'prosemirror-state';
2
+ import type { HandleInputEvent, InputRuleWrapper, OnBeforeRegexMatch, OnInputEvent } from './types';
3
+ type Options = {
4
+ pluginKey: PluginKey;
5
+ rules: InputRuleWrapper[];
6
+ allowInsertTextOnDocument: boolean;
7
+ onInputEvent?: OnInputEvent;
8
+ onBeforeRegexMatch?: OnBeforeRegexMatch;
9
+ };
10
+ export declare const createInputEventHandler: ({ rules, pluginKey, allowInsertTextOnDocument, onInputEvent, onBeforeRegexMatch, }: Options) => HandleInputEvent;
11
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { InputRuleHandler, InputRuleWrapper, OnHandlerApply, OnInputEvent } from './types';
2
+ export { leafNodeReplacementCharacter, TEXT_INPUT_RULE_TRANSACTION_KEY, MAX_REGEX_MATCH, } from './constants';
3
+ export { createInputRulePlugin } from './plugin';
4
+ export type { InputRuleWrapper, InputRuleHandler, OnInputEvent, OnHandlerApply, };
@@ -0,0 +1,9 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import type { InputRuleWrapper, OnBeforeRegexMatch, OnInputEvent } from './types';
3
+ type Options = {
4
+ allowInsertTextOnDocument?: boolean;
5
+ onInputEvent?: OnInputEvent;
6
+ onBeforeRegexMatch?: OnBeforeRegexMatch;
7
+ };
8
+ export declare function createInputRulePlugin(pluginName: string, rules: InputRuleWrapper[], options?: Options): SafePlugin;
9
+ export {};
@@ -0,0 +1,30 @@
1
+ import type { EditorState, Transaction } from 'prosemirror-state';
2
+ import type { EditorView } from 'prosemirror-view';
3
+ export type InputRuleHandler = (state: EditorState, matchResult: RegExpExecArray, start: number, end: number) => Transaction | null;
4
+ export type HandleInputEvent = (props: {
5
+ view: EditorView;
6
+ from: number;
7
+ to: number;
8
+ text: string;
9
+ }) => boolean;
10
+ export type InputRulePluginState = {
11
+ matchedRule: MatchedRule;
12
+ from: number;
13
+ to: number;
14
+ textInserted: string;
15
+ } | null;
16
+ export type OnHandlerApply = (state: EditorState, tr: Transaction, matchResult: RegExpExecArray) => void;
17
+ export interface InputRuleWrapper {
18
+ match: RegExp;
19
+ handler: InputRuleHandler;
20
+ onHandlerApply?: OnHandlerApply;
21
+ }
22
+ export type MatchedRule = InputRuleWrapper & {
23
+ result: RegExpExecArray;
24
+ };
25
+ export type OnInputEvent = (props: {
26
+ state: EditorState;
27
+ from: number;
28
+ to: number;
29
+ }) => boolean;
30
+ export type OnBeforeRegexMatch = (tr: Transaction) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-input-rules",
3
- "version": "2.2.0",
3
+ "version": "2.2.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/"
@@ -12,6 +12,14 @@
12
12
  "module": "dist/esm/index.js",
13
13
  "module:es2019": "dist/es2019/index.js",
14
14
  "types": "dist/types/index.d.ts",
15
+ "typesVersions": {
16
+ ">=4.5 <4.9": {
17
+ "*": [
18
+ "dist/types-ts4.5/*",
19
+ "dist/types-ts4.5/index.d.ts"
20
+ ]
21
+ }
22
+ },
15
23
  "sideEffects": false,
16
24
  "atlaskit:src": "src/index.ts",
17
25
  "atlassian": {
@@ -19,19 +27,19 @@
19
27
  "releaseModel": "scheduled"
20
28
  },
21
29
  "dependencies": {
22
- "@atlaskit/editor-common": "^74.0.0",
30
+ "@atlaskit/editor-common": "^74.1.0",
23
31
  "@babel/runtime": "^7.0.0",
24
32
  "prosemirror-state": "1.3.4"
25
33
  },
26
34
  "devDependencies": {
27
35
  "@atlaskit/adf-schema": "^25.6.0",
28
- "@atlaskit/editor-test-helpers": "^18.2.0",
36
+ "@atlaskit/editor-test-helpers": "^18.3.0",
29
37
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
30
38
  "@types/prosemirror-history": "^1.0.1",
31
39
  "@types/prosemirror-model": "^1.11.0",
32
40
  "@types/prosemirror-state": "^1.2.0",
33
41
  "@types/prosemirror-view": "^1.9.0",
34
- "prosemirror-view": "1.23.2"
42
+ "prosemirror-view": "1.23.7"
35
43
  },
36
44
  "techstack": {
37
45
  "@atlassian/frontend": {