@node-projects/web-component-designer 0.0.292 → 0.1.1
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 +1 -30
- package/dist/elements/helper/NpmPackageLoader.d.ts +1 -2
- package/dist/elements/{loader → services/manifestParsers}/OldCustomElementsManifestLoader.d.ts +1 -1
- package/dist/elements/{loader → services/manifestParsers}/OldCustomElementsManifestLoader.js +2 -2
- package/dist/index.d.ts +4 -17
- package/dist/index.js +2 -16
- package/package.json +3 -25
- package/.editorconfig +0 -7
- package/.github/FUNDING.yml +0 -4
- package/.vscode/settings.json +0 -3
- package/ACKNOWLEDGMENTS +0 -15
- package/LICENSE +0 -21
- package/RemoveOldRemoteBranches.bat +0 -7
- package/dist/elements/services/demoProviderService/DemoProviderService.d.ts +0 -6
- package/dist/elements/services/demoProviderService/DemoProviderService.js +0 -38
- package/dist/elements/services/demoProviderService/IframeDemoProviderService copy.d.ts +0 -6
- package/dist/elements/services/demoProviderService/IframeDemoProviderService copy.js +0 -38
- package/dist/elements/services/designerAddons/IDesignerAddonJson copy.d.ts +0 -3
- package/dist/elements/services/designerAddons/IDesignerAddonJson copy.js +0 -1
- package/dist/elements/services/designerAddons/IDesignerInfoJson.d.ts +0 -7
- package/dist/elements/services/designerAddons/IDesignerInfoJson.js +0 -19
- package/dist/elements/services/dragDropService/IExternalDragDropService copy.d.ts +0 -5
- package/dist/elements/services/dragDropService/IExternalDragDropService copy.js +0 -1
- package/dist/elements/services/eventsService/IEventsService copy.d.ts +0 -2
- package/dist/elements/services/eventsService/IEventsService copy.js +0 -1
- package/dist/elements/services/htmlParserService/BaseCustomWebcomponentParserService.d.ts +0 -11
- package/dist/elements/services/htmlParserService/BaseCustomWebcomponentParserService.js +0 -90
- package/dist/elements/services/htmlParserService/LitElementParserService.d.ts +0 -12
- package/dist/elements/services/htmlParserService/LitElementParserService.js +0 -91
- package/dist/elements/services/htmlParserService/NodeHtmlParserService.d.ts +0 -11
- package/dist/elements/services/htmlParserService/NodeHtmlParserService.js +0 -89
- package/dist/elements/services/htmlParserService/VueParserService.d.ts +0 -9
- package/dist/elements/services/htmlParserService/VueParserService.js +0 -10
- package/dist/elements/services/htmlWriterService/HtmlWriterOptions.d.ts +0 -7
- package/dist/elements/services/htmlWriterService/HtmlWriterOptions.js +0 -7
- package/dist/elements/services/propertiesService/propertyEditors/GridAssignedRowColumnPropertyEditor.d.ts +0 -8
- package/dist/elements/services/propertiesService/propertyEditors/GridAssignedRowColumnPropertyEditor.js +0 -45
- package/dist/elements/services/propertiesService/propertyEditors/GridRowColumnPropertyEditor.d.ts +0 -10
- package/dist/elements/services/propertiesService/propertyEditors/GridRowColumnPropertyEditor.js +0 -25
- package/dist/elements/services/propertiesService/propertyEditors/JsonPropertyEditor copy.d.ts +0 -9
- package/dist/elements/services/propertiesService/propertyEditors/JsonPropertyEditor copy.js +0 -21
- package/dist/elements/services/propertiesService/propertyEditors/MetricsPropertyEditor.d.ts +0 -8
- package/dist/elements/services/propertiesService/propertyEditors/MetricsPropertyEditor.js +0 -14
- package/dist/elements/services/propertiesService/propertyEditors/SelectPropertyEditor copy.d.ts +0 -7
- package/dist/elements/services/propertiesService/propertyEditors/SelectPropertyEditor copy.js +0 -28
- package/dist/elements/services/propertiesService/services/CommonPropertiesService copy.d.ts +0 -13
- package/dist/elements/services/propertiesService/services/CommonPropertiesService copy.js +0 -44
- package/dist/elements/services/propertiesService/services/ContentPropertiesService.d.ts +0 -14
- package/dist/elements/services/propertiesService/services/ContentPropertiesService.js +0 -30
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.d.ts +0 -34
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.js +0 -105
- package/dist/elements/services/propertiesService/services/PolymerPropertiesService copy.d.ts +0 -8
- package/dist/elements/services/propertiesService/services/PolymerPropertiesService copy.js +0 -10
- package/dist/elements/services/propertiesService/services/UnkownElemntPropertiesService.d.ts +0 -24
- package/dist/elements/services/propertiesService/services/UnkownElemntPropertiesService.js +0 -198
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.d.ts +0 -42
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.js +0 -114
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.d.ts +0 -58
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.js +0 -204
- package/dist/elements/services/stylesheetService/SpecificityCalculator.d.ts +0 -7
- package/dist/elements/services/stylesheetService/SpecificityCalculator.js +0 -178
- package/dist/elements/services/undoService/transactionItems/AttributeChangeAction copy.d.ts +0 -15
- package/dist/elements/services/undoService/transactionItems/AttributeChangeAction copy.js +0 -70
- package/dist/elements/widgets/bindableObjectsBrowser/bindable-objects-browser.d.ts +0 -14
- package/dist/elements/widgets/bindableObjectsBrowser/bindable-objects-browser.js +0 -137
- package/dist/elements/widgets/codeView/code-view-ace.d.ts +0 -24
- package/dist/elements/widgets/codeView/code-view-ace.js +0 -134
- package/dist/elements/widgets/codeView/code-view-code-mirror.d.ts +0 -25
- package/dist/elements/widgets/codeView/code-view-code-mirror.js +0 -117
- package/dist/elements/widgets/codeView/code-view-monaco.d.ts +0 -37
- package/dist/elements/widgets/codeView/code-view-monaco.js +0 -197
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextWithStyloExtension.d.ts +0 -23
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextWithStyloExtension.js +0 -87
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextWithStyloExtensionProvider.d.ts +0 -10
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextWithStyloExtensionProvider.js +0 -15
- package/dist/elements/widgets/miniatureView/html-2-canvas-miniature-view.d.ts +0 -10
- package/dist/elements/widgets/miniatureView/html-2-canvas-miniature-view.js +0 -21
- package/dist/elements/widgets/paletteView/paletteTreeView.d.ts +0 -12
- package/dist/elements/widgets/paletteView/paletteTreeView.js +0 -141
- package/dist/elements/widgets/treeView/treeViewExtended.d.ts +0 -32
- package/dist/elements/widgets/treeView/treeViewExtended.js +0 -366
- package/fixesimport.js +0 -98
- package/jest.config.cjs +0 -7
- package/polymer.json +0 -42
- package/tsconfig.json +0 -75
- /package/dist/elements/{loader → services/manifestParsers}/IOldCustomElementsManifest.d.ts +0 -0
- /package/dist/elements/{loader → services/manifestParsers}/IOldCustomElementsManifest.js +0 -0
package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { PropertyType } from '../PropertyType.js';
|
|
2
|
-
import { RefreshMode } from '../IPropertiesService.js';
|
|
3
|
-
import { CommonPropertiesService } from './CommonPropertiesService.js';
|
|
4
|
-
import { ValueType } from '../ValueType.js';
|
|
5
|
-
import { NodeType } from '../../../item/NodeType.js';
|
|
6
|
-
//TODO: remove this code when import asserts are supported
|
|
7
|
-
let cssProperties;
|
|
8
|
-
//@ts-ignore
|
|
9
|
-
if (window.importShim) {
|
|
10
|
-
const cssPropertiesUrl = import.meta.resolve('./CssProperties.json');
|
|
11
|
-
//@ts-ignore
|
|
12
|
-
cssProperties = await importShim(cssPropertiesUrl, { assert: { type: 'json' } });
|
|
13
|
-
}
|
|
14
|
-
else
|
|
15
|
-
//@ts-ignore
|
|
16
|
-
cssProperties = await import("./CssProperties.json", { assert: { type: 'json' } });
|
|
17
|
-
if (cssProperties.default)
|
|
18
|
-
cssProperties = cssProperties.default;
|
|
19
|
-
const localName = '<local>';
|
|
20
|
-
export class CssCurrentPropertiesService extends CommonPropertiesService {
|
|
21
|
-
getRefreshMode(designItem) {
|
|
22
|
-
return RefreshMode.fullOnValueChange;
|
|
23
|
-
}
|
|
24
|
-
constructor() {
|
|
25
|
-
super();
|
|
26
|
-
this.name = 'styles';
|
|
27
|
-
}
|
|
28
|
-
isHandledElement(designItem) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
getProperty(designItem, name) {
|
|
32
|
-
return { name: name, type: 'string', service: this, propertyType: PropertyType.cssValue };
|
|
33
|
-
}
|
|
34
|
-
getProperties(designItem) {
|
|
35
|
-
if (!designItem || designItem.nodeType != NodeType.Element)
|
|
36
|
-
return [];
|
|
37
|
-
let styles = designItem.getAllStyles();
|
|
38
|
-
let arr = styles.map(x => ({
|
|
39
|
-
name: x.selector ?? localName, description: x.stylesheetName ?? '', properties: [
|
|
40
|
-
...x.declarations.map(y => ({
|
|
41
|
-
name: y.name,
|
|
42
|
-
renamable: true,
|
|
43
|
-
type: cssProperties[y.name]?.type ?? 'string',
|
|
44
|
-
values: cssProperties[y.name]?.values ? [...cssProperties[y.name]?.values, 'initial', 'inherit', 'unset'] : ['initial', 'inherit', 'unset'],
|
|
45
|
-
service: this,
|
|
46
|
-
propertyType: PropertyType.cssValue,
|
|
47
|
-
styleRule: x,
|
|
48
|
-
styleDeclaration: y
|
|
49
|
-
})),
|
|
50
|
-
{ name: '', type: 'addNew', service: this, propertyType: PropertyType.complex, styleRule: x }
|
|
51
|
-
]
|
|
52
|
-
}));
|
|
53
|
-
return arr;
|
|
54
|
-
}
|
|
55
|
-
setValue(designItems, property, value) {
|
|
56
|
-
// No selector means local style, styleDeclaration is null means new property
|
|
57
|
-
if (property.styleRule?.selector !== null && property.styleDeclaration) {
|
|
58
|
-
// styleDeclaration stored Propertygrid is not refreshed after entering a new value, so we need to reload
|
|
59
|
-
// TODO: we do not respect if a same style is found in a media query or another @rule, maybe we need a refresh in the stylesheet parser
|
|
60
|
-
const decls = designItems[0].instanceServiceContainer.stylesheetService?.getDeclarations(designItems[0], property.styleDeclaration.name);
|
|
61
|
-
const currentDecl = decls.find(x => x.parent.selector == property.styleDeclaration.parent.selector && x.parent.stylesheetName == property.styleDeclaration.parent.stylesheetName);
|
|
62
|
-
designItems[0].instanceServiceContainer.stylesheetService.updateDeclarationValue(currentDecl, value, false);
|
|
63
|
-
this._notifyChangedProperty(designItems[0], property, value);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (property.styleRule?.selector !== null && !property.styleDeclaration) {
|
|
67
|
-
designItems[0].instanceServiceContainer.stylesheetService.insertDeclarationIntoRule(property.styleRule, property.name, value, false);
|
|
68
|
-
this._notifyChangedProperty(designItems[0], property, value);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
for (const d of designItems) {
|
|
72
|
-
// Local style
|
|
73
|
-
d.setStyle(property.name, value);
|
|
74
|
-
//unkown css property names do not trigger the mutation observer of property grid,
|
|
75
|
-
//fixed by assinging stle again to the attribute
|
|
76
|
-
d.element.setAttribute('style', d.element.getAttribute('style'));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
clearValue(designItems, property, clearType) {
|
|
80
|
-
if (property.styleRule?.selector !== null && property.styleDeclaration) {
|
|
81
|
-
designItems[0].instanceServiceContainer.stylesheetService.removeDeclarationFromRule(property.styleRule, property.styleDeclaration.name);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
super.clearValue(designItems, property, clearType);
|
|
85
|
-
}
|
|
86
|
-
getValue(designItems, property) {
|
|
87
|
-
if (property.styleRule?.selector && property.styleDeclaration)
|
|
88
|
-
return property.styleDeclaration.value;
|
|
89
|
-
return super.getValue(designItems, property);
|
|
90
|
-
}
|
|
91
|
-
getUnsetValue(designItems, property) {
|
|
92
|
-
if (property.styleRule?.selector && property.styleDeclaration)
|
|
93
|
-
return property.styleDeclaration.value;
|
|
94
|
-
return super.getUnsetValue(designItems, property);
|
|
95
|
-
}
|
|
96
|
-
isSet(designItems, property) {
|
|
97
|
-
if (property.styleRule?.selector && property.styleDeclaration) {
|
|
98
|
-
if (designItems[0].hasStyle(property.name))
|
|
99
|
-
return ValueType.none;
|
|
100
|
-
//TODO: we need to check if this is the dec. with the highest specifity
|
|
101
|
-
return ValueType.all;
|
|
102
|
-
}
|
|
103
|
-
return super.isSet(designItems, property);
|
|
104
|
-
}
|
|
105
|
-
}
|
package/dist/elements/services/propertiesService/services/PolymerPropertiesService copy.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { IProperty } from '../IProperty.js';
|
|
2
|
-
import { IDesignItem } from '../../../item/IDesignItem.js';
|
|
3
|
-
import { AbstractPolymerLikePropertiesService } from './AbstractPolymerLikePropertiesService.js';
|
|
4
|
-
export declare class PolymerPropertiesService extends AbstractPolymerLikePropertiesService {
|
|
5
|
-
name: string;
|
|
6
|
-
isHandledElement(designItem: IDesignItem): boolean;
|
|
7
|
-
protected _notifyChangedProperty(designItem: IDesignItem, property: IProperty, value: any): void;
|
|
8
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AbstractPolymerLikePropertiesService } from './AbstractPolymerLikePropertiesService.js';
|
|
2
|
-
export class PolymerPropertiesService extends AbstractPolymerLikePropertiesService {
|
|
3
|
-
name = "polymer";
|
|
4
|
-
isHandledElement(designItem) {
|
|
5
|
-
return designItem.element.constructor.polymerElementVersion != null;
|
|
6
|
-
}
|
|
7
|
-
_notifyChangedProperty(designItem, property, value) {
|
|
8
|
-
designItem.element.set(property.name, value);
|
|
9
|
-
}
|
|
10
|
-
}
|
package/dist/elements/services/propertiesService/services/UnkownElemntPropertiesService.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IPropertiesService, RefreshMode } from '../IPropertiesService.js';
|
|
3
|
-
import { IProperty } from '../IProperty.js';
|
|
4
|
-
import { IDesignItem } from '../../../item/IDesignItem.js';
|
|
5
|
-
import { ValueType } from '../ValueType.js';
|
|
6
|
-
import { BindingTarget } from '../../../item/BindingTarget.js';
|
|
7
|
-
import { IBinding } from '../../../item/IBinding.js';
|
|
8
|
-
import { IPropertyGroup } from '../IPropertyGroup.js';
|
|
9
|
-
export declare abstract class AbstractPropertiesService implements IPropertiesService {
|
|
10
|
-
_stylesCache: Map<IDesignItem, Set<string>>;
|
|
11
|
-
_cacheClearTimer: NodeJS.Timeout;
|
|
12
|
-
abstract getRefreshMode(designItem: IDesignItem): RefreshMode;
|
|
13
|
-
abstract isHandledElement(designItem: IDesignItem): boolean;
|
|
14
|
-
protected _notifyChangedProperty(designItem: IDesignItem, property: IProperty, value: any): void;
|
|
15
|
-
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
16
|
-
getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
|
|
17
|
-
setValue(designItems: IDesignItem[], property: IProperty, value: any): void;
|
|
18
|
-
getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
|
|
19
|
-
clearValue(designItems: IDesignItem[], property: IProperty, clearType: 'all' | 'binding' | 'value'): void;
|
|
20
|
-
isSet(designItems: IDesignItem[], property: IProperty): ValueType;
|
|
21
|
-
getValue(designItems: IDesignItem[], property: IProperty): string | boolean;
|
|
22
|
-
getBinding(designItems: IDesignItem[], property: IProperty): IBinding;
|
|
23
|
-
getUnsetValue(designItems: IDesignItem[], property: IProperty): any;
|
|
24
|
-
}
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { ValueType } from '../ValueType.js';
|
|
2
|
-
import { PropertiesHelper } from './PropertiesHelper.js';
|
|
3
|
-
import { BindingTarget } from '../../../item/BindingTarget.js';
|
|
4
|
-
import { PropertyType } from '../PropertyType.js';
|
|
5
|
-
import { NodeType } from '../../../item/NodeType.js';
|
|
6
|
-
export class AbstractPropertiesService {
|
|
7
|
-
_stylesCache = new Map;
|
|
8
|
-
_cacheClearTimer;
|
|
9
|
-
_notifyChangedProperty(designItem, property, value) {
|
|
10
|
-
}
|
|
11
|
-
getProperty(designItem, name) {
|
|
12
|
-
let properties = this.getProperties(designItem);
|
|
13
|
-
if ('properties' in properties[0]) {
|
|
14
|
-
return properties.flatMap(x => x.properties).find(x => x.name == name);
|
|
15
|
-
}
|
|
16
|
-
else
|
|
17
|
-
return properties.find(x => x.name == name);
|
|
18
|
-
}
|
|
19
|
-
getProperties(designItem) {
|
|
20
|
-
Object.getOwnPropertyNames(Object.getPrototypeOf(designItem.element));
|
|
21
|
-
}
|
|
22
|
-
setValue(designItems, property, value) {
|
|
23
|
-
const cg = designItems[0].openGroup("property changed: " + property.name + " to " + value);
|
|
24
|
-
for (let d of designItems) {
|
|
25
|
-
if (property.propertyType == PropertyType.cssValue) {
|
|
26
|
-
d.updateStyleInSheetOrLocal(property.name, value);
|
|
27
|
-
//unkown css property names do not trigger the mutation observer of property grid,
|
|
28
|
-
//fixed by assinging stle again to the attribute
|
|
29
|
-
d.element.setAttribute('style', d.element.getAttribute('style'));
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
let attributeName = property.attributeName;
|
|
33
|
-
if (!attributeName)
|
|
34
|
-
attributeName = PropertiesHelper.camelToDashCase(property.name);
|
|
35
|
-
if (property.type === 'object') {
|
|
36
|
-
const json = JSON.stringify(value);
|
|
37
|
-
if (property.propertyType == PropertyType.attribute || property.propertyType == PropertyType.propertyAndAttribute)
|
|
38
|
-
d.setAttribute(attributeName, json);
|
|
39
|
-
if (property.propertyType == PropertyType.property || property.propertyType == PropertyType.propertyAndAttribute)
|
|
40
|
-
d.element[property.name] = value;
|
|
41
|
-
}
|
|
42
|
-
else if (property.type == 'boolean' && !value) {
|
|
43
|
-
if (property.propertyType == PropertyType.attribute || property.propertyType == PropertyType.propertyAndAttribute)
|
|
44
|
-
d.removeAttribute(attributeName);
|
|
45
|
-
if (property.propertyType == PropertyType.property || property.propertyType == PropertyType.propertyAndAttribute)
|
|
46
|
-
d.element[property.name] = false;
|
|
47
|
-
}
|
|
48
|
-
else if (property.type == 'boolean' && value) {
|
|
49
|
-
if (property.propertyType == PropertyType.attribute || property.propertyType == PropertyType.propertyAndAttribute)
|
|
50
|
-
d.setAttribute(attributeName, "");
|
|
51
|
-
if (property.propertyType == PropertyType.property || property.propertyType == PropertyType.propertyAndAttribute)
|
|
52
|
-
d.element[property.name] = true;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
if (property.propertyType == PropertyType.attribute || property.propertyType == PropertyType.propertyAndAttribute)
|
|
56
|
-
d.setAttribute(attributeName, value.toString());
|
|
57
|
-
if (property.propertyType == PropertyType.property || property.propertyType == PropertyType.propertyAndAttribute)
|
|
58
|
-
d.element[property.name] = value;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
this._notifyChangedProperty(d, property, value);
|
|
62
|
-
}
|
|
63
|
-
cg.commit();
|
|
64
|
-
}
|
|
65
|
-
getPropertyTarget(designItem, property) {
|
|
66
|
-
return BindingTarget.property;
|
|
67
|
-
}
|
|
68
|
-
clearValue(designItems, property, clearType) {
|
|
69
|
-
const cg = designItems[0].openGroup("property cleared: " + property.name);
|
|
70
|
-
for (let d of designItems) {
|
|
71
|
-
if (clearType != 'binding') {
|
|
72
|
-
if (property.propertyType == PropertyType.cssValue) {
|
|
73
|
-
d.removeStyle(property.name);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
let attributeName = property.attributeName;
|
|
77
|
-
if (!attributeName)
|
|
78
|
-
attributeName = PropertiesHelper.camelToDashCase(property.name);
|
|
79
|
-
d.removeAttribute(attributeName);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (clearType != 'value') {
|
|
83
|
-
d.serviceContainer.forSomeServicesTillResult('bindingService', (s) => {
|
|
84
|
-
return s.clearBinding(d, property.name, this.getPropertyTarget(d, property));
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
this._notifyChangedProperty(d, property, undefined);
|
|
88
|
-
}
|
|
89
|
-
cg.commit();
|
|
90
|
-
}
|
|
91
|
-
isSet(designItems, property) {
|
|
92
|
-
let all = true;
|
|
93
|
-
let some = false;
|
|
94
|
-
if (designItems != null && designItems.length !== 0) {
|
|
95
|
-
let attributeName = property.attributeName;
|
|
96
|
-
if (!attributeName)
|
|
97
|
-
attributeName = PropertiesHelper.camelToDashCase(property.name);
|
|
98
|
-
for (let x of designItems) {
|
|
99
|
-
let has = false;
|
|
100
|
-
if (property.propertyType == PropertyType.cssValue)
|
|
101
|
-
has = x.hasStyle(property.name);
|
|
102
|
-
else
|
|
103
|
-
has = x.hasAttribute(attributeName);
|
|
104
|
-
all = all && has;
|
|
105
|
-
some = some || has;
|
|
106
|
-
if (!all && some)
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
;
|
|
110
|
-
//todo: optimize perf, do not call bindings service for each property.
|
|
111
|
-
const bindings = designItems[0].serviceContainer.forSomeServicesTillResult('bindingService', (s) => {
|
|
112
|
-
return s.getBindings(designItems[0]);
|
|
113
|
-
});
|
|
114
|
-
if (property.propertyType == PropertyType.cssValue) {
|
|
115
|
-
if (bindings && bindings.find(x => x.target == BindingTarget.css && x.targetName == property.name))
|
|
116
|
-
return ValueType.bound;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
if (bindings && bindings.find(x => x.target == BindingTarget.property && x.targetName == property.name))
|
|
120
|
-
return ValueType.bound;
|
|
121
|
-
}
|
|
122
|
-
if (!all && property.propertyType == PropertyType.cssValue) {
|
|
123
|
-
let styles = this._stylesCache.get(designItems[0]);
|
|
124
|
-
if (!styles) {
|
|
125
|
-
styles = new Set(designItems[0].getAllStyles().filter(x => x.selector != null).flatMap(x => x.declarations).map(x => x.name));
|
|
126
|
-
this._stylesCache.set(designItems[0], styles);
|
|
127
|
-
clearTimeout(this._cacheClearTimer);
|
|
128
|
-
this._cacheClearTimer = setTimeout(() => this._stylesCache.clear(), 30);
|
|
129
|
-
}
|
|
130
|
-
let cssValue = styles.has(property.name);
|
|
131
|
-
if (cssValue)
|
|
132
|
-
return ValueType.fromStylesheet;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else
|
|
136
|
-
return ValueType.none;
|
|
137
|
-
return all ? ValueType.all : some ? ValueType.some : ValueType.none;
|
|
138
|
-
}
|
|
139
|
-
getValue(designItems, property) {
|
|
140
|
-
if (designItems != null && designItems.length !== 0) {
|
|
141
|
-
if (property.propertyType == PropertyType.cssValue) {
|
|
142
|
-
let lastValue = designItems[0].getStyle(property.name);
|
|
143
|
-
for (const d of designItems) {
|
|
144
|
-
let value = d.getStyle(property.name);
|
|
145
|
-
if (value != lastValue) {
|
|
146
|
-
lastValue = null;
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return lastValue;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
let attributeName = property.attributeName;
|
|
154
|
-
if (!attributeName)
|
|
155
|
-
attributeName = PropertiesHelper.camelToDashCase(property.name);
|
|
156
|
-
if (property.type == 'boolean')
|
|
157
|
-
return designItems[0].hasAttribute(attributeName);
|
|
158
|
-
let lastValue = designItems[0].getAttribute(attributeName);
|
|
159
|
-
/*
|
|
160
|
-
for (const x of designItems) {
|
|
161
|
-
let value = x.attributes.get(attributeName);
|
|
162
|
-
if (value != lastValue) {
|
|
163
|
-
lastValue = null;
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
*/
|
|
168
|
-
return lastValue;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return null;
|
|
172
|
-
}
|
|
173
|
-
getBinding(designItems, property) {
|
|
174
|
-
//TODO: optimize perf, do not call bindings service for each property.
|
|
175
|
-
const bindings = designItems[0].serviceContainer.forSomeServicesTillResult('bindingService', (s) => {
|
|
176
|
-
return s.getBindings(designItems[0]);
|
|
177
|
-
});
|
|
178
|
-
if (property.propertyType == PropertyType.cssValue) {
|
|
179
|
-
return bindings.find(x => (x.target == BindingTarget.css) && x.targetName == property.name);
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
return bindings.find(x => (x.target == BindingTarget.property || x.target == BindingTarget.attribute) && x.targetName == property.name);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
getUnsetValue(designItems, property) {
|
|
186
|
-
if (property.propertyType == PropertyType.cssValue) {
|
|
187
|
-
if (designItems != null && designItems.length !== 0) {
|
|
188
|
-
if (designItems[0].nodeType == NodeType.Element) {
|
|
189
|
-
let v = window.getComputedStyle(designItems[0].element)[property.name];
|
|
190
|
-
return v;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
195
|
-
else
|
|
196
|
-
return property.defaultValue;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
2
|
-
import { IStyleDeclaration, IStyleRule, IStylesheet } from "./IStylesheetService.js";
|
|
3
|
-
import { AbstractStylesheetService } from "./AbstractStylesheetService.js";
|
|
4
|
-
import { IDesignerCanvas } from "../../widgets/designerView/IDesignerCanvas.js";
|
|
5
|
-
type CssRuleAST = any;
|
|
6
|
-
type CssDeclarationAST = any;
|
|
7
|
-
type CssStylesheetAST = any;
|
|
8
|
-
interface IRuleWithAST extends IStyleRule {
|
|
9
|
-
ast: CssRuleAST;
|
|
10
|
-
declarations: IDeclarationWithAST[];
|
|
11
|
-
stylesheet: IStylesheet;
|
|
12
|
-
stylesheetName: string;
|
|
13
|
-
}
|
|
14
|
-
interface IDeclarationWithAST extends IStyleDeclaration {
|
|
15
|
-
ast: CssDeclarationAST;
|
|
16
|
-
}
|
|
17
|
-
export declare class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
18
|
-
constructor(designerCanvas: IDesignerCanvas);
|
|
19
|
-
_tools: {
|
|
20
|
-
parse: (css: string, options?: {
|
|
21
|
-
source?: string;
|
|
22
|
-
silent?: boolean;
|
|
23
|
-
}) => CssStylesheetAST;
|
|
24
|
-
stringify: (node: CssStylesheetAST, options?: {
|
|
25
|
-
indent?: string;
|
|
26
|
-
compress?: boolean;
|
|
27
|
-
emptyDeclarations?: boolean;
|
|
28
|
-
}) => string;
|
|
29
|
-
};
|
|
30
|
-
internalParse(style: string): Promise<any>;
|
|
31
|
-
getAppliedRules(designItem: IDesignItem): IRuleWithAST[];
|
|
32
|
-
private getRulesFromAst;
|
|
33
|
-
getDeclarations(designItem: IDesignItem, styleName: string): IStyleDeclaration[];
|
|
34
|
-
updateDeclarationValueWithoutUndo(declaration: IDeclarationWithAST, value: string, important: boolean): void;
|
|
35
|
-
insertDeclarationIntoRule(rule: IRuleWithAST, property: string, value: string, important: boolean): boolean;
|
|
36
|
-
removeDeclarationFromRule(rule: IRuleWithAST, property: string): boolean;
|
|
37
|
-
private updateStylesheet;
|
|
38
|
-
updateCompleteStylesheet(name: string, newStyle: string): void;
|
|
39
|
-
updateCompleteStylesheetWithoutUndo(name: string, newStyle: string, noUndo?: boolean): void;
|
|
40
|
-
private updateCompleteStylesheetInternal;
|
|
41
|
-
}
|
|
42
|
-
export {};
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { AbstractStylesheetService } from "./AbstractStylesheetService.js";
|
|
2
|
-
export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
3
|
-
constructor(designerCanvas) {
|
|
4
|
-
super(designerCanvas);
|
|
5
|
-
}
|
|
6
|
-
_tools;
|
|
7
|
-
async internalParse(style) {
|
|
8
|
-
if (!this._tools)
|
|
9
|
-
this._tools = await import('@adobe/css-tools');
|
|
10
|
-
return this._tools.parse(style);
|
|
11
|
-
}
|
|
12
|
-
getAppliedRules(designItem) {
|
|
13
|
-
let rules = [];
|
|
14
|
-
for (let item of this._allStylesheets.entries()) {
|
|
15
|
-
if (!item[1].ast?.stylesheet?.rules)
|
|
16
|
-
continue;
|
|
17
|
-
let rs = Array.from(this.getRulesFromAst(item[1].ast?.stylesheet?.rules, item[1].stylesheet, designItem))
|
|
18
|
-
.map(x => ({
|
|
19
|
-
selector: x.selectors.join(', '),
|
|
20
|
-
declarations: x.declarations.filter(y => y.type == 'declaration').map(y => ({
|
|
21
|
-
name: y.property,
|
|
22
|
-
value: y.value.endsWith('!important') ? y.value.substring(0, y.value.length - 10).trimEnd() : y.value,
|
|
23
|
-
important: y.value.endsWith('!important'),
|
|
24
|
-
parent: null,
|
|
25
|
-
ast: y,
|
|
26
|
-
stylesheet: item[1].stylesheet
|
|
27
|
-
})),
|
|
28
|
-
specificity: 0,
|
|
29
|
-
stylesheetName: item[0],
|
|
30
|
-
ast: x,
|
|
31
|
-
}));
|
|
32
|
-
rs.forEach(x => x.declarations.forEach(y => y.parent = x));
|
|
33
|
-
rules.push(...rs);
|
|
34
|
-
}
|
|
35
|
-
;
|
|
36
|
-
return rules;
|
|
37
|
-
}
|
|
38
|
-
*getRulesFromAst(cssAtRuleAst, stylesheet, designItem) {
|
|
39
|
-
for (const atRule of cssAtRuleAst) {
|
|
40
|
-
if (atRule.type == 'media') {
|
|
41
|
-
yield* this.getRulesFromAst(atRule.rules, stylesheet, designItem);
|
|
42
|
-
}
|
|
43
|
-
else if (atRule.type == 'supports') {
|
|
44
|
-
yield* this.getRulesFromAst(atRule.rules, stylesheet, designItem);
|
|
45
|
-
}
|
|
46
|
-
else if (atRule.type == 'rule') {
|
|
47
|
-
if (this.elementMatchesASelector(designItem, atRule.selectors))
|
|
48
|
-
yield atRule;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
getDeclarations(designItem, styleName) {
|
|
54
|
-
return this.getAppliedRules(designItem).flatMap(x => x.declarations).filter(x => x.name == styleName);
|
|
55
|
-
}
|
|
56
|
-
updateDeclarationValueWithoutUndo(declaration, value, important) {
|
|
57
|
-
declaration.ast.value = important ? value + ' !important' : value;
|
|
58
|
-
let ss = this._allStylesheets.get(declaration.parent.stylesheetName);
|
|
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
|
-
*/
|
|
69
|
-
}
|
|
70
|
-
insertDeclarationIntoRule(rule, property, value, important) {
|
|
71
|
-
rule.ast.declarations.push({
|
|
72
|
-
type: 'declaration',
|
|
73
|
-
property: property,
|
|
74
|
-
value: important ? value + ' !important' : value
|
|
75
|
-
});
|
|
76
|
-
this.updateStylesheet(this._allStylesheets.get(rule.stylesheetName));
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
removeDeclarationFromRule(rule, property) {
|
|
80
|
-
let idx = rule.ast.declarations.findIndex(x => x.property == property);
|
|
81
|
-
if (idx == -1)
|
|
82
|
-
return false;
|
|
83
|
-
rule.ast.declarations.splice(idx, 1);
|
|
84
|
-
this.updateStylesheet(this._allStylesheets.get(rule.stylesheetName));
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
updateStylesheet(ss) {
|
|
88
|
-
const old = ss.stylesheet.content;
|
|
89
|
-
ss.stylesheet.content = this._tools.stringify(ss.ast, { indent: ' ', compress: false, emptyDeclarations: true });
|
|
90
|
-
if (ss.stylesheet.designItem) {
|
|
91
|
-
ss.stylesheet.designItem.content = ss.stylesheet.content;
|
|
92
|
-
}
|
|
93
|
-
else
|
|
94
|
-
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
95
|
-
}
|
|
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) {
|
|
103
|
-
const ss = this._allStylesheets.get(name);
|
|
104
|
-
if (ss.stylesheet.content != newStyle) {
|
|
105
|
-
const old = ss.stylesheet.content;
|
|
106
|
-
ss.stylesheet.content = newStyle;
|
|
107
|
-
if (ss.stylesheet.designItem) {
|
|
108
|
-
ss.stylesheet.designItem.content = ss.stylesheet.content;
|
|
109
|
-
}
|
|
110
|
-
else
|
|
111
|
-
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource });
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
2
|
-
import { IStyleDeclaration, IStyleRule, IStylesheet } from "./IStylesheetService.js";
|
|
3
|
-
import { AbstractStylesheetService } from "./AbstractStylesheetService.js";
|
|
4
|
-
import { IDesignerCanvas } from "../../widgets/designerView/IDesignerCanvas.js";
|
|
5
|
-
declare namespace csstree {
|
|
6
|
-
type CssNodePlain = any;
|
|
7
|
-
type CssNode = any;
|
|
8
|
-
type ParseOptions = any;
|
|
9
|
-
type GenerateOptions = any;
|
|
10
|
-
type RulePlain = any;
|
|
11
|
-
type DeclarationPlain = any;
|
|
12
|
-
type StyleSheetPlain = any;
|
|
13
|
-
type Raw = any;
|
|
14
|
-
type Declaration = any;
|
|
15
|
-
type AtrulePlain = any;
|
|
16
|
-
type BlockPlain = any;
|
|
17
|
-
type SelectorListPlain = any;
|
|
18
|
-
}
|
|
19
|
-
declare global {
|
|
20
|
-
interface Window {
|
|
21
|
-
csstree: {
|
|
22
|
-
fromPlainObject(node: csstree.CssNodePlain): csstree.CssNode;
|
|
23
|
-
toPlainObject(node: csstree.CssNode): csstree.CssNodePlain;
|
|
24
|
-
parse(text: string, options?: csstree.ParseOptions): csstree.CssNode;
|
|
25
|
-
generate(ast: csstree.CssNode, options?: csstree.GenerateOptions): string;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
interface IRuleWithAST extends IStyleRule {
|
|
30
|
-
ast: csstree.RulePlain;
|
|
31
|
-
declarations: IDeclarationWithAST[];
|
|
32
|
-
stylesheet: IStylesheet;
|
|
33
|
-
}
|
|
34
|
-
interface IDeclarationWithAST extends IStyleDeclaration {
|
|
35
|
-
ast: csstree.DeclarationPlain;
|
|
36
|
-
}
|
|
37
|
-
export declare class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
38
|
-
constructor(designerCanvas: IDesignerCanvas);
|
|
39
|
-
internalParse(style: string): Promise<any>;
|
|
40
|
-
private getAppliedRulesInternal;
|
|
41
|
-
getAppliedRules(designItem: IDesignItem): IRuleWithAST[];
|
|
42
|
-
private getDeclarationInternal;
|
|
43
|
-
getDeclarations(designItem: IDesignItem, stlyeName: string): IDeclarationWithAST[];
|
|
44
|
-
updateDeclarationValueWithoutUndo(declaration: IDeclarationWithAST, value: string, important: boolean): void;
|
|
45
|
-
insertDeclarationIntoRule(rule: IRuleWithAST, property: string, value: string, important: boolean): boolean;
|
|
46
|
-
removeDeclarationFromRule(rule: IRuleWithAST, property: string): boolean;
|
|
47
|
-
updateCompleteStylesheet(name: string, newStyle: string): void;
|
|
48
|
-
updateCompleteStylesheetWithoutUndo(name: string, newStyle: string, noUndo?: boolean): void;
|
|
49
|
-
private updateCompleteStylesheetInternal;
|
|
50
|
-
private rulesFromAST;
|
|
51
|
-
private astHasChildren;
|
|
52
|
-
private buildSelectorString;
|
|
53
|
-
private getSpecificity;
|
|
54
|
-
private findDeclarationInRule;
|
|
55
|
-
private buildAtRuleString;
|
|
56
|
-
private sortDeclarations;
|
|
57
|
-
}
|
|
58
|
-
export {};
|