@node-projects/web-component-designer 0.1.53 → 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;
@@ -84,6 +84,7 @@ import { MultipleSelectionRectExtensionProvider } from '../widgets/designerView/
84
84
  import { DragDropService } from './dragDropService/DragDropService.js';
85
85
  import { EventsService } from './eventsService/EventsService.js';
86
86
  import { SimpleDemoProviderService } from './demoProviderService/SimpleDemoProviderService.js';
87
+ import { DrawElementTool } from '../widgets/designerView/tools/DrawElementTool.js';
87
88
  export function createDefaultServiceContainer() {
88
89
  let serviceContainer = new ServiceContainer();
89
90
  let defaultPlacementService = new DefaultPlacementService();
@@ -175,6 +176,7 @@ export function createDefaultServiceContainer() {
175
176
  serviceContainer.designerTools.set(NamedTools.MagicWandSelector, new MagicWandSelectorTool());
176
177
  serviceContainer.designerTools.set(NamedTools.PickColor, new PickColorTool());
177
178
  serviceContainer.designerTools.set(NamedTools.Text, new TextTool());
179
+ serviceContainer.designerTools.set(NamedTools.DrawElementTool, DrawElementTool);
178
180
  serviceContainer.designerPointerExtensions.push(
179
181
  //new CursorLinePointerExtensionProvider()
180
182
  );
@@ -94,7 +94,7 @@ export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMa
94
94
  readonly options: {
95
95
  zoomDesignerBackground: boolean;
96
96
  };
97
- readonly designerTools: Map<string | NamedTools, ITool>;
97
+ readonly designerTools: Map<string | NamedTools, ITool | (new (IElementDefinition: any) => ITool)>;
98
98
  get bindingService(): IBindingService;
99
99
  get bindableObjectsServices(): IBindableObjectsService[];
100
100
  get bindableObjectDragDropService(): IBindableObjectDragDropService;
@@ -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;
@@ -11,5 +11,5 @@ export declare enum NamedTools {
11
11
  RectangleSelector = "RectangleSelector",
12
12
  PickColor = "PickColor",
13
13
  Text = "Text",
14
- TextBoc = "TextBoc"
14
+ DrawElementTool = "DrawElementTool"
15
15
  }
@@ -12,5 +12,5 @@ export var NamedTools;
12
12
  NamedTools["RectangleSelector"] = "RectangleSelector";
13
13
  NamedTools["PickColor"] = "PickColor";
14
14
  NamedTools["Text"] = "Text";
15
- NamedTools["TextBoc"] = "TextBoc";
15
+ NamedTools["DrawElementTool"] = "DrawElementTool";
16
16
  })(NamedTools || (NamedTools = {}));
@@ -1,6 +1,6 @@
1
1
  import { dragDropFormatNameElementDefinition } from '../../../Constants.js';
2
2
  import { BaseCustomWebComponentLazyAppend, css, html } from '@node-projects/base-custom-webcomponent';
3
- import { DrawElementTool } from '../designerView/tools/DrawElementTool.js';
3
+ import { NamedTools } from '../designerView/tools/NamedTools.js';
4
4
  export class PaletteElements extends BaseCustomWebComponentLazyAppend {
5
5
  static style = css `
6
6
  :host {
@@ -125,7 +125,10 @@ export class PaletteElements extends BaseCustomWebComponentLazyAppend {
125
125
  e.preventDefault();
126
126
  };
127
127
  button.onclick = (x) => {
128
- serviceContainer.globalContext.tool = new DrawElementTool(elementDefintion);
128
+ let tool = serviceContainer.designerTools.get(elementDefintion.tool ?? NamedTools.DrawElementTool);
129
+ if (typeof tool == 'function')
130
+ tool = new tool(elementDefintion);
131
+ serviceContainer.globalContext.tool = tool;
129
132
  };
130
133
  tdEl.appendChild(button);
131
134
  tr.appendChild(tdEl);
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.53",
4
+ "version": "0.1.55",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",