@atlaskit/editor-plugin-autocomplete 0.1.0 → 0.3.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 (58) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/afm-cc/tsconfig.json +2 -1
  3. package/afm-jira/tsconfig.json +2 -1
  4. package/afm-products/tsconfig.json +2 -1
  5. package/build/tsconfig.json +20 -0
  6. package/build/url-module.d.ts +8 -0
  7. package/dist/cjs/autocompletePlugin.js +18 -5
  8. package/dist/cjs/autocompletePluginType.js +5 -1
  9. package/dist/cjs/pm-plugins/autocomplete-plugin.js +368 -0
  10. package/dist/cjs/pm-plugins/ghost-text-decoration.js +39 -0
  11. package/dist/cjs/pm-plugins/scoring-pipeline.js +256 -0
  12. package/dist/cjs/pm-plugins/slow-lane-client.js +199 -0
  13. package/dist/cjs/pm-plugins/text-predictor.js +796 -0
  14. package/dist/es2019/autocompletePlugin.js +20 -6
  15. package/dist/es2019/autocompletePluginType.js +1 -0
  16. package/dist/es2019/pm-plugins/autocomplete-plugin.js +368 -0
  17. package/dist/es2019/pm-plugins/ghost-text-decoration.js +33 -0
  18. package/dist/es2019/pm-plugins/scoring-pipeline.js +221 -0
  19. package/dist/es2019/pm-plugins/slow-lane-client.js +157 -0
  20. package/dist/es2019/pm-plugins/text-predictor.js +631 -0
  21. package/dist/esm/autocompletePlugin.js +18 -5
  22. package/dist/esm/autocompletePluginType.js +1 -0
  23. package/dist/esm/pm-plugins/autocomplete-plugin.js +362 -0
  24. package/dist/esm/pm-plugins/ghost-text-decoration.js +33 -0
  25. package/dist/esm/pm-plugins/scoring-pipeline.js +252 -0
  26. package/dist/esm/pm-plugins/slow-lane-client.js +192 -0
  27. package/dist/esm/pm-plugins/text-predictor.js +793 -0
  28. package/dist/types/autocompletePluginType.d.ts +6 -3
  29. package/dist/types/pm-plugins/autocomplete-plugin.d.ts +36 -0
  30. package/dist/types/pm-plugins/ghost-text-decoration.d.ts +7 -0
  31. package/dist/types/pm-plugins/scoring-pipeline.d.ts +33 -0
  32. package/dist/types/pm-plugins/slow-lane-client.d.ts +46 -0
  33. package/dist/types/pm-plugins/text-predictor.d.ts +90 -0
  34. package/dist/types-ts4.5/autocompletePluginType.d.ts +6 -3
  35. package/dist/types-ts4.5/pm-plugins/autocomplete-plugin.d.ts +36 -0
  36. package/dist/types-ts4.5/pm-plugins/ghost-text-decoration.d.ts +7 -0
  37. package/dist/types-ts4.5/pm-plugins/scoring-pipeline.d.ts +33 -0
  38. package/dist/types-ts4.5/pm-plugins/slow-lane-client.d.ts +46 -0
  39. package/dist/types-ts4.5/pm-plugins/text-predictor.d.ts +90 -0
  40. package/package.json +2 -2
  41. package/src/autocompletePlugin.tsx +25 -5
  42. package/src/autocompletePluginType.ts +14 -3
  43. package/src/pm-plugins/autocomplete-plugin/package.json +15 -0
  44. package/src/pm-plugins/autocomplete-plugin.ts +443 -0
  45. package/src/pm-plugins/data/combined_l2_l3_pos_tags.json +73571 -3
  46. package/src/pm-plugins/data/ghost_pos_tags.json +43 -3
  47. package/src/pm-plugins/data/grammar_transitions_10k.json +46 -3
  48. package/src/pm-plugins/data/l3_vocabulary.json +20002 -3
  49. package/src/pm-plugins/data/vocabulary_10k.json +38794 -3
  50. package/src/pm-plugins/data/word_index_10k.json +7760 -3
  51. package/src/pm-plugins/ghost-text-decoration.ts +44 -0
  52. package/src/pm-plugins/scoring-pipeline.ts +294 -0
  53. package/src/pm-plugins/slow-lane-client/package.json +15 -0
  54. package/src/pm-plugins/slow-lane-client.ts +222 -0
  55. package/src/pm-plugins/text-predictor/package.json +15 -0
  56. package/src/pm-plugins/text-predictor.ts +780 -0
  57. package/tsconfig.app.json +12 -3
  58. package/tsconfig.json +4 -1
@@ -1,3 +1,6 @@
1
- export type AutocompletePlugin = () => {
2
- name: 'autocomplete';
3
- };
1
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ import type { AutocompletePluginOptions, AutocompletePluginState } from './pm-plugins/autocomplete-plugin';
3
+ export type AutocompletePlugin = NextEditorPlugin<'autocomplete', {
4
+ pluginConfiguration?: AutocompletePluginOptions | undefined;
5
+ sharedState: AutocompletePluginState | undefined;
6
+ }>;
@@ -0,0 +1,36 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
+ export declare const autocompletePluginKey: PluginKey<any>;
5
+ export interface AutocompletePluginState {
6
+ /** The decoration set containing the ghost text widget */
7
+ decorationSet: DecorationSet;
8
+ /** The document position where the ghost text should appear */
9
+ ghostPosition: number;
10
+ /** The predicted ghost text to display */
11
+ ghostText: string;
12
+ }
13
+ /**
14
+ * Context provided to the autocomplete plugin on first editor focus.
15
+ * Text fields are selectively ingested to boost word-frequency scoring for
16
+ * predictions, giving words already present in the document/thread an L1
17
+ * priority boost.
18
+ */
19
+ export interface AutocompleteContext {
20
+ /** Full page content as a string (e.g. markdown). */
21
+ fullPageContent?: string;
22
+ /** The currently selected text on the page, if any. */
23
+ pageSelectionContent?: string;
24
+ /** Content of the parent comment when the editor is in reply or edit mode. */
25
+ parentCommentContent?: string;
26
+ /** Contents of sibling comments when the editor is in reply or edit mode. */
27
+ siblingCommentsContents?: string[];
28
+ }
29
+ export interface AutocompletePluginOptions {
30
+ /**
31
+ * Async function called once on first editor focus to retrieve context for
32
+ * word-frequency boosting. Called lazily so the preset can remain synchronous.
33
+ */
34
+ getContext?: () => Promise<AutocompleteContext | undefined>;
35
+ }
36
+ export declare const createAutocompletePlugin: (options?: AutocompletePluginOptions) => SafePlugin<any>;
@@ -0,0 +1,7 @@
1
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
+ /**
4
+ * Creates a DecorationSet containing a ghost text widget at the given position.
5
+ * The ghost text is rendered as a styled <span> that appears after the cursor.
6
+ */
7
+ export declare const createGhostTextDecorationSet: (state: EditorState, position: number, text: string) => DecorationSet;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Scoring Pipeline: Stage 1 (Semantic + Frequency), Grammar Filter, Stage 2 (LM Re-ranking).
3
+ *
4
+ * Operates synchronously on pre-loaded data. Each stage gracefully degrades
5
+ * when its required data isn't available (cold → warm → full warm).
6
+ */
7
+ export interface ScoringCandidate {
8
+ authorFreq: number;
9
+ docFreq: number;
10
+ sessionFreq: number;
11
+ tenantFreq: number;
12
+ word: string;
13
+ }
14
+ export interface ScoredCandidate {
15
+ finalScore: number;
16
+ freqScore: number;
17
+ lmScore: number;
18
+ semanticScore: number;
19
+ word: string;
20
+ }
21
+ /** Metadata returned by the grammar filter for debug logging in the caller. */
22
+ export interface GrammarFilterMeta {
23
+ after: number;
24
+ before: number;
25
+ dropped: string[];
26
+ prevTags: string[];
27
+ prevWord: string;
28
+ }
29
+ export interface RankCandidatesResult {
30
+ candidates: ScoredCandidate[];
31
+ grammarMeta: GrammarFilterMeta | null;
32
+ }
33
+ export declare function rankCandidates(candidates: ScoringCandidate[], contextVector: Float32Array | null, getWordVector: (word: string) => Float32Array | null, lmLogits: Record<string, number> | null, maxTenantFreq: number, previousWord: string): RankCandidatesResult;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Slow Lane Client: Backend context encoding for autocomplete.
3
+ *
4
+ * Fires a BE request on word boundaries to encode document context.
5
+ * Expects the typeahead-encodings API format:
6
+ * Request: { text, session_id }
7
+ * Response: { semantic_vector: number[], lm_logits: Record<string, number> }
8
+ */
9
+ /** Request payload for typeahead-encodings endpoint. */
10
+ export interface TypeaheadEncodingsRequest {
11
+ session_id: string;
12
+ text: string;
13
+ }
14
+ /** Response from typeahead-encodings endpoint. */
15
+ export interface TypeaheadEncodingsResponse {
16
+ lm_logits: Record<string, number>;
17
+ semantic_vector: number[];
18
+ }
19
+ /**
20
+ * Check if text ends with a word boundary character (space or punctuation).
21
+ */
22
+ export declare const isWordBoundary: (text: string) => boolean;
23
+ export interface SlowLaneClientConfig {
24
+ baseUrl: string;
25
+ debounceMs?: number;
26
+ endpoint?: string;
27
+ fetchFn?: typeof fetch;
28
+ onUpdate?: (opts: {
29
+ hasLmLogits: boolean;
30
+ hasVector: boolean;
31
+ textLength: number;
32
+ }) => void;
33
+ productKey?: string;
34
+ sessionId?: string;
35
+ }
36
+ export declare const createSlowLaneClient: (config: SlowLaneClientConfig) => {
37
+ getContextVector: () => Float32Array | null;
38
+ getLmLogits: () => Record<string, number> | null;
39
+ isWordBoundary: (text: string) => boolean;
40
+ setContextVector: (vector: Float32Array | null) => void;
41
+ setLmLogits: (logits: Record<string, number> | null) => void;
42
+ updateContext: (text: string) => void;
43
+ };
44
+ export declare const setDefaultSlowLaneClient: (client: ReturnType<typeof createSlowLaneClient> | null) => void;
45
+ export declare const getStoredContextVector: () => Float32Array | null;
46
+ export declare const getStoredLmLogits: () => Record<string, number> | null;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Fast Lane Predictor: Local autocomplete using weighted trie + frequency + semantic scoring.
3
+ *
4
+ * Two prediction modes:
5
+ * 1. Word boundary → bigram-based next-word suggestion (grammar-filtered)
6
+ * 2. Mid-word (≥3 chars) → trie prefix search → scoring pipeline → top result
7
+ *
8
+ * Scoring is delegated to scoring-pipeline.ts which handles:
9
+ * Stage 1 (semantic + frequency), grammar filter, Stage 2 (optional LM re-ranking).
10
+ *
11
+ * Context vector: average of word vectors from text before cursor (last N words).
12
+ * Falls back to cold mode (freq-only) when vectors not yet loaded.
13
+ *
14
+ * Session personalization (L1): words the user types are incrementally boosted
15
+ * via incrementSessionFreq(), called on word boundaries from the plugin.
16
+ */
17
+ export interface WeightedTerm {
18
+ authorFreq: number;
19
+ docFreq: number;
20
+ freq: number;
21
+ word: string;
22
+ }
23
+ export interface TenantVocabulary {
24
+ terms: WeightedTerm[];
25
+ }
26
+ interface VectorStore {
27
+ dim: number;
28
+ float32: Float32Array;
29
+ wordIndex: Record<string, number>;
30
+ }
31
+ /**
32
+ * Loads the General English vocabulary.
33
+ * expects a simple array of strings: ["about", "above", "actually", ...]
34
+ */
35
+ export declare const initL3Vocabulary: (l3Words: string[]) => void;
36
+ /** Enable or disable debug logging. Also checks localStorage key `autocomplete-debug`. */
37
+ export declare const setDebugMode: (enabled: boolean) => void;
38
+ /**
39
+ * Get predictor status for debugging.
40
+ * vectorsLoaded: true when semantic scoring is active
41
+ * wordCount: number of words in vector store (0 if not loaded)
42
+ */
43
+ export declare const getPredictorStatus: () => {
44
+ isInitialized: boolean;
45
+ vectorsLoaded: boolean;
46
+ vectorsLoadStarted: boolean;
47
+ wordCount: number;
48
+ };
49
+ /**
50
+ * Get details of the last prediction (for debugging).
51
+ * Returns null if no prediction has run yet or debug was off.
52
+ */
53
+ export declare const getLastPredictionDebug: () => {
54
+ contextWords: string[];
55
+ currentWord: string;
56
+ mode: "cold" | "warm";
57
+ suggestion: string | null;
58
+ textBefore: string;
59
+ topCandidates: Array<{
60
+ finalScore: number;
61
+ freqScore: number;
62
+ lmScore: number;
63
+ semanticScore: number;
64
+ word: string;
65
+ }>;
66
+ } | null;
67
+ export declare const initVocabulary: (vocabulary: TenantVocabulary) => void;
68
+ /**
69
+ * Increment L1 session frequency for a single word.
70
+ * Called from the plugin on word boundaries for efficient incremental boosting.
71
+ */
72
+ export declare const incrementSessionFreq: (word: string) => void;
73
+ /**
74
+ * Prime session frequencies from a document page string.
75
+ *
76
+ * Iterates through every token in `pageContent` and increments its session
77
+ * frequency so that words already present on the page receive an L1 boost
78
+ * before the user starts typing.
79
+ *
80
+ * Pass `undefined` (or omit the argument) to skip priming — useful when the
81
+ * calling context does not yet have a page value available.
82
+ */
83
+ export declare const ingestDocumentPage: (pageContent: string | undefined) => void;
84
+ export declare const predict: (textBefore: string) => string | null;
85
+ export declare const loadVectorsAsync: (options?: {
86
+ vectorsUrl?: string;
87
+ }) => Promise<void>;
88
+ export declare const initVectors: (store: VectorStore) => void;
89
+ export declare const loadDefaultVocabulary: () => void;
90
+ export {};
@@ -1,3 +1,6 @@
1
- export type AutocompletePlugin = () => {
2
- name: 'autocomplete';
3
- };
1
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ import type { AutocompletePluginOptions, AutocompletePluginState } from './pm-plugins/autocomplete-plugin';
3
+ export type AutocompletePlugin = NextEditorPlugin<'autocomplete', {
4
+ pluginConfiguration?: AutocompletePluginOptions | undefined;
5
+ sharedState: AutocompletePluginState | undefined;
6
+ }>;
@@ -0,0 +1,36 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
+ export declare const autocompletePluginKey: PluginKey<any>;
5
+ export interface AutocompletePluginState {
6
+ /** The decoration set containing the ghost text widget */
7
+ decorationSet: DecorationSet;
8
+ /** The document position where the ghost text should appear */
9
+ ghostPosition: number;
10
+ /** The predicted ghost text to display */
11
+ ghostText: string;
12
+ }
13
+ /**
14
+ * Context provided to the autocomplete plugin on first editor focus.
15
+ * Text fields are selectively ingested to boost word-frequency scoring for
16
+ * predictions, giving words already present in the document/thread an L1
17
+ * priority boost.
18
+ */
19
+ export interface AutocompleteContext {
20
+ /** Full page content as a string (e.g. markdown). */
21
+ fullPageContent?: string;
22
+ /** The currently selected text on the page, if any. */
23
+ pageSelectionContent?: string;
24
+ /** Content of the parent comment when the editor is in reply or edit mode. */
25
+ parentCommentContent?: string;
26
+ /** Contents of sibling comments when the editor is in reply or edit mode. */
27
+ siblingCommentsContents?: string[];
28
+ }
29
+ export interface AutocompletePluginOptions {
30
+ /**
31
+ * Async function called once on first editor focus to retrieve context for
32
+ * word-frequency boosting. Called lazily so the preset can remain synchronous.
33
+ */
34
+ getContext?: () => Promise<AutocompleteContext | undefined>;
35
+ }
36
+ export declare const createAutocompletePlugin: (options?: AutocompletePluginOptions) => SafePlugin<any>;
@@ -0,0 +1,7 @@
1
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
+ /**
4
+ * Creates a DecorationSet containing a ghost text widget at the given position.
5
+ * The ghost text is rendered as a styled <span> that appears after the cursor.
6
+ */
7
+ export declare const createGhostTextDecorationSet: (state: EditorState, position: number, text: string) => DecorationSet;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Scoring Pipeline: Stage 1 (Semantic + Frequency), Grammar Filter, Stage 2 (LM Re-ranking).
3
+ *
4
+ * Operates synchronously on pre-loaded data. Each stage gracefully degrades
5
+ * when its required data isn't available (cold → warm → full warm).
6
+ */
7
+ export interface ScoringCandidate {
8
+ authorFreq: number;
9
+ docFreq: number;
10
+ sessionFreq: number;
11
+ tenantFreq: number;
12
+ word: string;
13
+ }
14
+ export interface ScoredCandidate {
15
+ finalScore: number;
16
+ freqScore: number;
17
+ lmScore: number;
18
+ semanticScore: number;
19
+ word: string;
20
+ }
21
+ /** Metadata returned by the grammar filter for debug logging in the caller. */
22
+ export interface GrammarFilterMeta {
23
+ after: number;
24
+ before: number;
25
+ dropped: string[];
26
+ prevTags: string[];
27
+ prevWord: string;
28
+ }
29
+ export interface RankCandidatesResult {
30
+ candidates: ScoredCandidate[];
31
+ grammarMeta: GrammarFilterMeta | null;
32
+ }
33
+ export declare function rankCandidates(candidates: ScoringCandidate[], contextVector: Float32Array | null, getWordVector: (word: string) => Float32Array | null, lmLogits: Record<string, number> | null, maxTenantFreq: number, previousWord: string): RankCandidatesResult;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Slow Lane Client: Backend context encoding for autocomplete.
3
+ *
4
+ * Fires a BE request on word boundaries to encode document context.
5
+ * Expects the typeahead-encodings API format:
6
+ * Request: { text, session_id }
7
+ * Response: { semantic_vector: number[], lm_logits: Record<string, number> }
8
+ */
9
+ /** Request payload for typeahead-encodings endpoint. */
10
+ export interface TypeaheadEncodingsRequest {
11
+ session_id: string;
12
+ text: string;
13
+ }
14
+ /** Response from typeahead-encodings endpoint. */
15
+ export interface TypeaheadEncodingsResponse {
16
+ lm_logits: Record<string, number>;
17
+ semantic_vector: number[];
18
+ }
19
+ /**
20
+ * Check if text ends with a word boundary character (space or punctuation).
21
+ */
22
+ export declare const isWordBoundary: (text: string) => boolean;
23
+ export interface SlowLaneClientConfig {
24
+ baseUrl: string;
25
+ debounceMs?: number;
26
+ endpoint?: string;
27
+ fetchFn?: typeof fetch;
28
+ onUpdate?: (opts: {
29
+ hasLmLogits: boolean;
30
+ hasVector: boolean;
31
+ textLength: number;
32
+ }) => void;
33
+ productKey?: string;
34
+ sessionId?: string;
35
+ }
36
+ export declare const createSlowLaneClient: (config: SlowLaneClientConfig) => {
37
+ getContextVector: () => Float32Array | null;
38
+ getLmLogits: () => Record<string, number> | null;
39
+ isWordBoundary: (text: string) => boolean;
40
+ setContextVector: (vector: Float32Array | null) => void;
41
+ setLmLogits: (logits: Record<string, number> | null) => void;
42
+ updateContext: (text: string) => void;
43
+ };
44
+ export declare const setDefaultSlowLaneClient: (client: ReturnType<typeof createSlowLaneClient> | null) => void;
45
+ export declare const getStoredContextVector: () => Float32Array | null;
46
+ export declare const getStoredLmLogits: () => Record<string, number> | null;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Fast Lane Predictor: Local autocomplete using weighted trie + frequency + semantic scoring.
3
+ *
4
+ * Two prediction modes:
5
+ * 1. Word boundary → bigram-based next-word suggestion (grammar-filtered)
6
+ * 2. Mid-word (≥3 chars) → trie prefix search → scoring pipeline → top result
7
+ *
8
+ * Scoring is delegated to scoring-pipeline.ts which handles:
9
+ * Stage 1 (semantic + frequency), grammar filter, Stage 2 (optional LM re-ranking).
10
+ *
11
+ * Context vector: average of word vectors from text before cursor (last N words).
12
+ * Falls back to cold mode (freq-only) when vectors not yet loaded.
13
+ *
14
+ * Session personalization (L1): words the user types are incrementally boosted
15
+ * via incrementSessionFreq(), called on word boundaries from the plugin.
16
+ */
17
+ export interface WeightedTerm {
18
+ authorFreq: number;
19
+ docFreq: number;
20
+ freq: number;
21
+ word: string;
22
+ }
23
+ export interface TenantVocabulary {
24
+ terms: WeightedTerm[];
25
+ }
26
+ interface VectorStore {
27
+ dim: number;
28
+ float32: Float32Array;
29
+ wordIndex: Record<string, number>;
30
+ }
31
+ /**
32
+ * Loads the General English vocabulary.
33
+ * expects a simple array of strings: ["about", "above", "actually", ...]
34
+ */
35
+ export declare const initL3Vocabulary: (l3Words: string[]) => void;
36
+ /** Enable or disable debug logging. Also checks localStorage key `autocomplete-debug`. */
37
+ export declare const setDebugMode: (enabled: boolean) => void;
38
+ /**
39
+ * Get predictor status for debugging.
40
+ * vectorsLoaded: true when semantic scoring is active
41
+ * wordCount: number of words in vector store (0 if not loaded)
42
+ */
43
+ export declare const getPredictorStatus: () => {
44
+ isInitialized: boolean;
45
+ vectorsLoaded: boolean;
46
+ vectorsLoadStarted: boolean;
47
+ wordCount: number;
48
+ };
49
+ /**
50
+ * Get details of the last prediction (for debugging).
51
+ * Returns null if no prediction has run yet or debug was off.
52
+ */
53
+ export declare const getLastPredictionDebug: () => {
54
+ contextWords: string[];
55
+ currentWord: string;
56
+ mode: "cold" | "warm";
57
+ suggestion: string | null;
58
+ textBefore: string;
59
+ topCandidates: Array<{
60
+ finalScore: number;
61
+ freqScore: number;
62
+ lmScore: number;
63
+ semanticScore: number;
64
+ word: string;
65
+ }>;
66
+ } | null;
67
+ export declare const initVocabulary: (vocabulary: TenantVocabulary) => void;
68
+ /**
69
+ * Increment L1 session frequency for a single word.
70
+ * Called from the plugin on word boundaries for efficient incremental boosting.
71
+ */
72
+ export declare const incrementSessionFreq: (word: string) => void;
73
+ /**
74
+ * Prime session frequencies from a document page string.
75
+ *
76
+ * Iterates through every token in `pageContent` and increments its session
77
+ * frequency so that words already present on the page receive an L1 boost
78
+ * before the user starts typing.
79
+ *
80
+ * Pass `undefined` (or omit the argument) to skip priming — useful when the
81
+ * calling context does not yet have a page value available.
82
+ */
83
+ export declare const ingestDocumentPage: (pageContent: string | undefined) => void;
84
+ export declare const predict: (textBefore: string) => string | null;
85
+ export declare const loadVectorsAsync: (options?: {
86
+ vectorsUrl?: string;
87
+ }) => Promise<void>;
88
+ export declare const initVectors: (store: VectorStore) => void;
89
+ export declare const loadDefaultVocabulary: () => void;
90
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-autocomplete",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Client-side text autocomplete plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  "wink-nlp": "^2.4.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "@atlaskit/editor-common": "^112.14.0",
36
+ "@atlaskit/editor-common": "^112.16.0",
37
37
  "react": "^18.2.0"
38
38
  },
39
39
  "techstack": {
@@ -1,7 +1,27 @@
1
- // This file will contain the autocomplete plugin implementation.
2
- // The full implementation will be added in a follow-up PR.
3
1
  import type { AutocompletePlugin } from './autocompletePluginType';
2
+ import {
3
+ autocompletePluginKey,
4
+ createAutocompletePlugin,
5
+ } from './pm-plugins/autocomplete-plugin';
6
+ import type { AutocompletePluginState } from './pm-plugins/autocomplete-plugin';
4
7
 
5
- export const autocompletePlugin: AutocompletePlugin = () => ({
6
- name: 'autocomplete',
7
- });
8
+ export const autocompletePlugin: AutocompletePlugin = ({ config: options }) => {
9
+ return {
10
+ name: 'autocomplete',
11
+ getSharedState(editorState): AutocompletePluginState | undefined {
12
+ if (!editorState) {
13
+ return undefined;
14
+ }
15
+ return autocompletePluginKey.getState(editorState) as AutocompletePluginState | undefined;
16
+ },
17
+
18
+ pmPlugins() {
19
+ return [
20
+ {
21
+ name: 'autocomplete',
22
+ plugin: () => createAutocompletePlugin(options),
23
+ },
24
+ ];
25
+ },
26
+ };
27
+ };
@@ -1,3 +1,14 @@
1
- // This file will contain the autocomplete plugin type definitions.
2
- // The full implementation will be added in a follow-up PR.
3
- export type AutocompletePlugin = () => { name: 'autocomplete' };
1
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+
3
+ import type {
4
+ AutocompletePluginOptions,
5
+ AutocompletePluginState,
6
+ } from './pm-plugins/autocomplete-plugin';
7
+
8
+ export type AutocompletePlugin = NextEditorPlugin<
9
+ 'autocomplete',
10
+ {
11
+ pluginConfiguration?: AutocompletePluginOptions | undefined;
12
+ sharedState: AutocompletePluginState | undefined;
13
+ }
14
+ >;
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-autocomplete/src/pm-plugins/autocomplete-plugin",
3
+ "main": "../../../dist/cjs/pm-plugins/autocomplete-plugin.js",
4
+ "module": "../../../dist/esm/pm-plugins/autocomplete-plugin.js",
5
+ "module:es2019": "../../../dist/es2019/pm-plugins/autocomplete-plugin.js",
6
+ "sideEffects": false,
7
+ "types": "../../../dist/types/pm-plugins/autocomplete-plugin.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <5.9": {
10
+ "*": [
11
+ "../../../dist/types-ts4.5/pm-plugins/autocomplete-plugin.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }