locize 4.0.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 4.0.0
2
+
3
+ - support also non-i18next environments
4
+
1
5
  ### 3.3.0
2
6
 
3
7
  - support i18next-subliminal in clickHandler used in locize iframe
package/README.md CHANGED
@@ -66,7 +66,7 @@ If not using recommended 1) or 2) the script will send the raw texts to the edit
66
66
 
67
67
  This plugin is already included in [locizify](https://github.com/locize/locizify) >= v4.1.0
68
68
 
69
- ** Hint: ** show the incontext editor popup by adding incontext=true query paramenter, i.e. http://localhost:8080?incontext=true
69
+ **Hint:** show the incontext editor popup by adding incontext=true query paramenter, i.e. http://localhost:8080?incontext=true
70
70
 
71
71
  ## with i18next
72
72
 
@@ -78,7 +78,7 @@ import { locizePlugin } from 'locize'
78
78
  i18next.use(locizePlugin)
79
79
  ```
80
80
 
81
- ** Hint: ** this will show the locize incontext editor as a popup in your website only if the url contains the incontext=true query paramenter, i.e. http://localhost:8080?incontext=true
81
+ **Hint:** this will show the locize incontext editor as a popup in your website only if the url contains the incontext=true query paramenter, i.e. http://localhost:8080?incontext=true
82
82
 
83
83
  Open as default:
84
84
 
@@ -101,7 +101,7 @@ i18next.init({
101
101
 
102
102
  **Hint** you can match the integration to a locize project by:
103
103
 
104
- Having [i18next-locize-backend[(https://github.com/locize/i18next-locize-backend) configured or adding
104
+ Having [i18next-locize-backend](https://github.com/locize/i18next-locize-backend) configured or adding
105
105
 
106
106
  ```js
107
107
  i18next.init({
@@ -115,7 +115,7 @@ i18next.init({
115
115
 
116
116
  ## not using i18next (messageformat, fluent, ...)
117
117
 
118
- Not using i18next currently only the option to show your website inside the locize incontext solution (https://locize.app) is available.
118
+ Not using i18next currently only the option to show your website inside the locize incontext view (https://www.locize.com/docs/incontext).
119
119
 
120
120
  ### using import
121
121
 
@@ -150,7 +150,7 @@ startStandalone({
150
150
 
151
151
  ### vanilla javascript
152
152
 
153
- Only relevant when your website is shown inside the locize incontext solution on https://locize.app.
153
+ Only relevant when your website is shown inside the locize incontext solution via incontext view (https://www.locize.com/docs/incontext).
154
154
 
155
155
  ```html
156
156
  <script src="https://unpkg.com/locize/locize.min.js" />
package/dist/cjs/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var locizePlugin = require('./locizePlugin.js');
6
- var _startStandalone = require('./_startStandalone.js');
6
+ var startStandalone = require('./startStandalone.js');
7
7
  require('./api/handleEditKey.js');
8
8
  require('./api/handleCommitKey.js');
9
9
  require('./api/handleCommitKeys.js');
@@ -25,12 +25,12 @@ var index = {
25
25
  locizePlugin: locizePlugin.locizePlugin,
26
26
  locizeEditorPlugin: locizePlugin.locizeEditorPlugin,
27
27
  setEditorLng: postMessage.setEditorLng,
28
- startStandalone: _startStandalone.startStandalone
28
+ startStandalone: startStandalone.startStandalone
29
29
  };
30
30
 
31
31
  exports.locizeEditorPlugin = locizePlugin.locizeEditorPlugin;
32
32
  exports.locizePlugin = locizePlugin.locizePlugin;
33
- exports.startStandalone = _startStandalone.startStandalone;
33
+ exports.startStandalone = startStandalone.startStandalone;
34
34
  exports.addLocizeSavedHandler = postMessage.addLocizeSavedHandler;
35
35
  exports.setEditorLng = postMessage.setEditorLng;
36
36
  Object.defineProperty(exports, 'PostProcessor', {
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
6
+ var process = require('./process.js');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
11
+
12
+ var _excluded = ["implementation"];
13
+ function startStandalone(options) {
14
+ var implementation = options.implementation,
15
+ rest = _objectWithoutProperties__default["default"](options, _excluded);
16
+ process.start(implementation, rest);
17
+ }
18
+ if (typeof window !== 'undefined') window.locizeStartStandalone = startStandalone;
19
+
20
+ exports.startStandalone = startStandalone;
package/dist/cjs/utils.js CHANGED
@@ -3,12 +3,11 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
6
- var _typeof = require('@babel/runtime/helpers/typeof');
6
+ require('@babel/runtime/helpers/typeof');
7
7
 
8
8
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
9
 
10
10
  var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
11
- var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
12
11
 
13
12
  function debounce(func, wait, immediate) {
14
13
  var timeout;
@@ -25,76 +24,6 @@ function debounce(func, wait, immediate) {
25
24
  if (callNow) func.apply(context, args);
26
25
  };
27
26
  }
28
- function isWindow(obj) {
29
- return obj != null && obj === obj.window;
30
- }
31
- function getWindow(elem) {
32
- return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView;
33
- }
34
- function offset(elem) {
35
- var box = {
36
- top: 0,
37
- left: 0,
38
- right: 0,
39
- bottom: 0
40
- };
41
- var doc = elem && elem.ownerDocument;
42
- var docElem = doc && doc.documentElement;
43
- if (!docElem) return box;
44
- if (_typeof__default["default"](elem.getBoundingClientRect) !== ("undefined" )) {
45
- box = elem.getBoundingClientRect();
46
- }
47
- var win = getWindow(doc);
48
- var top = box.top + win.pageYOffset - docElem.clientTop;
49
- var left = box.left + win.pageXOffset - docElem.clientLeft;
50
- return {
51
- top: top,
52
- left: left,
53
- right: left + (box.right - box.left),
54
- bottom: top + (box.bottom - box.top)
55
- };
56
- }
57
- function getClickedElement(e) {
58
- if (e.srcElement && e.srcElement.nodeType === 1 && (e.srcElement.nodeName === 'BUTTON' || e.srcElement.nodeName === 'INPUT')) {
59
- if (e.srcElement.getAttribute && e.srcElement.getAttribute('ignorelocizeeditor') === '') {
60
- return null;
61
- }
62
- return e.srcElement;
63
- }
64
- var el;
65
- if (e.originalEvent && e.originalEvent.explicitOriginalTarget) {
66
- el = e.originalEvent.explicitOriginalTarget;
67
- } else {
68
- var parent = e.srcElement;
69
- if (parent.getAttribute && parent.getAttribute('ignorelocizeeditor') === '') return null;
70
- var left = e.pageX;
71
- var top = e.pageY;
72
- var topStartsAt = 0;
73
- var topBreaksAt;
74
- for (var i = 0; i < parent.childNodes.length; i++) {
75
- var n = parent.childNodes[i];
76
- var nOffset = offset(n);
77
- if (n.nodeType === 1 && nOffset.bottom < top) topStartsAt = i + 1;
78
- if (!topBreaksAt && nOffset.top + (n.clientHeight || 0) > top) topBreaksAt = i;
79
- }
80
- if (topStartsAt + 1 > parent.childNodes.length) topStartsAt = parent.childNodes.length - 1;
81
- if (!topBreaksAt) topBreaksAt = parent.childNodes.length;
82
- for (var y = topStartsAt; y < topBreaksAt; y++) {
83
- var _n = parent.childNodes[y];
84
- var _nOffset = offset(_n);
85
- if (_nOffset.left > left) {
86
- break;
87
- }
88
- if (_n && _n.nodeType !== 8) el = _n;
89
- }
90
- }
91
- return el;
92
- }
93
- function getElementText(el) {
94
- var str = el.textContent || el.text && el.text.innerText || el.placeholder;
95
- if (typeof str !== 'string') return;
96
- return str.replace(/\n +/g, '').trim();
97
- }
98
27
  function getAttribute(el, name) {
99
28
  return el && el.getAttribute && el.getAttribute(name);
100
29
  }
@@ -192,12 +121,7 @@ function getQsParameterByName(name, url) {
192
121
  }
193
122
 
194
123
  exports.debounce = debounce;
195
- exports.getClickedElement = getClickedElement;
196
124
  exports.getElementI18nKey = getElementI18nKey;
197
125
  exports.getElementNamespace = getElementNamespace;
198
- exports.getElementText = getElementText;
199
126
  exports.getI18nMetaFromNode = getI18nMetaFromNode;
200
127
  exports.getQsParameterByName = getQsParameterByName;
201
- exports.getWindow = getWindow;
202
- exports.isWindow = isWindow;
203
- exports.offset = offset;
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { locizePlugin, locizeEditorPlugin } from './locizePlugin.js';
2
2
  export { locizeEditorPlugin, locizePlugin } from './locizePlugin.js';
3
- import { startStandalone } from './_startStandalone.js';
4
- export { startStandalone } from './_startStandalone.js';
3
+ import { startStandalone } from './startStandalone.js';
4
+ export { startStandalone } from './startStandalone.js';
5
5
  import './api/handleEditKey.js';
6
6
  import './api/handleCommitKey.js';
7
7
  import './api/handleCommitKeys.js';
@@ -0,0 +1,12 @@
1
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
2
+ import { start } from './process.js';
3
+
4
+ var _excluded = ["implementation"];
5
+ function startStandalone(options) {
6
+ var implementation = options.implementation,
7
+ rest = _objectWithoutProperties(options, _excluded);
8
+ start(implementation, rest);
9
+ }
10
+ if (typeof window !== 'undefined') window.locizeStartStandalone = startStandalone;
11
+
12
+ export { startStandalone };
package/dist/esm/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
2
- import _typeof from '@babel/runtime/helpers/esm/typeof';
2
+ import '@babel/runtime/helpers/esm/typeof';
3
3
 
4
4
  function debounce(func, wait, immediate) {
5
5
  var timeout;
@@ -16,76 +16,6 @@ function debounce(func, wait, immediate) {
16
16
  if (callNow) func.apply(context, args);
17
17
  };
18
18
  }
19
- function isWindow(obj) {
20
- return obj != null && obj === obj.window;
21
- }
22
- function getWindow(elem) {
23
- return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView;
24
- }
25
- function offset(elem) {
26
- var box = {
27
- top: 0,
28
- left: 0,
29
- right: 0,
30
- bottom: 0
31
- };
32
- var doc = elem && elem.ownerDocument;
33
- var docElem = doc && doc.documentElement;
34
- if (!docElem) return box;
35
- if (_typeof(elem.getBoundingClientRect) !== ("undefined" )) {
36
- box = elem.getBoundingClientRect();
37
- }
38
- var win = getWindow(doc);
39
- var top = box.top + win.pageYOffset - docElem.clientTop;
40
- var left = box.left + win.pageXOffset - docElem.clientLeft;
41
- return {
42
- top: top,
43
- left: left,
44
- right: left + (box.right - box.left),
45
- bottom: top + (box.bottom - box.top)
46
- };
47
- }
48
- function getClickedElement(e) {
49
- if (e.srcElement && e.srcElement.nodeType === 1 && (e.srcElement.nodeName === 'BUTTON' || e.srcElement.nodeName === 'INPUT')) {
50
- if (e.srcElement.getAttribute && e.srcElement.getAttribute('ignorelocizeeditor') === '') {
51
- return null;
52
- }
53
- return e.srcElement;
54
- }
55
- var el;
56
- if (e.originalEvent && e.originalEvent.explicitOriginalTarget) {
57
- el = e.originalEvent.explicitOriginalTarget;
58
- } else {
59
- var parent = e.srcElement;
60
- if (parent.getAttribute && parent.getAttribute('ignorelocizeeditor') === '') return null;
61
- var left = e.pageX;
62
- var top = e.pageY;
63
- var topStartsAt = 0;
64
- var topBreaksAt;
65
- for (var i = 0; i < parent.childNodes.length; i++) {
66
- var n = parent.childNodes[i];
67
- var nOffset = offset(n);
68
- if (n.nodeType === 1 && nOffset.bottom < top) topStartsAt = i + 1;
69
- if (!topBreaksAt && nOffset.top + (n.clientHeight || 0) > top) topBreaksAt = i;
70
- }
71
- if (topStartsAt + 1 > parent.childNodes.length) topStartsAt = parent.childNodes.length - 1;
72
- if (!topBreaksAt) topBreaksAt = parent.childNodes.length;
73
- for (var y = topStartsAt; y < topBreaksAt; y++) {
74
- var _n = parent.childNodes[y];
75
- var _nOffset = offset(_n);
76
- if (_nOffset.left > left) {
77
- break;
78
- }
79
- if (_n && _n.nodeType !== 8) el = _n;
80
- }
81
- }
82
- return el;
83
- }
84
- function getElementText(el) {
85
- var str = el.textContent || el.text && el.text.innerText || el.placeholder;
86
- if (typeof str !== 'string') return;
87
- return str.replace(/\n +/g, '').trim();
88
- }
89
19
  function getAttribute(el, name) {
90
20
  return el && el.getAttribute && el.getAttribute(name);
91
21
  }
@@ -182,4 +112,4 @@ function getQsParameterByName(name, url) {
182
112
  return decodeURIComponent(results[2].replace(/\+/g, ' '));
183
113
  }
184
114
 
185
- export { debounce, getClickedElement, getElementI18nKey, getElementNamespace, getElementText, getI18nMetaFromNode, getQsParameterByName, getWindow, isWindow, offset };
115
+ export { debounce, getElementI18nKey, getElementNamespace, getI18nMetaFromNode, getQsParameterByName };