@atlaskit/editor-plugin-annotation 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 (80) hide show
  1. package/.eslintrc.js +18 -0
  2. package/CHANGELOG.md +1 -0
  3. package/LICENSE.md +13 -0
  4. package/README.md +30 -0
  5. package/dist/cjs/commands/index.js +150 -0
  6. package/dist/cjs/commands/transform.js +86 -0
  7. package/dist/cjs/index.js +12 -0
  8. package/dist/cjs/nodeviews/index.js +59 -0
  9. package/dist/cjs/plugin.js +132 -0
  10. package/dist/cjs/pm-plugins/inline-comment.js +246 -0
  11. package/dist/cjs/pm-plugins/keymap.js +15 -0
  12. package/dist/cjs/pm-plugins/plugin-factory.js +107 -0
  13. package/dist/cjs/pm-plugins/reducer.js +84 -0
  14. package/dist/cjs/pm-plugins/types.js +17 -0
  15. package/dist/cjs/toolbar.js +59 -0
  16. package/dist/cjs/types.js +20 -0
  17. package/dist/cjs/ui/AnnotationViewWrapper.js +39 -0
  18. package/dist/cjs/ui/InlineCommentView.js +149 -0
  19. package/dist/cjs/utils.js +372 -0
  20. package/dist/es2019/commands/index.js +123 -0
  21. package/dist/es2019/commands/transform.js +64 -0
  22. package/dist/es2019/index.js +1 -0
  23. package/dist/es2019/nodeviews/index.js +31 -0
  24. package/dist/es2019/plugin.js +127 -0
  25. package/dist/es2019/pm-plugins/inline-comment.js +181 -0
  26. package/dist/es2019/pm-plugins/keymap.js +9 -0
  27. package/dist/es2019/pm-plugins/plugin-factory.js +108 -0
  28. package/dist/es2019/pm-plugins/reducer.js +94 -0
  29. package/dist/es2019/pm-plugins/types.js +11 -0
  30. package/dist/es2019/toolbar.js +53 -0
  31. package/dist/es2019/types.js +14 -0
  32. package/dist/es2019/ui/AnnotationViewWrapper.js +15 -0
  33. package/dist/es2019/ui/InlineCommentView.js +145 -0
  34. package/dist/es2019/utils.js +334 -0
  35. package/dist/esm/commands/index.js +143 -0
  36. package/dist/esm/commands/transform.js +80 -0
  37. package/dist/esm/index.js +1 -0
  38. package/dist/esm/nodeviews/index.js +52 -0
  39. package/dist/esm/plugin.js +120 -0
  40. package/dist/esm/pm-plugins/inline-comment.js +239 -0
  41. package/dist/esm/pm-plugins/keymap.js +9 -0
  42. package/dist/esm/pm-plugins/plugin-factory.js +101 -0
  43. package/dist/esm/pm-plugins/reducer.js +77 -0
  44. package/dist/esm/pm-plugins/types.js +11 -0
  45. package/dist/esm/toolbar.js +52 -0
  46. package/dist/esm/types.js +14 -0
  47. package/dist/esm/ui/AnnotationViewWrapper.js +32 -0
  48. package/dist/esm/ui/InlineCommentView.js +142 -0
  49. package/dist/esm/utils.js +345 -0
  50. package/dist/types/commands/index.d.ts +15 -0
  51. package/dist/types/commands/transform.d.ts +11 -0
  52. package/dist/types/index.d.ts +3 -0
  53. package/dist/types/nodeviews/index.d.ts +11 -0
  54. package/dist/types/plugin.d.ts +6 -0
  55. package/dist/types/pm-plugins/inline-comment.d.ts +3 -0
  56. package/dist/types/pm-plugins/keymap.d.ts +3 -0
  57. package/dist/types/pm-plugins/plugin-factory.d.ts +2 -0
  58. package/dist/types/pm-plugins/reducer.d.ts +3 -0
  59. package/dist/types/pm-plugins/types.d.ts +78 -0
  60. package/dist/types/toolbar.d.ts +5 -0
  61. package/dist/types/types.d.ts +100 -0
  62. package/dist/types/ui/AnnotationViewWrapper.d.ts +10 -0
  63. package/dist/types/ui/InlineCommentView.d.ts +12 -0
  64. package/dist/types/utils.d.ts +44 -0
  65. package/dist/types-ts4.5/commands/index.d.ts +15 -0
  66. package/dist/types-ts4.5/commands/transform.d.ts +11 -0
  67. package/dist/types-ts4.5/index.d.ts +3 -0
  68. package/dist/types-ts4.5/nodeviews/index.d.ts +11 -0
  69. package/dist/types-ts4.5/plugin.d.ts +6 -0
  70. package/dist/types-ts4.5/pm-plugins/inline-comment.d.ts +3 -0
  71. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -0
  72. package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +2 -0
  73. package/dist/types-ts4.5/pm-plugins/reducer.d.ts +3 -0
  74. package/dist/types-ts4.5/pm-plugins/types.d.ts +78 -0
  75. package/dist/types-ts4.5/toolbar.d.ts +5 -0
  76. package/dist/types-ts4.5/types.d.ts +102 -0
  77. package/dist/types-ts4.5/ui/AnnotationViewWrapper.d.ts +10 -0
  78. package/dist/types-ts4.5/ui/InlineCommentView.d.ts +12 -0
  79. package/dist/types-ts4.5/utils.d.ts +44 -0
  80. package/package.json +106 -0
@@ -0,0 +1,44 @@
1
+ import type { AnalyticsEventPayloadCallback, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ import { containsAnyAnnotations, hasAnnotationMark } from '@atlaskit/editor-common/utils';
3
+ import type { Mark, Node, ResolvedPos, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
4
+ import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
5
+ import { AllSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
+ import type { InlineCommentPluginState } from './pm-plugins/types';
8
+ import type { AnnotationInfo } from './types';
9
+ import { AnnotationSelectionType } from './types';
10
+ export { hasAnnotationMark, containsAnyAnnotations };
11
+ /**
12
+ * Finds the marks in the nodes to the left and right.
13
+ * @param $pos Position to center search around
14
+ */
15
+ export declare const surroundingMarks: ($pos: ResolvedPos) => (readonly Mark[])[];
16
+ export declare const getAllAnnotations: (doc: Node) => string[];
17
+ export declare const addDraftDecoration: (start: number, end: number) => Decoration;
18
+ export declare const getAnnotationViewKey: (annotations: AnnotationInfo[]) => string;
19
+ export declare const findAnnotationsInSelection: (selection: Selection, doc: Node) => AnnotationInfo[];
20
+ /**
21
+ * get selection from position to apply new comment for
22
+ * @return bookmarked positions if they exists, otherwise current selection positions
23
+ */
24
+ export declare function getSelectionPositions(editorState: EditorState, inlineCommentState?: InlineCommentPluginState | null | undefined): Selection;
25
+ export declare const inlineCommentPluginKey: PluginKey<InlineCommentPluginState>;
26
+ export declare const getPluginState: (state: EditorState) => InlineCommentPluginState | undefined;
27
+ /**
28
+ * get payload for the open/close analytics event
29
+ */
30
+ export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT) => AnalyticsEventPayloadCallback;
31
+ export declare const isSelectionValid: (state: EditorState) => AnnotationSelectionType;
32
+ export declare const hasInvalidNodes: (state: EditorState) => boolean;
33
+ /**
34
+ * Checks if any of the nodes in a given selection are completely whitespace
35
+ * This is to conform to Confluence annotation specifications
36
+ */
37
+ export declare function hasInvalidWhitespaceNode(selection: TextSelection | AllSelection, schema: Schema): boolean;
38
+ export declare function annotationExists(annotationId: string, state: EditorState): boolean;
39
+ export declare function stripNonExistingAnnotations(slice: Slice, state: EditorState): false | undefined;
40
+ /**
41
+ * Compares two sets of annotationInfos to see if the annotations have changed
42
+ * This function assumes annotations will have unique id's for simplicity
43
+ */
44
+ export declare function isSelectedAnnotationsChanged(oldSelectedAnnotations: AnnotationInfo[], newSelectedAnnotations: AnnotationInfo[]): boolean;
package/package.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-annotation",
3
+ "version": "0.1.0",
4
+ "description": "Annotation 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: AI",
12
+ "inPublicMirror": false,
13
+ "releaseModel": "continuous",
14
+ "website": {
15
+ "name": "EditorPluginAnnotation",
16
+ "category": "Components"
17
+ }
18
+ },
19
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
20
+ "main": "dist/cjs/index.js",
21
+ "module": "dist/esm/index.js",
22
+ "module:es2019": "dist/es2019/index.js",
23
+ "types": "dist/types/index.d.ts",
24
+ "typesVersions": {
25
+ ">=4.5 <4.9": {
26
+ "*": [
27
+ "dist/types-ts4.5/*",
28
+ "dist/types-ts4.5/index.d.ts"
29
+ ]
30
+ }
31
+ },
32
+ "sideEffects": false,
33
+ "atlaskit:src": "src/index.ts",
34
+ "af:exports": {
35
+ ".": "./src/index.ts"
36
+ },
37
+ "dependencies": {
38
+ "@atlaskit/adf-schema": "^35.2.0",
39
+ "@atlaskit/editor-common": "^76.28.0",
40
+ "@atlaskit/editor-plugin-analytics": "^0.4.0",
41
+ "@atlaskit/editor-prosemirror": "1.1.0",
42
+ "@atlaskit/icon": "^22.0.0",
43
+ "@atlaskit/platform-feature-flags": "^0.2.0",
44
+ "@babel/runtime": "^7.0.0"
45
+ },
46
+ "peerDependencies": {
47
+ "react": "^16.8.0"
48
+ },
49
+ "devDependencies": {
50
+ "@af/integration-testing": "*",
51
+ "@af/visual-regression": "*",
52
+ "@atlaskit/ssr": "*",
53
+ "@atlaskit/visual-regression": "*",
54
+ "@atlaskit/webdriver-runner": "*",
55
+ "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
56
+ "@atlassian/feature-flags-test-utils": "^0.1.1",
57
+ "@testing-library/react": "^12.1.5",
58
+ "react-dom": "^16.8.0",
59
+ "typescript": "~4.9.5",
60
+ "wait-for-expect": "^1.2.0"
61
+ },
62
+ "techstack": {
63
+ "@atlassian/frontend": {
64
+ "import-structure": [
65
+ "atlassian-conventions"
66
+ ],
67
+ "circular-dependencies": [
68
+ "file-and-folder-level"
69
+ ]
70
+ },
71
+ "@repo/internal": {
72
+ "dom-events": "use-bind-event-listener",
73
+ "analytics": [
74
+ "analytics-next"
75
+ ],
76
+ "design-tokens": [
77
+ "color"
78
+ ],
79
+ "theming": [
80
+ "react-context"
81
+ ],
82
+ "ui-components": [
83
+ "lite-mode"
84
+ ],
85
+ "deprecation": [
86
+ "no-deprecated-imports"
87
+ ],
88
+ "styling": [
89
+ "static",
90
+ "emotion"
91
+ ],
92
+ "imports": [
93
+ "import-no-extraneous-disable-for-examples-and-docs"
94
+ ]
95
+ }
96
+ },
97
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
98
+ "platform-feature-flags": {
99
+ "platform.editor.annotation.decouple-inline-comment-closed_flmox": {
100
+ "type": "boolean"
101
+ },
102
+ "platform.editor.enable-selection-toolbar_ucdwd": {
103
+ "type": "boolean"
104
+ }
105
+ }
106
+ }