@atlaskit/editor-plugin-autocomplete 0.2.0 → 0.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 +19 -0
- package/afm-cc/tsconfig.json +1 -4
- package/afm-jira/tsconfig.json +1 -4
- package/afm-products/tsconfig.json +1 -4
- package/build/tsconfig.json +1 -6
- package/dist/cjs/pm-plugins/autocomplete-plugin.js +7 -3
- package/dist/cjs/pm-plugins/scoring-pipeline.js +1 -3
- package/dist/cjs/pm-plugins/slow-lane-client.js +3 -1
- package/dist/cjs/pm-plugins/text-predictor.js +47 -23
- package/dist/es2019/pm-plugins/autocomplete-plugin.js +7 -3
- package/dist/es2019/pm-plugins/scoring-pipeline.js +0 -3
- package/dist/es2019/pm-plugins/slow-lane-client.js +5 -2
- package/dist/es2019/pm-plugins/text-predictor.js +24 -9
- package/dist/esm/pm-plugins/autocomplete-plugin.js +7 -3
- package/dist/esm/pm-plugins/scoring-pipeline.js +0 -3
- package/dist/esm/pm-plugins/slow-lane-client.js +3 -1
- package/dist/esm/pm-plugins/text-predictor.js +47 -23
- package/dist/types/pm-plugins/autocomplete-plugin.d.ts +6 -0
- package/dist/types/pm-plugins/text-predictor.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/autocomplete-plugin.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/text-predictor.d.ts +1 -1
- package/package.json +2 -2
- package/src/pm-plugins/autocomplete-plugin.ts +20 -5
- package/src/pm-plugins/data/combined_l2_l3_pos_tags.json +73571 -3
- package/src/pm-plugins/data/ghost_pos_tags.json +43 -3
- package/src/pm-plugins/data/grammar_transitions_10k.json +46 -3
- package/src/pm-plugins/data/l3_vocabulary.json +20002 -3
- package/src/pm-plugins/data/vocabulary_10k.json +38794 -3
- package/src/pm-plugins/data/word_index_10k.json +7760 -3
- package/src/pm-plugins/scoring-pipeline.ts +0 -3
- package/src/pm-plugins/slow-lane-client.ts +4 -2
- package/src/pm-plugins/text-predictor.ts +30 -10
- package/tsconfig.app.json +2 -2
- package/tsconfig.json +1 -1
- package/src/pm-plugins/typings.d.ts +0 -12
|
@@ -32,5 +32,11 @@ export interface AutocompletePluginOptions {
|
|
|
32
32
|
* word-frequency boosting. Called lazily so the preset can remain synchronous.
|
|
33
33
|
*/
|
|
34
34
|
getContext?: () => Promise<AutocompleteContext | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* Async function that resolves to a URL for the word vectors binary file.
|
|
37
|
+
* When provided, this takes precedence over the bundled asset URL.
|
|
38
|
+
* Use this to serve vectors from a CDN or media service in production.
|
|
39
|
+
*/
|
|
40
|
+
getVectorsBinaryUrl?: () => Promise<string>;
|
|
35
41
|
}
|
|
36
42
|
export declare const createAutocompletePlugin: (options?: AutocompletePluginOptions) => SafePlugin<AutocompletePluginState>;
|
|
@@ -83,7 +83,7 @@ export declare const incrementSessionFreq: (word: string) => void;
|
|
|
83
83
|
export declare const ingestDocumentPage: (pageContent: string | undefined) => void;
|
|
84
84
|
export declare const predict: (textBefore: string) => string | null;
|
|
85
85
|
export declare const loadVectorsAsync: (options?: {
|
|
86
|
-
|
|
86
|
+
getBinaryUrl?: () => Promise<string>;
|
|
87
87
|
}) => Promise<void>;
|
|
88
88
|
export declare const initVectors: (store: VectorStore) => void;
|
|
89
89
|
export declare const loadDefaultVocabulary: () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-autocomplete",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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.
|
|
36
|
+
"@atlaskit/editor-common": "^112.18.0",
|
|
37
37
|
"react": "^18.2.0"
|
|
38
38
|
},
|
|
39
39
|
"techstack": {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
EditorState,
|
|
6
|
+
ReadonlyTransaction,
|
|
7
|
+
Transaction,
|
|
8
|
+
} from '@atlaskit/editor-prosemirror/state';
|
|
5
9
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
10
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
11
|
|
|
@@ -162,6 +166,12 @@ export interface AutocompletePluginOptions {
|
|
|
162
166
|
* word-frequency boosting. Called lazily so the preset can remain synchronous.
|
|
163
167
|
*/
|
|
164
168
|
getContext?: () => Promise<AutocompleteContext | undefined>;
|
|
169
|
+
/**
|
|
170
|
+
* Async function that resolves to a URL for the word vectors binary file.
|
|
171
|
+
* When provided, this takes precedence over the bundled asset URL.
|
|
172
|
+
* Use this to serve vectors from a CDN or media service in production.
|
|
173
|
+
*/
|
|
174
|
+
getVectorsBinaryUrl?: () => Promise<string>;
|
|
165
175
|
}
|
|
166
176
|
|
|
167
177
|
/**
|
|
@@ -261,14 +271,16 @@ export const createAutocompletePlugin = (options?: AutocompletePluginOptions) =>
|
|
|
261
271
|
}
|
|
262
272
|
|
|
263
273
|
const lastChar = newText[newText.length - 1];
|
|
264
|
-
|
|
274
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
275
|
+
if (!/[\s.,;:!?]/.test(lastChar)) {
|
|
265
276
|
return;
|
|
266
277
|
}
|
|
267
278
|
|
|
268
279
|
// Only fire if the previous state did not already end on a boundary,
|
|
269
280
|
// so we don't double-count when multiple boundary chars are inserted.
|
|
270
281
|
const prevLastChar = prevText[prevText.length - 1];
|
|
271
|
-
|
|
282
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
283
|
+
if (prevLastChar && /[\s.,;:!?]/.test(prevLastChar)) {
|
|
272
284
|
return;
|
|
273
285
|
}
|
|
274
286
|
|
|
@@ -286,7 +298,10 @@ export const createAutocompletePlugin = (options?: AutocompletePluginOptions) =>
|
|
|
286
298
|
|
|
287
299
|
state: {
|
|
288
300
|
init: (): AutocompletePluginState => createInitialState(),
|
|
289
|
-
apply: (
|
|
301
|
+
apply: (
|
|
302
|
+
tr: ReadonlyTransaction,
|
|
303
|
+
pluginState: AutocompletePluginState,
|
|
304
|
+
): AutocompletePluginState => {
|
|
290
305
|
const meta = tr.getMeta(autocompletePluginKey) as
|
|
291
306
|
| Partial<AutocompletePluginState>
|
|
292
307
|
| undefined;
|
|
@@ -360,7 +375,7 @@ export const createAutocompletePlugin = (options?: AutocompletePluginOptions) =>
|
|
|
360
375
|
},
|
|
361
376
|
focus: () => {
|
|
362
377
|
loadDefaultVocabulary();
|
|
363
|
-
loadVectorsAsync().catch(() => {});
|
|
378
|
+
loadVectorsAsync({ getBinaryUrl: options?.getVectorsBinaryUrl }).catch(() => {});
|
|
364
379
|
if (!hasIngestedPage) {
|
|
365
380
|
hasIngestedPage = true;
|
|
366
381
|
if (options?.getContext) {
|