@atlaskit/editor-plugin-autocomplete 3.0.0 → 3.2.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 +16 -0
- package/dist/cjs/pm-plugins/autocomplete-plugin.js +6 -22
- package/dist/cjs/pm-plugins/local-slow-lane-client.js +676 -148
- package/dist/cjs/pm-plugins/scoring-pipeline.js +5 -4
- package/dist/cjs/pm-plugins/text-predictor.js +152 -60
- package/dist/es2019/pm-plugins/autocomplete-plugin.js +6 -22
- package/dist/es2019/pm-plugins/local-slow-lane-client.js +493 -85
- package/dist/es2019/pm-plugins/scoring-pipeline.js +5 -4
- package/dist/es2019/pm-plugins/text-predictor.js +105 -50
- package/dist/esm/pm-plugins/autocomplete-plugin.js +6 -22
- package/dist/esm/pm-plugins/local-slow-lane-client.js +668 -144
- package/dist/esm/pm-plugins/scoring-pipeline.js +5 -4
- package/dist/esm/pm-plugins/text-predictor.js +144 -60
- package/dist/types/pm-plugins/local-slow-lane-client.d.ts +102 -15
- package/dist/types/pm-plugins/text-predictor.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/local-slow-lane-client.d.ts +102 -15
- package/dist/types-ts4.5/pm-plugins/text-predictor.d.ts +1 -1
- package/package.json +2 -2
- package/scripts/gen_first_token_to_words.py +170 -0
- package/src/pm-plugins/autocomplete-plugin.ts +6 -16
- package/src/pm-plugins/data/first_token_to_words.json +1 -0
- package/src/pm-plugins/data/word_index_10k.json +7761 -7759
- package/src/pm-plugins/local-slow-lane-client.ts +587 -95
- package/src/pm-plugins/scoring-pipeline.ts +4 -5
- package/src/pm-plugins/text-predictor.ts +124 -45
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-autocomplete
|
|
2
2
|
|
|
3
|
+
## 3.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`3fb8d945f6f22`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3fb8d945f6f22) -
|
|
8
|
+
Update local only client setup for contextual typeahead completion to use Snowflake embedding
|
|
9
|
+
model
|
|
10
|
+
|
|
11
|
+
## 3.1.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [`f003833231999`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f003833231999) -
|
|
16
|
+
Code-split the autocomplete vocabulary, L3 word list and word-index JSON via dynamic import so
|
|
17
|
+
they load on autocomplete initialisation instead of being bundled into the editor's main chunk.
|
|
18
|
+
|
|
3
19
|
## 3.0.0
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -38,8 +38,6 @@ var createInitialState = function createInitialState() {
|
|
|
38
38
|
var getTextBeforeCursor = function getTextBeforeCursor(state) {
|
|
39
39
|
var $from = state.selection.$from;
|
|
40
40
|
var maxChars = 200;
|
|
41
|
-
|
|
42
|
-
// 1. Get the perfectly flattened text of the current block up to the cursor
|
|
43
41
|
var blockNode = $from.parent;
|
|
44
42
|
var offsetInBlock = $from.parentOffset;
|
|
45
43
|
var blockText = blockNode.textContent.slice(0, offsetInBlock);
|
|
@@ -48,7 +46,7 @@ var getTextBeforeCursor = function getTextBeforeCursor(state) {
|
|
|
48
46
|
}
|
|
49
47
|
var fullText = blockText;
|
|
50
48
|
|
|
51
|
-
//
|
|
49
|
+
// Walk backwards through previous blocks until we have enough context.
|
|
52
50
|
var depth = $from.depth - 1;
|
|
53
51
|
while (fullText.length < maxChars && depth >= 0) {
|
|
54
52
|
var parentNode = $from.node(depth);
|
|
@@ -249,8 +247,6 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
|
|
|
249
247
|
try {
|
|
250
248
|
var state = view.state;
|
|
251
249
|
var selection = state.selection;
|
|
252
|
-
|
|
253
|
-
// Only predict for cursor selections (not range selections)
|
|
254
250
|
if (!selection.empty) {
|
|
255
251
|
return;
|
|
256
252
|
}
|
|
@@ -262,13 +258,9 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
|
|
|
262
258
|
return;
|
|
263
259
|
}
|
|
264
260
|
dismissedContext = null;
|
|
265
|
-
|
|
266
|
-
// Don't predict if there's not enough context
|
|
267
261
|
if (textBefore.trim().length < 3) {
|
|
268
262
|
return;
|
|
269
263
|
}
|
|
270
|
-
|
|
271
|
-
// Tier 1 prediction is synchronous -- no async needed
|
|
272
264
|
var prediction = (0, _textPredictor.predict)(textBefore);
|
|
273
265
|
if (prediction && prediction.length > 0) {
|
|
274
266
|
var typedLength = getTypedLengthForPrediction(textBefore);
|
|
@@ -330,8 +322,7 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
|
|
|
330
322
|
return _objectSpread(_objectSpread({}, pluginState), meta);
|
|
331
323
|
}
|
|
332
324
|
|
|
333
|
-
//
|
|
334
|
-
// (new prediction will be scheduled from view.update)
|
|
325
|
+
// A new prediction is scheduled from view.update.
|
|
335
326
|
if (tr.docChanged) {
|
|
336
327
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
337
328
|
ghostText: '',
|
|
@@ -339,8 +330,6 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
|
|
|
339
330
|
decorationSet: _view.DecorationSet.empty
|
|
340
331
|
});
|
|
341
332
|
}
|
|
342
|
-
|
|
343
|
-
// If selection changed without doc change, clear ghost text
|
|
344
333
|
if (tr.selectionSet && pluginState.ghostText) {
|
|
345
334
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
346
335
|
ghostText: '',
|
|
@@ -401,13 +390,11 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
|
|
|
401
390
|
return false;
|
|
402
391
|
},
|
|
403
392
|
focus: function focus() {
|
|
404
|
-
|
|
405
|
-
(0, _textPredictor.loadDefaultVocabulary)();
|
|
406
|
-
} catch (error) {
|
|
393
|
+
(0, _textPredictor.loadDefaultVocabulary)().catch(function (error) {
|
|
407
394
|
(0, _monitoring.logException)(error, {
|
|
408
395
|
location: 'editor-plugin-autocomplete/loadDefaultVocabulary'
|
|
409
396
|
});
|
|
410
|
-
}
|
|
397
|
+
});
|
|
411
398
|
(0, _textPredictor.loadVectorsAsync)({
|
|
412
399
|
getBinaryUrl: options === null || options === void 0 ? void 0 : options.getVectorsBinaryUrl
|
|
413
400
|
}).catch(function (error) {
|
|
@@ -449,12 +436,9 @@ var createAutocompletePlugin = exports.createAutocompletePlugin = function creat
|
|
|
449
436
|
if (justAccepted) {
|
|
450
437
|
justAccepted = false;
|
|
451
438
|
|
|
452
|
-
//
|
|
453
|
-
//
|
|
454
|
-
// block and abort until the user actually types a new character!
|
|
439
|
+
// Snapshot the post-acceptance text so follow-up transactions hit
|
|
440
|
+
// the dismissedContext guard and abort until the user types again.
|
|
455
441
|
dismissedContext = getTextBeforeCursor(view.state);
|
|
456
|
-
|
|
457
|
-
// Also clear any pending debounce timers from before the acceptance
|
|
458
442
|
if (debounceTimer) {
|
|
459
443
|
clearTimeout(debounceTimer);
|
|
460
444
|
}
|