@node-projects/web-component-designer 0.1.54 → 0.1.56
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/dist/elements/documentContainer.js +3 -3
- package/dist/elements/services/elementsService/IElementDefinition.d.ts +8 -0
- package/dist/elements/services/propertiesService/services/NativeElementsPropertiesService.js +6 -0
- package/dist/elements/services/selectionService/ISelectionService.d.ts +1 -0
- package/dist/elements/services/selectionService/SelectionService.d.ts +1 -0
- package/dist/elements/services/selectionService/SelectionService.js +20 -0
- package/dist/elements/widgets/codeView/ICodeView.d.ts +2 -1
- package/dist/elements/widgets/paletteView/paletteElements.d.ts +1 -1
- package/dist/elements/widgets/paletteView/paletteElements.js +17 -4
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { IBinding } from '../../item/IBinding.js';
|
|
2
2
|
export interface IElementDefinition {
|
|
3
3
|
tag: string;
|
|
4
|
+
/**
|
|
5
|
+
* A path or a Object URL to an image
|
|
6
|
+
*/
|
|
7
|
+
icon?: string;
|
|
8
|
+
/**
|
|
9
|
+
* A HTML String wich is used in the Palette
|
|
10
|
+
*/
|
|
11
|
+
displayHtml?: string;
|
|
4
12
|
name?: string;
|
|
5
13
|
description?: string;
|
|
6
14
|
import?: string;
|
package/dist/elements/services/propertiesService/services/NativeElementsPropertiesService.js
CHANGED
|
@@ -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;
|
|
@@ -6,5 +6,5 @@ export declare class PaletteElements extends BaseCustomWebComponentLazyAppend {
|
|
|
6
6
|
static readonly template: HTMLTemplateElement;
|
|
7
7
|
private _table;
|
|
8
8
|
constructor();
|
|
9
|
-
loadElements(serviceContainer: ServiceContainer, elementDefintions: IElementDefinition[]): void;
|
|
9
|
+
loadElements(serviceContainer: ServiceContainer, elementDefintions: IElementDefinition[], relativeImagePath?: string): void;
|
|
10
10
|
}
|
|
@@ -50,14 +50,27 @@ export class PaletteElements extends BaseCustomWebComponentLazyAppend {
|
|
|
50
50
|
super();
|
|
51
51
|
this._table = this._getDomElement('table');
|
|
52
52
|
}
|
|
53
|
-
loadElements(serviceContainer, elementDefintions) {
|
|
53
|
+
loadElements(serviceContainer, elementDefintions, relativeImagePath) {
|
|
54
54
|
for (const elementDefintion of elementDefintions) {
|
|
55
|
-
let option = document.createElement("option");
|
|
56
|
-
option.value = elementDefintion.tag;
|
|
57
55
|
const tr = document.createElement("tr");
|
|
58
56
|
const tdEl = document.createElement("td");
|
|
59
57
|
const button = document.createElement("button");
|
|
60
|
-
button.
|
|
58
|
+
button.setAttribute("part", "button");
|
|
59
|
+
if (elementDefintion.icon && !elementDefintion.displayHtml) {
|
|
60
|
+
let icon = elementDefintion.icon;
|
|
61
|
+
if (!elementDefintion.icon.startsWith('data:')) {
|
|
62
|
+
icon = relativeImagePath + elementDefintion.icon;
|
|
63
|
+
}
|
|
64
|
+
button.innerHTML =
|
|
65
|
+
'<table><tr>' +
|
|
66
|
+
'<td align="left" valign="middle" style="width:20px;"><img style="width:16px;height:16px" src="' + icon + '"></td>' +
|
|
67
|
+
'<td align="left" >' + elementDefintion.tag + '</td>' +
|
|
68
|
+
'</tr></table>\n';
|
|
69
|
+
}
|
|
70
|
+
else if (elementDefintion.displayHtml)
|
|
71
|
+
button.innerHTML = elementDefintion.displayHtml;
|
|
72
|
+
else
|
|
73
|
+
button.innerText = elementDefintion.name ? elementDefintion.name : elementDefintion.tag;
|
|
61
74
|
button.draggable = true;
|
|
62
75
|
button.ondragstart = (e) => {
|
|
63
76
|
e.dataTransfer.setData(dragDropFormatNameElementDefinition, JSON.stringify(elementDefintion));
|