locize 3.3.0 → 4.0.1

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 (98) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +76 -38
  3. package/dist/cjs/api/handleCommitKeys.js +7 -0
  4. package/dist/cjs/api/handleEditKey.js +1 -1
  5. package/dist/cjs/api/handleIsLocizeEnabled.js +2 -2
  6. package/dist/cjs/api/handleRequestPopupChanges.js +11 -0
  7. package/dist/cjs/api/handleSendMatchedUninstrumented.js +26 -0
  8. package/dist/cjs/api/postMessage.js +32 -45
  9. package/dist/cjs/implementations/dummyImplementation.js +35 -0
  10. package/dist/cjs/implementations/i18nextImplementation.js +94 -0
  11. package/dist/cjs/index.d.ts +9 -16
  12. package/dist/cjs/index.js +1 -6
  13. package/dist/cjs/locizePlugin.js +6 -90
  14. package/dist/cjs/observer.js +1 -0
  15. package/dist/cjs/parser.js +100 -14
  16. package/dist/cjs/process.js +37 -5
  17. package/dist/cjs/startStandalone.js +11 -17
  18. package/dist/cjs/store.js +1 -0
  19. package/dist/cjs/ui/elements/highlightBox.js +13 -0
  20. package/dist/cjs/ui/elements/icons.js +1 -17
  21. package/dist/cjs/ui/elements/popup.js +3 -3
  22. package/dist/cjs/ui/elements/ribbonBox.js +3 -6
  23. package/dist/cjs/ui/highlightNode.js +28 -77
  24. package/dist/cjs/ui/popup.js +10 -0
  25. package/dist/cjs/ui/utils.js +18 -0
  26. package/dist/cjs/uninstrumentedStore.js +18 -2
  27. package/dist/cjs/utils.js +55 -77
  28. package/dist/cjs/vars.js +5 -2
  29. package/dist/esm/api/handleCommitKeys.js +7 -0
  30. package/dist/esm/api/handleEditKey.js +1 -1
  31. package/dist/esm/api/handleIsLocizeEnabled.js +2 -2
  32. package/dist/esm/api/handleRequestPopupChanges.js +11 -0
  33. package/dist/esm/api/handleSendMatchedUninstrumented.js +20 -0
  34. package/dist/esm/api/postMessage.js +33 -44
  35. package/dist/esm/implementations/dummyImplementation.js +31 -0
  36. package/dist/esm/implementations/i18nextImplementation.js +85 -0
  37. package/dist/esm/index.d.ts +9 -16
  38. package/dist/esm/index.js +3 -6
  39. package/dist/esm/locizePlugin.js +5 -85
  40. package/dist/esm/observer.js +1 -0
  41. package/dist/esm/parser.js +101 -16
  42. package/dist/esm/process.js +38 -6
  43. package/dist/esm/startStandalone.js +7 -17
  44. package/dist/esm/store.js +1 -0
  45. package/dist/esm/ui/elements/highlightBox.js +9 -0
  46. package/dist/esm/ui/elements/icons.js +2 -16
  47. package/dist/esm/ui/elements/popup.js +3 -3
  48. package/dist/esm/ui/elements/ribbonBox.js +4 -7
  49. package/dist/esm/ui/highlightNode.js +28 -78
  50. package/dist/esm/ui/popup.js +10 -0
  51. package/dist/esm/ui/utils.js +18 -1
  52. package/dist/esm/uninstrumentedStore.js +18 -2
  53. package/dist/esm/utils.js +54 -72
  54. package/dist/esm/vars.js +5 -3
  55. package/dist/umd/locize.js +637 -592
  56. package/dist/umd/locize.min.js +1 -1
  57. package/index.d.ts +9 -16
  58. package/locize.js +637 -592
  59. package/locize.min.js +1 -1
  60. package/package.json +1 -1
  61. package/src/_startStandalone.js +22 -0
  62. package/src/api/handleCommitKeys.js +9 -0
  63. package/src/api/handleEditKey.js +5 -11
  64. package/src/api/handleIsLocizeEnabled.js +7 -2
  65. package/src/api/handleRequestPopupChanges.js +27 -0
  66. package/src/api/handleSendMatchedUninstrumented.js +38 -0
  67. package/src/api/index.js +1 -4
  68. package/src/api/postMessage.js +37 -53
  69. package/src/implementations/dummyImplementation.js +29 -0
  70. package/src/implementations/i18nextImplementation.js +114 -0
  71. package/src/implementations/index.js +2 -0
  72. package/src/index.js +7 -6
  73. package/src/locizePlugin.js +51 -28
  74. package/src/observer.js +1 -0
  75. package/src/parser.js +207 -19
  76. package/src/process.js +52 -5
  77. package/src/startStandalone.js +4 -17
  78. package/src/store.js +2 -0
  79. package/src/ui/elements/highlightBox.js +17 -0
  80. package/src/ui/elements/popup.js +4 -4
  81. package/src/ui/elements/ribbonBox.js +12 -8
  82. package/src/ui/highlightNode.js +102 -71
  83. package/src/ui/popup.js +33 -5
  84. package/src/ui/utils.js +28 -1
  85. package/src/uninstrumentedStore.js +18 -2
  86. package/src/utils.js +72 -5
  87. package/src/vars.js +6 -4
  88. package/dist/cjs/api/handleTurnOff.js +0 -8
  89. package/dist/cjs/api/handleTurnOn.js +0 -8
  90. package/dist/cjs/clickHandler.js +0 -55
  91. package/dist/cjs/processLegacy.js +0 -80
  92. package/dist/esm/api/handleTurnOff.js +0 -6
  93. package/dist/esm/api/handleTurnOn.js +0 -6
  94. package/dist/esm/clickHandler.js +0 -51
  95. package/dist/esm/processLegacy.js +0 -72
  96. /package/src/{processLegacy.js → _processLegacy.js} +0 -0
  97. /package/src/api/{handleTurnOff.js → _handleTurnOff.js} +0 -0
  98. /package/src/api/{handleTurnOn.js → _handleTurnOn.js} +0 -0
@@ -45,6 +45,37 @@
45
45
  return obj;
46
46
  }
47
47
 
48
+ function _arrayLikeToArray(arr, len) {
49
+ if (len == null || len > arr.length) len = arr.length;
50
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
51
+ return arr2;
52
+ }
53
+
54
+ function _arrayWithoutHoles(arr) {
55
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
56
+ }
57
+
58
+ function _iterableToArray(iter) {
59
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
60
+ }
61
+
62
+ function _unsupportedIterableToArray(o, minLen) {
63
+ if (!o) return;
64
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
65
+ var n = Object.prototype.toString.call(o).slice(8, -1);
66
+ if (n === "Object" && o.constructor) n = o.constructor.name;
67
+ if (n === "Map" || n === "Set") return Array.from(o);
68
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
69
+ }
70
+
71
+ function _nonIterableSpread() {
72
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
73
+ }
74
+
75
+ function _toConsumableArray(arr) {
76
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
77
+ }
78
+
48
79
  var INVISIBLE_CHARACTERS = ["\u200B", "\u200C"];
49
80
  var INVISIBLE_REGEX = RegExp("([".concat(INVISIBLE_CHARACTERS.join(''), "]{9})+"), 'gu');
50
81
  var TEMPLATE_MINIMUM_LENGTH = '{"k":"a"}'.length;
@@ -141,18 +172,18 @@
141
172
  return text.startsWith(encodedInvisibleStartMarker);
142
173
  }
143
174
 
144
- function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
145
- function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
175
+ function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
176
+ function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
146
177
  var postProcessorName = 'subliminal';
147
178
  var SubliminalPostProcessor = {
148
179
  name: postProcessorName,
149
180
  type: 'postProcessor',
150
181
  options: {},
151
182
  setOptions: function setOptions(options) {
152
- this.options = _objectSpread$8(_objectSpread$8({}, options), this.options);
183
+ this.options = _objectSpread$7(_objectSpread$7({}, options), this.options);
153
184
  },
154
185
  process: function process(value, keyIn, options, translator) {
155
- var opt = this.options = _objectSpread$8(_objectSpread$8({}, options), this.options);
186
+ var opt = this.options = _objectSpread$7(_objectSpread$7({}, options), this.options);
156
187
  var key, ns, lng, source;
157
188
  if (options.i18nResolved) {
158
189
  key = options.i18nResolved.exactUsedKey;
@@ -198,9 +229,11 @@
198
229
  };
199
230
 
200
231
  var validAttributes = ['placeholder', 'title', 'alt'];
232
+ var ignoreElements = ['SCRIPT'];
201
233
  var colors = {
202
- highlight: '#26a69a',
203
- warning: '#e67a00'
234
+ highlight: '#1976d2',
235
+ warning: '#e67a00',
236
+ gray: '#ccc'
204
237
  };
205
238
  var getIframeUrl = function getIframeUrl() {
206
239
  var _prc$env;
@@ -219,8 +252,206 @@
219
252
  return style.sheet;
220
253
  }();
221
254
 
222
- function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
223
- function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
255
+ function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
256
+ function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
257
+ var data$1 = {};
258
+ function clean$1() {
259
+ Object.values(data$1).forEach(function (item) {
260
+ if (!document.body.contains(item.node)) {
261
+ resetHighlight(item.id, item.node);
262
+ delete data$1[item.id];
263
+ }
264
+ });
265
+ }
266
+ function save$1(id, type, node, txt) {
267
+ if (!id || !type || !node) return;
268
+ if (!data$1[id]) {
269
+ data$1[id] = {
270
+ id: id,
271
+ node: node
272
+ };
273
+ }
274
+ data$1[id].keys = _objectSpread$6(_objectSpread$6({}, data$1[id].keys), {}, _defineProperty({}, "".concat(type), {
275
+ value: txt,
276
+ eleUniqueID: id,
277
+ textType: type
278
+ }));
279
+ }
280
+ function remove(id, node) {
281
+ resetHighlight(id, node);
282
+ delete data$1[id];
283
+ }
284
+ function removeKey(id, key, node) {
285
+ var item = get$1(id);
286
+ if (!item) return;
287
+ delete item.keys["".concat(key)];
288
+ if (!Object.keys(item.keys).length) remove(id, node);
289
+ }
290
+ function get$1(id) {
291
+ return data$1[id];
292
+ }
293
+ var uninstrumentedStore = {
294
+ save: save$1,
295
+ remove: remove,
296
+ removeKey: removeKey,
297
+ clean: clean$1,
298
+ get: get$1,
299
+ data: data$1
300
+ };
301
+
302
+ function _arrayWithHoles(arr) {
303
+ if (Array.isArray(arr)) return arr;
304
+ }
305
+
306
+ function _iterableToArrayLimit(r, l) {
307
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
308
+ if (null != t) {
309
+ var e,
310
+ n,
311
+ i,
312
+ u,
313
+ a = [],
314
+ f = !0,
315
+ o = !1;
316
+ try {
317
+ if (i = (t = t.call(r)).next, 0 === l) {
318
+ if (Object(t) !== t) return;
319
+ f = !1;
320
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
321
+ } catch (r) {
322
+ o = !0, n = r;
323
+ } finally {
324
+ try {
325
+ if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
326
+ } finally {
327
+ if (o) throw n;
328
+ }
329
+ }
330
+ return a;
331
+ }
332
+ }
333
+
334
+ function _nonIterableRest() {
335
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
336
+ }
337
+
338
+ function _slicedToArray(arr, i) {
339
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
340
+ }
341
+
342
+ function debounce(func, wait, immediate) {
343
+ var timeout;
344
+ return function () {
345
+ var context = this;
346
+ var args = arguments;
347
+ var later = function later() {
348
+ timeout = null;
349
+ if (!immediate) func.apply(context, args);
350
+ };
351
+ var callNow = immediate && !timeout;
352
+ clearTimeout(timeout);
353
+ timeout = setTimeout(later, wait);
354
+ if (callNow) func.apply(context, args);
355
+ };
356
+ }
357
+ function getAttribute(el, name) {
358
+ return el && el.getAttribute && el.getAttribute(name);
359
+ }
360
+ function getElementI18nKey(el) {
361
+ var key = getAttribute(el, 'data-i18n');
362
+ if (key) return key;
363
+ if (el.nodeType === window.Node.TEXT_NODE && el.parentElement) {
364
+ return getElementI18nKey(el.parentElement);
365
+ }
366
+ return undefined;
367
+ }
368
+ function parseAttrFromKey(key) {
369
+ var attr = 'text';
370
+ if (key.indexOf('[') == 0) {
371
+ var parts = key.split(']');
372
+ key = parts[1];
373
+ attr = parts[0].substr(1, parts[0].length - 1);
374
+ }
375
+ var newKey = key.indexOf(';') == key.length - 1 ? key.substr(0, key.length - 2) : key;
376
+ return [newKey, attr];
377
+ }
378
+ function getI18nMetaFromNode(el) {
379
+ var hasNamespacePrependToKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
380
+ var key = getElementI18nKey(el);
381
+ var ns = getElementNamespace(el);
382
+ var allKeys = {};
383
+ if (key && key.indexOf(';') >= 0) {
384
+ var keys = key.split(';');
385
+ for (var ix = 0, l_ix = keys.length; ix < l_ix; ix++) {
386
+ if (keys[ix] != '') {
387
+ var _parseAttrFromKey = parseAttrFromKey(keys[ix]),
388
+ _parseAttrFromKey2 = _slicedToArray(_parseAttrFromKey, 2),
389
+ usedKey = _parseAttrFromKey2[0],
390
+ attr = _parseAttrFromKey2[1];
391
+ allKeys[attr] = usedKey;
392
+ }
393
+ }
394
+ } else if (key) {
395
+ var _parseAttrFromKey3 = parseAttrFromKey(key),
396
+ _parseAttrFromKey4 = _slicedToArray(_parseAttrFromKey3, 2),
397
+ _usedKey = _parseAttrFromKey4[0],
398
+ _attr = _parseAttrFromKey4[1];
399
+ allKeys[_attr] = _usedKey;
400
+ }
401
+ if (Object.keys(allKeys).length < 1) return null;
402
+ var res = Object.keys(allKeys).reduce(function (mem, attr) {
403
+ var key = allKeys[attr];
404
+ var usedNS = ns;
405
+ var usedKey = key;
406
+ if (hasNamespacePrependToKey && key.indexOf(':') > -1) {
407
+ var parts = key.split(':');
408
+ usedKey = parts[1];
409
+ usedNS = parts[0];
410
+ }
411
+ mem[attr] = {
412
+ key: usedKey,
413
+ ns: usedNS
414
+ };
415
+ return mem;
416
+ }, {});
417
+ return res;
418
+ }
419
+ function getElementNamespace(el) {
420
+ var found;
421
+ var find = function find(ele) {
422
+ var opts = getAttribute(ele, 'i18next-options');
423
+ if (!opts) opts = getAttribute(ele, 'data-i18next-options');
424
+ if (!opts) opts = getAttribute(ele, 'i18n-options');
425
+ if (!opts) opts = getAttribute(ele, 'data-i18n-options');
426
+ if (opts) {
427
+ var jsonData = {};
428
+ try {
429
+ jsonData = JSON.parse(opts);
430
+ } catch (e) {}
431
+ if (jsonData.ns) found = jsonData.ns;
432
+ }
433
+ if (!found) found = getAttribute(ele, 'i18next-ns');
434
+ if (!found) found = getAttribute(ele, 'data-i18next-ns');
435
+ if (!found) found = getAttribute(ele, 'i18n-ns');
436
+ if (!found) found = getAttribute(ele, 'data-i18n-ns');
437
+ if (!found && ele.parentElement) find(ele.parentElement);
438
+ };
439
+ find(el);
440
+ return found;
441
+ }
442
+ function getQsParameterByName(name, url) {
443
+ if (typeof window === 'undefined') return null;
444
+ if (!url) url = window.location.href.toLowerCase();
445
+ name = name.replace(/[\[\]]/g, '\\$&');
446
+ var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
447
+ var results = regex.exec(url);
448
+ if (!results) return null;
449
+ if (!results[2]) return '';
450
+ return decodeURIComponent(results[2].replace(/\+/g, ' '));
451
+ }
452
+
453
+ function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
454
+ function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
224
455
  var legacyEventMapping = {
225
456
  committed: 'commitKeys'
226
457
  };
@@ -231,27 +462,18 @@
231
462
  function addLocizeSavedHandler(handler) {
232
463
  api.locizeSavedHandler = handler;
233
464
  }
234
- function turnOn() {
235
- api.scriptTurnedOff = false;
236
- api.turnOn();
237
- return api.scriptTurnedOff;
238
- }
239
- function turnOff() {
240
- api.turnOff();
241
- api.scriptTurnedOff = true;
242
- return api.scriptTurnedOff;
243
- }
244
465
  function setEditorLng(lng) {
245
466
  api.sendCurrentTargetLanguage(lng);
246
467
  }
247
468
  var pendingMsgs = [];
469
+ var allowedActionsBeforeInit = ['locizeIsEnabled', 'requestInitialize'];
248
470
  function sendMessage(action, payload) {
249
471
  if (!api.source) {
250
472
  var _document$getElementB;
251
473
  api.source = (_document$getElementB = document.getElementById('i18next-editor-iframe')) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.contentWindow;
252
474
  }
253
475
  if (!api.origin) api.origin = getIframeUrl();
254
- if (!api.source || !api.source.postMessage) {
476
+ if (!api.source || !api.source.postMessage || !api.initialized && allowedActionsBeforeInit.indexOf(action) < 0) {
255
477
  pendingMsgs.push({
256
478
  action: action,
257
479
  payload: payload
@@ -259,13 +481,13 @@
259
481
  return;
260
482
  }
261
483
  if (api.legacy) {
262
- api.source.postMessage(_objectSpread$7({
484
+ api.source.postMessage(_objectSpread$5({
263
485
  message: action
264
486
  }, payload), api.origin);
265
487
  } else {
266
488
  api.source.postMessage({
267
489
  sender: 'i18next-editor',
268
- senderAPIVersion: 'v1',
490
+ senderAPIVersion: 'v2',
269
491
  action: action,
270
492
  message: action,
271
493
  payload: payload
@@ -279,6 +501,22 @@
279
501
  sendMessage(action, payload);
280
502
  });
281
503
  }
504
+ var sendCurrentParsedContentDebounced = function sendCurrentParsedContentDebounced() {
505
+ sendMessage('sendCurrentParsedContent', {
506
+ content: Object.values(store.data).map(function (item) {
507
+ return {
508
+ id: item.id,
509
+ keys: item.keys
510
+ };
511
+ }),
512
+ uninstrumented: Object.values(uninstrumentedStore.data).map(function (item) {
513
+ return {
514
+ id: item.id,
515
+ keys: item.keys
516
+ };
517
+ })
518
+ });
519
+ };
282
520
  var handlers = {};
283
521
  var repeat = 5;
284
522
  var api = {
@@ -296,7 +534,7 @@
296
534
  clearInterval(api.initInterval);
297
535
  delete api.initInterval;
298
536
  }
299
- }, 1000);
537
+ }, 2000);
300
538
  },
301
539
  selectKey: function selectKey(meta) {
302
540
  sendMessage('selectKey', meta);
@@ -304,45 +542,25 @@
304
542
  confirmResourceBundle: function confirmResourceBundle(payload) {
305
543
  sendMessage('confirmResourceBundle', payload);
306
544
  },
307
- sendCurrentParsedContent: function sendCurrentParsedContent() {
308
- sendMessage('sendCurrentParsedContent', {
309
- content: Object.values(store.data).map(function (item) {
310
- return {
311
- id: item.id,
312
- keys: item.keys
313
- };
314
- })
315
- });
316
- },
545
+ sendCurrentParsedContent: debounce(sendCurrentParsedContentDebounced, 500),
317
546
  sendCurrentTargetLanguage: function sendCurrentTargetLanguage(lng) {
318
547
  sendMessage('sendCurrentTargetLanguage', {
319
548
  targetLng: lng || api.i18n.getLng()
320
549
  });
321
550
  },
551
+ sendHrefchanged: function sendHrefchanged(href) {
552
+ sendMessage('hrefChanged', {
553
+ href: href
554
+ });
555
+ },
322
556
  addHandler: function addHandler(action, fc) {
323
557
  if (!handlers[action]) handlers[action] = [];
324
558
  handlers[action].push(fc);
325
559
  },
326
- sendLocizeIsEnabled: function sendLocizeIsEnabled() {
327
- sendMessage('locizeIsEnabled', {
560
+ sendLocizeIsEnabled: function sendLocizeIsEnabled(payload) {
561
+ sendMessage('locizeIsEnabled', _objectSpread$5(_objectSpread$5({}, payload), {}, {
328
562
  enabled: true
329
- });
330
- },
331
- turnOn: function turnOn() {
332
- if (api.scriptTurnedOff) return sendMessage('forcedOff');
333
- if (!api.clickInterceptionEnabled) {
334
- window.document.body.addEventListener('click', api.clickHandler, true);
335
- }
336
- api.clickInterceptionEnabled = true;
337
- sendMessage('turnedOn');
338
- },
339
- turnOff: function turnOff() {
340
- if (api.scriptTurnedOff) return sendMessage('forcedOff');
341
- if (api.clickInterceptionEnabled) {
342
- window.document.body.removeEventListener('click', api.clickHandler, true);
343
- }
344
- api.clickInterceptionEnabled = false;
345
- sendMessage('turnedOff');
563
+ }));
346
564
  },
347
565
  onAddedKey: function onAddedKey(lng, ns, key, value) {
348
566
  var msg = {
@@ -370,7 +588,7 @@
370
588
  }
371
589
  } else if (sender === 'i18next-editor-frame' && handlers[action]) {
372
590
  handlers[action].forEach(function (fc) {
373
- fc(payload);
591
+ fc(payload, e);
374
592
  });
375
593
  }
376
594
  });
@@ -379,7 +597,7 @@
379
597
  function setValueOnNode(meta, value) {
380
598
  var item = store.get(meta.eleUniqueID);
381
599
  if (!item || !item.keys[meta.textType]) return;
382
- var txtWithHiddenMeta = wrap(value, item.subliminal);
600
+ var txtWithHiddenMeta = item.subliminal ? wrap(value, item.subliminal) : value;
383
601
  if (meta.textType === 'text') {
384
602
  item.node.textContent = txtWithHiddenMeta;
385
603
  } else if (meta.textType.indexOf('attr:') === 0) {
@@ -418,16 +636,16 @@
418
636
  }
419
637
  }
420
638
  }
421
- function handler$9(payload) {
639
+ function handler$8(payload) {
422
640
  var meta = payload.meta,
423
641
  value = payload.value;
424
642
  if (meta && value !== undefined) {
425
643
  setValueOnNode(meta, value);
426
644
  }
427
645
  }
428
- api.addHandler('editKey', handler$9);
646
+ api.addHandler('editKey', handler$8);
429
647
 
430
- function handler$8(payload) {
648
+ function handler$7(payload) {
431
649
  var meta = payload.meta,
432
650
  value = payload.value,
433
651
  lng = payload.lng;
@@ -438,40 +656,9 @@
438
656
  api.i18n.triggerRerender();
439
657
  }
440
658
  }
441
- api.addHandler('commitKey', handler$8);
659
+ api.addHandler('commitKey', handler$7);
442
660
 
443
- function _arrayLikeToArray(arr, len) {
444
- if (len == null || len > arr.length) len = arr.length;
445
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
446
- return arr2;
447
- }
448
-
449
- function _arrayWithoutHoles(arr) {
450
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
451
- }
452
-
453
- function _iterableToArray(iter) {
454
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
455
- }
456
-
457
- function _unsupportedIterableToArray(o, minLen) {
458
- if (!o) return;
459
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
460
- var n = Object.prototype.toString.call(o).slice(8, -1);
461
- if (n === "Object" && o.constructor) n = o.constructor.name;
462
- if (n === "Map" || n === "Set") return Array.from(o);
463
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
464
- }
465
-
466
- function _nonIterableSpread() {
467
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
468
- }
469
-
470
- function _toConsumableArray(arr) {
471
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
472
- }
473
-
474
- function handler$7(payload) {
661
+ function handler$6(payload) {
475
662
  var updated = payload.updated;
476
663
  updated.forEach(function (item) {
477
664
  var lng = item.lng,
@@ -487,6 +674,12 @@
487
674
  });
488
675
  }
489
676
  api.i18n.setResource(lng, ns, key, data.value);
677
+ if (metas) {
678
+ Object.values(metas).forEach(function (m) {
679
+ var sItem = store.get(m.eleUniqueID);
680
+ recalcSelectedHighlight(sItem, sItem.node, sItem.keys);
681
+ });
682
+ }
490
683
  });
491
684
  Object.values(store.data).forEach(function (item) {
492
685
  if (item.originalChildNodes) {
@@ -498,47 +691,16 @@
498
691
  if (api.locizeSavedHandler) api.locizeSavedHandler(payload);
499
692
  if (window.locizeSavedHandler) window.locizeSavedHandler(payload);
500
693
  }
501
- api.addHandler('commitKeys', handler$7);
694
+ api.addHandler('commitKeys', handler$6);
502
695
 
503
- function handler$6(payload) {
696
+ function handler$5(payload) {
504
697
  api.initialized = true;
505
698
  clearInterval(api.initInterval);
506
699
  delete api.initInterval;
507
700
  api.sendCurrentParsedContent();
508
701
  api.sendCurrentTargetLanguage();
509
702
  }
510
- api.addHandler('confirmInitialized', handler$6);
511
-
512
- function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
513
- function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
514
- var data$1 = {};
515
- function clean$1() {
516
- Object.values(data$1).forEach(function (item) {
517
- if (!document.body.contains(item.node)) {
518
- resetHighlight(item.id, item.node);
519
- delete data$1[item.id];
520
- }
521
- });
522
- }
523
- function save$1(id, type, node) {
524
- if (!id || !type || !node) return;
525
- if (!data$1[id]) {
526
- data$1[id] = {
527
- id: id,
528
- node: node
529
- };
530
- }
531
- data$1[id].keys = _objectSpread$6(_objectSpread$6({}, data$1[id].keys), {}, _defineProperty({}, "".concat(type), 'uninstrumented'));
532
- }
533
- function get$1(id) {
534
- return data$1[id];
535
- }
536
- var uninstrumentedStore = {
537
- save: save$1,
538
- clean: clean$1,
539
- get: get$1,
540
- data: data$1
541
- };
703
+ api.addHandler('confirmInitialized', handler$5);
542
704
 
543
705
  function isInViewport(el) {
544
706
  var rect = el.getBoundingClientRect();
@@ -576,135 +738,22 @@
576
738
  hypot = Math.pow(Math.pow(distX, 2) + Math.pow(distY, 2), 1 / 2);
577
739
  return Math.floor(hypot);
578
740
  }
579
-
580
- function debounce(func, wait, immediate) {
581
- var timeout;
582
- return function () {
583
- var context = this;
584
- var args = arguments;
585
- var later = function later() {
586
- timeout = null;
587
- if (!immediate) func.apply(context, args);
588
- };
589
- var callNow = immediate && !timeout;
590
- clearTimeout(timeout);
591
- timeout = setTimeout(later, wait);
592
- if (callNow) func.apply(context, args);
593
- };
594
- }
595
- function isWindow(obj) {
596
- return obj != null && obj === obj.window;
597
- }
598
- function getWindow$1(elem) {
599
- return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView;
600
- }
601
- function offset$1(elem) {
602
- var box = {
603
- top: 0,
604
- left: 0,
605
- right: 0,
606
- bottom: 0
607
- };
608
- var doc = elem && elem.ownerDocument;
609
- var docElem = doc && doc.documentElement;
610
- if (!docElem) return box;
611
- if (_typeof(elem.getBoundingClientRect) !== ("undefined" )) {
612
- box = elem.getBoundingClientRect();
613
- }
614
- var win = getWindow$1(doc);
615
- var top = box.top + win.pageYOffset - docElem.clientTop;
616
- var left = box.left + win.pageXOffset - docElem.clientLeft;
617
- return {
618
- top: top,
619
- left: left,
620
- right: left + (box.right - box.left),
621
- bottom: top + (box.bottom - box.top)
622
- };
623
- }
624
- function getClickedElement(e) {
625
- if (e.srcElement && e.srcElement.nodeType === 1 && (e.srcElement.nodeName === 'BUTTON' || e.srcElement.nodeName === 'INPUT')) {
626
- if (e.srcElement.getAttribute && e.srcElement.getAttribute('ignorelocizeeditor') === '') {
627
- return null;
628
- }
629
- return e.srcElement;
630
- }
631
- var el;
632
- if (e.originalEvent && e.originalEvent.explicitOriginalTarget) {
633
- el = e.originalEvent.explicitOriginalTarget;
634
- } else {
635
- var parent = e.srcElement;
636
- if (parent.getAttribute && parent.getAttribute('ignorelocizeeditor') === '') return null;
637
- var left = e.pageX;
638
- var top = e.pageY;
639
- var topStartsAt = 0;
640
- var topBreaksAt;
641
- for (var i = 0; i < parent.childNodes.length; i++) {
642
- var n = parent.childNodes[i];
643
- var nOffset = offset$1(n);
644
- if (n.nodeType === 1 && nOffset.bottom < top) topStartsAt = i + 1;
645
- if (!topBreaksAt && nOffset.top + (n.clientHeight || 0) > top) topBreaksAt = i;
646
- }
647
- if (topStartsAt + 1 > parent.childNodes.length) topStartsAt = parent.childNodes.length - 1;
648
- if (!topBreaksAt) topBreaksAt = parent.childNodes.length;
649
- for (var y = topStartsAt; y < topBreaksAt; y++) {
650
- var _n = parent.childNodes[y];
651
- var _nOffset = offset$1(_n);
652
- if (_nOffset.left > left) {
653
- break;
654
- }
655
- if (_n && _n.nodeType !== 8) el = _n;
741
+ function getOptimizedBoundingRectEle(node) {
742
+ var refEle = node;
743
+ if (node.childNodes.length === 1) {
744
+ var childNode = node.childNodes[0];
745
+ if (childNode && childNode.nodeName === '#text') {
746
+ var range = document.createRange();
747
+ range.selectNode(childNode);
748
+ var rect = range.getBoundingClientRect();
749
+ refEle = {
750
+ getBoundingClientRect: function getBoundingClientRect() {
751
+ return rect;
752
+ }
753
+ };
656
754
  }
657
755
  }
658
- return el;
659
- }
660
- function getElementText(el) {
661
- var str = el.textContent || el.text && el.text.innerText || el.placeholder;
662
- if (typeof str !== 'string') return;
663
- return str.replace(/\n +/g, '').trim();
664
- }
665
- function getAttribute(el, name) {
666
- return el && el.getAttribute && el.getAttribute(name);
667
- }
668
- function getElementI18nKey(el) {
669
- var key = getAttribute(el, 'data-i18n');
670
- if (key) return key;
671
- if (el.nodeType === window.Node.TEXT_NODE && el.parentElement) {
672
- return getElementI18nKey(el.parentElement);
673
- }
674
- return undefined;
675
- }
676
- function getElementNamespace(el) {
677
- var found;
678
- var find = function find(ele) {
679
- var opts = getAttribute(ele, 'i18next-options');
680
- if (!opts) opts = getAttribute(ele, 'data-i18next-options');
681
- if (!opts) opts = getAttribute(ele, 'i18n-options');
682
- if (!opts) opts = getAttribute(ele, 'data-i18n-options');
683
- if (opts) {
684
- var jsonData = {};
685
- try {
686
- jsonData = JSON.parse(opts);
687
- } catch (e) {}
688
- if (jsonData.ns) found = jsonData.ns;
689
- }
690
- if (!found) found = getAttribute(ele, 'i18next-ns');
691
- if (!found) found = getAttribute(ele, 'data-i18next-ns');
692
- if (!found) found = getAttribute(ele, 'i18n-ns');
693
- if (!found) found = getAttribute(ele, 'data-i18n-ns');
694
- if (!found && ele.parentElement) find(ele.parentElement);
695
- };
696
- find(el);
697
- return found;
698
- }
699
- function getQsParameterByName(name, url) {
700
- if (typeof window === 'undefined') return null;
701
- if (!url) url = window.location.href.toLowerCase();
702
- name = name.replace(/[\[\]]/g, '\\$&');
703
- var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
704
- var results = regex.exec(url);
705
- if (!results) return null;
706
- if (!results[2]) return '';
707
- return decodeURIComponent(results[2].replace(/\+/g, ' '));
756
+ return refEle;
708
757
  }
709
758
 
710
759
  var debouncedUpdateDistance = debounce(function (e, observer) {
@@ -746,7 +795,7 @@
746
795
  var editIconUrl = URL.createObjectURL(new Blob([iconEdit], {
747
796
  type: 'image/svg+xml'
748
797
  }));
749
- var i18nextIconUrl = URL.createObjectURL(new Blob([i18nextIcon], {
798
+ URL.createObjectURL(new Blob([i18nextIcon], {
750
799
  type: 'image/svg+xml'
751
800
  }));
752
801
  var minimizeIconUrl = URL.createObjectURL(new Blob([minimizeIcon], {
@@ -762,18 +811,6 @@
762
811
  image.style.width = '15px';
763
812
  return image;
764
813
  }
765
- function RibbonLogo() {
766
- var circleSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '18px';
767
- var logoSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '15px';
768
- var ribbon = document.createElement('div');
769
- ribbon.setAttribute('data-i18next-editor-element', 'true');
770
- ribbon.style = "display: inline-flex; align-items: center; justify-content: center; width: ".concat(circleSize, "; height: ").concat(circleSize, "; box-shadow: inset 0 0 5px ").concat(colors.highlight, "; border: 2px solid ").concat(colors.highlight, "; border-radius: 50%");
771
- var image = document.createElement('img');
772
- image.src = i18nextIconUrl;
773
- image.style.width = logoSize;
774
- ribbon.appendChild(image);
775
- return ribbon;
776
- }
777
814
 
778
815
  if (sheet) {
779
816
  sheet.insertRule("@keyframes i18next-editor-animate-top { \n from {\n top: calc(100vh + 600px); \n left: calc(100vw + 300px);\n opacity: 0;\n }\n to {\n top: var(--i18next-editor-popup-position-top);\n left: var(--i18next-editor-popup-position-left);\n opacity: 1;\n }\n }");
@@ -786,7 +823,7 @@
786
823
  function Ribbon(popupEle, onMaximize) {
787
824
  var ribbon = document.createElement('div');
788
825
  ribbon.setAttribute('data-i18next-editor-element', 'true');
789
- ribbon.style = "\n cursor: pointer;\n position: fixed;\n bottom: 25px;\n right: 25px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 50px;\n height: 50px;\n background-color: rgba(249, 249, 249, 0.2);\n backdrop-filter: blur(3px);\n box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);\n border-radius: 50%\n ";
826
+ ribbon.style = "\n cursor: pointer;\n position: fixed;\n bottom: 25px;\n right: 25px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 50px;\n height: 50px;\n background-color: rgba(249, 249, 249, 0.2);\n backdrop-filter: blur(3px);\n box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);\n border-radius: 50%;\n ";
790
827
  ribbon.onclick = function () {
791
828
  onMaximize();
792
829
  };
@@ -815,7 +852,7 @@
815
852
  var popup = document.createElement('div');
816
853
  popup.setAttribute('id', popupId);
817
854
  popup.classList.add('i18next-editor-popup');
818
- popup.style = "\n z-index: 9;\n background-color: transparent;\n border: 1px solid rgba(200, 200, 200, 0.9);\n box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);\n border-radius: 3px;\n --i18next-editor-popup-height: 200px;\n height: var(--i18next-editor-popup-height);\n min-height: 150px;\n min-width: 300px;\n --i18next-editor-popup-width: 400px;\n width: var(--i18next-editor-popup-width);\n max-height: 600px;\n max-width: 800px;\n\n position: fixed;\n --i18next-editor-popup-position-top: calc(100vh - var(--i18next-editor-popup-height) - 10px);\n top: calc(100vh - var(--i18next-editor-popup-height) - 10px);\n --i18next-editor-popup-position-left: calc(100vw - var(--i18next-editor-popup-width) - 10px);\n left: calc(100vw - var(--i18next-editor-popup-width) - 10px);\n\n overflow: visible;\n ";
855
+ popup.style = "\n z-index: 9;\n background-color: transparent;\n border: 1px solid rgba(200, 200, 200, 0.9);\n box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);\n border-radius: 3px;\n --i18next-editor-popup-height: 200px;\n height: var(--i18next-editor-popup-height);\n min-height: 150px;\n min-width: 300px;\n --i18next-editor-popup-width: 400px;\n width: var(--i18next-editor-popup-width);\n max-height: 800px;\n max-width: 1000px;\n\n position: fixed;\n --i18next-editor-popup-position-top: calc(100vh - var(--i18next-editor-popup-height) - 10px);\n top: calc(100vh - var(--i18next-editor-popup-height) - 10px);\n --i18next-editor-popup-position-left: calc(100vw - var(--i18next-editor-popup-width) - 10px);\n left: calc(100vw - var(--i18next-editor-popup-width) - 10px);\n\n overflow: visible;\n ";
819
856
  popup.setAttribute('data-i18next-editor-element', 'true');
820
857
  var header = document.createElement('div');
821
858
  header.classList.add('i18next-editor-popup-header');
@@ -835,7 +872,7 @@
835
872
  var iframe = document.createElement('iframe');
836
873
  iframe.setAttribute('id', 'i18next-editor-iframe');
837
874
  iframe.setAttribute('data-i18next-editor-element', 'true');
838
- iframe.style = "\n z-index: 100;\n width: 100%;\n height: calc(100% - 28px);\n border: none;\n background: #fff;\n ";
875
+ iframe.style = "\n z-index: 100;\n width: 100%;\n height: calc(100% - 32px);\n border: none;\n background: #fff;\n ";
839
876
  iframe.setAttribute('src', url);
840
877
  iframe.addEventListener('load', cb);
841
878
  popup.appendChild(iframe);
@@ -847,10 +884,19 @@
847
884
  return popup;
848
885
  }
849
886
 
850
- function handler$5(payload) {
887
+ function handler$4(payload) {
851
888
  var containerStyle = payload.containerStyle;
852
889
  if (containerStyle) {
853
890
  var popup = document.getElementById(popupId);
891
+ if (!popup) return;
892
+ var storedPos = localStorage.getItem('locize_popup_pos');
893
+ if (storedPos) storedPos = JSON.parse(storedPos);
894
+ var storedSize = localStorage.getItem('locize_popup_size');
895
+ if (storedSize) storedSize = JSON.parse(storedSize);
896
+ if (storedSize && storedSize.height && storedSize.width) {
897
+ containerStyle.height = storedSize.height + 'px';
898
+ containerStyle.width = storedSize.width + 'px';
899
+ }
854
900
  if (containerStyle.height) {
855
901
  var diff = "calc(".concat(containerStyle.height, " - ").concat(popup.style.height, ")");
856
902
  popup.style.setProperty('top', "calc(".concat(popup.style.top, " - ").concat(diff, ")"));
@@ -861,9 +907,11 @@
861
907
  popup.style.setProperty('left', "calc(".concat(popup.style.left, " - ").concat(_diff, ")"));
862
908
  popup.style.setProperty('width', containerStyle.width);
863
909
  }
910
+ if (storedPos && storedPos.top && storedPos.top < window.innerHeight - containerStyle.height.replace('px', '')) popup.style.setProperty('top', storedPos.top + 'px');
911
+ if (storedPos && storedPos.left && storedPos.left < window.innerWidth - containerStyle.width.replace('px', '')) popup.style.setProperty('left', storedPos.left + 'px');
864
912
  }
865
913
  }
866
- api.addHandler('requestPopupChanges', handler$5);
914
+ api.addHandler('requestPopupChanges', handler$4);
867
915
 
868
916
  function _objectWithoutPropertiesLoose(source, excluded) {
869
917
  if (source == null) return {};
@@ -894,25 +942,25 @@
894
942
  return target;
895
943
  }
896
944
 
897
- var _excluded = ["lng", "ns"];
898
- function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
899
- function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
900
- function handler$4(payload) {
945
+ var _excluded$1 = ["lng", "ns"];
946
+ function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
947
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
948
+ function handler$3(payload) {
901
949
  var lng = payload.lng,
902
950
  ns = payload.ns,
903
- rest = _objectWithoutProperties(payload, _excluded);
951
+ rest = _objectWithoutProperties(payload, _excluded$1);
904
952
  api.i18n.getResourceBundle(lng, ns, function (resources) {
905
- api.confirmResourceBundle(_objectSpread$5({
953
+ api.confirmResourceBundle(_objectSpread$4({
906
954
  resources: resources,
907
955
  lng: lng,
908
956
  ns: ns
909
957
  }, rest));
910
958
  });
911
959
  }
912
- api.addHandler('requestResourceBundle', handler$4);
960
+ api.addHandler('requestResourceBundle', handler$3);
913
961
 
914
962
  var previousMatches = [];
915
- function handler$3(payload) {
963
+ function handler$2(payload) {
916
964
  var keys = payload.keys;
917
965
  var matchingItems = [];
918
966
  Object.values(store.data).forEach(function (item) {
@@ -929,34 +977,39 @@
929
977
  matchingItems.forEach(function (item) {
930
978
  selectedHighlight(item, item.node, item.keys);
931
979
  });
932
- previousMatches = matchingItems;
933
- }
934
- api.addHandler('selectedKeys', handler$3);
935
-
936
- function handler$2(payload, e) {
937
- api.source = e.source;
938
- api.origin = e.origin;
939
- api.legacy = true;
940
- api.sendLocizeIsEnabled();
980
+ previousMatches = matchingItems;
941
981
  }
942
- api.addHandler('isLocizeEnabled', handler$2);
982
+ api.addHandler('selectedKeys', handler$2);
943
983
 
944
984
  function handler$1(payload, e) {
945
- api.turnOn();
946
- }
947
- api.addHandler('turnOn', handler$1);
948
-
949
- function handler(payload, e) {
950
- api.turnOff();
985
+ api.source = e.source;
986
+ api.origin = e.origin;
987
+ api.sendLocizeIsEnabled(payload);
988
+ api.requestInitialize(api.config);
989
+ }
990
+ api.addHandler('isLocizeEnabled', handler$1);
991
+
992
+ function handler(payload) {
993
+ if (!payload.length) return;
994
+ payload.forEach(function (item) {
995
+ var uni = uninstrumentedStore.get(item.eleUniqueID);
996
+ store.save(item.eleUniqueID, undefined, item.textType, extractNodeMeta(item.eleUniqueID, item.textType, _defineProperty({}, "".concat(item.textType), {
997
+ ns: item.ns,
998
+ key: item.key
999
+ }), item.value), uni === null || uni === void 0 ? void 0 : uni.node);
1000
+ delete uni.keys["".concat(item.textType)];
1001
+ if (!Object.keys(uni.keys).length) uninstrumentedStore.remove(item.eleUniqueID, uni.node);
1002
+ });
1003
+ api.sendCurrentParsedContent();
951
1004
  }
952
- api.addHandler('turnOff', handler);
1005
+ api.addHandler('sendMatchedUninstrumented', handler);
953
1006
 
954
1007
  if (sheet) {
955
- sheet.insertRule('.i18next-editor-button:hover { background-color: rgba(38, 166, 154, 1) !important; }');
1008
+ sheet.insertRule('.i18next-editor-button:hover { background-color: rgba(21, 65, 154, 1) !important; }');
956
1009
  }
957
1010
  function RibbonButton(text, attrTitle, onClick) {
958
1011
  var btn = document.createElement('button');
959
- btn.style = 'font-family: Arial; position: relative; backdrop-filter: blur(3px); cursor: pointer; padding: 2px 10px 2px 20px; font-size: 15px; font-weight: 300; text-transform: uppercase; color: #fff; background-color: rgba(38, 166, 154, 0.8); border: none; border-radius: 12px';
1012
+ btn.style = 'font-family: Arial; position: relative; backdrop-filter: blur(3px); cursor: pointer; padding: 2px 10px 2px 20px; font-size: 15px; font-weight: 300; text-transform: uppercase; color: #fff; background-color: rgba(25, 118, 210, 0.8); border: none; border-radius: 12px; z-index: 99999;';
960
1013
  btn.classList.add('i18next-editor-button');
961
1014
  btn.setAttribute('data-i18next-editor-element', 'true');
962
1015
  btn.setAttribute('title', attrTitle);
@@ -978,8 +1031,6 @@
978
1031
  var arrow = document.createElement('div');
979
1032
  arrow.style = "\n position: absolute;\n width: 0;\n height: 0;\n border-top-width: 7px;\n border-bottom-width: 7px;\n border-left-width: 10px;\n border-right-width: 10px;\n border-style: solid;\n border-color: transparent ".concat(colors.highlight, " transparent\n transparent;\n ");
980
1033
  box.appendChild(arrow);
981
- var logo = RibbonLogo();
982
- box.appendChild(logo);
983
1034
  var btnbox = document.createElement('div');
984
1035
  btnbox.style = 'display: flex; flex-direction: column; align-items: flex-start; margin-left: 2px; margin-top: 1px';
985
1036
  Object.keys(keys).forEach(function (k) {
@@ -997,6 +1048,14 @@
997
1048
  };
998
1049
  }
999
1050
 
1051
+ function HighlightBox(ele, borderColor, shadowColor) {
1052
+ var rect = ele.getBoundingClientRect();
1053
+ var box = document.createElement('div');
1054
+ box.style = "position: absolute; top: ".concat(rect.top - 2 + window.scrollY, "px; left: ").concat(rect.left - 2 + window.scrollX, "px; height: ").concat(rect.height + 4, "px; width: ").concat(rect.width + 4, "px; border: 1px solid ").concat(borderColor, "; border-radius: 2px; ").concat(shadowColor ? "box-shadow: 0 0 20px 0 ".concat(shadowColor, ";") : '');
1055
+ box.setAttribute('data-i18next-editor-element', 'true');
1056
+ return box;
1057
+ }
1058
+
1000
1059
  const min = Math.min;
1001
1060
  const max = Math.max;
1002
1061
  const round = Math.round;
@@ -2239,50 +2298,21 @@
2239
2298
  });
2240
2299
  };
2241
2300
 
2242
- var eleToOutline = ['DIV', 'P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'OL', 'UL', 'ADDRESS', 'BLOCKQUOTE', 'DL', 'PRE'];
2243
- var overriddenStyles = ['outline', 'border-radius', 'outline-offset', 'filter'];
2244
- var originalStyles = {};
2245
2301
  var selected = {};
2246
2302
  function highlight(item, node, keys) {
2247
- var id = item.id;
2248
- if (selected[id]) return;
2249
- if (!originalStyles[id]) {
2250
- originalStyles[id] = overriddenStyles.reduce(function (mem, s) {
2251
- mem[s] = node.style[s];
2252
- return mem;
2253
- }, {});
2254
- }
2255
- if (eleToOutline.includes(node.nodeName)) {
2256
- node.style.outline = "".concat(colors.highlight, " solid 1px");
2257
- node.style.setProperty('border-radius', '1px');
2258
- node.style.setProperty('outline-offset', '2px');
2259
- node.style.filter = 'brightness(110%)';
2260
- } else {
2261
- node.style.outline = "".concat(colors.highlight, " solid 1px");
2262
- node.style.setProperty('border-radius', '1px');
2263
- node.style.setProperty('outline-offset', '1px');
2264
- node.style.filter = 'brightness(110%)';
2303
+ item.id;
2304
+ var rectEle = getOptimizedBoundingRectEle(node);
2305
+ if (!item.highlightBox) {
2306
+ var box = HighlightBox(rectEle, colors.highlight);
2307
+ document.body.appendChild(box);
2308
+ item.highlightBox = box;
2265
2309
  }
2266
2310
  if (!item.ribbonBox) {
2267
2311
  var _RibbonBox = RibbonBox(keys),
2268
2312
  actions = _RibbonBox.box,
2269
2313
  arrowEle = _RibbonBox.arrow;
2270
2314
  document.body.appendChild(actions);
2271
- var refEle = node;
2272
- if (node.childNodes.length === 1) {
2273
- var childNode = node.childNodes[0];
2274
- if (childNode && childNode.nodeName === '#text') {
2275
- var range = document.createRange();
2276
- range.selectNode(childNode);
2277
- var rect = range.getBoundingClientRect();
2278
- refEle = {
2279
- getBoundingClientRect: function getBoundingClientRect() {
2280
- return rect;
2281
- }
2282
- };
2283
- }
2284
- }
2285
- computePosition(refEle, actions, {
2315
+ computePosition(rectEle, actions, {
2286
2316
  placement: 'right',
2287
2317
  middleware: [flip({
2288
2318
  fallbackPlacements: ['left', 'bottom']
@@ -2329,58 +2359,35 @@
2329
2359
  function highlightUninstrumented(item, node, keys) {
2330
2360
  var id = item.id;
2331
2361
  if (selected[id]) return;
2332
- if (!originalStyles[id]) {
2333
- originalStyles[id] = overriddenStyles.reduce(function (mem, s) {
2334
- mem[s] = node.style[s];
2335
- return mem;
2336
- }, {});
2337
- }
2338
- if (eleToOutline.includes(node.nodeName)) {
2339
- node.style.outline = "".concat(colors.warning, " solid 1px");
2340
- node.style.setProperty('border-radius', '1px');
2341
- node.style.setProperty('outline-offset', '2px');
2342
- node.style.filter = 'brightness(110%)';
2343
- } else {
2344
- node.style.outline = "".concat(colors.warning, " solid 1px");
2345
- node.style.setProperty('border-radius', '1px');
2346
- node.style.setProperty('outline-offset', '1px');
2347
- node.style.filter = 'brightness(110%)';
2362
+ var rectEle = getOptimizedBoundingRectEle(node);
2363
+ if (!item.highlightBox) {
2364
+ var box = HighlightBox(rectEle, colors.warning);
2365
+ document.body.appendChild(box);
2366
+ item.highlightBox = box;
2348
2367
  }
2349
2368
  }
2350
2369
  function selectedHighlight(item, node, keys) {
2351
2370
  var id = item.id;
2352
- if (!originalStyles[id]) {
2353
- originalStyles[id] = overriddenStyles.reduce(function (mem, s) {
2354
- mem[s] = node.style[s];
2355
- return mem;
2356
- }, {});
2357
- }
2358
- if (eleToOutline.includes(node.nodeName)) {
2359
- node.style.outline = "".concat(colors.highlight, " solid 1px");
2360
- node.style.setProperty('border-radius', '1px');
2361
- node.style.setProperty('outline-offset', '2px');
2362
- node.style.filter = "brightness(110%) drop-shadow(0px 0px 2px ".concat(colors.highlight, " )");
2363
- } else {
2364
- node.style.outline = "".concat(colors.highlight, " solid 1px");
2365
- node.style.setProperty('border-radius', '1px');
2366
- node.style.setProperty('outline-offset', '1px');
2367
- node.style.filter = "brightness(110%) drop-shadow(0px 0px 2px ".concat(colors.highlight, " )");
2368
- }
2369
- if (item.ribbonBox) {
2370
- document.body.removeChild(item.ribbonBox);
2371
- delete item.ribbonBox;
2371
+ var rectEle = getOptimizedBoundingRectEle(node);
2372
+ if (!item.highlightBox) {
2373
+ var box = HighlightBox(rectEle, colors.highlight, colors.gray);
2374
+ document.body.appendChild(box);
2375
+ item.highlightBox = box;
2372
2376
  }
2373
2377
  selected[id] = true;
2374
2378
  }
2379
+ function recalcSelectedHighlight(item, node, keys) {
2380
+ if (!selected[item.id]) return;
2381
+ resetHighlight(item, node, keys, false);
2382
+ selectedHighlight(item, node);
2383
+ }
2375
2384
  function resetHighlight(item, node, keys) {
2376
2385
  var ignoreSelected = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
2377
2386
  var id = item.id;
2378
2387
  if (ignoreSelected && selected[id]) return;
2379
- if (originalStyles[id]) {
2380
- overriddenStyles.forEach(function (s) {
2381
- node.style.setProperty(s, originalStyles[id][s]);
2382
- });
2383
- delete originalStyles[id];
2388
+ if (item.highlightBox) {
2389
+ document.body.removeChild(item.highlightBox);
2390
+ delete item.highlightBox;
2384
2391
  }
2385
2392
  if (item.ribbonBox) {
2386
2393
  document.body.removeChild(item.ribbonBox);
@@ -2389,8 +2396,8 @@
2389
2396
  delete selected[id];
2390
2397
  }
2391
2398
 
2392
- function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2393
- function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2399
+ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2400
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2394
2401
  var data = {};
2395
2402
  function clean() {
2396
2403
  Object.values(data).forEach(function (item) {
@@ -2409,9 +2416,10 @@
2409
2416
  subliminal: subliminal
2410
2417
  };
2411
2418
  }
2412
- data[id].keys = _objectSpread$4(_objectSpread$4({}, data[id].keys), {}, _defineProperty({}, "".concat(type), meta));
2419
+ if (subliminal) data[id].subliminal = subliminal;
2420
+ data[id].keys = _objectSpread$3(_objectSpread$3({}, data[id].keys), {}, _defineProperty({}, "".concat(type), meta));
2413
2421
  if (children) {
2414
- data[id].children = _objectSpread$4(_objectSpread$4({}, data[id].children), {}, _defineProperty({}, "".concat(type, "-").concat(children.map(function (c) {
2422
+ data[id].children = _objectSpread$3(_objectSpread$3({}, data[id].children), {}, _defineProperty({}, "".concat(type, "-").concat(children.map(function (c) {
2415
2423
  return c.childIndex;
2416
2424
  }).join(',')), children));
2417
2425
  }
@@ -2456,8 +2464,8 @@
2456
2464
  });
2457
2465
  })();
2458
2466
 
2459
- function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2460
- function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2467
+ function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2468
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2461
2469
  var currentSourceLng;
2462
2470
  var i18n;
2463
2471
  var ignoreMergedEleUniqueIds = [];
@@ -2467,35 +2475,84 @@
2467
2475
  function walk(node, func) {
2468
2476
  if (node.dataset && node.dataset.i18nextEditorElement === 'true') return;
2469
2477
  func(node);
2478
+ var instr = store.get(node.uniqueID);
2479
+ var uninstr = uninstrumentedStore.get(node.uniqueID);
2480
+ if (instr || uninstr) {
2481
+ var _node$parentElement;
2482
+ var id = (_node$parentElement = node.parentElement) === null || _node$parentElement === void 0 ? void 0 : _node$parentElement.uniqueID;
2483
+ uninstrumentedStore.remove(id, node.parentElement);
2484
+ }
2470
2485
  var children = node.childNodes;
2471
- for (var i = 0; i < children.length; i++) {
2472
- walk(children[i], func);
2486
+ for (var _i = 0; _i < children.length; _i++) {
2487
+ walk(children[_i], func);
2473
2488
  }
2474
2489
  }
2475
- function extractMeta(id, type, meta, children) {
2476
- var _i18n, _i18n2;
2490
+ function extractHiddenMeta(id, type, meta, children) {
2491
+ var _i18n, _i18n2, _i18n3;
2477
2492
  var invisibleMeta = meta.invisibleMeta,
2478
2493
  text = meta.text;
2479
2494
  if (!invisibleMeta || !invisibleMeta.key || !invisibleMeta.ns) return;
2480
- if (!currentSourceLng) currentSourceLng = (_i18n = i18n) === null || _i18n === void 0 ? void 0 : _i18n.getSourceLng();
2481
- return _objectSpread$3(_objectSpread$3({
2495
+ if (!currentSourceLng) currentSourceLng = i18n.getSourceLng();
2496
+ return _objectSpread$2(_objectSpread$2({
2482
2497
  eleUniqueID: id,
2483
2498
  textType: type,
2484
- children: children ? children.map(function (c) {
2499
+ children: children && children.map ? children.map(function (c) {
2485
2500
  return c.childIndex;
2486
2501
  }).join(',') : null,
2487
2502
  qualifiedKey: "".concat(invisibleMeta.ns, ":").concat(invisibleMeta.key)
2488
2503
  }, invisibleMeta), {}, {
2489
2504
  extractedText: text,
2490
- i18nTargetLng: (_i18n2 = i18n) === null || _i18n2 === void 0 ? void 0 : _i18n2.getLng(),
2505
+ i18nTargetLng: (_i18n = i18n) === null || _i18n === void 0 ? void 0 : _i18n.getLng(),
2491
2506
  i18nSourceLng: currentSourceLng,
2492
- i18nRawText: _defineProperty(_defineProperty({}, "".concat(invisibleMeta.lng), invisibleMeta.source === 'translation' && i18n ? i18n.getResource(invisibleMeta.lng, invisibleMeta.ns, invisibleMeta.key) : null), "".concat(currentSourceLng), invisibleMeta.source === 'translation' && i18n ? i18n.getResource(currentSourceLng, invisibleMeta.ns, invisibleMeta.key) : null)
2507
+ i18nRawText: _defineProperty(_defineProperty({}, "".concat(invisibleMeta.lng), invisibleMeta.source === 'translation' && i18n ? (_i18n2 = i18n) === null || _i18n2 === void 0 ? void 0 : _i18n2.getResource(invisibleMeta.lng, invisibleMeta.ns, invisibleMeta.key) : null), "".concat(currentSourceLng), invisibleMeta.source === 'translation' && i18n ? (_i18n3 = i18n) === null || _i18n3 === void 0 ? void 0 : _i18n3.getResource(currentSourceLng, invisibleMeta.ns, invisibleMeta.key) : null)
2493
2508
  });
2494
2509
  }
2510
+ function extractNodeMeta(id, type) {
2511
+ var _i18n4, _i18n5, _i18n6, _i18n7, _i18n8;
2512
+ var nodeMeta = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2513
+ var text = arguments.length > 3 ? arguments[3] : undefined;
2514
+ var children = arguments.length > 4 ? arguments[4] : undefined;
2515
+ var meta = nodeMeta[type];
2516
+ if (!meta) return;
2517
+ if (!currentSourceLng) currentSourceLng = i18n.getSourceLng();
2518
+ var i18nTargetLng = i18n.getLng();
2519
+ return {
2520
+ eleUniqueID: id,
2521
+ textType: type,
2522
+ children: children && children.map ? children.map(function (c) {
2523
+ return c.childIndex;
2524
+ }).join(',') : null,
2525
+ qualifiedKey: meta.key && (meta.ns || (_i18n4 = i18n) !== null && _i18n4 !== void 0 && _i18n4.getDefaultNS()) ? "".concat(meta.ns || ((_i18n5 = i18n) === null || _i18n5 === void 0 ? void 0 : _i18n5.getDefaultNS()), ":").concat(meta.key) : null,
2526
+ key: meta.key,
2527
+ ns: meta.ns || ((_i18n6 = i18n) === null || _i18n6 === void 0 ? void 0 : _i18n6.getDefaultNS()),
2528
+ extractedText: text,
2529
+ i18nTargetLng: i18nTargetLng,
2530
+ i18nSourceLng: currentSourceLng,
2531
+ i18nRawText: _defineProperty(_defineProperty({}, "".concat(i18nTargetLng), i18n && meta.ns && meta.key ? ((_i18n7 = i18n) === null || _i18n7 === void 0 ? void 0 : _i18n7.getResource(i18nTargetLng, meta.ns, meta.key)) || text : text), "".concat(currentSourceLng), i18n && meta.ns && meta.key ? (_i18n8 = i18n) === null || _i18n8 === void 0 ? void 0 : _i18n8.getResource(currentSourceLng, meta.ns, meta.key) : null)
2532
+ };
2533
+ }
2495
2534
  function containsOnlySpaces(str) {
2496
2535
  return /^\s*$/.test(str);
2497
2536
  }
2537
+ function storeIfQualifiedKey(id, subliminal, type, nodeI18nMeta, node, children, txt) {
2538
+ var stored = store.get(id);
2539
+ var storedMeta = stored && stored.keys["".concat(type)] || {};
2540
+ var typeMeta = nodeI18nMeta["".concat(type)] || {};
2541
+ if (!typeMeta.key && storedMeta.key) typeMeta.key = storedMeta.key;
2542
+ if (!typeMeta.ns && storedMeta.ns) typeMeta.ns = storedMeta.ns;
2543
+ nodeI18nMeta["".concat(type)] = typeMeta;
2544
+ var meta = extractNodeMeta(id, type, nodeI18nMeta, txt, children);
2545
+ if (meta.qualifiedKey) {
2546
+ store.save(id, null, type, meta, node, children);
2547
+ uninstrumentedStore.removeKey(i, type, node);
2548
+ } else {
2549
+ uninstrumentedStore.save(id, type, node, txt);
2550
+ }
2551
+ }
2498
2552
  function handleNode(node) {
2553
+ if (ignoreElements.indexOf(node.nodeName) > -1) return;
2554
+ var nodeI18nMeta = getI18nMetaFromNode(node);
2555
+ var usedSubliminalForText = false;
2499
2556
  if (node.childNodes && !ignoreMergedEleUniqueIds.includes(node.uniqueID)) {
2500
2557
  var merge = [];
2501
2558
  node.childNodes.forEach(function (child, i) {
@@ -2511,9 +2568,11 @@
2511
2568
  if (containsOnlySpaces(txt)) return;
2512
2569
  var hasHiddenMeta = containsHiddenMeta(txt);
2513
2570
  var hasHiddenStartMarker = containsHiddenStartMarker(txt);
2571
+ if (hasHiddenMeta) usedSubliminalForText = true;
2514
2572
  if (hasHiddenStartMarker && hasHiddenMeta) {
2515
2573
  var meta = unwrap(txt);
2516
- store.save(node.uniqueID, meta.invisibleMeta, 'text', extractMeta(node.uniqueID, 'text', meta), node);
2574
+ uninstrumentedStore.remove(node.uniqueID, node);
2575
+ store.save(node.uniqueID, meta.invisibleMeta, 'text', extractHiddenMeta(node.uniqueID, 'text', meta), node);
2517
2576
  } else if (hasHiddenStartMarker) {
2518
2577
  merge.push({
2519
2578
  childIndex: i,
@@ -2535,21 +2594,54 @@
2535
2594
  var _meta = unwrap(merge.reduce(function (mem, item) {
2536
2595
  return mem + item.text;
2537
2596
  }, ''));
2538
- store.save(node.uniqueID, _meta.invisibleMeta, 'html', extractMeta(node.uniqueID, 'html', _meta, merge), node, merge);
2597
+ uninstrumentedStore.removeKey(node.uniqueID, 'html', node, txt);
2598
+ store.save(node.uniqueID, _meta.invisibleMeta, 'html', extractHiddenMeta(node.uniqueID, 'html', _meta, merge), node, merge);
2539
2599
  merge = [];
2540
- } else if (txt) {
2541
- uninstrumentedStore.save(node.uniqueID, 'text', node);
2542
2600
  }
2543
2601
  });
2602
+ if (!usedSubliminalForText) {
2603
+ node.childNodes.forEach(function (child, i) {
2604
+ if (merge.length && child.nodeName !== '#text') {
2605
+ ignoreMergedEleUniqueIds.push(child.uniqueID);
2606
+ }
2607
+ var txt = child.textContent;
2608
+ if (nodeI18nMeta && nodeI18nMeta['html'] && i < node.childNodes.length - 1) {
2609
+ merge.push({
2610
+ childIndex: i,
2611
+ child: child,
2612
+ text: txt
2613
+ });
2614
+ } else if (nodeI18nMeta && nodeI18nMeta['html'] && i === node.childNodes.length - 1) {
2615
+ merge.push({
2616
+ childIndex: i,
2617
+ child: child,
2618
+ text: txt
2619
+ });
2620
+ storeIfQualifiedKey(node.uniqueID, null, 'html', nodeI18nMeta, node, merge, node.innerHTML);
2621
+ merge = [];
2622
+ } else if (txt) {
2623
+ if (nodeI18nMeta && nodeI18nMeta['text']) {
2624
+ storeIfQualifiedKey(node.uniqueID, null, 'text', nodeI18nMeta, node, undefined, txt);
2625
+ } else if (child.nodeName === '#text' && !containsOnlySpaces(txt)) {
2626
+ uninstrumentedStore.save(node.uniqueID, 'text', node, txt);
2627
+ }
2628
+ }
2629
+ });
2630
+ }
2544
2631
  }
2545
2632
  if (!node.getAttribute) return;
2546
2633
  validAttributes.forEach(function (attr) {
2547
2634
  var txt = node.getAttribute(attr);
2548
2635
  if (containsHiddenMeta(txt)) {
2549
2636
  var meta = unwrap(txt);
2550
- store.save(node.uniqueID, meta.invisibleMeta, "attr:".concat(attr), extractMeta(node.uniqueID, "attr:".concat(attr), meta), node);
2637
+ uninstrumentedStore.removeKey(node.uniqueID, attr, node);
2638
+ store.save(node.uniqueID, meta.invisibleMeta, attr, extractHiddenMeta(node.uniqueID, "".concat(attr), meta), node);
2551
2639
  } else if (txt) {
2552
- uninstrumentedStore.save(node.uniqueID, "attr:".concat(attr), node);
2640
+ if (nodeI18nMeta && nodeI18nMeta[attr]) {
2641
+ storeIfQualifiedKey(node.uniqueID, null, attr, nodeI18nMeta, node, undefined, txt);
2642
+ } else {
2643
+ uninstrumentedStore.save(node.uniqueID, attr, node, txt);
2644
+ }
2553
2645
  }
2554
2646
  });
2555
2647
  }
@@ -2653,6 +2745,7 @@
2653
2745
  characterData: true,
2654
2746
  subtree: true
2655
2747
  };
2748
+ handle([ele]);
2656
2749
  observer.observe(ele, observerConfig);
2657
2750
  },
2658
2751
  skipNext: function skipNext() {
@@ -2708,6 +2801,11 @@
2708
2801
  function closeDragElement() {
2709
2802
  startMouseTracking();
2710
2803
  if (overlay) overlay.style.display = 'none';
2804
+ var ele = document.getElementById('i18next-editor-popup');
2805
+ localStorage.setItem('locize_popup_pos', JSON.stringify({
2806
+ top: parseInt(document.defaultView.getComputedStyle(ele).top, 10),
2807
+ left: parseInt(document.defaultView.getComputedStyle(ele).left, 10)
2808
+ }));
2711
2809
  document.onmouseup = null;
2712
2810
  document.onmousemove = null;
2713
2811
  }
@@ -2761,179 +2859,22 @@
2761
2859
  function stopDrag() {
2762
2860
  startMouseTracking();
2763
2861
  if (overlay) overlay.style.display = 'none';
2862
+ var ele = document.getElementById('i18next-editor-popup');
2863
+ localStorage.setItem('locize_popup_size', JSON.stringify({
2864
+ width: parseInt(document.defaultView.getComputedStyle(ele).width, 10),
2865
+ height: parseInt(document.defaultView.getComputedStyle(ele).height, 10)
2866
+ }));
2764
2867
  document.documentElement.removeEventListener('mousemove', doDrag, false);
2765
2868
  document.documentElement.removeEventListener('mouseup', stopDrag, false);
2766
2869
  }
2767
2870
  }
2768
2871
 
2769
- function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2770
- function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2771
- function start() {
2772
- var implementation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2773
- if (typeof document === 'undefined') return;
2774
- var scriptEle = document.getElementById('locize');
2775
- var config = {};
2776
- ['projectId', 'version'].forEach(function (attr) {
2777
- if (!scriptEle) return;
2778
- var value = scriptEle.getAttribute(attr.toLowerCase()) || scriptEle.getAttribute('data-' + attr.toLowerCase());
2779
- if (value === 'true') value = true;
2780
- if (value === 'false') value = false;
2781
- if (value !== undefined && value !== null) config[attr] = value;
2782
- });
2783
- config = _objectSpread$2(_objectSpread$2({}, implementation.getLocizeDetails()), config);
2784
- api.init(implementation);
2785
- setImplementation(implementation);
2786
- implementation === null || implementation === void 0 || implementation.bindLanguageChange(function (lng) {
2787
- api.sendCurrentTargetLanguage(implementation.getLng());
2788
- });
2789
- function continueToStart() {
2790
- var observer = createObserver(document.body, function (eles) {
2791
- eles.forEach(function (ele) {
2792
- parseTree(ele);
2793
- });
2794
- api.sendCurrentParsedContent();
2795
- });
2796
- observer.start();
2797
- startMouseTracking(observer);
2798
- if (!document.getElementById(popupId)) {
2799
- document.body.append(Popup(getIframeUrl(), function () {
2800
- api.requestInitialize(config);
2801
- }));
2802
- initDragElement();
2803
- initResizeElement();
2804
- }
2805
- }
2806
- if (document.body) return continueToStart();
2807
- window.addEventListener('load', function () {
2808
- return continueToStart();
2809
- });
2810
- }
2811
-
2812
- function createClickHandler(cb) {
2813
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2814
- var handler = function handler(e) {
2815
- var el = getClickedElement(e);
2816
- if (!el) return {};
2817
- e.preventDefault();
2818
- e.stopPropagation();
2819
- function getFallbackNS() {
2820
- if (options.isLocizify) return options.defaultNS;
2821
- }
2822
- var text = getElementText(el);
2823
- var key = getElementI18nKey(el);
2824
- var ns = getElementNamespace(el) || getFallbackNS();
2825
- if (containsHiddenMeta(text)) {
2826
- var meta = unwrap(text);
2827
- if (meta && meta.invisibleMeta && meta.invisibleMeta.key) key = meta.invisibleMeta.key;
2828
- if (meta && meta.invisibleMeta && meta.invisibleMeta.ns) ns = meta.invisibleMeta.ns;
2829
- }
2830
- var rectEl = el.getBoundingClientRect ? el : el.parentElement;
2831
- var _rectEl$getBoundingCl = rectEl.getBoundingClientRect(),
2832
- top = _rectEl$getBoundingCl.top,
2833
- left = _rectEl$getBoundingCl.left,
2834
- width = _rectEl$getBoundingCl.width,
2835
- height = _rectEl$getBoundingCl.height;
2836
- var style = window.getComputedStyle(rectEl, null);
2837
- var pT = parseFloat(style.getPropertyValue('padding-top'));
2838
- var pB = parseFloat(style.getPropertyValue('padding-bottom'));
2839
- var pR = parseFloat(style.getPropertyValue('padding-right'));
2840
- var pL = parseFloat(style.getPropertyValue('padding-left'));
2841
- var sizing = style.getPropertyValue('box-sizing');
2842
- cb({
2843
- tagName: rectEl.tagName,
2844
- text: text,
2845
- key: key,
2846
- ns: ns,
2847
- box: {
2848
- top: top,
2849
- left: left,
2850
- width: sizing === 'border-box' ? width : width - pR - pL,
2851
- height: sizing === 'border-box' ? height : height - pT - pB
2852
- },
2853
- style: style.cssText
2854
- });
2855
- };
2856
- return handler;
2857
- }
2858
-
2859
2872
  function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2860
2873
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2861
- function startLegacy() {
2862
- var implementation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2863
- if (typeof document === 'undefined') return;
2864
- var scriptEle = document.getElementById('locize');
2865
- var config = {};
2866
- ['projectId', 'version'].forEach(function (attr) {
2867
- if (!scriptEle) return;
2868
- var value = scriptEle.getAttribute(attr.toLowerCase()) || scriptEle.getAttribute('data-' + attr.toLowerCase());
2869
- if (value === 'true') value = true;
2870
- if (value === 'false') value = false;
2871
- if (value !== undefined && value !== null) config[attr] = value;
2872
- });
2873
- config = _objectSpread$1(_objectSpread$1({}, implementation.getLocizeDetails()), config);
2874
- api.init(implementation, createClickHandler(function (payload) {
2875
- sendMessage('clickedElement', {
2876
- payload: payload
2877
- });
2878
- }, implementation.getLocizeDetails()));
2879
- api.sendCurrentTargetLanguage = function (lng) {
2880
- sendMessage('setLng', {
2881
- lng: lng || implementation.getLng()
2882
- });
2883
- };
2884
- if (typeof window !== 'undefined') {
2885
- var oldHref = window.document.location.href;
2886
- window.addEventListener('load', function () {
2887
- sendMessage('hrefChanged', {
2888
- href: window.document.location.href
2889
- });
2890
- var bodyList = window.document.querySelector('body');
2891
- var observer = new window.MutationObserver(function (mutations) {
2892
- mutations.forEach(function (mutation) {
2893
- if (oldHref !== window.document.location.href) {
2894
- oldHref = window.document.location.href;
2895
- sendMessage('hrefChanged', {
2896
- href: oldHref
2897
- });
2898
- }
2899
- });
2900
- });
2901
- var config = {
2902
- childList: true,
2903
- subtree: true
2904
- };
2905
- observer.observe(bodyList, config);
2906
- });
2907
- }
2908
- implementation === null || implementation === void 0 || implementation.bindLanguageChange(function (lng) {
2909
- api.sendCurrentTargetLanguage(implementation.getLng());
2910
- });
2911
- implementation === null || implementation === void 0 || implementation.bindMissingKeyHandler(function (lng, ns, k, val) {
2912
- api.onAddedKey(lng, ns, k, val);
2913
- });
2914
- }
2915
-
2916
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2917
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2918
- var isInIframe = typeof window !== 'undefined';
2919
- try {
2920
- isInIframe = self !== top;
2921
- } catch (e) {}
2922
- function configurePostProcessor(i18next, options) {
2923
- i18next.use(SubliminalPostProcessor);
2924
- if (typeof options.postProcess === 'string') {
2925
- options.postProcess = [options.postProcess, 'subliminal'];
2926
- } else if (Array.isArray(options.postProcess)) {
2927
- options.postProcess.push('subliminal');
2928
- } else {
2929
- options.postProcess = 'subliminal';
2930
- }
2931
- options.postProcessPassResolved = true;
2932
- }
2933
- function getImplementation(i18n) {
2874
+ function getImplementation$1(i18n) {
2934
2875
  var impl = {
2935
2876
  getResource: function getResource(lng, ns, key) {
2936
- return i18n.getResource(lng, ns, key);
2877
+ return i18n.getResource && i18n.getResource(lng, ns, key);
2937
2878
  },
2938
2879
  setResource: function setResource(lng, ns, key, value) {
2939
2880
  return i18n.addResource(lng, ns, key, value, {
@@ -2945,8 +2886,11 @@
2945
2886
  cb(i18n.getResourceBundle(lng, ns));
2946
2887
  });
2947
2888
  },
2889
+ getDefaultNS: function getDefaultNS() {
2890
+ return i18n.options.defaultNS;
2891
+ },
2948
2892
  getLng: function getLng() {
2949
- return i18n.resolvedLanguage || i18n.languages[0];
2893
+ return i18n.resolvedLanguage || i18n.languages && i18n.languages[0] || i18n.options.lng;
2950
2894
  },
2951
2895
  getSourceLng: function getSourceLng() {
2952
2896
  var fallback = i18n.options.fallbackLng;
@@ -2966,7 +2910,7 @@
2966
2910
  getLocizeDetails: function getLocizeDetails() {
2967
2911
  var backendName;
2968
2912
  if (i18n.services.backendConnector.backend && i18n.services.backendConnector.backend.options && i18n.services.backendConnector.backend.options.loadPath && i18n.services.backendConnector.backend.options.loadPath.indexOf('.locize.') > 0) {
2969
- backendName = 'I18NextLocizeBackend';
2913
+ backendName = 'I18nextLocizeBackend';
2970
2914
  } else {
2971
2915
  backendName = i18n.services.backendConnector.backend ? i18n.services.backendConnector.backend.constructor.name : 'options.resources';
2972
2916
  }
@@ -2976,11 +2920,17 @@
2976
2920
  i18nFormat: i18n.options.compatibilityJSON === 'v3' ? 'i18next_v3' : 'i18next_v4',
2977
2921
  i18nFramework: 'i18next',
2978
2922
  isLocizify: i18n.options.isLocizify,
2979
- defaultNS: i18n.options.defaultNS
2923
+ defaultNS: i18n.options.defaultNS,
2924
+ targetLngs: _toConsumableArray(new Set([].concat(i18n.options.preload, i18n.options.supportedLngs, [impl.getLng()]))).filter(function (l) {
2925
+ return l !== 'cimode' && l !== false && l !== 'false' && l !== undefined && l !== impl.getSourceLng();
2926
+ }),
2927
+ ns: _toConsumableArray(new Set([].concat(i18n.options.ns, i18n.options.fallbackNS, i18n.options.defaultNS))).filter(function (n) {
2928
+ return n !== false && n !== 'false';
2929
+ })
2980
2930
  };
2981
2931
  if (!i18n.options.backend && !i18n.options.editor) return opts;
2982
- var pickFrom = i18n.options.backend || i18n.options.editor;
2983
- return _objectSpread(_objectSpread({}, opts), {}, {
2932
+ var pickFrom = i18n.options.editor || i18n.options.backend;
2933
+ return _objectSpread$1(_objectSpread$1({}, opts), {}, {
2984
2934
  projectId: pickFrom.projectId,
2985
2935
  version: pickFrom.version
2986
2936
  });
@@ -2999,6 +2949,121 @@
2999
2949
  };
3000
2950
  return impl;
3001
2951
  }
2952
+
2953
+ function getImplementation() {
2954
+ var impl = {
2955
+ getResource: function getResource(lng, ns, key) {
2956
+ return {};
2957
+ },
2958
+ setResource: function setResource(lng, ns, key, value) {
2959
+ return;
2960
+ },
2961
+ getResourceBundle: function getResourceBundle(lng, ns, cb) {
2962
+ cb({});
2963
+ },
2964
+ getDefaultNS: function getDefaultNS() {
2965
+ return;
2966
+ },
2967
+ getLng: function getLng() {
2968
+ return;
2969
+ },
2970
+ getSourceLng: function getSourceLng() {
2971
+ return;
2972
+ },
2973
+ getLocizeDetails: function getLocizeDetails() {
2974
+ return {};
2975
+ },
2976
+ bindLanguageChange: function bindLanguageChange(cb) {},
2977
+ bindMissingKeyHandler: function bindMissingKeyHandler(cb) {},
2978
+ triggerRerender: function triggerRerender() {}
2979
+ };
2980
+ return impl;
2981
+ }
2982
+
2983
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2984
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2985
+ var dummyImplementation = getImplementation();
2986
+ var isInIframe = typeof window !== 'undefined';
2987
+ try {
2988
+ isInIframe = self !== top;
2989
+ } catch (e) {}
2990
+ function start() {
2991
+ var implementation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : dummyImplementation;
2992
+ var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
2993
+ show: false,
2994
+ qsProp: 'incontext'
2995
+ };
2996
+ if (typeof document === 'undefined') return;
2997
+ var showInContext = opt.show || getQsParameterByName(opt.qsProp) === 'true';
2998
+ var scriptEle = document.getElementById('locize');
2999
+ var config = {};
3000
+ ['projectId', 'version'].forEach(function (attr) {
3001
+ if (!scriptEle) return;
3002
+ var value = scriptEle.getAttribute(attr.toLowerCase()) || scriptEle.getAttribute('data-' + attr.toLowerCase());
3003
+ if (value === 'true') value = true;
3004
+ if (value === 'false') value = false;
3005
+ if (value !== undefined && value !== null) config[attr] = value;
3006
+ });
3007
+ config = _objectSpread(_objectSpread(_objectSpread({}, implementation.getLocizeDetails()), config), opt);
3008
+ api.config = config;
3009
+ api.init(implementation);
3010
+ setImplementation(implementation);
3011
+ implementation === null || implementation === void 0 || implementation.bindLanguageChange(function (lng) {
3012
+ api.sendCurrentTargetLanguage(implementation.getLng());
3013
+ });
3014
+ function continueToStart() {
3015
+ if (!isInIframe && !showInContext) return;
3016
+ var observer = createObserver(document.body, function (eles) {
3017
+ eles.forEach(function (ele) {
3018
+ parseTree(ele);
3019
+ });
3020
+ api.sendCurrentParsedContent();
3021
+ });
3022
+ observer.start();
3023
+ startMouseTracking(observer);
3024
+ if (!isInIframe && !document.getElementById(popupId)) {
3025
+ document.body.append(Popup(getIframeUrl(), function () {
3026
+ api.requestInitialize(config);
3027
+ }));
3028
+ initDragElement();
3029
+ initResizeElement();
3030
+ }
3031
+ if (typeof window !== 'undefined') {
3032
+ var oldHref = window.document.location.href;
3033
+ api.sendHrefchanged(oldHref);
3034
+ var bodyList = window.document.querySelector('body');
3035
+ var _observer = new window.MutationObserver(function (mutations) {
3036
+ mutations.forEach(function (mutation) {
3037
+ if (oldHref !== window.document.location.href) {
3038
+ oldHref = window.document.location.href;
3039
+ api.sendHrefchanged(oldHref);
3040
+ }
3041
+ });
3042
+ });
3043
+ var _config = {
3044
+ childList: true,
3045
+ subtree: true
3046
+ };
3047
+ _observer.observe(bodyList, _config);
3048
+ }
3049
+ }
3050
+ if (document.body) return continueToStart();
3051
+ window.addEventListener('load', function () {
3052
+ return continueToStart();
3053
+ });
3054
+ }
3055
+
3056
+ function configurePostProcessor(i18next, options) {
3057
+ i18next.use(SubliminalPostProcessor);
3058
+ if (typeof options.postProcess === 'string') {
3059
+ options.postProcess = [options.postProcess, 'subliminal'];
3060
+ } else if (Array.isArray(options.postProcess)) {
3061
+ options.postProcess.push('subliminal');
3062
+ } else {
3063
+ options.postProcess = 'subliminal';
3064
+ }
3065
+ options.postProcessPassResolved = true;
3066
+ }
3002
3067
  var i18next;
3003
3068
  var locizeEditorPlugin = function locizeEditorPlugin() {
3004
3069
  var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -3008,35 +3073,19 @@
3008
3073
  init: function init(i18n) {
3009
3074
  var options = i18n.options;
3010
3075
  i18next = i18n;
3011
- var showInContext = opt.show || getQsParameterByName(opt.qsProp) === 'true';
3012
- if (!isInIframe && showInContext) configurePostProcessor(i18next, options);
3013
- var impl = getImplementation(i18n);
3014
- if (!isInIframe && showInContext) {
3015
- start(impl);
3016
- } else if (isInIframe) {
3017
- startLegacy(impl);
3018
- }
3076
+ var impl = getImplementation$1(i18n);
3077
+ configurePostProcessor(i18next, options);
3078
+ start(impl, opt);
3019
3079
  }
3020
3080
  };
3021
3081
  };
3022
3082
  var locizePlugin = locizeEditorPlugin();
3023
3083
 
3024
- function startStandalone() {
3025
- startLegacy({
3026
- getLocizeDetails: function getLocizeDetails() {
3027
- return {};
3028
- },
3029
- getLng: function getLng() {
3030
- return undefined;
3031
- },
3032
- setResource: function setResource() {},
3033
- triggerRerender: function triggerRerender() {},
3034
- getResourceBundle: function getResourceBundle() {
3035
- return {};
3036
- },
3037
- bindMissingKeyHandler: function bindMissingKeyHandler() {},
3038
- bindLanguageChange: function bindLanguageChange() {}
3039
- });
3084
+ var _excluded = ["implementation"];
3085
+ function startStandalone(options) {
3086
+ var implementation = options.implementation,
3087
+ rest = _objectWithoutProperties(options, _excluded);
3088
+ start(implementation, rest);
3040
3089
  }
3041
3090
  if (typeof window !== 'undefined') window.locizeStartStandalone = startStandalone;
3042
3091
 
@@ -3048,8 +3097,6 @@
3048
3097
  addLocizeSavedHandler: addLocizeSavedHandler,
3049
3098
  locizePlugin: locizePlugin,
3050
3099
  locizeEditorPlugin: locizeEditorPlugin,
3051
- turnOn: turnOn,
3052
- turnOff: turnOff,
3053
3100
  setEditorLng: setEditorLng,
3054
3101
  startStandalone: startStandalone
3055
3102
  };
@@ -3062,8 +3109,6 @@
3062
3109
  exports.locizePlugin = locizePlugin;
3063
3110
  exports.setEditorLng = setEditorLng;
3064
3111
  exports.startStandalone = startStandalone;
3065
- exports.turnOff = turnOff;
3066
- exports.turnOn = turnOn;
3067
3112
  exports.unwrap = unwrap;
3068
3113
  exports.wrap = wrap;
3069
3114