@innovastudio/contentbuilder 1.0.56 → 1.0.57

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder",
3
- "version": "1.0.56",
3
+ "version": "1.0.57",
4
4
  "description": "",
5
5
  "main": "public/contentbuilder/contentbuilder.esm.js",
6
6
  "files": [
@@ -52293,12 +52293,6 @@ class Preferences {
52293
52293
 
52294
52294
  }
52295
52295
 
52296
- /*
52297
- LATER:
52298
- - Get/show current font size, line height & letter spacing
52299
- - Click toggle button shows gray highlight
52300
- - Image di luar domain gak bisa di-edit (kasih warning)
52301
- */
52302
52296
  const dom$5 = new Dom();
52303
52297
 
52304
52298
  class Rte {
@@ -54163,23 +54157,51 @@ class Rte {
54163
54157
  } // var text = dom.getSelected();
54164
54158
 
54165
54159
 
54166
- this.builder.uo.saveForUndo();
54167
- let currentLineHeight = Number(window.getComputedStyle(elm).getPropertyValue('line-height').match(/\d+/)[0]);
54160
+ this.builder.uo.saveForUndo(); // let currentLineHeight = Number(window.getComputedStyle(elm).getPropertyValue('line-height').match(/\d+/)[0]);
54161
+
54162
+ let isInPx = false;
54163
+ let currentLineHeight = elm.style.lineHeight;
54164
+
54165
+ if (currentLineHeight) {
54166
+ if (currentLineHeight.indexOf('px') === -1) {
54167
+ currentLineHeight = parseFloat(currentLineHeight);
54168
+ } else {
54169
+ isInPx = true;
54170
+ }
54171
+ } else {
54172
+ isInPx = true;
54173
+ }
54174
+
54175
+ if (isInPx) {
54176
+ let fontSize = Number(window.getComputedStyle(elm).getPropertyValue('font-size').match(/\d+/)[0]);
54177
+ currentLineHeight = Number(window.getComputedStyle(elm).getPropertyValue('line-height').match(/\d+/)[0]);
54178
+
54179
+ if (fontSize > currentLineHeight) {
54180
+ currentLineHeight = fontSize / currentLineHeight;
54181
+ } else if (fontSize < currentLineHeight) {
54182
+ currentLineHeight = currentLineHeight / fontSize;
54183
+ } else {
54184
+ currentLineHeight = 1;
54185
+ }
54186
+ }
54187
+
54168
54188
  let lineheight;
54169
54189
 
54170
54190
  if (num === '+') {
54171
- lineheight = currentLineHeight + 1 + 'px';
54191
+ lineheight = currentLineHeight + 0.2;
54172
54192
  } else if (num === '-') {
54173
- lineheight = currentLineHeight - 1 + 'px';
54193
+ lineheight = currentLineHeight - 0.2;
54174
54194
  } else if (num === '') {
54175
54195
  lineheight = '';
54176
54196
  } else {
54177
54197
  lineheight = num;
54178
54198
  }
54199
+
54200
+ if (lineheight < 0.2) lineheight = 0.2; // prevent very small number
54201
+
54179
54202
  /** mod by Jack */
54180
54203
  //elm.style.lineHeight = lineheight;
54181
54204
 
54182
-
54183
54205
  dom$5.doFunction(elm, function (theEl) {
54184
54206
  theEl.style.lineHeight = lineheight;
54185
54207
  }, true); //save selection