@atlaskit/editor-plugin-find-replace 0.1.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.
Files changed (121) hide show
  1. package/.eslintrc.js +26 -0
  2. package/CHANGELOG.md +11 -0
  3. package/LICENSE.md +13 -0
  4. package/README.md +30 -0
  5. package/dist/cjs/FindReplaceToolbarButtonWithState.js +166 -0
  6. package/dist/cjs/actions.js +19 -0
  7. package/dist/cjs/commands-with-analytics.js +101 -0
  8. package/dist/cjs/commands.js +255 -0
  9. package/dist/cjs/index.js +12 -0
  10. package/dist/cjs/plugin.js +93 -0
  11. package/dist/cjs/pm-plugins/keymap.js +24 -0
  12. package/dist/cjs/pm-plugins/main.js +39 -0
  13. package/dist/cjs/pm-plugins/plugin-factory.js +109 -0
  14. package/dist/cjs/pm-plugins/plugin-key.js +8 -0
  15. package/dist/cjs/reducer.js +61 -0
  16. package/dist/cjs/styles.js +17 -0
  17. package/dist/cjs/types.js +5 -0
  18. package/dist/cjs/ui/Find.js +309 -0
  19. package/dist/cjs/ui/FindReplace.js +104 -0
  20. package/dist/cjs/ui/FindReplaceToolbarButton.js +133 -0
  21. package/dist/cjs/ui/FindReplaceTooltipButton.js +77 -0
  22. package/dist/cjs/ui/Replace.js +176 -0
  23. package/dist/cjs/ui/styles.js +46 -0
  24. package/dist/cjs/utils/array.js +13 -0
  25. package/dist/cjs/utils/batch-decorations.js +310 -0
  26. package/dist/cjs/utils/commands.js +16 -0
  27. package/dist/cjs/utils/index.js +290 -0
  28. package/dist/es2019/FindReplaceToolbarButtonWithState.js +153 -0
  29. package/dist/es2019/actions.js +13 -0
  30. package/dist/es2019/commands-with-analytics.js +72 -0
  31. package/dist/es2019/commands.js +240 -0
  32. package/dist/es2019/index.js +1 -0
  33. package/dist/es2019/plugin.js +88 -0
  34. package/dist/es2019/pm-plugins/keymap.js +16 -0
  35. package/dist/es2019/pm-plugins/main.js +30 -0
  36. package/dist/es2019/pm-plugins/plugin-factory.js +91 -0
  37. package/dist/es2019/pm-plugins/plugin-key.js +2 -0
  38. package/dist/es2019/reducer.js +56 -0
  39. package/dist/es2019/styles.js +18 -0
  40. package/dist/es2019/types.js +1 -0
  41. package/dist/es2019/ui/Find.js +286 -0
  42. package/dist/es2019/ui/FindReplace.js +81 -0
  43. package/dist/es2019/ui/FindReplaceToolbarButton.js +122 -0
  44. package/dist/es2019/ui/FindReplaceTooltipButton.js +51 -0
  45. package/dist/es2019/ui/Replace.js +155 -0
  46. package/dist/es2019/ui/styles.js +50 -0
  47. package/dist/es2019/utils/array.js +3 -0
  48. package/dist/es2019/utils/batch-decorations.js +189 -0
  49. package/dist/es2019/utils/commands.js +6 -0
  50. package/dist/es2019/utils/index.js +249 -0
  51. package/dist/esm/FindReplaceToolbarButtonWithState.js +157 -0
  52. package/dist/esm/actions.js +13 -0
  53. package/dist/esm/commands-with-analytics.js +95 -0
  54. package/dist/esm/commands.js +248 -0
  55. package/dist/esm/index.js +1 -0
  56. package/dist/esm/plugin.js +86 -0
  57. package/dist/esm/pm-plugins/keymap.js +18 -0
  58. package/dist/esm/pm-plugins/main.js +33 -0
  59. package/dist/esm/pm-plugins/plugin-factory.js +104 -0
  60. package/dist/esm/pm-plugins/plugin-key.js +2 -0
  61. package/dist/esm/reducer.js +54 -0
  62. package/dist/esm/styles.js +11 -0
  63. package/dist/esm/types.js +1 -0
  64. package/dist/esm/ui/Find.js +304 -0
  65. package/dist/esm/ui/FindReplace.js +100 -0
  66. package/dist/esm/ui/FindReplaceToolbarButton.js +126 -0
  67. package/dist/esm/ui/FindReplaceTooltipButton.js +70 -0
  68. package/dist/esm/ui/Replace.js +171 -0
  69. package/dist/esm/ui/styles.js +39 -0
  70. package/dist/esm/utils/array.js +7 -0
  71. package/dist/esm/utils/batch-decorations.js +304 -0
  72. package/dist/esm/utils/commands.js +10 -0
  73. package/dist/esm/utils/index.js +280 -0
  74. package/dist/types/FindReplaceToolbarButtonWithState.d.ts +4 -0
  75. package/dist/types/actions.d.ts +64 -0
  76. package/dist/types/commands-with-analytics.d.ts +27 -0
  77. package/dist/types/commands.d.ts +12 -0
  78. package/dist/types/index.d.ts +2 -0
  79. package/dist/types/plugin.d.ts +2 -0
  80. package/dist/types/pm-plugins/keymap.d.ts +4 -0
  81. package/dist/types/pm-plugins/main.d.ts +5 -0
  82. package/dist/types/pm-plugins/plugin-factory.d.ts +2 -0
  83. package/dist/types/pm-plugins/plugin-key.d.ts +3 -0
  84. package/dist/types/reducer.d.ts +4 -0
  85. package/dist/types/styles.d.ts +3 -0
  86. package/dist/types/types.d.ts +76 -0
  87. package/dist/types/ui/Find.d.ts +71 -0
  88. package/dist/types/ui/FindReplace.d.ts +43 -0
  89. package/dist/types/ui/FindReplaceToolbarButton.d.ts +21 -0
  90. package/dist/types/ui/FindReplaceTooltipButton.d.ts +18 -0
  91. package/dist/types/ui/Replace.d.ts +27 -0
  92. package/dist/types/ui/styles.d.ts +6 -0
  93. package/dist/types/utils/array.d.ts +1 -0
  94. package/dist/types/utils/batch-decorations.d.ts +36 -0
  95. package/dist/types/utils/commands.d.ts +2 -0
  96. package/dist/types/utils/index.d.ts +49 -0
  97. package/dist/types-ts4.5/FindReplaceToolbarButtonWithState.d.ts +4 -0
  98. package/dist/types-ts4.5/actions.d.ts +64 -0
  99. package/dist/types-ts4.5/commands-with-analytics.d.ts +27 -0
  100. package/dist/types-ts4.5/commands.d.ts +12 -0
  101. package/dist/types-ts4.5/index.d.ts +2 -0
  102. package/dist/types-ts4.5/plugin.d.ts +2 -0
  103. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +4 -0
  104. package/dist/types-ts4.5/pm-plugins/main.d.ts +5 -0
  105. package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +2 -0
  106. package/dist/types-ts4.5/pm-plugins/plugin-key.d.ts +3 -0
  107. package/dist/types-ts4.5/reducer.d.ts +4 -0
  108. package/dist/types-ts4.5/styles.d.ts +3 -0
  109. package/dist/types-ts4.5/types.d.ts +76 -0
  110. package/dist/types-ts4.5/ui/Find.d.ts +71 -0
  111. package/dist/types-ts4.5/ui/FindReplace.d.ts +43 -0
  112. package/dist/types-ts4.5/ui/FindReplaceToolbarButton.d.ts +21 -0
  113. package/dist/types-ts4.5/ui/FindReplaceTooltipButton.d.ts +18 -0
  114. package/dist/types-ts4.5/ui/Replace.d.ts +27 -0
  115. package/dist/types-ts4.5/ui/styles.d.ts +6 -0
  116. package/dist/types-ts4.5/utils/array.d.ts +1 -0
  117. package/dist/types-ts4.5/utils/batch-decorations.d.ts +36 -0
  118. package/dist/types-ts4.5/utils/commands.d.ts +2 -0
  119. package/dist/types-ts4.5/utils/index.d.ts +49 -0
  120. package/package.json +117 -0
  121. package/styles/package.json +17 -0
@@ -0,0 +1,49 @@
1
+ import type { Fragment, Node as PmNode, Slice } from '@atlaskit/editor-prosemirror/model';
2
+ import type { ReadonlyTransaction, Selection } from '@atlaskit/editor-prosemirror/state';
3
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
+ import type { Step } from '@atlaskit/editor-prosemirror/transform';
5
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
6
+ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
+ import type { Match } from '../types';
8
+ export declare function getSelectedText(selection: TextSelection): string;
9
+ export declare const createDecorations: (selectedIndex: number, matches: {
10
+ start: number;
11
+ end: number;
12
+ }[]) => Decoration[];
13
+ export declare const createDecoration: (start: number, end: number, isSelected?: boolean) => Decoration;
14
+ export declare function findMatches(content: PmNode | Fragment, searchText: string, shouldMatchCase: boolean, contentIndex?: number): Match[];
15
+ /**
16
+ * Finds index of first item in matches array that comes after user's cursor pos.
17
+ * If `backward` is `true`, finds index of first item that comes before instead.
18
+ */
19
+ export declare function findSearchIndex(selectionPos: number, matches: Match[], backward?: boolean): number;
20
+ export declare const nextIndex: (currentIndex: number, total: number) => number;
21
+ export declare const prevIndex: (currentIndex: number, total: number) => number;
22
+ export declare const getSelectionForMatch: (selection: Selection, doc: PmNode, index: number, matches: Match[], offset?: number) => Selection;
23
+ export declare const findDecorationFromMatch: (decorationSet: DecorationSet, match: Match) => Decoration | undefined;
24
+ export declare const removeDecorationsFromSet: (decorationSet: DecorationSet, decorationsToRemove: Decoration[], doc: PmNode) => DecorationSet;
25
+ export declare const removeMatchesFromSet: (decorationSet: DecorationSet, matches: Match[], doc: PmNode) => DecorationSet;
26
+ /**
27
+ * Finds decorations in prevDecorations that are not in newDecorations or decorationsToRemove
28
+ * These decorations have been lost by Prosemirror during an over eager decoration removal
29
+ * We need to be smart to cope with thousands of decorations without crashing everything
30
+ */
31
+ export declare const findLostAdjacentDecorations: (decorationsToRemove: Decoration[], prevDecorations: Decoration[], newDecorations: Decoration[]) => Decoration[];
32
+ /**
33
+ * Searches through array in bumps of 100 to return the index of the first
34
+ * decoration whose 'from' value is before or equal to the position
35
+ */
36
+ export declare const findIndexBeforePosition: (items: Decoration[], position: number) => number;
37
+ /**
38
+ * Determines whether a find/replace text Match will be changed as a result
39
+ * of a Step modification to the document. This is evaluated by checking
40
+ * both mapped and unmapped versions of the Step as in different cases the
41
+ * matches will match.
42
+ *
43
+ * **Note:** Match state received here is after step has been applied.
44
+ */
45
+ export declare const isMatchAffectedByStep: (match: Match, step: Step & {
46
+ from: number;
47
+ to: number;
48
+ slice: Slice;
49
+ }, tr: ReadonlyTransaction) => boolean;
package/package.json ADDED
@@ -0,0 +1,117 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-find-replace",
3
+ "version": "0.1.0",
4
+ "description": "find replace plugin for @atlaskit/editor-core",
5
+ "author": "Atlassian Pty Ltd",
6
+ "license": "Apache-2.0",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/"
9
+ },
10
+ "atlassian": {
11
+ "team": "Editor: Lego",
12
+ "inPublicMirror": false,
13
+ "releaseModel": "continuous"
14
+ },
15
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
16
+ "main": "dist/cjs/index.js",
17
+ "module": "dist/esm/index.js",
18
+ "module:es2019": "dist/es2019/index.js",
19
+ "types": "dist/types/index.d.ts",
20
+ "typesVersions": {
21
+ ">=4.5 <4.9": {
22
+ "*": [
23
+ "dist/types-ts4.5/*",
24
+ "dist/types-ts4.5/index.d.ts"
25
+ ]
26
+ }
27
+ },
28
+ "sideEffects": [
29
+ "*.compiled.css"
30
+ ],
31
+ "atlaskit:src": "src/index.ts",
32
+ "af:exports": {
33
+ ".": "./src/index.ts",
34
+ "./styles": "./src/styles.ts"
35
+ },
36
+ "dependencies": {
37
+ "@atlaskit/button": "^17.2.0",
38
+ "@atlaskit/editor-common": "^76.39.0",
39
+ "@atlaskit/editor-plugin-analytics": "^0.4.0",
40
+ "@atlaskit/editor-plugin-feature-flags": "^1.0.0",
41
+ "@atlaskit/editor-prosemirror": "1.1.0",
42
+ "@atlaskit/editor-shared-styles": "^2.9.0",
43
+ "@atlaskit/icon": "^22.0.0",
44
+ "@atlaskit/platform-feature-flags": "^0.2.0",
45
+ "@atlaskit/textfield": "^6.0.0",
46
+ "@atlaskit/theme": "^12.6.0",
47
+ "@atlaskit/tokens": "^1.33.0",
48
+ "@atlaskit/tooltip": "^18.1.0",
49
+ "@babel/runtime": "^7.0.0",
50
+ "@emotion/react": "^11.7.1",
51
+ "lodash": "^4.17.21",
52
+ "raf-schd": "^4.0.3"
53
+ },
54
+ "devDependencies": {
55
+ "@atlaskit/editor-plugin-block-type": "^3.0.0",
56
+ "@atlaskit/editor-plugin-text-formatting": "^0.4.0",
57
+ "@atlaskit/primitives": "^1.17.0",
58
+ "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
59
+ "@testing-library/react": "^12.1.5",
60
+ "@testing-library/user-event": "^14.4.3",
61
+ "mockdate": "^3.0.5",
62
+ "raf-stub": "^2.0.1",
63
+ "react-dom": "^16.8.0"
64
+ },
65
+ "peerDependencies": {
66
+ "react": "^16.8.0",
67
+ "react-intl-next": "npm:react-intl@^5.18.1"
68
+ },
69
+ "techstack": {
70
+ "@atlassian/frontend": {
71
+ "import-structure": [
72
+ "atlassian-conventions"
73
+ ],
74
+ "circular-dependencies": [
75
+ "file-and-folder-level"
76
+ ]
77
+ },
78
+ "@repo/internal": {
79
+ "dom-events": "use-bind-event-listener",
80
+ "analytics": [
81
+ "analytics-next"
82
+ ],
83
+ "design-tokens": [
84
+ "color"
85
+ ],
86
+ "theming": [
87
+ "react-context"
88
+ ],
89
+ "ui-components": [
90
+ "lite-mode"
91
+ ],
92
+ "deprecation": [
93
+ "no-deprecated-imports"
94
+ ],
95
+ "styling": [
96
+ "static",
97
+ "emotion"
98
+ ],
99
+ "imports": [
100
+ "import-no-extraneous-disable-for-examples-and-docs"
101
+ ]
102
+ }
103
+ },
104
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
105
+ "platform-feature-flags": {
106
+ "platform.editor.a11y-find-replace": {
107
+ "type": "boolean"
108
+ }
109
+ },
110
+ "stricter": {
111
+ "no-unused-dependencies": {
112
+ "exclude": [
113
+ "@atlaskit/editor-plugin-analytics"
114
+ ]
115
+ }
116
+ }
117
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-find-replace/styles",
3
+ "main": "../dist/cjs/styles.js",
4
+ "module": "../dist/esm/styles.js",
5
+ "module:es2019": "../dist/es2019/styles.js",
6
+ "sideEffects": [
7
+ "*.compiled.css"
8
+ ],
9
+ "types": "../dist/types/styles.d.ts",
10
+ "typesVersions": {
11
+ ">=4.5 <4.9": {
12
+ "*": [
13
+ "../dist/types-ts4.5/styles.d.ts"
14
+ ]
15
+ }
16
+ }
17
+ }