@atlaskit/prosemirror-input-rules 2.3.1 → 2.4.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/prosemirror-input-rules
2
2
 
3
+ ## 2.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`1944b35b538`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1944b35b538) - move common utilities to editor-common, to help with decoupling block-type plugin
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
13
+ ## 2.3.2
14
+
15
+ ### Patch Changes
16
+
17
+ - [`d2ecb6bf1a3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d2ecb6bf1a3) - [ED-19203] Moved input rule types to editor-common to avoid circular dependencies
18
+ - Updated dependencies
19
+
3
20
  ## 2.3.1
4
21
 
5
22
  ### Patch Changes
package/dist/cjs/utils.js CHANGED
@@ -3,21 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createRule = exports.createPlugin = void 0;
6
+ exports.createPlugin = void 0;
7
+ Object.defineProperty(exports, "createRule", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _utils.createRule;
11
+ }
12
+ });
7
13
  var _selection = require("@atlaskit/editor-common/selection");
8
14
  var _history = require("@atlaskit/editor-prosemirror/history");
9
15
  var _state = require("@atlaskit/editor-prosemirror/state");
10
16
  var _plugin = require("./plugin");
11
- var createRule = function createRule(match, handler) {
12
- return {
13
- match: match,
14
- handler: handler,
15
- onHandlerApply: function onHandlerApply(state, tr) {
16
- (0, _history.closeHistory)(tr);
17
- }
18
- };
19
- };
20
- exports.createRule = createRule;
17
+ var _utils = require("@atlaskit/editor-common/utils");
21
18
  var hasUnsupportedMarks = function hasUnsupportedMarks(state, start, end, marksNameUnsupported) {
22
19
  var isUnsupportedMark = function isUnsupportedMark(node) {
23
20
  return (marksNameUnsupported || []).includes(node.type.name);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-input-rules",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -2,15 +2,7 @@ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
2
2
  import { closeHistory } from '@atlaskit/editor-prosemirror/history';
3
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { createInputRulePlugin } from './plugin';
5
- export const createRule = (match, handler) => {
6
- return {
7
- match,
8
- handler,
9
- onHandlerApply: (state, tr) => {
10
- closeHistory(tr);
11
- }
12
- };
13
- };
5
+ export { createRule } from '@atlaskit/editor-common/utils';
14
6
  const hasUnsupportedMarks = (state, start, end, marksNameUnsupported) => {
15
7
  const isUnsupportedMark = node => (marksNameUnsupported || []).includes(node.type.name);
16
8
  const $from = state.doc.resolve(start);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-input-rules",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "sideEffects": false
5
5
  }
package/dist/esm/utils.js CHANGED
@@ -2,15 +2,7 @@ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
2
2
  import { closeHistory } from '@atlaskit/editor-prosemirror/history';
3
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { createInputRulePlugin } from './plugin';
5
- export var createRule = function createRule(match, handler) {
6
- return {
7
- match: match,
8
- handler: handler,
9
- onHandlerApply: function onHandlerApply(state, tr) {
10
- closeHistory(tr);
11
- }
12
- };
13
- };
5
+ export { createRule } from '@atlaskit/editor-common/utils';
14
6
  var hasUnsupportedMarks = function hasUnsupportedMarks(state, start, end, marksNameUnsupported) {
15
7
  var isUnsupportedMark = function isUnsupportedMark(node) {
16
8
  return (marksNameUnsupported || []).includes(node.type.name);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-input-rules",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,18 @@
1
- import type { InputRuleHandler, InputRuleWrapper, OnHandlerApply, OnInputEvent } from './types';
1
+ import type { InputRuleHandler, InputRuleWrapper, OnHandlerApply } from '@atlaskit/editor-common/types';
2
+ import type { OnInputEvent } from './types';
2
3
  export { leafNodeReplacementCharacter, TEXT_INPUT_RULE_TRANSACTION_KEY, MAX_REGEX_MATCH, } from './constants';
3
4
  export { createInputRulePlugin } from './plugin';
4
- export type { InputRuleWrapper, InputRuleHandler, OnInputEvent, OnHandlerApply, };
5
+ export type {
6
+ /**
7
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
8
+ */
9
+ InputRuleWrapper,
10
+ /**
11
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
12
+ */
13
+ InputRuleHandler, OnInputEvent,
14
+ /**
15
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
16
+ */
17
+ OnHandlerApply, };
5
18
  export { createRule, createPlugin } from './utils';
@@ -1,6 +1,6 @@
1
+ import type { InputRuleHandler, InputRuleWrapper, OnHandlerApply } from '@atlaskit/editor-common/types';
1
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
- export type InputRuleHandler = (state: EditorState, matchResult: RegExpExecArray, start: number, end: number) => Transaction | null;
4
4
  export type HandleInputEvent = (props: {
5
5
  view: EditorView;
6
6
  from: number;
@@ -13,12 +13,6 @@ export type InputRulePluginState = {
13
13
  to: number;
14
14
  textInserted: string;
15
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
16
  export type MatchedRule = InputRuleWrapper & {
23
17
  result: RegExpExecArray;
24
18
  };
@@ -28,3 +22,16 @@ export type OnInputEvent = (props: {
28
22
  to: number;
29
23
  }) => boolean;
30
24
  export type OnBeforeRegexMatch = (tr: Transaction) => void;
25
+ export type {
26
+ /**
27
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
28
+ */
29
+ InputRuleHandler,
30
+ /**
31
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
32
+ */
33
+ OnHandlerApply,
34
+ /**
35
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
36
+ */
37
+ InputRuleWrapper, };
@@ -1,9 +1,8 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { InputRuleHandler, InputRuleWrapper } from './types';
3
- export declare const createRule: (match: RegExp, handler: InputRuleHandler) => InputRuleWrapper;
2
+ import type { InputRuleWrapper } from '@atlaskit/editor-common/types';
3
+ export { createRule } from '@atlaskit/editor-common/utils';
4
4
  type Options = {
5
5
  isBlockNodeRule?: boolean;
6
6
  allowInsertTextOnDocument?: boolean;
7
7
  };
8
8
  export declare const createPlugin: (pluginName: string, rules: Array<InputRuleWrapper>, options?: Options) => SafePlugin;
9
- export {};
@@ -1,5 +1,18 @@
1
- import type { InputRuleHandler, InputRuleWrapper, OnHandlerApply, OnInputEvent } from './types';
1
+ import type { InputRuleHandler, InputRuleWrapper, OnHandlerApply } from '@atlaskit/editor-common/types';
2
+ import type { OnInputEvent } from './types';
2
3
  export { leafNodeReplacementCharacter, TEXT_INPUT_RULE_TRANSACTION_KEY, MAX_REGEX_MATCH, } from './constants';
3
4
  export { createInputRulePlugin } from './plugin';
4
- export type { InputRuleWrapper, InputRuleHandler, OnInputEvent, OnHandlerApply, };
5
+ export type {
6
+ /**
7
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
8
+ */
9
+ InputRuleWrapper,
10
+ /**
11
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
12
+ */
13
+ InputRuleHandler, OnInputEvent,
14
+ /**
15
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
16
+ */
17
+ OnHandlerApply, };
5
18
  export { createRule, createPlugin } from './utils';
@@ -1,6 +1,6 @@
1
+ import type { InputRuleHandler, InputRuleWrapper, OnHandlerApply } from '@atlaskit/editor-common/types';
1
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
- export type InputRuleHandler = (state: EditorState, matchResult: RegExpExecArray, start: number, end: number) => Transaction | null;
4
4
  export type HandleInputEvent = (props: {
5
5
  view: EditorView;
6
6
  from: number;
@@ -13,12 +13,6 @@ export type InputRulePluginState = {
13
13
  to: number;
14
14
  textInserted: string;
15
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
16
  export type MatchedRule = InputRuleWrapper & {
23
17
  result: RegExpExecArray;
24
18
  };
@@ -28,3 +22,16 @@ export type OnInputEvent = (props: {
28
22
  to: number;
29
23
  }) => boolean;
30
24
  export type OnBeforeRegexMatch = (tr: Transaction) => void;
25
+ export type {
26
+ /**
27
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
28
+ */
29
+ InputRuleHandler,
30
+ /**
31
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
32
+ */
33
+ OnHandlerApply,
34
+ /**
35
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
36
+ */
37
+ InputRuleWrapper, };
@@ -1,9 +1,8 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { InputRuleHandler, InputRuleWrapper } from './types';
3
- export declare const createRule: (match: RegExp, handler: InputRuleHandler) => InputRuleWrapper;
2
+ import type { InputRuleWrapper } from '@atlaskit/editor-common/types';
3
+ export { createRule } from '@atlaskit/editor-common/utils';
4
4
  type Options = {
5
5
  isBlockNodeRule?: boolean;
6
6
  allowInsertTextOnDocument?: boolean;
7
7
  };
8
8
  export declare const createPlugin: (pluginName: string, rules: Array<InputRuleWrapper>, options?: Options) => SafePlugin;
9
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-input-rules",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "A package that contains helpers to create autoformatting rules for ProseMirror",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -28,7 +28,7 @@
28
28
  "releaseModel": "continuous"
29
29
  },
30
30
  "dependencies": {
31
- "@atlaskit/editor-common": "^74.29.0",
31
+ "@atlaskit/editor-common": "^74.34.0",
32
32
  "@atlaskit/editor-prosemirror": "1.0.2",
33
33
  "@babel/runtime": "^7.0.0"
34
34
  },
package/report.api.md CHANGED
@@ -15,7 +15,11 @@
15
15
  <!--SECTION START: Main Entry Types-->
16
16
 
17
17
  ```ts
18
+ import { createRule } from '@atlaskit/editor-common/utils';
18
19
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
20
+ import type { InputRuleHandler } from '@atlaskit/editor-common/types';
21
+ import type { InputRuleWrapper } from '@atlaskit/editor-common/types';
22
+ import type { OnHandlerApply } from '@atlaskit/editor-common/types';
19
23
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
20
24
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
21
25
 
@@ -33,29 +37,11 @@ export const createPlugin: (
33
37
  options?: Options_2,
34
38
  ) => SafePlugin;
35
39
 
36
- // @public (undocumented)
37
- export const createRule: (
38
- match: RegExp,
39
- handler: InputRuleHandler,
40
- ) => InputRuleWrapper;
40
+ export { createRule };
41
41
 
42
- // @public (undocumented)
43
- export type InputRuleHandler = (
44
- state: EditorState,
45
- matchResult: RegExpExecArray,
46
- start: number,
47
- end: number,
48
- ) => Transaction | null;
42
+ export { InputRuleHandler };
49
43
 
50
- // @public (undocumented)
51
- export interface InputRuleWrapper {
52
- // (undocumented)
53
- handler: InputRuleHandler;
54
- // (undocumented)
55
- match: RegExp;
56
- // (undocumented)
57
- onHandlerApply?: OnHandlerApply;
58
- }
44
+ export { InputRuleWrapper };
59
45
 
60
46
  // @public (undocumented)
61
47
  export const leafNodeReplacementCharacter = '\uFFFC';
@@ -66,12 +52,7 @@ export const MAX_REGEX_MATCH = 500;
66
52
  // @public (undocumented)
67
53
  type OnBeforeRegexMatch = (tr: Transaction) => void;
68
54
 
69
- // @public (undocumented)
70
- export type OnHandlerApply = (
71
- state: EditorState,
72
- tr: Transaction,
73
- matchResult: RegExpExecArray,
74
- ) => void;
55
+ export { OnHandlerApply };
75
56
 
76
57
  // @public (undocumented)
77
58
  export type OnInputEvent = (props: {
package/src/index.ts CHANGED
@@ -2,8 +2,9 @@ import type {
2
2
  InputRuleHandler,
3
3
  InputRuleWrapper,
4
4
  OnHandlerApply,
5
- OnInputEvent,
6
- } from './types';
5
+ } from '@atlaskit/editor-common/types';
6
+
7
+ import type { OnInputEvent } from './types';
7
8
 
8
9
  export {
9
10
  leafNodeReplacementCharacter,
@@ -12,9 +13,18 @@ export {
12
13
  } from './constants';
13
14
  export { createInputRulePlugin } from './plugin';
14
15
  export type {
16
+ /**
17
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
18
+ */
15
19
  InputRuleWrapper,
20
+ /**
21
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
22
+ */
16
23
  InputRuleHandler,
17
24
  OnInputEvent,
25
+ /**
26
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
27
+ */
18
28
  OnHandlerApply,
19
29
  };
20
30
 
package/src/types.ts CHANGED
@@ -1,16 +1,14 @@
1
+ import type {
2
+ InputRuleHandler,
3
+ InputRuleWrapper,
4
+ OnHandlerApply,
5
+ } from '@atlaskit/editor-common/types';
1
6
  import type {
2
7
  EditorState,
3
8
  Transaction,
4
9
  } from '@atlaskit/editor-prosemirror/state';
5
10
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
11
 
7
- export type InputRuleHandler = (
8
- state: EditorState,
9
- matchResult: RegExpExecArray,
10
- start: number,
11
- end: number,
12
- ) => Transaction | null;
13
-
14
12
  export type HandleInputEvent = (props: {
15
13
  view: EditorView;
16
14
  from: number;
@@ -25,18 +23,6 @@ export type InputRulePluginState = {
25
23
  textInserted: string;
26
24
  } | null;
27
25
 
28
- export type OnHandlerApply = (
29
- state: EditorState,
30
- tr: Transaction,
31
- matchResult: RegExpExecArray,
32
- ) => void;
33
-
34
- export interface InputRuleWrapper {
35
- match: RegExp;
36
- handler: InputRuleHandler;
37
- onHandlerApply?: OnHandlerApply;
38
- }
39
-
40
26
  export type MatchedRule = InputRuleWrapper & {
41
27
  result: RegExpExecArray;
42
28
  };
@@ -48,3 +34,18 @@ export type OnInputEvent = (props: {
48
34
  }) => boolean;
49
35
 
50
36
  export type OnBeforeRegexMatch = (tr: Transaction) => void;
37
+
38
+ export type {
39
+ /**
40
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
41
+ */
42
+ InputRuleHandler,
43
+ /**
44
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
45
+ */
46
+ OnHandlerApply,
47
+ /**
48
+ * @deprecated Please import this type from @atlaskit/editor-commmon/types
49
+ */
50
+ InputRuleWrapper,
51
+ };
package/src/utils.ts CHANGED
@@ -1,24 +1,14 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { GapCursorSelection } from '@atlaskit/editor-common/selection';
3
+ import type { InputRuleWrapper } from '@atlaskit/editor-common/types';
3
4
  import { closeHistory } from '@atlaskit/editor-prosemirror/history';
4
5
  import { Mark as PMMark } from '@atlaskit/editor-prosemirror/model';
5
6
  import { EditorState, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
7
 
7
8
  import { createInputRulePlugin } from './plugin';
8
- import type { InputRuleHandler, InputRuleWrapper, OnInputEvent } from './types';
9
+ import type { OnInputEvent } from './types';
9
10
 
10
- export const createRule = (
11
- match: RegExp,
12
- handler: InputRuleHandler,
13
- ): InputRuleWrapper => {
14
- return {
15
- match,
16
- handler,
17
- onHandlerApply: (state, tr) => {
18
- closeHistory(tr);
19
- },
20
- };
21
- };
11
+ export { createRule } from '@atlaskit/editor-common/utils';
22
12
 
23
13
  const hasUnsupportedMarks = (
24
14
  state: EditorState,
@@ -4,7 +4,11 @@
4
4
 
5
5
  ```ts
6
6
 
7
+ import { createRule } from '@atlaskit/editor-common/utils';
7
8
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
9
+ import type { InputRuleHandler } from '@atlaskit/editor-common/types';
10
+ import type { InputRuleWrapper } from '@atlaskit/editor-common/types';
11
+ import type { OnHandlerApply } from '@atlaskit/editor-common/types';
8
12
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
9
13
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
10
14
 
@@ -14,21 +18,11 @@ export function createInputRulePlugin(pluginName: string, rules: InputRuleWrappe
14
18
  // @public (undocumented)
15
19
  export const createPlugin: (pluginName: string, rules: Array<InputRuleWrapper>, options?: Options_2) => SafePlugin;
16
20
 
17
- // @public (undocumented)
18
- export const createRule: (match: RegExp, handler: InputRuleHandler) => InputRuleWrapper;
21
+ export { createRule }
19
22
 
20
- // @public (undocumented)
21
- export type InputRuleHandler = (state: EditorState, matchResult: RegExpExecArray, start: number, end: number) => Transaction | null;
23
+ export { InputRuleHandler }
22
24
 
23
- // @public (undocumented)
24
- export interface InputRuleWrapper {
25
- // (undocumented)
26
- handler: InputRuleHandler;
27
- // (undocumented)
28
- match: RegExp;
29
- // (undocumented)
30
- onHandlerApply?: OnHandlerApply;
31
- }
25
+ export { InputRuleWrapper }
32
26
 
33
27
  // @public (undocumented)
34
28
  export const leafNodeReplacementCharacter = "\uFFFC";
@@ -39,8 +33,7 @@ export const MAX_REGEX_MATCH = 500;
39
33
  // @public (undocumented)
40
34
  type OnBeforeRegexMatch = (tr: Transaction) => void;
41
35
 
42
- // @public (undocumented)
43
- export type OnHandlerApply = (state: EditorState, tr: Transaction, matchResult: RegExpExecArray) => void;
36
+ export { OnHandlerApply }
44
37
 
45
38
  // @public (undocumented)
46
39
  export type OnInputEvent = (props: {