@node-projects/web-component-designer 0.0.192 → 0.0.194

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/README.md CHANGED
@@ -72,12 +72,11 @@ We have 2 tree components. One independent and one feature rich which uses Fancy
72
72
 
73
73
  ## DragDrop
74
74
 
75
- If you'd like to use the designer on mobile, you need the mobile-drag-drop npm library and include our polyfill.
75
+ If you'd like to use the designer on mobile, you need the mobile-drag-drop npm library.
76
76
  Your index.html should be extended as follows:
77
77
 
78
78
  <link rel="stylesheet" href="/node_modules/mobile-drag-drop/default.css">
79
79
  <script src="/node_modules/mobile-drag-drop/index.js"></script>
80
- <script src="/node_modules/@node-projects/web-component-designer/dist/polyfill/mobileDragDrop.js"></script>
81
80
 
82
81
  ## Copyright notice
83
82
 
@@ -24,7 +24,7 @@ export function convertCssUnitToPixel(cssValue, target, percentTarget) {
24
24
  'rlh': value => value * parseFloat(getComputedStyle(document.documentElement).lineHeight),
25
25
  '%': value => value / 100 * (percentTarget == 'height' ? target.getBoundingClientRect().height : target.getBoundingClientRect().width),
26
26
  /* todo
27
- //find parent with computed style where contaner-type is inline-size or size (regarding to query type)
27
+ //find parent with computed style where container-type is inline-size or size (regarding to query type)
28
28
  //use this size for calculation
29
29
  'cqw':
30
30
  'cqh':
@@ -11,9 +11,6 @@ export declare class ContextMenu {
11
11
  menu: IContextMenuItem[];
12
12
  options: IContextMenuOptions;
13
13
  private num;
14
- private _windowDownBound;
15
- private _windowKeyUpBound;
16
- private _windowResizeBound;
17
14
  private _menuElement;
18
15
  constructor(menu: IContextMenuItem[], options?: IContextMenuOptions);
19
16
  reload(): void;
@@ -1,5 +1,4 @@
1
1
  import { css } from "@node-projects/base-custom-webcomponent";
2
- import { sleep } from '../Helper.js';
3
2
  export class ContextMenu {
4
3
  static _contextMenuCss = css `
5
4
  .context_menu {
@@ -114,18 +113,15 @@ export class ContextMenu {
114
113
  menu;
115
114
  options;
116
115
  num;
117
- _windowDownBound;
118
- _windowKeyUpBound;
119
- _windowResizeBound;
120
116
  _menuElement;
121
117
  constructor(menu, options) {
122
118
  this.num = ContextMenu.count++;
123
119
  this.menu = menu;
124
120
  this.options = options;
125
121
  this.reload();
126
- this._windowDownBound = this._windowDown.bind(this);
127
- this._windowKeyUpBound = this._windowKeyUp.bind(this);
128
- this._windowResizeBound = this._windowResize.bind(this);
122
+ this._windowDown = this._windowDown.bind(this);
123
+ this._windowKeyUp = this._windowKeyUp.bind(this);
124
+ this._windowResize = this._windowResize.bind(this);
129
125
  }
130
126
  reload() {
131
127
  let shadowRoot = this.options?.shadowRoot ?? document;
@@ -241,10 +237,10 @@ export class ContextMenu {
241
237
  }
242
238
  menu.classList.add("context_menu_display");
243
239
  event.preventDefault();
244
- window.addEventListener("keyup", this._windowKeyUpBound);
245
- window.addEventListener("mousedown", this._windowDownBound);
246
- window.addEventListener("resize", this._windowResizeBound);
247
- sleep(100).then(() => window.addEventListener("contextmenu", this._windowDownBound));
240
+ window.addEventListener("keyup", this._windowKeyUp);
241
+ window.addEventListener("mousedown", this._windowDown);
242
+ window.addEventListener("resize", this._windowResize);
243
+ setTimeout(() => window.addEventListener("contextmenu", this._windowDown), 100);
248
244
  }
249
245
  _windowResize() {
250
246
  this.close();
@@ -266,10 +262,10 @@ export class ContextMenu {
266
262
  }
267
263
  close() {
268
264
  this._menuElement.remove();
269
- window.removeEventListener("keyup", this._windowKeyUpBound);
270
- window.removeEventListener("mousedown", this._windowDownBound);
271
- window.removeEventListener("contextmenu", this._windowDownBound);
272
- window.removeEventListener("resize", this._windowResizeBound);
265
+ window.removeEventListener("keyup", this._windowKeyUp);
266
+ window.removeEventListener("mousedown", this._windowDown);
267
+ window.removeEventListener("contextmenu", this._windowDown);
268
+ window.removeEventListener("resize", this._windowResize);
273
269
  }
274
270
  }
275
271
  class ContextUtil {
@@ -3,6 +3,7 @@ import { RefreshMode } from '../IPropertiesService.js';
3
3
  import { CommonPropertiesService } from './CommonPropertiesService.js';
4
4
  import { ValueType } from '../ValueType.js';
5
5
  import { NodeType } from '../../../item/NodeType.js';
6
+ //TODO: remove this code when import asserts are supported
6
7
  let cssProperties;
7
8
  //@ts-ignore
8
9
  if (window.importShim) {
@@ -3,6 +3,7 @@ import { PropertyType } from '../PropertyType.js';
3
3
  import { CommonPropertiesService } from './CommonPropertiesService.js';
4
4
  import { RefreshMode } from '../IPropertiesService.js';
5
5
  import { PropertiesHelper } from './PropertiesHelper.js';
6
+ //TODO: remove this code when import asserts are supported
6
7
  let cssProperties;
7
8
  //@ts-ignore
8
9
  if (window.importShim) {
@@ -1007,26 +1007,27 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
1007
1007
  return style;
1008
1008
  }
1009
1009
  traverseAndCollectRules(ruleContainer) {
1010
- let ruleCollector = [];
1010
+ let t = '';
1011
1011
  for (let rule of ruleContainer.cssRules) {
1012
1012
  if ((rule instanceof CSSContainerRule
1013
1013
  || rule instanceof CSSSupportsRule
1014
1014
  || rule instanceof CSSMediaRule)
1015
1015
  && rule.cssRules) {
1016
- return rule.cssText.split(rule.conditionText)[0] + rule.conditionText + " { " + this.traverseAndCollectRules(rule) + " }";
1016
+ t += rule.cssText.split(rule.conditionText)[0] + rule.conditionText + " { " + this.traverseAndCollectRules(rule) + " }";
1017
1017
  }
1018
1018
  if (rule instanceof CSSStyleRule) {
1019
1019
  let parts = rule.selectorText.split(',');
1020
- let t = '';
1020
+ let sel = "";
1021
1021
  for (let p of parts) {
1022
1022
  if (p.includes(this.cssprefixConstant)) {
1023
- t += p;
1023
+ sel += p;
1024
1024
  continue;
1025
1025
  }
1026
- if (t)
1027
- t += ',';
1028
- t += this.cssprefixConstant + p;
1026
+ if (sel)
1027
+ sel += ',';
1028
+ sel += this.cssprefixConstant + p.trimStart();
1029
1029
  }
1030
+ t += sel;
1030
1031
  let cssText = rule.style.cssText;
1031
1032
  //bugfix for chrome issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1394353
1032
1033
  if (rule.styleMap && rule.styleMap.get('grid-template') && rule.styleMap.get('grid-template').toString().includes('repeat(')) {
@@ -1036,10 +1037,10 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
1036
1037
  cssText += e[0] + ':' + e[1].toString() + ';';
1037
1038
  }
1038
1039
  }
1039
- ruleCollector.push(t + '{' + cssText + '}');
1040
+ t += '{' + cssText + '}';
1040
1041
  }
1041
1042
  }
1042
- return ruleCollector.join(' ');
1043
+ return t;
1043
1044
  }
1044
1045
  }
1045
1046
  customElements.define('node-projects-designer-canvas', DesignerCanvas);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "A UI designer for Polymer apps",
3
3
  "name": "@node-projects/web-component-designer",
4
- "version": "0.0.192",
4
+ "version": "0.0.194",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",