@atlaskit/editor-plugin-autocomplete 0.2.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.
- package/CHANGELOG.md +8 -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 +2 -6
- package/build/url-module.d.ts +8 -0
- package/dist/cjs/pm-plugins/autocomplete-plugin.js +11 -4
- 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 +32 -22
- package/dist/es2019/pm-plugins/autocomplete-plugin.js +11 -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 +16 -9
- package/dist/esm/pm-plugins/autocomplete-plugin.js +11 -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 +32 -22
- package/dist/types/pm-plugins/autocomplete-plugin.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/autocomplete-plugin.d.ts +1 -1
- package/package.json +1 -1
- package/src/pm-plugins/autocomplete-plugin.ts +19 -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 +18 -9
- package/tsconfig.app.json +3 -2
- package/tsconfig.json +2 -1
- package/src/pm-plugins/typings.d.ts +0 -12
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
// url: prefix is an Atlaspack/Parcel directive that resolves this file as an emitted
|
|
2
|
+
// asset URL (content-hashed). For rspack, this is handled via staticAssetsLoader.
|
|
3
|
+
// eslint-disable-next-line @repo/internal/import/no-unresolved
|
|
4
|
+
import wordVectorsUrl from 'url:./data/word-vectors_10k.bin';
|
|
5
|
+
|
|
1
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
7
|
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
8
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
EditorState,
|
|
11
|
+
ReadonlyTransaction,
|
|
12
|
+
Transaction,
|
|
13
|
+
} from '@atlaskit/editor-prosemirror/state';
|
|
5
14
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
15
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
16
|
|
|
@@ -261,14 +270,16 @@ export const createAutocompletePlugin = (options?: AutocompletePluginOptions) =>
|
|
|
261
270
|
}
|
|
262
271
|
|
|
263
272
|
const lastChar = newText[newText.length - 1];
|
|
264
|
-
|
|
273
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
274
|
+
if (!/[\s.,;:!?]/.test(lastChar)) {
|
|
265
275
|
return;
|
|
266
276
|
}
|
|
267
277
|
|
|
268
278
|
// Only fire if the previous state did not already end on a boundary,
|
|
269
279
|
// so we don't double-count when multiple boundary chars are inserted.
|
|
270
280
|
const prevLastChar = prevText[prevText.length - 1];
|
|
271
|
-
|
|
281
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
282
|
+
if (prevLastChar && /[\s.,;:!?]/.test(prevLastChar)) {
|
|
272
283
|
return;
|
|
273
284
|
}
|
|
274
285
|
|
|
@@ -286,7 +297,10 @@ export const createAutocompletePlugin = (options?: AutocompletePluginOptions) =>
|
|
|
286
297
|
|
|
287
298
|
state: {
|
|
288
299
|
init: (): AutocompletePluginState => createInitialState(),
|
|
289
|
-
apply: (
|
|
300
|
+
apply: (
|
|
301
|
+
tr: ReadonlyTransaction,
|
|
302
|
+
pluginState: AutocompletePluginState,
|
|
303
|
+
): AutocompletePluginState => {
|
|
290
304
|
const meta = tr.getMeta(autocompletePluginKey) as
|
|
291
305
|
| Partial<AutocompletePluginState>
|
|
292
306
|
| undefined;
|
|
@@ -360,7 +374,7 @@ export const createAutocompletePlugin = (options?: AutocompletePluginOptions) =>
|
|
|
360
374
|
},
|
|
361
375
|
focus: () => {
|
|
362
376
|
loadDefaultVocabulary();
|
|
363
|
-
loadVectorsAsync().catch(() => {});
|
|
377
|
+
loadVectorsAsync({ vectorsUrl: wordVectorsUrl }).catch(() => {});
|
|
364
378
|
if (!hasIngestedPage) {
|
|
365
379
|
hasIngestedPage = true;
|
|
366
380
|
if (options?.getContext) {
|