@node-projects/web-component-designer 0.0.242 → 0.0.244
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/controls/SimpleSplitView.js +1 -0
- package/dist/elements/documentContainer.d.ts +1 -1
- package/dist/elements/item/DesignItem.d.ts +1 -1
- package/dist/elements/item/DesignItem.js +9 -5
- package/dist/elements/services/ServiceContainer.d.ts +3 -0
- package/dist/elements/services/ServiceContainer.js +3 -0
- package/dist/elements/services/designItemService/DesignItemService.d.ts +7 -0
- package/dist/elements/services/designItemService/DesignItemService.js +6 -0
- package/dist/elements/services/designItemService/IDesignItemService.d.ts +6 -0
- package/dist/elements/services/designItemService/IDesignItemService.js +1 -0
- package/dist/elements/services/dragDropService/DragDropService.js +1 -1
- package/dist/elements/services/htmlParserService/LitElementParserService.js +3 -3
- package/dist/elements/services/htmlParserService/NodeHtmlParserService.js +3 -3
- package/dist/elements/services/stylesheetService/AbstractStylesheetService.d.ts +2 -1
- package/dist/elements/services/stylesheetService/AbstractStylesheetService.js +1 -8
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.d.ts +2 -0
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.js +16 -1
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.d.ts +2 -0
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.js +7 -1
- package/dist/elements/services/stylesheetService/IStylesheetService.d.ts +2 -1
- package/dist/elements/services/undoService/transactionItems/StylesheetChangedAction.js +2 -2
- package/dist/elements/widgets/codeView/code-view-code-mirror copy.d.ts +25 -0
- package/dist/elements/widgets/codeView/code-view-code-mirror copy.js +106 -0
- package/dist/elements/widgets/codeView/code-view-code-mirror-6.d.ts +25 -0
- package/dist/elements/widgets/codeView/code-view-code-mirror-6.js +102 -0
- package/dist/elements/widgets/debugView/debug-view.d.ts +5 -2
- package/dist/elements/widgets/debugView/debug-view.js +92 -23
- package/dist/elements/widgets/designerView/designerCanvas.js +4 -4
- package/dist/elements/widgets/designerView/extensions/ExtensionManager.js +2 -2
- package/dist/elements/widgets/designerView/extensions/contextMenu/ItemsBelowContextMenu.js +1 -1
- package/dist/elements/widgets/designerView/tools/MagicWandSelectorTool.js +1 -1
- package/dist/elements/widgets/designerView/tools/PointerTool.js +4 -4
- package/dist/elements/widgets/designerView/tools/RectangleSelectorTool.js +1 -1
- package/dist/elements/widgets/treeView/treeView.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/package.json +7 -7
|
@@ -9,6 +9,7 @@ export class SimpleSplitView extends BaseCustomWebComponentConstructorAppend {
|
|
|
9
9
|
height: 100%;
|
|
10
10
|
width: 100%;
|
|
11
11
|
grid-template-rows: calc(var(--split) * 1%) 5px calc(((100 - var(--split)) * 1%) - 5px);
|
|
12
|
+
grid-template-columns: 100%;
|
|
12
13
|
display: grid;
|
|
13
14
|
align-items: center;
|
|
14
15
|
}
|
|
@@ -26,7 +26,7 @@ export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend
|
|
|
26
26
|
name: string;
|
|
27
27
|
newStyle: string;
|
|
28
28
|
oldStyle: string;
|
|
29
|
-
changeSource: 'extern' | 'styleupdate';
|
|
29
|
+
changeSource: 'extern' | 'styleupdate' | 'undo';
|
|
30
30
|
}>;
|
|
31
31
|
onContentChanged: TypedEvent<void>;
|
|
32
32
|
private _serviceContainer;
|
|
@@ -71,7 +71,7 @@ export declare class DesignItem implements IDesignItem {
|
|
|
71
71
|
constructor(node: Node, parsedNode: any, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer);
|
|
72
72
|
openGroup(title: string): ChangeGroup;
|
|
73
73
|
getOrCreateDesignItem(node: Node): IDesignItem;
|
|
74
|
-
static GetOrCreateDesignItem(node: Node, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): IDesignItem;
|
|
74
|
+
static GetOrCreateDesignItem(node: Node, parsedNode: any, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): IDesignItem;
|
|
75
75
|
static GetDesignItem(node: Node): IDesignItem;
|
|
76
76
|
setStyle(name: string, value?: string | null, important?: boolean): void;
|
|
77
77
|
removeStyle(name: string): void;
|
|
@@ -215,7 +215,7 @@ export class DesignItem {
|
|
|
215
215
|
const grp = this.openGroup('set content');
|
|
216
216
|
this.clearChildren();
|
|
217
217
|
let t = document.createTextNode(value);
|
|
218
|
-
let di = DesignItem.GetOrCreateDesignItem(t, this.serviceContainer, this.instanceServiceContainer);
|
|
218
|
+
let di = DesignItem.GetOrCreateDesignItem(t, t, this.serviceContainer, this.instanceServiceContainer);
|
|
219
219
|
if (this.nodeType == NodeType.TextNode) {
|
|
220
220
|
const idx = this.parent.indexOf(this);
|
|
221
221
|
const parent = this.parent;
|
|
@@ -236,7 +236,7 @@ export class DesignItem {
|
|
|
236
236
|
range.selectNode(document.body);
|
|
237
237
|
const fragment = range.createContextualFragment(value);
|
|
238
238
|
for (const n of fragment.childNodes) {
|
|
239
|
-
let di = DesignItem.GetOrCreateDesignItem(n, this.serviceContainer, this.instanceServiceContainer);
|
|
239
|
+
let di = DesignItem.GetOrCreateDesignItem(n, n, this.serviceContainer, this.instanceServiceContainer);
|
|
240
240
|
this.insertChild(di);
|
|
241
241
|
}
|
|
242
242
|
grp.commit();
|
|
@@ -324,14 +324,18 @@ export class DesignItem {
|
|
|
324
324
|
return this.instanceServiceContainer.undoService.openGroup(title);
|
|
325
325
|
}
|
|
326
326
|
getOrCreateDesignItem(node) {
|
|
327
|
-
return DesignItem.GetOrCreateDesignItem(node, this.serviceContainer, this.instanceServiceContainer);
|
|
327
|
+
return DesignItem.GetOrCreateDesignItem(node, node, this.serviceContainer, this.instanceServiceContainer);
|
|
328
328
|
}
|
|
329
|
-
static GetOrCreateDesignItem(node, serviceContainer, instanceServiceContainer) {
|
|
329
|
+
static GetOrCreateDesignItem(node, parsedNode, serviceContainer, instanceServiceContainer) {
|
|
330
330
|
if (!node)
|
|
331
331
|
return null;
|
|
332
332
|
let designItem = DesignItem._designItemMap.get(node);
|
|
333
333
|
if (!designItem) {
|
|
334
|
-
|
|
334
|
+
let dis = serviceContainer.designItemService;
|
|
335
|
+
if (dis)
|
|
336
|
+
designItem = dis.createDesignItem(node, parsedNode, serviceContainer, instanceServiceContainer);
|
|
337
|
+
else
|
|
338
|
+
designItem = new DesignItem(node, parsedNode, serviceContainer, instanceServiceContainer);
|
|
335
339
|
}
|
|
336
340
|
return designItem;
|
|
337
341
|
}
|
|
@@ -40,6 +40,7 @@ import { IStylesheetService } from './stylesheetService/IStylesheetService.js';
|
|
|
40
40
|
import { IDesignerCanvas } from '../widgets/designerView/IDesignerCanvas.js';
|
|
41
41
|
import { IDesignItemDocumentPositionService } from './designItemDocumentPositionService/IDesignItemDocumentPositionService.js';
|
|
42
42
|
import { IDragDropService } from './dragDropService/IDragDropService.js';
|
|
43
|
+
import { IDesignItemService } from './designItemService/IDesignItemService.js';
|
|
43
44
|
interface ServiceNameMap {
|
|
44
45
|
"propertyService": IPropertiesService;
|
|
45
46
|
"containerService": IPlacementService;
|
|
@@ -61,6 +62,7 @@ interface ServiceNameMap {
|
|
|
61
62
|
"elementInteractionService": IElementInteractionService;
|
|
62
63
|
"propertyGroupsService": IPropertyTabsService;
|
|
63
64
|
"dragDropService": IDragDropService;
|
|
65
|
+
"designItemService": IDesignItemService;
|
|
64
66
|
"undoService": (designerCanvas: IDesignerCanvas) => IUndoService;
|
|
65
67
|
"selectionService": (designerCanvas: IDesignerCanvas) => ISelectionService;
|
|
66
68
|
"contentService": (designerCanvas: IDesignerCanvas) => IContentService;
|
|
@@ -104,5 +106,6 @@ export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMa
|
|
|
104
106
|
get copyPasteService(): ICopyPasteService;
|
|
105
107
|
get modelCommandService(): IModelCommandService;
|
|
106
108
|
get demoProviderService(): IDemoProviderService;
|
|
109
|
+
get designItemService(): IDesignItemService;
|
|
107
110
|
}
|
|
108
111
|
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
2
|
+
import { InstanceServiceContainer } from "../InstanceServiceContainer.js";
|
|
3
|
+
import { ServiceContainer } from "../ServiceContainer.js";
|
|
4
|
+
import { IDesignItemService } from "./IDesignItemService.js";
|
|
5
|
+
export declare class DesignItemService implements IDesignItemService {
|
|
6
|
+
createDesignItem(node: Node, parsedNode: any, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): IDesignItem;
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
2
|
+
import { InstanceServiceContainer } from "../InstanceServiceContainer.js";
|
|
3
|
+
import { ServiceContainer } from "../ServiceContainer.js";
|
|
4
|
+
export interface IDesignItemService {
|
|
5
|
+
createDesignItem(node: Node, parsedNode: any, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): IDesignItem;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -65,7 +65,7 @@ export class DragDropService {
|
|
|
65
65
|
//check we don't try to move a item over one of its children..
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
68
|
-
newContainerElementDesignItem = DesignItem.GetOrCreateDesignItem(e, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
68
|
+
newContainerElementDesignItem = DesignItem.GetOrCreateDesignItem(e, e, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
69
69
|
const containerStyle = getComputedStyle(newContainerElementDesignItem.element);
|
|
70
70
|
newContainerService = designerCanvas.serviceContainer.getLastServiceWhere('containerService', x => x.serviceForContainer(newContainerElementDesignItem, containerStyle));
|
|
71
71
|
if (newContainerService) {
|
|
@@ -47,7 +47,7 @@ export class LitElementParserService {
|
|
|
47
47
|
element = document.createElement(item.rawTagName);
|
|
48
48
|
manualCreatedElement = true;
|
|
49
49
|
}
|
|
50
|
-
designItem =
|
|
50
|
+
designItem = DesignItem.GetOrCreateDesignItem(element, item, serviceContainer, instanceServiceContainer);
|
|
51
51
|
let style = '';
|
|
52
52
|
let attr = item.attributes;
|
|
53
53
|
for (let a in attr) {
|
|
@@ -80,11 +80,11 @@ export class LitElementParserService {
|
|
|
80
80
|
else if (item.nodeType == 3) {
|
|
81
81
|
this._parseDiv.innerHTML = item.rawText;
|
|
82
82
|
let element = this._parseDiv.childNodes[0];
|
|
83
|
-
designItem =
|
|
83
|
+
designItem = DesignItem.GetOrCreateDesignItem(element, item, serviceContainer, instanceServiceContainer);
|
|
84
84
|
}
|
|
85
85
|
else if (item.nodeType == 8) {
|
|
86
86
|
let element = document.createComment(item.rawText);
|
|
87
|
-
designItem =
|
|
87
|
+
designItem = DesignItem.GetOrCreateDesignItem(element, item, serviceContainer, instanceServiceContainer);
|
|
88
88
|
}
|
|
89
89
|
return designItem;
|
|
90
90
|
}
|
|
@@ -37,7 +37,7 @@ export class NodeHtmlParserService {
|
|
|
37
37
|
element = document.createElement(item.rawTagName);
|
|
38
38
|
manualCreatedElement = true;
|
|
39
39
|
}
|
|
40
|
-
designItem =
|
|
40
|
+
designItem = DesignItem.GetOrCreateDesignItem(element, item, serviceContainer, instanceServiceContainer);
|
|
41
41
|
if (!snippet && instanceServiceContainer.designItemDocumentPositionService)
|
|
42
42
|
instanceServiceContainer.designItemDocumentPositionService.setPosition(designItem, { start: item.range[0], length: item.range[1] - item.range[0] });
|
|
43
43
|
let style = '';
|
|
@@ -74,13 +74,13 @@ export class NodeHtmlParserService {
|
|
|
74
74
|
else if (item.nodeType == 3) {
|
|
75
75
|
this._parseDiv.innerHTML = item.rawText;
|
|
76
76
|
let element = this._parseDiv.childNodes[0];
|
|
77
|
-
designItem =
|
|
77
|
+
designItem = DesignItem.GetOrCreateDesignItem(element, item, serviceContainer, instanceServiceContainer);
|
|
78
78
|
if (!snippet && instanceServiceContainer.designItemDocumentPositionService)
|
|
79
79
|
instanceServiceContainer.designItemDocumentPositionService.setPosition(designItem, { start: item.range[0], length: item.range[1] - item.range[0] });
|
|
80
80
|
}
|
|
81
81
|
else if (item.nodeType == 8) {
|
|
82
82
|
let element = document.createComment(item.rawText);
|
|
83
|
-
designItem =
|
|
83
|
+
designItem = DesignItem.GetOrCreateDesignItem(element, item, serviceContainer, instanceServiceContainer);
|
|
84
84
|
if (!snippet && instanceServiceContainer.designItemDocumentPositionService)
|
|
85
85
|
instanceServiceContainer.designItemDocumentPositionService.setPosition(designItem, { start: item.range[0], length: item.range[1] - item.range[0] });
|
|
86
86
|
}
|
|
@@ -32,12 +32,13 @@ export declare abstract class AbstractStylesheetService implements IStylesheetSe
|
|
|
32
32
|
abstract insertDeclarationIntoRule(rule: IStyleRule, property: string, value: string, important: boolean): boolean;
|
|
33
33
|
abstract removeDeclarationFromRule(rule: IStyleRule, property: string): boolean;
|
|
34
34
|
abstract updateCompleteStylesheet(name: string, newStyle: string): any;
|
|
35
|
+
abstract updateCompleteStylesheetWithoutUndo(name: string, newStyle: string): any;
|
|
35
36
|
abstract updateDeclarationValueWithoutUndo(declaration: IStyleDeclaration, value: string, important: boolean): any;
|
|
36
37
|
stylesheetChanged: TypedEvent<{
|
|
37
38
|
name: string;
|
|
38
39
|
newStyle: string;
|
|
39
40
|
oldStyle: string;
|
|
40
|
-
changeSource: 'extern' | 'styleupdate';
|
|
41
|
+
changeSource: 'extern' | 'styleupdate' | 'undo';
|
|
41
42
|
}>;
|
|
42
43
|
stylesheetsChanged: TypedEvent<void>;
|
|
43
44
|
protected elementMatchesASelector(designItem: IDesignItem, selectors: string[]): boolean;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
2
2
|
import { DesignerCanvas } from '../../widgets/designerView/designerCanvas.js';
|
|
3
|
-
import { StylesheetStyleChangeAction } from "../undoService/transactionItems/StylesheetStyleChangeAction.js";
|
|
4
3
|
export class AbstractStylesheetService {
|
|
5
4
|
_stylesheets = new Map();
|
|
6
5
|
_documentStylesheets = new Map();
|
|
@@ -74,13 +73,7 @@ export class AbstractStylesheetService {
|
|
|
74
73
|
return stylesheets;
|
|
75
74
|
}
|
|
76
75
|
updateDeclarationValue(declaration, value, important) {
|
|
77
|
-
|
|
78
|
-
const action = new StylesheetStyleChangeAction(this, declaration, value, declaration.value);
|
|
79
|
-
this._instanceServiceContainer.undoService.execute(action);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
this.updateDeclarationValueWithoutUndo(declaration, value, important);
|
|
83
|
-
}
|
|
76
|
+
this.updateDeclarationValueWithoutUndo(declaration, value, important);
|
|
84
77
|
}
|
|
85
78
|
stylesheetChanged = new TypedEvent();
|
|
86
79
|
stylesheetsChanged = new TypedEvent();
|
|
@@ -36,5 +36,7 @@ export declare class CssToolsStylesheetService extends AbstractStylesheetService
|
|
|
36
36
|
removeDeclarationFromRule(rule: IRuleWithAST, property: string): boolean;
|
|
37
37
|
private updateStylesheet;
|
|
38
38
|
updateCompleteStylesheet(name: string, newStyle: string): void;
|
|
39
|
+
updateCompleteStylesheetWithoutUndo(name: string, newStyle: string, noUndo?: boolean): void;
|
|
40
|
+
private updateCompleteStylesheetInternal;
|
|
39
41
|
}
|
|
40
42
|
export {};
|
|
@@ -57,6 +57,15 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
|
57
57
|
declaration.ast.value = important ? value + ' !important' : value;
|
|
58
58
|
let ss = this._allStylesheets.get(declaration.parent.stylesheetName);
|
|
59
59
|
this.updateStylesheet(ss);
|
|
60
|
+
/*
|
|
61
|
+
declaration.ast.value = important ? value + ' !important' : value;
|
|
62
|
+
let ss = declaration.ast;
|
|
63
|
+
while (ss?.parent)
|
|
64
|
+
ss = ss?.parent;
|
|
65
|
+
let obj = { ast: ss, stylesheet: declaration.stylesheet };
|
|
66
|
+
this._allStylesheets.set(declaration.parent.stylesheetName, obj)
|
|
67
|
+
this.updateStylesheet(obj);
|
|
68
|
+
*/
|
|
60
69
|
}
|
|
61
70
|
insertDeclarationIntoRule(rule, property, value, important) {
|
|
62
71
|
rule.ast.declarations.push({
|
|
@@ -85,6 +94,12 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
|
85
94
|
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
86
95
|
}
|
|
87
96
|
updateCompleteStylesheet(name, newStyle) {
|
|
97
|
+
this.updateCompleteStylesheetInternal(name, newStyle, 'styleupdate');
|
|
98
|
+
}
|
|
99
|
+
updateCompleteStylesheetWithoutUndo(name, newStyle, noUndo = false) {
|
|
100
|
+
this.updateCompleteStylesheetInternal(name, newStyle, 'undo');
|
|
101
|
+
}
|
|
102
|
+
updateCompleteStylesheetInternal(name, newStyle, changeSource) {
|
|
88
103
|
const ss = this._allStylesheets.get(name);
|
|
89
104
|
if (ss.stylesheet.content != newStyle) {
|
|
90
105
|
const old = ss.stylesheet.content;
|
|
@@ -93,7 +108,7 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
|
93
108
|
ss.stylesheet.designItem.content = ss.stylesheet.content;
|
|
94
109
|
}
|
|
95
110
|
else
|
|
96
|
-
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource
|
|
111
|
+
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource });
|
|
97
112
|
}
|
|
98
113
|
}
|
|
99
114
|
}
|
|
@@ -45,6 +45,8 @@ export declare class CssTreeStylesheetService extends AbstractStylesheetService
|
|
|
45
45
|
insertDeclarationIntoRule(rule: IRuleWithAST, property: string, value: string, important: boolean): boolean;
|
|
46
46
|
removeDeclarationFromRule(rule: IRuleWithAST, property: string): boolean;
|
|
47
47
|
updateCompleteStylesheet(name: string, newStyle: string): void;
|
|
48
|
+
updateCompleteStylesheetWithoutUndo(name: string, newStyle: string, noUndo?: boolean): void;
|
|
49
|
+
private updateCompleteStylesheetInternal;
|
|
48
50
|
private rulesFromAST;
|
|
49
51
|
private astHasChildren;
|
|
50
52
|
private buildSelectorString;
|
|
@@ -113,6 +113,12 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
|
113
113
|
return true;
|
|
114
114
|
}
|
|
115
115
|
updateCompleteStylesheet(name, newStyle) {
|
|
116
|
+
this.updateCompleteStylesheetInternal(name, newStyle, 'styleupdate');
|
|
117
|
+
}
|
|
118
|
+
updateCompleteStylesheetWithoutUndo(name, newStyle, noUndo = false) {
|
|
119
|
+
this.updateCompleteStylesheetInternal(name, newStyle, 'undo');
|
|
120
|
+
}
|
|
121
|
+
updateCompleteStylesheetInternal(name, newStyle, changeSource) {
|
|
116
122
|
const ss = this._allStylesheets.get(name);
|
|
117
123
|
if (ss.stylesheet.content != newStyle) {
|
|
118
124
|
const old = ss.stylesheet.content;
|
|
@@ -121,7 +127,7 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
|
121
127
|
ss.stylesheet.designItem.content = ss.stylesheet.content;
|
|
122
128
|
}
|
|
123
129
|
else
|
|
124
|
-
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource
|
|
130
|
+
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource });
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
133
|
/* Section covers the internal traversal creation of rules and declarations */
|
|
@@ -31,11 +31,12 @@ export interface IStylesheetService {
|
|
|
31
31
|
insertDeclarationIntoRule(rule: IStyleRule, property: string, value: string, important: boolean): boolean;
|
|
32
32
|
removeDeclarationFromRule(rule: IStyleRule, property: string): boolean;
|
|
33
33
|
updateCompleteStylesheet(name: string, newStyle: string): void;
|
|
34
|
+
updateCompleteStylesheetWithoutUndo(name: string, newStyle: string): void;
|
|
34
35
|
stylesheetChanged: TypedEvent<{
|
|
35
36
|
name: string;
|
|
36
37
|
newStyle: string;
|
|
37
38
|
oldStyle: string;
|
|
38
|
-
changeSource: 'extern' | 'styleupdate';
|
|
39
|
+
changeSource: 'extern' | 'styleupdate' | 'undo';
|
|
39
40
|
}>;
|
|
40
41
|
stylesheetsChanged: TypedEvent<void>;
|
|
41
42
|
}
|
|
@@ -12,10 +12,10 @@ export class StylesheetChangedAction {
|
|
|
12
12
|
return [];
|
|
13
13
|
}
|
|
14
14
|
undo() {
|
|
15
|
-
this.stylesheetService.
|
|
15
|
+
this.stylesheetService.updateCompleteStylesheetWithoutUndo(this.name, this.oldValue);
|
|
16
16
|
}
|
|
17
17
|
do() {
|
|
18
|
-
this.stylesheetService.
|
|
18
|
+
this.stylesheetService.updateCompleteStylesheetWithoutUndo(this.name, this.newValue);
|
|
19
19
|
}
|
|
20
20
|
name;
|
|
21
21
|
newValue;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
import { ICodeView } from './ICodeView.js';
|
|
3
|
+
import { IStringPosition } from '../../services/htmlWriterService/IStringPosition.js';
|
|
4
|
+
import { IUiCommand } from '../../../commandHandling/IUiCommand.js';
|
|
5
|
+
import { IDisposable } from '../../../interfaces/IDisposable.js';
|
|
6
|
+
export declare class CodeViewCodeMirror extends BaseCustomWebComponentLazyAppend implements ICodeView, IDisposable {
|
|
7
|
+
canvasElement: HTMLElement;
|
|
8
|
+
elementsToPackages: Map<string, string>;
|
|
9
|
+
code: string;
|
|
10
|
+
onTextChanged: any;
|
|
11
|
+
mode: string;
|
|
12
|
+
private _codeMirrorEditor;
|
|
13
|
+
private _editor;
|
|
14
|
+
static readonly style: any;
|
|
15
|
+
static readonly template: any;
|
|
16
|
+
constructor();
|
|
17
|
+
dispose(): void;
|
|
18
|
+
executeCommand(command: IUiCommand): void;
|
|
19
|
+
canExecuteCommand(command: IUiCommand): boolean;
|
|
20
|
+
focusEditor(): void;
|
|
21
|
+
ready(): void;
|
|
22
|
+
update(code: any): void;
|
|
23
|
+
getText(): string;
|
|
24
|
+
setSelection(position: IStringPosition): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
import { CommandType } from '../../../commandHandling/CommandType.js';
|
|
3
|
+
export class CodeViewCodeMirror extends BaseCustomWebComponentLazyAppend {
|
|
4
|
+
canvasElement;
|
|
5
|
+
elementsToPackages;
|
|
6
|
+
code;
|
|
7
|
+
onTextChanged = new TypedEvent();
|
|
8
|
+
mode = 'xml';
|
|
9
|
+
_codeMirrorEditor;
|
|
10
|
+
_editor;
|
|
11
|
+
static style = css `
|
|
12
|
+
:host {
|
|
13
|
+
display: block;
|
|
14
|
+
height: 100%;
|
|
15
|
+
width: 100%;
|
|
16
|
+
}`;
|
|
17
|
+
static template = html `
|
|
18
|
+
<div style="width: 100%; height: 100%; overflow: auto;">
|
|
19
|
+
<div id="textarea"></div>
|
|
20
|
+
</div>`;
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
this._restoreCachedInititalValues();
|
|
24
|
+
import("codemirror/lib/codemirror.css", { with: { type: 'css' } }).then(x => this.shadowRoot.adoptedStyleSheets = [x.default, ...this.shadowRoot.adoptedStyleSheets]);
|
|
25
|
+
import("codemirror/addon/fold/foldgutter.css", { with: { type: 'css' } }).then(x => this.shadowRoot.adoptedStyleSheets = [x.default, ...this.shadowRoot.adoptedStyleSheets]);
|
|
26
|
+
this.style.display = 'block';
|
|
27
|
+
this._editor = this._getDomElement('textarea');
|
|
28
|
+
}
|
|
29
|
+
dispose() {
|
|
30
|
+
}
|
|
31
|
+
executeCommand(command) {
|
|
32
|
+
switch (command.type) {
|
|
33
|
+
case CommandType.undo:
|
|
34
|
+
this._codeMirrorEditor.undo();
|
|
35
|
+
break;
|
|
36
|
+
case CommandType.redo:
|
|
37
|
+
this._codeMirrorEditor.redo();
|
|
38
|
+
break;
|
|
39
|
+
case CommandType.copy:
|
|
40
|
+
const text = this._codeMirrorEditor.getSelection();
|
|
41
|
+
navigator.clipboard.writeText(text);
|
|
42
|
+
break;
|
|
43
|
+
case CommandType.paste:
|
|
44
|
+
navigator.clipboard.readText().then(text => {
|
|
45
|
+
this._codeMirrorEditor.replaceSelection(text);
|
|
46
|
+
});
|
|
47
|
+
break;
|
|
48
|
+
case CommandType.cut:
|
|
49
|
+
const textc = this._codeMirrorEditor.getSelection();
|
|
50
|
+
navigator.clipboard.writeText(textc);
|
|
51
|
+
this._codeMirrorEditor.replaceSelection('');
|
|
52
|
+
break;
|
|
53
|
+
case CommandType.delete:
|
|
54
|
+
this._codeMirrorEditor.replaceSelection('');
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
canExecuteCommand(command) {
|
|
59
|
+
switch (command.type) {
|
|
60
|
+
case CommandType.undo:
|
|
61
|
+
case CommandType.redo:
|
|
62
|
+
case CommandType.copy:
|
|
63
|
+
case CommandType.paste:
|
|
64
|
+
case CommandType.cut:
|
|
65
|
+
case CommandType.delete:
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
focusEditor() {
|
|
71
|
+
requestAnimationFrame(() => {
|
|
72
|
+
this.focus();
|
|
73
|
+
this._codeMirrorEditor.focus();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
ready() {
|
|
77
|
+
const config = {
|
|
78
|
+
tabSize: 3,
|
|
79
|
+
lineNumbers: true,
|
|
80
|
+
mode: this.mode,
|
|
81
|
+
//@ts-ignore
|
|
82
|
+
htmlMode: true,
|
|
83
|
+
lineWrapping: true,
|
|
84
|
+
//@ts-ignore
|
|
85
|
+
extraKeys: { "Ctrl-Q": function (cm) { cm.foldCode(cm.getCursor()); } },
|
|
86
|
+
foldGutter: true,
|
|
87
|
+
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
|
88
|
+
};
|
|
89
|
+
//@ts-ignore
|
|
90
|
+
this._codeMirrorEditor = CodeMirror(this._editor, config);
|
|
91
|
+
this._codeMirrorEditor.setSize('100%', '100%');
|
|
92
|
+
this._codeMirrorEditor.on('change', () => this.onTextChanged.emit(this._codeMirrorEditor.getValue()));
|
|
93
|
+
}
|
|
94
|
+
update(code) {
|
|
95
|
+
this._codeMirrorEditor.setValue(code);
|
|
96
|
+
}
|
|
97
|
+
getText() {
|
|
98
|
+
return this._codeMirrorEditor.getValue();
|
|
99
|
+
}
|
|
100
|
+
setSelection(position) {
|
|
101
|
+
let point1 = this._codeMirrorEditor.posFromIndex(position.start);
|
|
102
|
+
let point2 = this._codeMirrorEditor.posFromIndex(position.start + position.length);
|
|
103
|
+
this._codeMirrorEditor.setSelection(point1, point2);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
customElements.define('node-projects-code-view-code-mirror', CodeViewCodeMirror);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
import { ICodeView } from './ICodeView.js';
|
|
3
|
+
import { IStringPosition } from '../../services/htmlWriterService/IStringPosition.js';
|
|
4
|
+
import { IUiCommand } from '../../../commandHandling/IUiCommand.js';
|
|
5
|
+
import { IDisposable } from '../../../interfaces/IDisposable.js';
|
|
6
|
+
export declare class CodeViewCodeMirror6 extends BaseCustomWebComponentLazyAppend implements ICodeView, IDisposable {
|
|
7
|
+
canvasElement: HTMLElement;
|
|
8
|
+
elementsToPackages: Map<string, string>;
|
|
9
|
+
code: string;
|
|
10
|
+
onTextChanged: TypedEvent<string>;
|
|
11
|
+
mode: string;
|
|
12
|
+
private _editor;
|
|
13
|
+
static readonly style: CSSStyleSheet;
|
|
14
|
+
static readonly template: HTMLTemplateElement;
|
|
15
|
+
private _cm;
|
|
16
|
+
constructor();
|
|
17
|
+
ready(): void;
|
|
18
|
+
dispose(): void;
|
|
19
|
+
executeCommand(command: IUiCommand): Promise<void>;
|
|
20
|
+
canExecuteCommand(command: IUiCommand): boolean;
|
|
21
|
+
focusEditor(): void;
|
|
22
|
+
update(code: any): void;
|
|
23
|
+
getText(): string;
|
|
24
|
+
setSelection(position: IStringPosition): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
import { CommandType } from '../../../commandHandling/CommandType.js';
|
|
3
|
+
export class CodeViewCodeMirror6 extends BaseCustomWebComponentLazyAppend {
|
|
4
|
+
canvasElement;
|
|
5
|
+
elementsToPackages;
|
|
6
|
+
code;
|
|
7
|
+
onTextChanged = new TypedEvent();
|
|
8
|
+
mode = 'xml';
|
|
9
|
+
_editor;
|
|
10
|
+
static style = css `
|
|
11
|
+
:host {
|
|
12
|
+
display: block;
|
|
13
|
+
height: 100%;
|
|
14
|
+
width: 100%;
|
|
15
|
+
background: white;
|
|
16
|
+
}
|
|
17
|
+
.cm-editor {
|
|
18
|
+
height: 100%
|
|
19
|
+
}`;
|
|
20
|
+
static template = html `
|
|
21
|
+
<div id="container" style="width: 100%; height: 100%; overflow: auto;">
|
|
22
|
+
</div>`;
|
|
23
|
+
_cm;
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this._restoreCachedInititalValues();
|
|
27
|
+
import("codemirror").then(async (cm) => {
|
|
28
|
+
this._cm = cm;
|
|
29
|
+
let js = await import("@codemirror/lang-javascript");
|
|
30
|
+
let html = await import("@codemirror/lang-html");
|
|
31
|
+
this._editor = new cm.EditorView({
|
|
32
|
+
extensions: [cm.basicSetup, js.javascript(), html.html()],
|
|
33
|
+
parent: this._getDomElement('container')
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
ready() {
|
|
38
|
+
/* this._codeMirrorEditor.on('change', () => this.onTextChanged.emit(this._codeMirrorEditor.getValue()))*/
|
|
39
|
+
}
|
|
40
|
+
dispose() {
|
|
41
|
+
}
|
|
42
|
+
async executeCommand(command) {
|
|
43
|
+
let cmds = await import("@codemirror/commands");
|
|
44
|
+
switch (command.type) {
|
|
45
|
+
case CommandType.undo:
|
|
46
|
+
cmds.undo(this._editor);
|
|
47
|
+
break;
|
|
48
|
+
case CommandType.redo:
|
|
49
|
+
cmds.redo(this._editor);
|
|
50
|
+
break;
|
|
51
|
+
case CommandType.copy:
|
|
52
|
+
const text = this._codeMirrorEditor.getSelection();
|
|
53
|
+
navigator.clipboard.writeText(text);
|
|
54
|
+
break;
|
|
55
|
+
case CommandType.paste:
|
|
56
|
+
navigator.clipboard.readText().then(text => {
|
|
57
|
+
this._codeMirrorEditor.replaceSelection(text);
|
|
58
|
+
});
|
|
59
|
+
break;
|
|
60
|
+
case CommandType.cut:
|
|
61
|
+
const textc = this._codeMirrorEditor.getSelection();
|
|
62
|
+
navigator.clipboard.writeText(textc);
|
|
63
|
+
this._codeMirrorEditor.replaceSelection('');
|
|
64
|
+
break;
|
|
65
|
+
case CommandType.delete:
|
|
66
|
+
this._codeMirrorEditor.replaceSelection('');
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
canExecuteCommand(command) {
|
|
71
|
+
switch (command.type) {
|
|
72
|
+
case CommandType.undo:
|
|
73
|
+
case CommandType.redo:
|
|
74
|
+
case CommandType.copy:
|
|
75
|
+
case CommandType.paste:
|
|
76
|
+
case CommandType.cut:
|
|
77
|
+
case CommandType.delete:
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
focusEditor() {
|
|
83
|
+
requestAnimationFrame(() => {
|
|
84
|
+
this.focus();
|
|
85
|
+
this._editor.focus();
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
update(code) {
|
|
89
|
+
this._editor.dispatch({
|
|
90
|
+
changes: { from: 0, to: this._editor.state.doc.length, insert: code }
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
getText() {
|
|
94
|
+
return this._editor.state.doc.toString();
|
|
95
|
+
}
|
|
96
|
+
setSelection(position) {
|
|
97
|
+
this._editor.dispatch({
|
|
98
|
+
selection: { anchor: position.start, head: position.start + position.length }
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
customElements.define('node-projects-code-view-code-mirror-6', CodeViewCodeMirror6);
|
|
@@ -6,10 +6,13 @@ export declare class DebugView extends BaseCustomWebComponentConstructorAppend {
|
|
|
6
6
|
private _ready;
|
|
7
7
|
computedStyle: CSSStyleDeclaration;
|
|
8
8
|
createsStackingContext: boolean;
|
|
9
|
-
createsStackingContextReason:
|
|
10
|
-
parentStackingContext:
|
|
9
|
+
createsStackingContextReason: string;
|
|
10
|
+
parentStackingContext: Element;
|
|
11
|
+
parentStackingContextText: string;
|
|
11
12
|
selectedElementOffsetParent: Element;
|
|
13
|
+
selectedElementOffsetParentText: string;
|
|
12
14
|
constructor();
|
|
13
15
|
ready(): void;
|
|
16
|
+
_clickLink(e: MouseEvent, target: 'offsetParent' | 'stackingContextParent'): void;
|
|
14
17
|
update(designItem: IDesignItem): void;
|
|
15
18
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
import { DesignItem } from "../../item/DesignItem.js";
|
|
2
3
|
function generateSelector(element) {
|
|
3
4
|
let selector, tag = element.nodeName.toLowerCase();
|
|
4
5
|
if (element.id) {
|
|
@@ -109,27 +110,57 @@ export class DebugView extends BaseCustomWebComponentConstructorAppend {
|
|
|
109
110
|
static template = html `
|
|
110
111
|
<div>
|
|
111
112
|
<table>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
<tr><th colspan="2">Styling</th></tr>
|
|
114
|
+
<tr><td>display</td><td>[[?this.computedStyle.display]]</td></tr>
|
|
115
|
+
<tr><td>position</td><td>[[?this.computedStyle.position]]</td></tr>
|
|
116
|
+
<tr><td>visibility</td><td>[[?this.computedStyle.visibility]]</td></tr>
|
|
117
|
+
<tr><td>pointerEvents</td><td>[[?this.computedStyle.pointerEvents]]</td></tr>
|
|
118
|
+
<tr><td>zIndex</td><td>[[?this.computedStyle.zIndex]]</td></tr>
|
|
119
|
+
<tr><th colspan="2">Context</th></tr>
|
|
120
|
+
<tr><td>offsetParent</td><td class="lnk" @click="[[this._clickLink(event, 'offsetParent')]]">[[?this.selectedElementOffsetParentText]]</td></tr>
|
|
121
|
+
<tr><td>createsStackingContext</td><td>[[this.createsStackingContext]]</td></tr>
|
|
122
|
+
<tr><td>stackingContextReason</td><td>[[this.createsStackingContextReason]]</td></tr>
|
|
123
|
+
<tr><td>stackingContextParent</td><td class="lnk" @click="[[this._clickLink(event, 'stackingContextParent')]]">[[?this.parentStackingContextText]]</td></tr>
|
|
123
124
|
</table>
|
|
124
125
|
</div>
|
|
125
126
|
`;
|
|
126
|
-
static style = css
|
|
127
|
+
static style = css `
|
|
128
|
+
table {
|
|
129
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
130
|
+
border-collapse: collapse;
|
|
131
|
+
width: 100%;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
table td, table th {
|
|
135
|
+
border: 1px solid #ddd;
|
|
136
|
+
padding: 2px 4px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
table tr:nth-child(even){background-color: #f2f2f2;}
|
|
140
|
+
|
|
141
|
+
table tr:hover {background-color: #ddd;}
|
|
142
|
+
|
|
143
|
+
table th {
|
|
144
|
+
text-align: left;
|
|
145
|
+
background-color: #989898;
|
|
146
|
+
color: white;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.lnk {
|
|
150
|
+
color: blue;
|
|
151
|
+
}
|
|
152
|
+
.lnk:hover {
|
|
153
|
+
text-decoration: underline;
|
|
154
|
+
cursor: pointer;
|
|
155
|
+
}`;
|
|
127
156
|
_ready;
|
|
128
157
|
computedStyle;
|
|
129
158
|
createsStackingContext;
|
|
130
159
|
createsStackingContextReason;
|
|
131
160
|
parentStackingContext;
|
|
161
|
+
parentStackingContextText;
|
|
132
162
|
selectedElementOffsetParent;
|
|
163
|
+
selectedElementOffsetParentText;
|
|
133
164
|
constructor() {
|
|
134
165
|
super();
|
|
135
166
|
this._restoreCachedInititalValues();
|
|
@@ -139,21 +170,59 @@ export class DebugView extends BaseCustomWebComponentConstructorAppend {
|
|
|
139
170
|
this._bindingsParse();
|
|
140
171
|
this._ready = true;
|
|
141
172
|
}
|
|
173
|
+
_clickLink(e, target) {
|
|
174
|
+
if (target == 'offsetParent') {
|
|
175
|
+
if (this.selectedElementOffsetParent) {
|
|
176
|
+
let di = DesignItem.GetDesignItem(this.selectedElementOffsetParent);
|
|
177
|
+
di.instanceServiceContainer.selectionService.setSelectedElements([di]);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else if (target == 'stackingContextParent') {
|
|
181
|
+
if (this.parentStackingContext) {
|
|
182
|
+
let di = DesignItem.GetDesignItem(this.parentStackingContext);
|
|
183
|
+
di.instanceServiceContainer.selectionService.setSelectedElements([di]);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
142
187
|
update(designItem) {
|
|
143
188
|
if (this._ready) {
|
|
144
189
|
requestAnimationFrame(() => {
|
|
145
|
-
let element = designItem
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
let parentContext = closest.node;
|
|
153
|
-
if (this.createsStackingContext && element.nodeName !== 'HTML') {
|
|
154
|
-
parentContext = getClosestStackingContext(element.parentNode).node;
|
|
190
|
+
let element = designItem?.element;
|
|
191
|
+
if (element) {
|
|
192
|
+
this.computedStyle = getComputedStyle(designItem.element);
|
|
193
|
+
this.selectedElementOffsetParent = designItem.element.offsetParent;
|
|
194
|
+
if (this.selectedElementOffsetParent == designItem.instanceServiceContainer.designerCanvas.rootDesignItem.element) {
|
|
195
|
+
this.selectedElementOffsetParentText = null;
|
|
196
|
+
this.selectedElementOffsetParent = null;
|
|
155
197
|
}
|
|
156
|
-
|
|
198
|
+
else
|
|
199
|
+
this.selectedElementOffsetParentText = generateSelector(designItem.element.offsetParent);
|
|
200
|
+
if (element && element.nodeType === 1) {
|
|
201
|
+
const closest = getClosestStackingContext(element);
|
|
202
|
+
this.createsStackingContext = element === closest.node;
|
|
203
|
+
this.createsStackingContextReason = this.createsStackingContext ? closest.reason : 'not a stacking context';
|
|
204
|
+
this.parentStackingContext = closest.node;
|
|
205
|
+
if (this.createsStackingContext && element.nodeName !== 'HTML') {
|
|
206
|
+
this.parentStackingContext = getClosestStackingContext(element.parentNode).node;
|
|
207
|
+
}
|
|
208
|
+
if (this.parentStackingContext == designItem.instanceServiceContainer.designerCanvas.rootDesignItem.element.parentElement.parentElement) {
|
|
209
|
+
this.parentStackingContextText = null;
|
|
210
|
+
this.parentStackingContext = null;
|
|
211
|
+
}
|
|
212
|
+
else
|
|
213
|
+
this.parentStackingContextText = generateSelector(this.parentStackingContext);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
//@ts-ignore
|
|
218
|
+
this.computedStyle = {};
|
|
219
|
+
this.createsStackingContext = false;
|
|
220
|
+
this.createsStackingContextReason = '';
|
|
221
|
+
this.createsStackingContext = false;
|
|
222
|
+
this.selectedElementOffsetParent = null;
|
|
223
|
+
this.selectedElementOffsetParentText = null;
|
|
224
|
+
this.parentStackingContext = null;
|
|
225
|
+
this.parentStackingContextText = null;
|
|
157
226
|
}
|
|
158
227
|
this._bindingsRefresh();
|
|
159
228
|
});
|
|
@@ -534,7 +534,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
534
534
|
if (designItemDocumentPositionService) {
|
|
535
535
|
this.instanceServiceContainer.register("designItemDocumentPositionService", designItemDocumentPositionService(this));
|
|
536
536
|
}
|
|
537
|
-
this.rootDesignItem = DesignItem.GetOrCreateDesignItem(this._canvas, this.serviceContainer, this.instanceServiceContainer);
|
|
537
|
+
this.rootDesignItem = DesignItem.GetOrCreateDesignItem(this._canvas, this._canvas, this.serviceContainer, this.instanceServiceContainer);
|
|
538
538
|
const contentService = this.serviceContainer.getLastService('contentService');
|
|
539
539
|
if (contentService) {
|
|
540
540
|
this.instanceServiceContainer.register("contentService", contentService(this));
|
|
@@ -544,7 +544,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
544
544
|
const instance = stylesheetService(this);
|
|
545
545
|
this.instanceServiceContainer.register("stylesheetService", instance);
|
|
546
546
|
this.instanceServiceContainer.stylesheetService.stylesheetChanged.on((ss) => {
|
|
547
|
-
if (ss.changeSource
|
|
547
|
+
if (ss.changeSource != 'undo') {
|
|
548
548
|
const ssca = new StylesheetChangedAction(this.instanceServiceContainer.stylesheetService, ss.name, ss.newStyle, ss.oldStyle);
|
|
549
549
|
this.instanceServiceContainer.undoService.execute(ssca);
|
|
550
550
|
}
|
|
@@ -998,7 +998,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
998
998
|
return currentElement;
|
|
999
999
|
}
|
|
1000
1000
|
showHoverExtension(element, event) {
|
|
1001
|
-
const currentDesignItem = DesignItem.GetOrCreateDesignItem(element, this.serviceContainer, this.instanceServiceContainer);
|
|
1001
|
+
const currentDesignItem = DesignItem.GetOrCreateDesignItem(element, element, this.serviceContainer, this.instanceServiceContainer);
|
|
1002
1002
|
if (this._lastHoverDesignItem != currentDesignItem) {
|
|
1003
1003
|
if (this._lastHoverDesignItem)
|
|
1004
1004
|
this.extensionManager.removeExtension(this._lastHoverDesignItem, ExtensionType.MouseOver);
|
|
@@ -1043,7 +1043,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
1043
1043
|
return;
|
|
1044
1044
|
}
|
|
1045
1045
|
this.clickOverlay.style.cursor = this._canvas.style.cursor;
|
|
1046
|
-
const currentDesignItem = DesignItem.GetOrCreateDesignItem(currentElement, this.serviceContainer, this.instanceServiceContainer);
|
|
1046
|
+
const currentDesignItem = DesignItem.GetOrCreateDesignItem(currentElement, currentElement, this.serviceContainer, this.instanceServiceContainer);
|
|
1047
1047
|
this.showHoverExtension(currentDesignItem.element, event);
|
|
1048
1048
|
//TODO: needed ??
|
|
1049
1049
|
if (currentElement && DomHelper.getHost(currentElement.parentNode) === this.overlayLayer) {
|
|
@@ -30,7 +30,7 @@ export class ExtensionManager {
|
|
|
30
30
|
_selectedElementsChanged(selectionChangedEvent) {
|
|
31
31
|
if (selectionChangedEvent.oldSelectedElements && selectionChangedEvent.oldSelectedElements.length) {
|
|
32
32
|
if (selectionChangedEvent.oldSelectedElements[0].parent) {
|
|
33
|
-
const primaryContainer = DesignItem.GetOrCreateDesignItem(selectionChangedEvent.oldSelectedElements[0].parent.element, this.designerCanvas.serviceContainer, this.designerCanvas.instanceServiceContainer);
|
|
33
|
+
const primaryContainer = DesignItem.GetOrCreateDesignItem(selectionChangedEvent.oldSelectedElements[0].parent.element, selectionChangedEvent.oldSelectedElements[0].parent.element, this.designerCanvas.serviceContainer, this.designerCanvas.instanceServiceContainer);
|
|
34
34
|
this.removeExtension(primaryContainer, ExtensionType.PrimarySelectionContainer);
|
|
35
35
|
this.removeExtension(selectionChangedEvent.oldSelectedElements[0], ExtensionType.PrimarySelection);
|
|
36
36
|
this.removeExtensions(selectionChangedEvent.oldSelectedElements, false, ExtensionType.Selection);
|
|
@@ -39,7 +39,7 @@ export class ExtensionManager {
|
|
|
39
39
|
if (selectionChangedEvent.selectedElements && selectionChangedEvent.selectedElements.length) {
|
|
40
40
|
this.applyExtensions(selectionChangedEvent.selectedElements, ExtensionType.Selection);
|
|
41
41
|
this.applyExtension(selectionChangedEvent.selectedElements[0], ExtensionType.PrimarySelection);
|
|
42
|
-
const primaryContainer = DesignItem.GetOrCreateDesignItem(selectionChangedEvent.selectedElements[0].parent.element, this.designerCanvas.serviceContainer, this.designerCanvas.instanceServiceContainer);
|
|
42
|
+
const primaryContainer = DesignItem.GetOrCreateDesignItem(selectionChangedEvent.selectedElements[0].parent.element, selectionChangedEvent.selectedElements[0].parent.element, this.designerCanvas.serviceContainer, this.designerCanvas.instanceServiceContainer);
|
|
43
43
|
this.applyExtension(primaryContainer, ExtensionType.PrimarySelectionContainer);
|
|
44
44
|
}
|
|
45
45
|
//this.refreshExtensions(selectionChangedEvent.selectedElements);
|
|
@@ -11,7 +11,7 @@ export class ItemsBelowContextMenu {
|
|
|
11
11
|
return [];
|
|
12
12
|
}
|
|
13
13
|
_select(designerView, element) {
|
|
14
|
-
const item = DesignItem.GetOrCreateDesignItem(element, designerView.serviceContainer, designerView.instanceServiceContainer);
|
|
14
|
+
const item = DesignItem.GetOrCreateDesignItem(element, element, designerView.serviceContainer, designerView.instanceServiceContainer);
|
|
15
15
|
designerView.instanceServiceContainer.selectionService.setSelectedElements([item]);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -46,7 +46,7 @@ export class MagicWandSelectorTool {
|
|
|
46
46
|
point.y = elementRect.y + elementRect.height;
|
|
47
47
|
const p4 = this._path.isPointInFill(point) || this._path.isPointInStroke(point);
|
|
48
48
|
if (p1 && p2 && p3 && p4) {
|
|
49
|
-
const desItem = DesignItem.GetOrCreateDesignItem(e, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
49
|
+
const desItem = DesignItem.GetOrCreateDesignItem(e, e, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
50
50
|
if (designerCanvas.instanceServiceContainer.selectionService.selectedElements)
|
|
51
51
|
inSelectionElements.push(...designerCanvas.instanceServiceContainer.selectionService.selectedElements);
|
|
52
52
|
inSelectionElements.push(desItem);
|
|
@@ -39,7 +39,7 @@ export class PointerTool {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
let newEl = designerCanvas.serviceContainer.elementAtPointService.getElementAtPoint(designerCanvas, { x: event.x, y: event.y });
|
|
42
|
-
const designItem = DesignItem.GetOrCreateDesignItem(newEl, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
42
|
+
const designItem = DesignItem.GetOrCreateDesignItem(newEl, newEl, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
43
43
|
if (!designerCanvas.instanceServiceContainer.selectionService.isSelected(designItem)) {
|
|
44
44
|
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements([designItem]);
|
|
45
45
|
}
|
|
@@ -98,7 +98,7 @@ export class PointerTool {
|
|
|
98
98
|
if (!currentElement)
|
|
99
99
|
return;
|
|
100
100
|
const currentPoint = designerCanvas.getNormalizedEventCoordinates(event);
|
|
101
|
-
const currentDesignItem = DesignItem.GetOrCreateDesignItem(currentElement, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
101
|
+
const currentDesignItem = DesignItem.GetOrCreateDesignItem(currentElement, currentElement, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
102
102
|
if (this._actionType == null) {
|
|
103
103
|
this._initialPoint = currentPoint;
|
|
104
104
|
this._initialOffset = designerCanvas.getNormalizedOffsetInElement(event, currentElement);
|
|
@@ -166,7 +166,7 @@ export class PointerTool {
|
|
|
166
166
|
}
|
|
167
167
|
let currentElement = elements[idx];
|
|
168
168
|
if (currentElement)
|
|
169
|
-
currentDesignItem = DesignItem.GetOrCreateDesignItem(currentElement, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
169
|
+
currentDesignItem = DesignItem.GetOrCreateDesignItem(currentElement, currentElement, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -379,7 +379,7 @@ export class PointerTool {
|
|
|
379
379
|
//check we don't try to move a item over one of its children..
|
|
380
380
|
}
|
|
381
381
|
else {
|
|
382
|
-
newContainerElementDesignItem = DesignItem.GetOrCreateDesignItem(e, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
382
|
+
newContainerElementDesignItem = DesignItem.GetOrCreateDesignItem(e, e, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
383
383
|
const containerStyle = getComputedStyle(newContainerElementDesignItem.element);
|
|
384
384
|
newContainerService = designerCanvas.serviceContainer.getLastServiceWhere('containerService', x => x.serviceForContainer(newContainerElementDesignItem, containerStyle));
|
|
385
385
|
if (newContainerService) {
|
|
@@ -68,7 +68,7 @@ export class RectangleSelectorTool {
|
|
|
68
68
|
point.y = elementRect.y + elementRect.height;
|
|
69
69
|
const p4 = p3 && this._rect.isPointInFill(point);
|
|
70
70
|
if (p4) {
|
|
71
|
-
const desItem = DesignItem.GetOrCreateDesignItem(e, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
71
|
+
const desItem = DesignItem.GetOrCreateDesignItem(e, e, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
72
72
|
if (designerCanvas.instanceServiceContainer.selectionService.selectedElements)
|
|
73
73
|
inSelectionElements.push(...designerCanvas.instanceServiceContainer.selectionService.selectedElements);
|
|
74
74
|
inSelectionElements.push(desItem);
|
|
@@ -220,7 +220,7 @@ export class TreeView extends BaseCustomWebComponentLazyAppend {
|
|
|
220
220
|
_selectDesignerElement(item) {
|
|
221
221
|
let index = item.dataset.index;
|
|
222
222
|
let el = this._items[index].ref;
|
|
223
|
-
let d = DesignItem.GetOrCreateDesignItem(el, this._rootItem.serviceContainer, this._rootItem.instanceServiceContainer);
|
|
223
|
+
let d = DesignItem.GetOrCreateDesignItem(el, el, this._rootItem.serviceContainer, this._rootItem.instanceServiceContainer);
|
|
224
224
|
d.instanceServiceContainer.selectionService.setSelectedElements([d]);
|
|
225
225
|
}
|
|
226
226
|
_highlight(element) {
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ export * from "./elements/services/demoProviderService/DemoProviderService.js";
|
|
|
45
45
|
export type { IDemoProviderService } from "./elements/services/demoProviderService/IDemoProviderService.js";
|
|
46
46
|
export * from "./elements/services/designItemDocumentPositionService/DesignItemDocumentPositionService.js";
|
|
47
47
|
export type { IDesignItemDocumentPositionService } from "./elements/services/designItemDocumentPositionService/IDesignItemDocumentPositionService.js";
|
|
48
|
+
export * from "./elements/services/designItemService/DesignItemService.js";
|
|
49
|
+
export type { IDesignItemService } from "./elements/services/designItemService/IDesignItemService.js";
|
|
48
50
|
export * from "./elements/services/dragDropService/ExternalDragDropService.js";
|
|
49
51
|
export type { IExternalDragDropService } from "./elements/services/dragDropService/IExternalDragDropService.js";
|
|
50
52
|
export * from "./elements/services/dragDropService/DragDropService.js";
|
|
@@ -126,7 +128,6 @@ export * from "./elements/services/undoService/transactionItems/DeleteAction.js"
|
|
|
126
128
|
export * from "./elements/services/undoService/transactionItems/InsertAction.js";
|
|
127
129
|
export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
|
|
128
130
|
export * from "./elements/services/undoService/transactionItems/StylesheetChangedAction.js";
|
|
129
|
-
export * from "./elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js";
|
|
130
131
|
export * from "./elements/services/undoService/transactionItems/SetDesignItemsAction.js";
|
|
131
132
|
export * from "./elements/services/BaseServiceContainer.js";
|
|
132
133
|
export * from "./elements/services/InstanceServiceContainer.js";
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export * from "./elements/services/copyPasteService/CopyPasteService.js";
|
|
|
29
29
|
export * from "./elements/services/copyPasteService/CopyPasteAsJsonService.js";
|
|
30
30
|
export * from "./elements/services/demoProviderService/DemoProviderService.js";
|
|
31
31
|
export * from "./elements/services/designItemDocumentPositionService/DesignItemDocumentPositionService.js";
|
|
32
|
+
export * from "./elements/services/designItemService/DesignItemService.js";
|
|
32
33
|
export * from "./elements/services/dragDropService/ExternalDragDropService.js";
|
|
33
34
|
export * from "./elements/services/dragDropService/DragDropService.js";
|
|
34
35
|
export * from "./elements/services/elementsService/JsonFileElementsService.js";
|
|
@@ -87,7 +88,6 @@ export * from "./elements/services/undoService/transactionItems/DeleteAction.js"
|
|
|
87
88
|
export * from "./elements/services/undoService/transactionItems/InsertAction.js";
|
|
88
89
|
export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
|
|
89
90
|
export * from "./elements/services/undoService/transactionItems/StylesheetChangedAction.js";
|
|
90
|
-
export * from "./elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js";
|
|
91
91
|
export * from "./elements/services/undoService/transactionItems/SetDesignItemsAction.js";
|
|
92
92
|
export * from "./elements/services/BaseServiceContainer.js";
|
|
93
93
|
export * from "./elements/services/InstanceServiceContainer.js";
|
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.
|
|
4
|
+
"version": "0.0.244",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"prepublishOnly": "npm run build"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@node-projects/base-custom-webcomponent": "^0.
|
|
16
|
+
"@node-projects/base-custom-webcomponent": "^0.13.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@adobe/css-tools": "4.3.0-
|
|
19
|
+
"@adobe/css-tools": "4.3.0-rc.1",
|
|
20
20
|
"@node-projects/lean-he-esm": "^3.3.0",
|
|
21
21
|
"@node-projects/node-html-parser-esm": "^6.1.5",
|
|
22
22
|
"@papyrs/stylo": "^0.0.45",
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
"@types/css-tree": "^2.3.1",
|
|
25
25
|
"@types/jquery": "^3.5.16",
|
|
26
26
|
"@types/jquery.fancytree": "0.0.7",
|
|
27
|
-
"@types/node": "^20.
|
|
28
|
-
"ace-builds": "^1.23.
|
|
27
|
+
"@types/node": "^20.4.5",
|
|
28
|
+
"ace-builds": "^1.23.4",
|
|
29
29
|
"codemirror": "^5.0.0",
|
|
30
30
|
"css-tree": "^2.3.1",
|
|
31
31
|
"esprima-next": "^5.8.4",
|
|
32
32
|
"html2canvas": "*",
|
|
33
|
-
"jest": "^29.
|
|
33
|
+
"jest": "^29.6.2",
|
|
34
34
|
"jquery": "^3.7.0",
|
|
35
35
|
"jquery.fancytree": "^2.38.3",
|
|
36
36
|
"mdn-data": "^2.0.32",
|
|
37
|
-
"monaco-editor": "^0.
|
|
37
|
+
"monaco-editor": "^0.40.0",
|
|
38
38
|
"ts-jest": "^29.1.1",
|
|
39
39
|
"typescript": "^5.1.6",
|
|
40
40
|
"typescript-lit-html-plugin": "^0.9.0"
|