@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.
Files changed (87) hide show
  1. package/README.md +1 -30
  2. package/dist/elements/helper/NpmPackageLoader.d.ts +1 -2
  3. package/dist/elements/{loader → services/manifestParsers}/OldCustomElementsManifestLoader.d.ts +1 -1
  4. package/dist/elements/{loader → services/manifestParsers}/OldCustomElementsManifestLoader.js +2 -2
  5. package/dist/index.d.ts +4 -17
  6. package/dist/index.js +2 -16
  7. package/package.json +3 -25
  8. package/.editorconfig +0 -7
  9. package/.github/FUNDING.yml +0 -4
  10. package/.vscode/settings.json +0 -3
  11. package/ACKNOWLEDGMENTS +0 -15
  12. package/LICENSE +0 -21
  13. package/RemoveOldRemoteBranches.bat +0 -7
  14. package/dist/elements/services/demoProviderService/DemoProviderService.d.ts +0 -6
  15. package/dist/elements/services/demoProviderService/DemoProviderService.js +0 -38
  16. package/dist/elements/services/demoProviderService/IframeDemoProviderService copy.d.ts +0 -6
  17. package/dist/elements/services/demoProviderService/IframeDemoProviderService copy.js +0 -38
  18. package/dist/elements/services/designerAddons/IDesignerAddonJson copy.d.ts +0 -3
  19. package/dist/elements/services/designerAddons/IDesignerAddonJson copy.js +0 -1
  20. package/dist/elements/services/designerAddons/IDesignerInfoJson.d.ts +0 -7
  21. package/dist/elements/services/designerAddons/IDesignerInfoJson.js +0 -19
  22. package/dist/elements/services/dragDropService/IExternalDragDropService copy.d.ts +0 -5
  23. package/dist/elements/services/dragDropService/IExternalDragDropService copy.js +0 -1
  24. package/dist/elements/services/eventsService/IEventsService copy.d.ts +0 -2
  25. package/dist/elements/services/eventsService/IEventsService copy.js +0 -1
  26. package/dist/elements/services/htmlParserService/BaseCustomWebcomponentParserService.d.ts +0 -11
  27. package/dist/elements/services/htmlParserService/BaseCustomWebcomponentParserService.js +0 -90
  28. package/dist/elements/services/htmlParserService/LitElementParserService.d.ts +0 -12
  29. package/dist/elements/services/htmlParserService/LitElementParserService.js +0 -91
  30. package/dist/elements/services/htmlParserService/NodeHtmlParserService.d.ts +0 -11
  31. package/dist/elements/services/htmlParserService/NodeHtmlParserService.js +0 -89
  32. package/dist/elements/services/htmlParserService/VueParserService.d.ts +0 -9
  33. package/dist/elements/services/htmlParserService/VueParserService.js +0 -10
  34. package/dist/elements/services/htmlWriterService/HtmlWriterOptions.d.ts +0 -7
  35. package/dist/elements/services/htmlWriterService/HtmlWriterOptions.js +0 -7
  36. package/dist/elements/services/propertiesService/propertyEditors/GridAssignedRowColumnPropertyEditor.d.ts +0 -8
  37. package/dist/elements/services/propertiesService/propertyEditors/GridAssignedRowColumnPropertyEditor.js +0 -45
  38. package/dist/elements/services/propertiesService/propertyEditors/GridRowColumnPropertyEditor.d.ts +0 -10
  39. package/dist/elements/services/propertiesService/propertyEditors/GridRowColumnPropertyEditor.js +0 -25
  40. package/dist/elements/services/propertiesService/propertyEditors/JsonPropertyEditor copy.d.ts +0 -9
  41. package/dist/elements/services/propertiesService/propertyEditors/JsonPropertyEditor copy.js +0 -21
  42. package/dist/elements/services/propertiesService/propertyEditors/MetricsPropertyEditor.d.ts +0 -8
  43. package/dist/elements/services/propertiesService/propertyEditors/MetricsPropertyEditor.js +0 -14
  44. package/dist/elements/services/propertiesService/propertyEditors/SelectPropertyEditor copy.d.ts +0 -7
  45. package/dist/elements/services/propertiesService/propertyEditors/SelectPropertyEditor copy.js +0 -28
  46. package/dist/elements/services/propertiesService/services/CommonPropertiesService copy.d.ts +0 -13
  47. package/dist/elements/services/propertiesService/services/CommonPropertiesService copy.js +0 -44
  48. package/dist/elements/services/propertiesService/services/ContentPropertiesService.d.ts +0 -14
  49. package/dist/elements/services/propertiesService/services/ContentPropertiesService.js +0 -30
  50. package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.d.ts +0 -34
  51. package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.js +0 -105
  52. package/dist/elements/services/propertiesService/services/PolymerPropertiesService copy.d.ts +0 -8
  53. package/dist/elements/services/propertiesService/services/PolymerPropertiesService copy.js +0 -10
  54. package/dist/elements/services/propertiesService/services/UnkownElemntPropertiesService.d.ts +0 -24
  55. package/dist/elements/services/propertiesService/services/UnkownElemntPropertiesService.js +0 -198
  56. package/dist/elements/services/stylesheetService/CssToolsStylesheetService.d.ts +0 -42
  57. package/dist/elements/services/stylesheetService/CssToolsStylesheetService.js +0 -114
  58. package/dist/elements/services/stylesheetService/CssTreeStylesheetService.d.ts +0 -58
  59. package/dist/elements/services/stylesheetService/CssTreeStylesheetService.js +0 -204
  60. package/dist/elements/services/stylesheetService/SpecificityCalculator.d.ts +0 -7
  61. package/dist/elements/services/stylesheetService/SpecificityCalculator.js +0 -178
  62. package/dist/elements/services/undoService/transactionItems/AttributeChangeAction copy.d.ts +0 -15
  63. package/dist/elements/services/undoService/transactionItems/AttributeChangeAction copy.js +0 -70
  64. package/dist/elements/widgets/bindableObjectsBrowser/bindable-objects-browser.d.ts +0 -14
  65. package/dist/elements/widgets/bindableObjectsBrowser/bindable-objects-browser.js +0 -137
  66. package/dist/elements/widgets/codeView/code-view-ace.d.ts +0 -24
  67. package/dist/elements/widgets/codeView/code-view-ace.js +0 -134
  68. package/dist/elements/widgets/codeView/code-view-code-mirror.d.ts +0 -25
  69. package/dist/elements/widgets/codeView/code-view-code-mirror.js +0 -117
  70. package/dist/elements/widgets/codeView/code-view-monaco.d.ts +0 -37
  71. package/dist/elements/widgets/codeView/code-view-monaco.js +0 -197
  72. package/dist/elements/widgets/designerView/extensions/EditText/EditTextWithStyloExtension.d.ts +0 -23
  73. package/dist/elements/widgets/designerView/extensions/EditText/EditTextWithStyloExtension.js +0 -87
  74. package/dist/elements/widgets/designerView/extensions/EditText/EditTextWithStyloExtensionProvider.d.ts +0 -10
  75. package/dist/elements/widgets/designerView/extensions/EditText/EditTextWithStyloExtensionProvider.js +0 -15
  76. package/dist/elements/widgets/miniatureView/html-2-canvas-miniature-view.d.ts +0 -10
  77. package/dist/elements/widgets/miniatureView/html-2-canvas-miniature-view.js +0 -21
  78. package/dist/elements/widgets/paletteView/paletteTreeView.d.ts +0 -12
  79. package/dist/elements/widgets/paletteView/paletteTreeView.js +0 -141
  80. package/dist/elements/widgets/treeView/treeViewExtended.d.ts +0 -32
  81. package/dist/elements/widgets/treeView/treeViewExtended.js +0 -366
  82. package/fixesimport.js +0 -98
  83. package/jest.config.cjs +0 -7
  84. package/polymer.json +0 -42
  85. package/tsconfig.json +0 -75
  86. /package/dist/elements/{loader → services/manifestParsers}/IOldCustomElementsManifest.d.ts +0 -0
  87. /package/dist/elements/{loader → services/manifestParsers}/IOldCustomElementsManifest.js +0 -0
@@ -1,204 +0,0 @@
1
- import { calculate as calculateSpecifity } from "./SpecificityCalculator.js";
2
- import { AbstractStylesheetService } from "./AbstractStylesheetService.js";
3
- export class CssTreeStylesheetService extends AbstractStylesheetService {
4
- constructor(designerCanvas) {
5
- super(designerCanvas);
6
- }
7
- async internalParse(style) {
8
- return window.csstree.toPlainObject((window.csstree.parse(style, { positions: true, parseValue: false })));
9
- }
10
- /* Section covers the retrieval of rules and declarations */
11
- getAppliedRulesInternal(designItem) {
12
- let styles = [];
13
- for (let item of this._allStylesheets) {
14
- if (!item[1].ast || !this.astHasChildren(item[1].ast))
15
- continue;
16
- styles = styles.concat(Array.from(this.rulesFromAST(item[1].ast, item[1].stylesheet.content, item[0], designItem)));
17
- }
18
- ;
19
- return styles;
20
- }
21
- getAppliedRules(designItem) {
22
- let rules = this.getAppliedRulesInternal(designItem);
23
- if (!rules || rules.length == 0)
24
- return [];
25
- let retCollection = [];
26
- for (let rule of rules) {
27
- retCollection.push({
28
- ...rule,
29
- declarations: rule.ast.block.children.map((declaration) => {
30
- return {
31
- name: declaration.property,
32
- value: declaration.value.value,
33
- important: declaration.important == true,
34
- specificity: rule.specificity,
35
- parent: rule,
36
- ast: declaration,
37
- };
38
- })
39
- });
40
- }
41
- return retCollection;
42
- }
43
- getDeclarationInternal(designItem, styleName) {
44
- let rules = this.getAppliedRulesInternal(designItem);
45
- if (!rules)
46
- return null;
47
- let declarations = [];
48
- for (let rule of rules) {
49
- let declaration = this.findDeclarationInRule(rule.ast, styleName);
50
- if (!declaration)
51
- continue;
52
- declarations.push({
53
- ast: declaration,
54
- parent: rule,
55
- name: styleName,
56
- value: declaration.value.value,
57
- important: declaration.important == true,
58
- stylesheet: rule.stylesheet
59
- });
60
- }
61
- ;
62
- return declarations;
63
- }
64
- getDeclarations(designItem, stlyeName) {
65
- let declarations = this.getDeclarationInternal(designItem, stlyeName);
66
- if (!declarations)
67
- return null;
68
- return this.sortDeclarations(declarations);
69
- }
70
- /* Section covers the update of rules and declarations */
71
- updateDeclarationValueWithoutUndo(declaration, value, important) {
72
- let sourceNode = this._allStylesheets.get(declaration.parent.stylesheetName);
73
- declaration.ast.value = window.csstree.toPlainObject(window.csstree.parse(declaration.name + ": " + value + (important ? " !important" : ""), { context: 'declaration', parseValue: false })).value;
74
- const old = sourceNode.stylesheet.content;
75
- sourceNode.stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(sourceNode.ast));
76
- // After generating the stylesheet, parse again (so line numbers are correct)
77
- sourceNode.ast = window.csstree.toPlainObject((window.csstree.parse(sourceNode.stylesheet.content, { positions: true, parseValue: false })));
78
- if (sourceNode.stylesheet.designItem) {
79
- sourceNode.stylesheet.designItem.content = sourceNode.stylesheet.content;
80
- }
81
- else
82
- this.stylesheetChanged.emit({ name: sourceNode.stylesheet.name, newStyle: sourceNode.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
83
- }
84
- insertDeclarationIntoRule(rule, property, value, important) {
85
- let sourceNode = this._allStylesheets.get(rule.stylesheetName);
86
- rule.ast.block.children.push(window.csstree.toPlainObject(window.csstree.parse(property + ": " + value + (important ? " !important" : ""), { context: 'declaration', parseValue: false })));
87
- const old = sourceNode.stylesheet.content;
88
- sourceNode.stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(sourceNode.ast));
89
- // After generating the stylesheet, parse again (so line numbers are correct)
90
- sourceNode.ast = window.csstree.toPlainObject((window.csstree.parse(sourceNode.stylesheet.content, { positions: true, parseValue: false })));
91
- if (sourceNode.stylesheet.designItem) {
92
- sourceNode.stylesheet.designItem.content = sourceNode.stylesheet.content;
93
- }
94
- else
95
- this.stylesheetChanged.emit({ name: sourceNode.stylesheet.name, newStyle: sourceNode.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
96
- return true;
97
- }
98
- removeDeclarationFromRule(rule, property) {
99
- let index = rule.ast.block.children.findIndex(x => x.property == property);
100
- if (index == -1)
101
- return false;
102
- rule.ast.block.children.splice(index, 1);
103
- const ss = this._allStylesheets.get(rule.stylesheetName);
104
- const old = ss.stylesheet.content;
105
- ss.stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(this._allStylesheets.get(rule.stylesheetName).ast));
106
- // After generating the stylesheet, parse again (so line numbers are correct)
107
- ss.ast = window.csstree.toPlainObject((window.csstree.parse(this._allStylesheets.get(rule.stylesheetName).stylesheet.content, { positions: true, parseValue: false })));
108
- if (ss.stylesheet.designItem) {
109
- ss.stylesheet.designItem.content = ss.stylesheet.content;
110
- }
111
- else
112
- this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
113
- return true;
114
- }
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) {
122
- const ss = this._allStylesheets.get(name);
123
- if (ss.stylesheet.content != newStyle) {
124
- const old = ss.stylesheet.content;
125
- ss.stylesheet.content = newStyle;
126
- if (ss.stylesheet.designItem) {
127
- ss.stylesheet.designItem.content = ss.stylesheet.content;
128
- }
129
- else
130
- this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource });
131
- }
132
- }
133
- /* Section covers the internal traversal creation of rules and declarations */
134
- *rulesFromAST(ast, stylesheet, source, designItem, previousCheck = '') {
135
- let parent = ast["children"] != null ? ast : ast.block;
136
- for (const child of parent.children) {
137
- if (child.type == "Atrule") {
138
- const currentCheck = this.buildAtRuleString(child, stylesheet);
139
- if (currentCheck.type === "@media" && !window.matchMedia(currentCheck.sel))
140
- continue;
141
- if (currentCheck.type === "@supports" && !CSS.supports(currentCheck.sel))
142
- continue;
143
- let ruleCollection = this.rulesFromAST(child, stylesheet, source, designItem, previousCheck + currentCheck.type + " " + currentCheck.sel + "\n");
144
- if (ruleCollection) {
145
- for (const r of ruleCollection) {
146
- if (!this.elementMatchesASelector(designItem, this.buildSelectorString(r.ast.prelude, stylesheet)))
147
- continue;
148
- yield r;
149
- }
150
- }
151
- }
152
- if (child.type == "Rule") {
153
- let selectors = this.buildSelectorString(child.prelude, stylesheet);
154
- if (!this.elementMatchesASelector(designItem, selectors))
155
- continue;
156
- yield ({
157
- ast: child,
158
- selector: previousCheck + this.buildSelectorString(child.prelude, stylesheet).join(", "),
159
- specificity: this.getSpecificity(child.prelude),
160
- stylesheetName: source,
161
- declarations: null,
162
- stylesheet: this._allStylesheets.get(source).stylesheet
163
- });
164
- }
165
- }
166
- ;
167
- }
168
- /* Utility functions for building selectors, specificity and so on */
169
- astHasChildren(ast) {
170
- return ast != null && ast["children"] != null && ast["children"].length > 0;
171
- }
172
- buildSelectorString(selectorsAST, stylesheet) {
173
- if (selectorsAST.type == 'SelectorList') {
174
- return [...selectorsAST.children.map(x => this.buildSelectorString(x, stylesheet)[0])];
175
- }
176
- else {
177
- return [stylesheet.substring(selectorsAST.loc.start.offset, selectorsAST.loc.end.offset)];
178
- }
179
- }
180
- getSpecificity(selector) {
181
- const specificities = calculateSpecifity(selector);
182
- let sum = 0;
183
- specificities.forEach(specificity => sum += specificity.a * 10000 + specificity.b * 100 + specificity.c);
184
- return sum;
185
- }
186
- findDeclarationInRule(rule, styleName) {
187
- return rule.block.children.find(declaration => declaration.property == styleName);
188
- }
189
- buildAtRuleString(ast, stylesheet) {
190
- return {
191
- sel: stylesheet.slice(ast.prelude.loc.start.offset, ast.prelude.loc.end.offset),
192
- type: "@" + ast.name
193
- };
194
- }
195
- sortDeclarations(declarations) {
196
- if (declarations == null || declarations.length == 0)
197
- return null;
198
- return declarations.sort((dec1, dec2) => {
199
- if (dec1.parent.specificity > dec2.parent.specificity)
200
- return -1;
201
- return 1;
202
- });
203
- }
204
- }
@@ -1,7 +0,0 @@
1
- type Specificity = {
2
- a: 0;
3
- b: 0;
4
- c: 0;
5
- };
6
- declare const calculate: (selectorAST: any) => Specificity[];
7
- export { calculate };
@@ -1,178 +0,0 @@
1
- const calculateSpecificityOfSelectorObject = (selectorObj) => {
2
- // https://www.w3.org/TR/selectors-4/#specificity-rules
3
- const specificity = { a: 0, b: 0, c: 0 };
4
- selectorObj.children.forEach((child) => {
5
- switch (child.type) {
6
- case 'IdSelector':
7
- specificity.a += 1;
8
- break;
9
- case 'AttributeSelector':
10
- case 'ClassSelector':
11
- specificity.b += 1;
12
- break;
13
- case 'PseudoClassSelector':
14
- switch (child.name.toLowerCase()) {
15
- // “The specificity of a :where() pseudo-class is replaced by zero.”
16
- case 'where':
17
- // Noop :)
18
- break;
19
- // “The specificity of an :is(), :not(), or :has() pseudo-class is replaced by the specificity of the most specific complex selector in its selector list argument.“
20
- case 'is':
21
- case 'matches':
22
- case '-webkit-any':
23
- case '-moz-any':
24
- case 'any':
25
- case 'not':
26
- case 'has':
27
- if (child.children) {
28
- // Calculate Specificity from nested SelectorList
29
- const max1 = max(...calculate(child.children.first));
30
- // Adjust orig specificity
31
- specificity.a += max1.a;
32
- specificity.b += max1.b;
33
- specificity.c += max1.c;
34
- }
35
- break;
36
- // “The specificity of an :nth-child() or :nth-last-child() selector is the specificity of the pseudo class itself (counting as one pseudo-class selector) plus the specificity of the most specific complex selector in its selector list argument”
37
- case 'nth-child':
38
- case 'nth-last-child':
39
- specificity.b += 1;
40
- if (child.children.first.selector) {
41
- // Calculate Specificity from SelectorList
42
- const max2 = max(...calculate(child.children.first.selector));
43
- // Adjust orig specificity
44
- specificity.a += max2.a;
45
- specificity.b += max2.b;
46
- specificity.c += max2.c;
47
- }
48
- break;
49
- // “The specificity of :host is that of a pseudo-class. The specificity of :host() is that of a pseudo-class, plus the specificity of its argument.”
50
- // “The specificity of :host-context() is that of a pseudo-class, plus the specificity of its argument.”
51
- case 'host-context':
52
- case 'host':
53
- specificity.b += 1;
54
- if (child.children) {
55
- // Workaround to a css-tree bug in which it allows complex selectors instead of only compound selectors
56
- // We work around it by filtering out any Combinator and successive Selectors
57
- const childAST = { type: 'Selector', children: [] };
58
- let foundCombinator = false;
59
- // @ts-ignore
60
- child.children.first.children.forEach((entry) => {
61
- if (foundCombinator)
62
- return false;
63
- if (entry.type === 'Combinator') {
64
- foundCombinator = true;
65
- return false;
66
- }
67
- childAST.children.push(entry);
68
- });
69
- // Calculate Specificity from Selector
70
- const childSpecificity = calculate(childAST)[0];
71
- // Adjust orig specificity
72
- specificity.a += childSpecificity.a;
73
- specificity.b += childSpecificity.b;
74
- specificity.c += childSpecificity.c;
75
- }
76
- break;
77
- // Improper use of Pseudo-Class Selectors instead of a Pseudo-Element
78
- // @ref https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements#index
79
- case 'after':
80
- case 'before':
81
- case 'first-letter':
82
- case 'first-line':
83
- specificity.c += 1;
84
- break;
85
- default:
86
- specificity.b += 1;
87
- break;
88
- }
89
- break;
90
- case 'PseudoElementSelector':
91
- switch (child.name) {
92
- // “The specificity of ::slotted() is that of a pseudo-element, plus the specificity of its argument.”
93
- case 'slotted':
94
- specificity.c += 1;
95
- if (child.children) {
96
- // Workaround to a css-tree bug in which it allows complex selectors instead of only compound selectors
97
- // We work around it by filtering out any Combinator and successive Selectors
98
- const childAST = { type: 'Selector', children: [] };
99
- let foundCombinator = false;
100
- // @ts-ignore
101
- child.children.first.children.forEach((entry) => {
102
- if (foundCombinator)
103
- return false;
104
- if (entry.type === 'Combinator') {
105
- foundCombinator = true;
106
- return false;
107
- }
108
- childAST.children.push(entry);
109
- });
110
- // Calculate Specificity from Selector
111
- const childSpecificity = calculate(childAST)[0];
112
- // Adjust orig specificity
113
- specificity.a += childSpecificity.a;
114
- specificity.b += childSpecificity.b;
115
- specificity.c += childSpecificity.c;
116
- }
117
- break;
118
- default:
119
- specificity.c += 1;
120
- break;
121
- }
122
- break;
123
- case 'TypeSelector':
124
- // Omit namespace
125
- let typeSelector = child.name;
126
- if (typeSelector.includes('|')) {
127
- typeSelector = typeSelector.split('|')[1];
128
- }
129
- // “Ignore the universal selector”
130
- if (typeSelector !== '*') {
131
- specificity.c += 1;
132
- }
133
- break;
134
- default:
135
- // NOOP
136
- break;
137
- }
138
- });
139
- return specificity;
140
- };
141
- const calculate = (selectorAST) => {
142
- // Quit while you're ahead
143
- if (!selectorAST) {
144
- return [];
145
- }
146
- // Selector?
147
- if (selectorAST.type === 'Selector')
148
- return [calculateSpecificityOfSelectorObject(selectorAST)];
149
- // SelectorList?
150
- // ~> Calculate Specificity for each contained Selector
151
- if (selectorAST.type === 'SelectorList') {
152
- const specificities = [];
153
- selectorAST.children.forEach((selector) => {
154
- const specificity = calculateSpecificityOfSelectorObject(selector);
155
- specificities.push(specificity);
156
- });
157
- return specificities;
158
- }
159
- return null;
160
- };
161
- const max = (...specificities) => {
162
- const sorted = sort(specificities);
163
- return sorted[0];
164
- };
165
- const sort = (specificities) => {
166
- const sorted = specificities.sort(compare);
167
- return sorted.reverse();
168
- };
169
- const compare = (s1, s2) => {
170
- if (s1.a === s2.a) {
171
- if (s1.b === s2.b) {
172
- return s1.c - s2.c;
173
- }
174
- return s1.b - s2.b;
175
- }
176
- return s1.a - s2.a;
177
- };
178
- export { calculate };
@@ -1,15 +0,0 @@
1
- import { ITransactionItem } from '../ITransactionItem.js';
2
- import { IDesignItem } from '../../../item/IDesignItem.js';
3
- import { IBinding } from '../../../item/IBinding.js';
4
- export declare class AttributeChangeAction implements ITransactionItem {
5
- constructor(designItem: IDesignItem, name: string, newValue: string | IBinding | null, oldValue: string | IBinding | null);
6
- title?: string;
7
- get affectedItems(): IDesignItem[];
8
- undo(): void;
9
- do(): void;
10
- designItem: IDesignItem;
11
- name: string;
12
- newValue: any;
13
- oldValue: any;
14
- mergeWith(other: ITransactionItem): boolean;
15
- }
@@ -1,70 +0,0 @@
1
- export class AttributeChangeAction {
2
- constructor(designItem, name, newValue, oldValue) {
3
- this.title = "Change Attribute " + name + " of <" + designItem.name + ">";
4
- this.designItem = designItem;
5
- this.name = name;
6
- this.newValue = newValue;
7
- this.oldValue = oldValue;
8
- }
9
- title;
10
- get affectedItems() {
11
- return [this.designItem];
12
- }
13
- undo() {
14
- if (this.oldValue == null) {
15
- this.designItem._withoutUndoRemoveAttribute(this.name);
16
- try {
17
- this.designItem.element.removeAttribute(this.name);
18
- }
19
- catch (e) {
20
- console.warn(e);
21
- }
22
- }
23
- else {
24
- this.designItem._withoutUndoSetAttribute(this.name, this.oldValue);
25
- if (this.name != "draggable") {
26
- try {
27
- if (typeof this.oldValue === 'string')
28
- this.designItem.element.setAttribute(this.name, this.oldValue);
29
- }
30
- catch (e) {
31
- console.warn(e);
32
- }
33
- }
34
- }
35
- }
36
- do() {
37
- if (this.newValue == null) {
38
- this.designItem._withoutUndoRemoveAttribute(this.name);
39
- try {
40
- this.designItem.element.removeAttribute(this.name);
41
- }
42
- catch (e) {
43
- console.warn(e);
44
- }
45
- }
46
- else {
47
- this.designItem._withoutUndoSetAttribute(this.name, this.newValue);
48
- if (this.name != "draggable") {
49
- try {
50
- if (typeof this.newValue === 'string')
51
- this.designItem.element.setAttribute(this.name, this.newValue);
52
- }
53
- catch (e) {
54
- console.warn(e);
55
- }
56
- }
57
- }
58
- }
59
- designItem;
60
- name;
61
- newValue;
62
- oldValue;
63
- mergeWith(other) {
64
- if (other instanceof AttributeChangeAction && this.designItem === other.designItem && this.name === other.name) {
65
- this.newValue = other.newValue;
66
- return true;
67
- }
68
- return false;
69
- }
70
- }
@@ -1,14 +0,0 @@
1
- import { BaseCustomWebComponentLazyAppend, TypedEvent } from '@node-projects/base-custom-webcomponent';
2
- import { IBindableObject } from '../../services/bindableObjectsService/IBindableObject.js';
3
- import { ServiceContainer } from '../../services/ServiceContainer.js';
4
- export declare class BindableObjectsBrowser extends BaseCustomWebComponentLazyAppend {
5
- private _treeDiv;
6
- private _tree;
7
- selectedObject: IBindableObject<any>;
8
- objectDoubleclicked: TypedEvent<void>;
9
- static readonly style: CSSStyleSheet;
10
- constructor();
11
- initialize(serviceContainer: ServiceContainer): Promise<void>;
12
- private deselectNodes;
13
- private lazyLoad;
14
- }
@@ -1,137 +0,0 @@
1
- import { BaseCustomWebComponentLazyAppend, TypedEvent, css } from '@node-projects/base-custom-webcomponent';
2
- import { dragDropFormatNameBindingObject } from '../../../Constants.js';
3
- export class BindableObjectsBrowser extends BaseCustomWebComponentLazyAppend {
4
- _treeDiv;
5
- _tree;
6
- selectedObject;
7
- objectDoubleclicked = new TypedEvent;
8
- static style = css `
9
- span.drag-source {
10
- border: 1px solid grey;
11
- border-radius: 3px;
12
- padding: 2px;
13
- background-color: silver;
14
- }
15
-
16
- span.fancytree-node.fancytree-drag-source {
17
- outline: 1px dotted grey;
18
- }
19
- span.fancytree-node.fancytree-drop-accept {
20
- outline: 1px dotted green;
21
- }
22
- span.fancytree-node.fancytree-drop-reject {
23
- outline: 1px dotted red;
24
- }
25
- #tree ul {
26
- border: none;
27
- }
28
- #tree ul:focus {
29
- outline: none;
30
- }
31
- `;
32
- constructor() {
33
- super();
34
- this._restoreCachedInititalValues();
35
- //@ts-ignore
36
- if (window.importShim)
37
- //@ts-ignore
38
- importShim("jquery.fancytree/dist/skin-win8/ui.fancytree.css", { assert: { type: 'css' } }).then(x => this.shadowRoot.adoptedStyleSheets = [x.default, this.constructor.style]);
39
- else
40
- //@ts-ignore
41
- import("jquery.fancytree/dist/skin-win8/ui.fancytree.css", { assert: { type: 'css' } }).then(x => this.shadowRoot.adoptedStyleSheets = [x.default, this.constructor.style]);
42
- this._treeDiv = document.createElement('div');
43
- this._treeDiv.style.height = '100%';
44
- this._treeDiv.style.overflow = 'auto';
45
- this._treeDiv.setAttribute('id', 'tree');
46
- this.shadowRoot.appendChild(this._treeDiv);
47
- $(this._treeDiv).fancytree({
48
- debugLevel: 0,
49
- icon: false,
50
- extensions: ['dnd5', 'filter'],
51
- quicksearch: true,
52
- source: [],
53
- lazyLoad: this.lazyLoad,
54
- dblclick: (e) => {
55
- this.objectDoubleclicked.emit();
56
- return true;
57
- },
58
- activate: (event, data) => {
59
- this.deselectNodes();
60
- let node = data.node;
61
- this.selectedObject = node.data.bindable;
62
- },
63
- filter: {
64
- autoApply: true,
65
- autoExpand: false,
66
- counter: true,
67
- fuzzy: false,
68
- hideExpandedCounter: true,
69
- hideExpanders: false,
70
- highlight: true,
71
- leavesOnly: false,
72
- nodata: true,
73
- mode: "dimm" // Grayout unmatched nodes (pass "hide" to remove unmatched node instead)
74
- },
75
- dnd5: {
76
- dropMarkerParent: this.shadowRoot,
77
- preventRecursion: true,
78
- preventVoidMoves: false,
79
- dropMarkerOffsetX: -24,
80
- dropMarkerInsertOffsetX: -16,
81
- dragStart: (node, data) => {
82
- data.effectAllowed = "all";
83
- data.dataTransfer.setData(dragDropFormatNameBindingObject, JSON.stringify(node.data.bindable));
84
- data.dropEffect = "copy";
85
- return true;
86
- },
87
- dragEnter: (node, data) => {
88
- return false;
89
- }
90
- }
91
- });
92
- this._tree = $.ui.fancytree.getTree(this._treeDiv);
93
- this._treeDiv.children[0].classList.add('fancytree-connectors');
94
- }
95
- async initialize(serviceContainer) {
96
- let rootNode = this._tree.getRootNode();
97
- rootNode.removeChildren();
98
- const services = serviceContainer.bindableObjectsServices;
99
- for (const s of services) {
100
- const newNode = rootNode.addChildren({
101
- title: s.name,
102
- folder: true,
103
- lazy: true,
104
- data: {
105
- service: s
106
- }
107
- });
108
- rootNode.addNode(newNode);
109
- }
110
- }
111
- deselectNodes() {
112
- let nodes = this._tree.getSelectedNodes();
113
- nodes.forEach(node => {
114
- node.setSelected(false);
115
- node.setActive(false);
116
- });
117
- }
118
- lazyLoad(event, data) {
119
- data.result = new Promise(async (resolve) => {
120
- const service = data.node.data.service;
121
- const bindable = data.node.data.bindable;
122
- let children;
123
- if (bindable?.children)
124
- children = bindable.children;
125
- else
126
- children = await service.getBindableObjects(bindable);
127
- resolve(children.map(x => ({
128
- service,
129
- title: x.name,
130
- bindable: x,
131
- folder: x.children !== false,
132
- lazy: x.children !== false
133
- })));
134
- });
135
- }
136
- }
137
- customElements.define('node-projects-bindable-objects-browser', BindableObjectsBrowser);
@@ -1,24 +0,0 @@
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 CodeViewAce extends BaseCustomWebComponentLazyAppend implements ICodeView, IDisposable {
7
- canvasElement: HTMLElement;
8
- elementsToPackages: Map<string, string>;
9
- code: string;
10
- onTextChanged: TypedEvent<string>;
11
- private _aceEditor;
12
- private _editor;
13
- static readonly style: CSSStyleSheet;
14
- constructor();
15
- dispose(): void;
16
- executeCommand(command: IUiCommand): void;
17
- canExecuteCommand(command: IUiCommand): boolean;
18
- focusEditor(): void;
19
- oneTimeSetup(): void;
20
- ready(): void;
21
- update(code: any): void;
22
- getText(): string;
23
- setSelection(position: IStringPosition): void;
24
- }