@yorkie-js/sdk 0.6.38 → 0.6.39
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/dist/quill.html +53 -33
- package/dist/yorkie-js-sdk.es.js +1 -1
- package/dist/yorkie-js-sdk.js +1 -1
- package/package.json +2 -2
package/dist/quill.html
CHANGED
|
@@ -246,6 +246,9 @@
|
|
|
246
246
|
});
|
|
247
247
|
|
|
248
248
|
// 03. create an instance of Quill
|
|
249
|
+
// Track composition state to prevent selection updates during IME input
|
|
250
|
+
let isComposing = false;
|
|
251
|
+
|
|
249
252
|
const editorElem = clientElem?.getElementsByClassName('editor')[0];
|
|
250
253
|
Quill.register('modules/cursors', QuillCursors);
|
|
251
254
|
const quill = new Quill(editorElem, {
|
|
@@ -292,6 +295,14 @@
|
|
|
292
295
|
}
|
|
293
296
|
|
|
294
297
|
// 04. bind the document with the Quill.
|
|
298
|
+
// Track composition events to prevent selection updates during IME input
|
|
299
|
+
quill.root.addEventListener('compositionstart', () => {
|
|
300
|
+
isComposing = true;
|
|
301
|
+
});
|
|
302
|
+
quill.root.addEventListener('compositionend', () => {
|
|
303
|
+
isComposing = false;
|
|
304
|
+
});
|
|
305
|
+
|
|
295
306
|
// 04-1. Quill to Document.
|
|
296
307
|
quill
|
|
297
308
|
.on('text-change', (delta, _, source) => {
|
|
@@ -354,6 +365,7 @@
|
|
|
354
365
|
(typeof op.insert === 'string'
|
|
355
366
|
? op.insert.length
|
|
356
367
|
: 1);
|
|
368
|
+
to = from;
|
|
357
369
|
}
|
|
358
370
|
|
|
359
371
|
if (range) {
|
|
@@ -380,7 +392,7 @@
|
|
|
380
392
|
op.retain !== undefined &&
|
|
381
393
|
typeof op.retain === 'number'
|
|
382
394
|
) {
|
|
383
|
-
from
|
|
395
|
+
from += op.retain;
|
|
384
396
|
to = from;
|
|
385
397
|
}
|
|
386
398
|
}
|
|
@@ -391,6 +403,12 @@
|
|
|
391
403
|
return;
|
|
392
404
|
}
|
|
393
405
|
|
|
406
|
+
// Ignore selection changes during composition (e.g., Korean IME input)
|
|
407
|
+
// to prevent cursor position from being broadcast incorrectly to other users
|
|
408
|
+
if (isComposing) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
394
412
|
// NOTE(chacha912): If the selection in the Quill editor does not match the range computed by yorkie,
|
|
395
413
|
// additional updates are necessary. This condition addresses situations where Quill's selection behaves
|
|
396
414
|
// differently, such as when inserting text before a range selection made by another user, causing
|
|
@@ -420,15 +438,10 @@
|
|
|
420
438
|
|
|
421
439
|
// 04-2. document to Quill(remote).
|
|
422
440
|
function handleOperations(quill, ops) {
|
|
423
|
-
const deltaOperations = [];
|
|
424
|
-
let prevTo = 0;
|
|
425
441
|
for (const op of ops) {
|
|
426
442
|
if (op.type === 'edit') {
|
|
427
443
|
const from = op.from;
|
|
428
444
|
const to = op.to;
|
|
429
|
-
const retainFrom = from - prevTo;
|
|
430
|
-
const retainTo = to - from;
|
|
431
|
-
|
|
432
445
|
const { insert, attributes } = toDeltaOperation(
|
|
433
446
|
op.value,
|
|
434
447
|
true,
|
|
@@ -438,14 +451,17 @@
|
|
|
438
451
|
'color: skyblue',
|
|
439
452
|
);
|
|
440
453
|
|
|
441
|
-
|
|
442
|
-
|
|
454
|
+
const deltaOperations = [];
|
|
455
|
+
|
|
456
|
+
if (from > 0) {
|
|
457
|
+
deltaOperations.push({ retain: from });
|
|
443
458
|
}
|
|
444
|
-
|
|
445
|
-
|
|
459
|
+
|
|
460
|
+
const deleteLength = to - from;
|
|
461
|
+
if (deleteLength > 0) {
|
|
462
|
+
deltaOperations.push({ delete: deleteLength });
|
|
446
463
|
}
|
|
447
|
-
|
|
448
|
-
typeof insert === 'string' ? insert.length : 0;
|
|
464
|
+
|
|
449
465
|
if (insert) {
|
|
450
466
|
const op = { insert };
|
|
451
467
|
if (attributes) {
|
|
@@ -453,43 +469,47 @@
|
|
|
453
469
|
}
|
|
454
470
|
deltaOperations.push(op);
|
|
455
471
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
472
|
+
|
|
473
|
+
if (deltaOperations.length > 0) {
|
|
474
|
+
console.log(
|
|
475
|
+
`%c to quill: ${JSON.stringify(deltaOperations)}`,
|
|
476
|
+
'color: green',
|
|
477
|
+
);
|
|
478
|
+
const delta = new Quill.imports.delta(deltaOperations);
|
|
479
|
+
quill.updateContents(delta, 'api');
|
|
480
|
+
}
|
|
459
481
|
} else if (op.type === 'style') {
|
|
460
482
|
const from = op.from;
|
|
461
483
|
const to = op.to;
|
|
462
|
-
const retainFrom = from - prevTo;
|
|
463
|
-
const retainTo = to - from;
|
|
464
484
|
const { attributes } = toDeltaOperation(op.value, false);
|
|
465
485
|
console.log(
|
|
466
486
|
`%c remote: ${from}-${to}: ${JSON.stringify(attributes)}`,
|
|
467
487
|
'color: skyblue',
|
|
468
488
|
);
|
|
469
489
|
|
|
470
|
-
if (retainFrom) {
|
|
471
|
-
deltaOperations.push({ retain: retainFrom });
|
|
472
|
-
}
|
|
473
490
|
if (attributes) {
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
491
|
+
const deltaOperations = [];
|
|
492
|
+
|
|
493
|
+
if (from > 0) {
|
|
494
|
+
deltaOperations.push({ retain: from });
|
|
477
495
|
}
|
|
478
496
|
|
|
497
|
+
const op = { attributes };
|
|
498
|
+
const retainLength = to - from;
|
|
499
|
+
if (retainLength > 0) {
|
|
500
|
+
op.retain = retainLength;
|
|
501
|
+
}
|
|
479
502
|
deltaOperations.push(op);
|
|
503
|
+
|
|
504
|
+
console.log(
|
|
505
|
+
`%c to quill: ${JSON.stringify(deltaOperations)}`,
|
|
506
|
+
'color: green',
|
|
507
|
+
);
|
|
508
|
+
const delta = new Quill.imports.delta(deltaOperations);
|
|
509
|
+
quill.updateContents(delta, 'api');
|
|
480
510
|
}
|
|
481
|
-
prevTo = to;
|
|
482
511
|
}
|
|
483
512
|
}
|
|
484
|
-
|
|
485
|
-
if (deltaOperations.length) {
|
|
486
|
-
console.log(
|
|
487
|
-
`%c to quill: ${JSON.stringify(deltaOperations)}`,
|
|
488
|
-
'color: green',
|
|
489
|
-
);
|
|
490
|
-
const delta = new Quill.imports.delta(deltaOperations);
|
|
491
|
-
quill.updateContents(delta, 'api');
|
|
492
|
-
}
|
|
493
513
|
}
|
|
494
514
|
|
|
495
515
|
// 05. synchronize text of document and Quill.
|
package/dist/yorkie-js-sdk.es.js
CHANGED
|
@@ -22272,7 +22272,7 @@ function createAuthInterceptor(apiKey, token) {
|
|
|
22272
22272
|
};
|
|
22273
22273
|
}
|
|
22274
22274
|
const name = "@yorkie-js/sdk";
|
|
22275
|
-
const version = "0.6.
|
|
22275
|
+
const version = "0.6.39";
|
|
22276
22276
|
const pkg = {
|
|
22277
22277
|
name,
|
|
22278
22278
|
version
|
package/dist/yorkie-js-sdk.js
CHANGED
|
@@ -22276,7 +22276,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
22276
22276
|
};
|
|
22277
22277
|
}
|
|
22278
22278
|
const name = "@yorkie-js/sdk";
|
|
22279
|
-
const version = "0.6.
|
|
22279
|
+
const version = "0.6.39";
|
|
22280
22280
|
const pkg = {
|
|
22281
22281
|
name,
|
|
22282
22282
|
version
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yorkie-js/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.39",
|
|
4
4
|
"description": "Yorkie JS SDK",
|
|
5
5
|
"main": "./dist/yorkie-js-sdk.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@connectrpc/connect": "^1.4.0",
|
|
57
57
|
"@connectrpc/connect-web": "^1.4.0",
|
|
58
58
|
"long": "^5.2.0",
|
|
59
|
-
"@yorkie-js/schema": "0.6.
|
|
59
|
+
"@yorkie-js/schema": "0.6.39"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsc && vite build -c vite.build.ts",
|