@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.
Files changed (34) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/afm-cc/tsconfig.json +1 -4
  3. package/afm-jira/tsconfig.json +1 -4
  4. package/afm-products/tsconfig.json +1 -4
  5. package/build/tsconfig.json +2 -6
  6. package/build/url-module.d.ts +8 -0
  7. package/dist/cjs/pm-plugins/autocomplete-plugin.js +11 -4
  8. package/dist/cjs/pm-plugins/scoring-pipeline.js +1 -3
  9. package/dist/cjs/pm-plugins/slow-lane-client.js +3 -1
  10. package/dist/cjs/pm-plugins/text-predictor.js +32 -22
  11. package/dist/es2019/pm-plugins/autocomplete-plugin.js +11 -3
  12. package/dist/es2019/pm-plugins/scoring-pipeline.js +0 -3
  13. package/dist/es2019/pm-plugins/slow-lane-client.js +5 -2
  14. package/dist/es2019/pm-plugins/text-predictor.js +16 -9
  15. package/dist/esm/pm-plugins/autocomplete-plugin.js +11 -3
  16. package/dist/esm/pm-plugins/scoring-pipeline.js +0 -3
  17. package/dist/esm/pm-plugins/slow-lane-client.js +3 -1
  18. package/dist/esm/pm-plugins/text-predictor.js +32 -22
  19. package/dist/types/pm-plugins/autocomplete-plugin.d.ts +1 -1
  20. package/dist/types-ts4.5/pm-plugins/autocomplete-plugin.d.ts +1 -1
  21. package/package.json +1 -1
  22. package/src/pm-plugins/autocomplete-plugin.ts +19 -5
  23. package/src/pm-plugins/data/combined_l2_l3_pos_tags.json +73571 -3
  24. package/src/pm-plugins/data/ghost_pos_tags.json +43 -3
  25. package/src/pm-plugins/data/grammar_transitions_10k.json +46 -3
  26. package/src/pm-plugins/data/l3_vocabulary.json +20002 -3
  27. package/src/pm-plugins/data/vocabulary_10k.json +38794 -3
  28. package/src/pm-plugins/data/word_index_10k.json +7760 -3
  29. package/src/pm-plugins/scoring-pipeline.ts +0 -3
  30. package/src/pm-plugins/slow-lane-client.ts +4 -2
  31. package/src/pm-plugins/text-predictor.ts +18 -9
  32. package/tsconfig.app.json +3 -2
  33. package/tsconfig.json +2 -1
  34. package/src/pm-plugins/typings.d.ts +0 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-autocomplete",
3
- "version": "0.2.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",
@@ -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 { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
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
- if (!/[\s.,;:!?]/u.test(lastChar)) {
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
- if (prevLastChar && /[\s.,;:!?]/u.test(prevLastChar)) {
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: (tr: ReadonlyTransaction, pluginState: AutocompletePluginState): AutocompletePluginState => {
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) {