@node-projects/web-component-designer 0.1.54 → 0.1.55

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.
@@ -131,7 +131,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
131
131
  if (this._tabControl.selectedIndex === 2) {
132
132
  let primarySelection = this.instanceServiceContainer.selectionService.primarySelection;
133
133
  this._content = this.designerView.getHTML();
134
- this.codeView.update(this._content);
134
+ this.codeView.update(this._content, this.designerView.instanceServiceContainer);
135
135
  if (primarySelection) {
136
136
  if (this.designerView.instanceServiceContainer.designItemDocumentPositionService) {
137
137
  this._selectionPosition = this.designerView.instanceServiceContainer.designItemDocumentPositionService.getPosition(primarySelection);
@@ -177,7 +177,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
177
177
  if (this._tabControl.selectedIndex === 0)
178
178
  this.designerView.parseHTML(this._content, this._firstLoad);
179
179
  else if (this._tabControl.selectedIndex === 1)
180
- this.codeView.update(this._content);
180
+ this.codeView.update(this._content, this.designerView.instanceServiceContainer);
181
181
  else if (this._tabControl.selectedIndex === 2) {
182
182
  }
183
183
  else if (this._tabControl.selectedIndex === 3)
@@ -213,7 +213,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
213
213
  if (i.newIndex === 0 || i.newIndex === 2)
214
214
  this.designerView.parseHTML(this._content, this._firstLoad);
215
215
  if (i.newIndex === 1 || i.newIndex === 2) {
216
- this.codeView.update(this._content);
216
+ this.codeView.update(this._content, this.designerView.instanceServiceContainer);
217
217
  if (this._selectionPosition) {
218
218
  this.codeView.setSelection(this._selectionPosition);
219
219
  this._selectionPosition = null;
@@ -54,6 +54,12 @@ export class NativeElementsPropertiesService extends CommonPropertiesService {
54
54
  }
55
55
  ];
56
56
  textareaProperties = [
57
+ {
58
+ name: "value",
59
+ type: "string",
60
+ service: this,
61
+ propertyType: PropertyType.property
62
+ },
57
63
  {
58
64
  name: "placeholder",
59
65
  type: "string",
@@ -5,6 +5,7 @@ export interface ISelectionService {
5
5
  primarySelection: IDesignItem;
6
6
  selectedElements: IDesignItem[];
7
7
  setSelectedElements(designItems: IDesignItem[]): void;
8
+ setSelectionByTextRange(positionStart: number, positionEnd: number): any;
8
9
  clearSelectedElements(): void;
9
10
  isSelected(designItem: IDesignItem): boolean;
10
11
  readonly onSelectionChanged: TypedEvent<ISelectionChangedEvent>;
@@ -10,6 +10,7 @@ export declare class SelectionService implements ISelectionService {
10
10
  _undoSelectionChanges: boolean;
11
11
  constructor(designerCanvas: IDesignerCanvas, undoSelectionChanges: boolean);
12
12
  setSelectedElements(designItems: IDesignItem[]): void;
13
+ setSelectionByTextRange(positionStart: number, positionEnd: number): void;
13
14
  _withoutUndoSetSelectedElements(designItems: IDesignItem[]): void;
14
15
  clearSelectedElements(): void;
15
16
  isSelected(designItem: IDesignItem): boolean;
@@ -1,5 +1,21 @@
1
1
  import { TypedEvent } from '@node-projects/base-custom-webcomponent';
2
2
  import { SelectionChangedAction } from '../undoService/transactionItems/SelectionChangedAction.js';
3
+ function findDesignItem(designItem, position) {
4
+ let usedItem = null;
5
+ if (designItem.hasChildren) {
6
+ for (let d of designItem.children()) {
7
+ const nodePosition = designItem.instanceServiceContainer.designItemDocumentPositionService.getPosition(d);
8
+ if (nodePosition) {
9
+ if (nodePosition.start <= position)
10
+ usedItem = d;
11
+ }
12
+ }
13
+ }
14
+ if (usedItem) {
15
+ return findDesignItem(usedItem, position);
16
+ }
17
+ return designItem;
18
+ }
3
19
  export class SelectionService {
4
20
  primarySelection;
5
21
  selectedElements = [];
@@ -20,6 +36,10 @@ export class SelectionService {
20
36
  }
21
37
  }
22
38
  }
39
+ setSelectionByTextRange(positionStart, positionEnd) {
40
+ const item = findDesignItem(this._designerCanvas.rootDesignItem, positionStart);
41
+ this.setSelectedElements([item]);
42
+ }
23
43
  _withoutUndoSetSelectedElements(designItems) {
24
44
  let oldSelectedElements = this.selectedElements;
25
45
  if (!designItems) {
@@ -1,9 +1,10 @@
1
1
  import { IUiCommandHandler } from '../../../commandHandling/IUiCommandHandler.js';
2
2
  import { IDisposable } from '../../../interfaces/IDisposable.js';
3
+ import { InstanceServiceContainer } from '../../services/InstanceServiceContainer.js';
3
4
  import { IStringPosition } from '../../services/htmlWriterService/IStringPosition.js';
4
5
  import { TypedEvent } from '@node-projects/base-custom-webcomponent';
5
6
  export interface ICodeView extends IUiCommandHandler, IDisposable, HTMLElement {
6
- update(code: string): any;
7
+ update(code: string, instanceServiceContainer?: InstanceServiceContainer): any;
7
8
  getText(): any;
8
9
  setSelection(position: IStringPosition): any;
9
10
  focusEditor(): any;
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.1.54",
4
+ "version": "0.1.55",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",