@elice/material-exercise 1.241220.0 → 1.250108.0-runboxswitch.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.
|
@@ -11,6 +11,7 @@ var blocks = require('@elice/blocks');
|
|
|
11
11
|
var types = require('@elice/types');
|
|
12
12
|
var utils = require('@elice/utils');
|
|
13
13
|
var recoil = require('recoil');
|
|
14
|
+
var unicount = require('unicount');
|
|
14
15
|
var ExerciseFileShimmer = require('../../shared/exercise-shimmer/ExerciseFileShimmer.js');
|
|
15
16
|
require('../../shared/exercise-shimmer/ExerciseFileTabsShimmer.js');
|
|
16
17
|
require('../../shared/exercise-shimmer/ExerciseFileTabShimmer.js');
|
|
@@ -237,7 +238,8 @@ var ExerciseFileEditor = function ExerciseFileEditor() {
|
|
|
237
238
|
*/
|
|
238
239
|
var handleChange = function handleChange(e) {
|
|
239
240
|
var _a, _b;
|
|
240
|
-
|
|
241
|
+
var rawContent = (_b = (_a = editorApis.current) === null || _a === void 0 ? void 0 : _a.getValue()) !== null && _b !== void 0 ? _b : '';
|
|
242
|
+
setFileEditorContent(rawContent);
|
|
241
243
|
// === server initiated ===
|
|
242
244
|
var index = serverInitiatedVersions.current.indexOf(e.versionId - 1);
|
|
243
245
|
if (index !== -1) {
|
|
@@ -252,20 +254,23 @@ var ExerciseFileEditor = function ExerciseFileEditor() {
|
|
|
252
254
|
try {
|
|
253
255
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
254
256
|
var change = _step2.value;
|
|
257
|
+
// the offset calculates a 32bit unicode(ex: emoji) to 1 but vanila JS calculates to 2
|
|
258
|
+
var utf32Offset = unicount.uniCount(rawContent.slice(0, change.rangeOffset));
|
|
255
259
|
// insertion
|
|
256
260
|
if (change.rangeLength === 0 && !readOnly) {
|
|
257
|
-
wsUsercode.sendOTs(
|
|
261
|
+
wsUsercode.sendOTs(utf32Offset > 0 ? [utf32Offset, change.text] : [change.text]);
|
|
258
262
|
}
|
|
259
263
|
// deletion
|
|
260
264
|
else {
|
|
261
265
|
if (prevDoc && !readOnly) {
|
|
262
|
-
wsUsercode.sendOTs([
|
|
266
|
+
wsUsercode.sendOTs([utf32Offset || null, {
|
|
267
|
+
// when using slice do not use utf32Offset (because it's vanila JS's method)
|
|
263
268
|
d: prevDoc.slice(change.rangeOffset, change.rangeOffset + change.rangeLength)
|
|
264
269
|
}].filter(Boolean));
|
|
265
270
|
}
|
|
266
271
|
// replace
|
|
267
272
|
if (change.text.length > 0 && !readOnly) {
|
|
268
|
-
wsUsercode.sendOTs(
|
|
273
|
+
wsUsercode.sendOTs(utf32Offset > 0 ? [utf32Offset, change.text] : [change.text]);
|
|
269
274
|
}
|
|
270
275
|
}
|
|
271
276
|
}
|
|
@@ -7,6 +7,7 @@ import { Flex } from '@elice/blocks';
|
|
|
7
7
|
import { enums } from '@elice/types';
|
|
8
8
|
import { FlutterApp } from '@elice/utils';
|
|
9
9
|
import { useRecoilValue, useSetRecoilState, useRecoilState } from 'recoil';
|
|
10
|
+
import { uniCount } from 'unicount';
|
|
10
11
|
import ExerciseFileShimmer from '../../shared/exercise-shimmer/ExerciseFileShimmer.js';
|
|
11
12
|
import '../../shared/exercise-shimmer/ExerciseFileTabsShimmer.js';
|
|
12
13
|
import '../../shared/exercise-shimmer/ExerciseFileTabShimmer.js';
|
|
@@ -229,7 +230,8 @@ var ExerciseFileEditor = function ExerciseFileEditor() {
|
|
|
229
230
|
*/
|
|
230
231
|
var handleChange = function handleChange(e) {
|
|
231
232
|
var _a, _b;
|
|
232
|
-
|
|
233
|
+
var rawContent = (_b = (_a = editorApis.current) === null || _a === void 0 ? void 0 : _a.getValue()) !== null && _b !== void 0 ? _b : '';
|
|
234
|
+
setFileEditorContent(rawContent);
|
|
233
235
|
// === server initiated ===
|
|
234
236
|
var index = serverInitiatedVersions.current.indexOf(e.versionId - 1);
|
|
235
237
|
if (index !== -1) {
|
|
@@ -244,20 +246,23 @@ var ExerciseFileEditor = function ExerciseFileEditor() {
|
|
|
244
246
|
try {
|
|
245
247
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
246
248
|
var change = _step2.value;
|
|
249
|
+
// the offset calculates a 32bit unicode(ex: emoji) to 1 but vanila JS calculates to 2
|
|
250
|
+
var utf32Offset = uniCount(rawContent.slice(0, change.rangeOffset));
|
|
247
251
|
// insertion
|
|
248
252
|
if (change.rangeLength === 0 && !readOnly) {
|
|
249
|
-
wsUsercode.sendOTs(
|
|
253
|
+
wsUsercode.sendOTs(utf32Offset > 0 ? [utf32Offset, change.text] : [change.text]);
|
|
250
254
|
}
|
|
251
255
|
// deletion
|
|
252
256
|
else {
|
|
253
257
|
if (prevDoc && !readOnly) {
|
|
254
|
-
wsUsercode.sendOTs([
|
|
258
|
+
wsUsercode.sendOTs([utf32Offset || null, {
|
|
259
|
+
// when using slice do not use utf32Offset (because it's vanila JS's method)
|
|
255
260
|
d: prevDoc.slice(change.rangeOffset, change.rangeOffset + change.rangeLength)
|
|
256
261
|
}].filter(Boolean));
|
|
257
262
|
}
|
|
258
263
|
// replace
|
|
259
264
|
if (change.text.length > 0 && !readOnly) {
|
|
260
|
-
wsUsercode.sendOTs(
|
|
265
|
+
wsUsercode.sendOTs(utf32Offset > 0 ? [utf32Offset, change.text] : [change.text]);
|
|
261
266
|
}
|
|
262
267
|
}
|
|
263
268
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elice/material-exercise",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.250108.0-runboxswitch.0",
|
|
4
4
|
"description": "User view and editing components of Elice material exercise",
|
|
5
5
|
"repository": "https://git.elicer.io/elice/frontend/library/elice-material",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
"@elice/icons": "^1.230814.0",
|
|
84
84
|
"@elice/intl": "0.241127.0",
|
|
85
85
|
"@elice/markdown": "1.241015.0",
|
|
86
|
-
"@elice/material-shared-types": "1.
|
|
87
|
-
"@elice/material-shared-utils": "1.
|
|
88
|
-
"@elice/mui-elements": "^5.
|
|
89
|
-
"@elice/mui-system": "^5.
|
|
86
|
+
"@elice/material-shared-types": "1.250108.0-runboxswitch.0",
|
|
87
|
+
"@elice/material-shared-utils": "1.250108.0-runboxswitch.0",
|
|
88
|
+
"@elice/mui-elements": "^5.250108.0-controllabel.0",
|
|
89
|
+
"@elice/mui-system": "^5.250108.0-controllabel.0",
|
|
90
90
|
"@elice/types": "1.241220.0",
|
|
91
91
|
"@elice/websocket": "^1.220815.0",
|
|
92
92
|
"@emotion/react": "^11.10.5",
|