@node-projects/web-component-designer 0.0.202 → 0.0.204
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/item/DesignItem.js +6 -3
- package/dist/elements/services/DefaultServiceBootstrap.js +1 -1
- package/dist/elements/services/propertiesService/DefaultEditorTypesService copy.d.ts +6 -0
- package/dist/elements/services/propertiesService/DefaultEditorTypesService copy.js +64 -0
- package/dist/elements/services/propertiesService/GridEditorTypesService.d.ts +6 -0
- package/dist/elements/services/propertiesService/GridEditorTypesService.js +64 -0
- package/dist/elements/services/propertiesService/propertyEditors/GridCellPropertyEditor.d.ts +9 -0
- package/dist/elements/services/propertiesService/propertyEditors/GridCellPropertyEditor.js +16 -0
- package/dist/elements/services/propertiesService/propertyEditors/JsonPropertyEditor copy.d.ts +9 -0
- package/dist/elements/services/propertiesService/propertyEditors/JsonPropertyEditor copy.js +21 -0
- package/dist/elements/services/selectionService/SelectionService.d.ts +2 -1
- package/dist/elements/services/selectionService/SelectionService.js +10 -3
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.d.ts +1 -3
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.js +1 -1
- package/dist/elements/widgets/codeView/code-view-ace copy.d.ts +24 -0
- package/dist/elements/widgets/codeView/code-view-ace copy.js +133 -0
- package/dist/elements/widgets/codeView/code-view-jar.d.ts +23 -0
- package/dist/elements/widgets/codeView/code-view-jar.js +121 -0
- package/dist/elements/widgets/designerView/designerCanvas.js +5 -2
- package/dist/elements/widgets/designerView/extensions/grid/DisplayGridExtension.d.ts +1 -0
- package/dist/elements/widgets/designerView/extensions/grid/DisplayGridExtension.js +5 -2
- package/package.json +1 -1
|
@@ -373,10 +373,13 @@ export class DesignItem {
|
|
|
373
373
|
return [];
|
|
374
374
|
const localStyles = [...this._styles.entries()].map(x => ({ name: x[0], value: x[1], important: false, parent: null }));
|
|
375
375
|
if (this.instanceServiceContainer.stylesheetService) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
376
|
+
try {
|
|
377
|
+
const rules = this.instanceServiceContainer.stylesheetService?.getAppliedRules(this);
|
|
378
|
+
if (rules) {
|
|
379
|
+
return [{ selector: null, declarations: localStyles, specificity: -1 }, ...rules];
|
|
380
|
+
}
|
|
379
381
|
}
|
|
382
|
+
catch (err) { }
|
|
380
383
|
}
|
|
381
384
|
return [{ selector: null, declarations: localStyles, specificity: -1 }];
|
|
382
385
|
}
|
|
@@ -102,7 +102,7 @@ export function createDefaultServiceContainer() {
|
|
|
102
102
|
serviceContainer.register("modelCommandService", new DefaultModelCommandService());
|
|
103
103
|
serviceContainer.register("demoProviderService", new DemoProviderService());
|
|
104
104
|
serviceContainer.register("undoService", (designerCanvas) => new UndoService(designerCanvas));
|
|
105
|
-
serviceContainer.register("selectionService", (designerCanvas) => new SelectionService(designerCanvas));
|
|
105
|
+
serviceContainer.register("selectionService", (designerCanvas) => new SelectionService(designerCanvas, false));
|
|
106
106
|
serviceContainer.register("contentService", (designerCanvas) => new ContentService(designerCanvas.rootDesignItem));
|
|
107
107
|
//serviceContainer.register("stylesheetService", new DemoProviderService());
|
|
108
108
|
serviceContainer.designerExtensions.set(ExtensionType.Permanent, [
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IEditorTypesService } from './IEditorTypesService.js';
|
|
2
|
+
import { IProperty } from './IProperty.js';
|
|
3
|
+
import { IPropertyEditor } from './IPropertyEditor.js';
|
|
4
|
+
export declare class DefaultEditorTypesService implements IEditorTypesService {
|
|
5
|
+
getEditorForProperty(property: IProperty): IPropertyEditor;
|
|
6
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ColorPropertyEditor } from './propertyEditors/ColorPropertyEditor.js';
|
|
2
|
+
import { DatePropertyEditor } from './propertyEditors/DatePropertyEditor.js';
|
|
3
|
+
import { JsonPropertyEditor } from './propertyEditors/JsonPropertyEditor.js';
|
|
4
|
+
import { NumberPropertyEditor } from './propertyEditors/NumberPropertyEditor.js';
|
|
5
|
+
import { SelectPropertyEditor } from './propertyEditors/SelectPropertyEditor.js';
|
|
6
|
+
import { TextPropertyEditor } from './propertyEditors/TextPropertyEditor.js';
|
|
7
|
+
import { BooleanPropertyEditor } from './propertyEditors/BooleanPropertyEditor.js';
|
|
8
|
+
import { ImageButtonListPropertyEditor } from './propertyEditors/ImageButtonListPropertyEditor.js';
|
|
9
|
+
import { ThicknessPropertyEditor } from "./propertyEditors/ThicknessPropertyEditor.js";
|
|
10
|
+
import { MetricsPropertyEditor } from './propertyEditors/MetricsPropertyEditor.js';
|
|
11
|
+
export class DefaultEditorTypesService {
|
|
12
|
+
getEditorForProperty(property) {
|
|
13
|
+
if (property.createEditor)
|
|
14
|
+
return property.createEditor(property);
|
|
15
|
+
switch (property.type) {
|
|
16
|
+
case "json":
|
|
17
|
+
{
|
|
18
|
+
return new JsonPropertyEditor(property);
|
|
19
|
+
}
|
|
20
|
+
case "color":
|
|
21
|
+
{
|
|
22
|
+
return new ColorPropertyEditor(property);
|
|
23
|
+
}
|
|
24
|
+
case "date":
|
|
25
|
+
{
|
|
26
|
+
return new DatePropertyEditor(property);
|
|
27
|
+
}
|
|
28
|
+
case "number":
|
|
29
|
+
{
|
|
30
|
+
return new NumberPropertyEditor(property);
|
|
31
|
+
}
|
|
32
|
+
case "list":
|
|
33
|
+
{
|
|
34
|
+
return new SelectPropertyEditor(property);
|
|
35
|
+
}
|
|
36
|
+
case "enum":
|
|
37
|
+
{
|
|
38
|
+
return new SelectPropertyEditor(property);
|
|
39
|
+
}
|
|
40
|
+
case "boolean":
|
|
41
|
+
{
|
|
42
|
+
return new BooleanPropertyEditor(property);
|
|
43
|
+
}
|
|
44
|
+
case "img-list":
|
|
45
|
+
{
|
|
46
|
+
return new ImageButtonListPropertyEditor(property);
|
|
47
|
+
}
|
|
48
|
+
case "thickness":
|
|
49
|
+
{
|
|
50
|
+
return new ThicknessPropertyEditor(property);
|
|
51
|
+
}
|
|
52
|
+
case "metrics":
|
|
53
|
+
{
|
|
54
|
+
return new MetricsPropertyEditor(property);
|
|
55
|
+
}
|
|
56
|
+
case "css-length":
|
|
57
|
+
case "string":
|
|
58
|
+
default:
|
|
59
|
+
{
|
|
60
|
+
return new TextPropertyEditor(property);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IEditorTypesService } from './IEditorTypesService.js';
|
|
2
|
+
import { IProperty } from './IProperty.js';
|
|
3
|
+
import { IPropertyEditor } from './IPropertyEditor.js';
|
|
4
|
+
export declare class DefaultEditorTypesService implements IEditorTypesService {
|
|
5
|
+
getEditorForProperty(property: IProperty): IPropertyEditor;
|
|
6
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ColorPropertyEditor } from './propertyEditors/ColorPropertyEditor.js';
|
|
2
|
+
import { DatePropertyEditor } from './propertyEditors/DatePropertyEditor.js';
|
|
3
|
+
import { JsonPropertyEditor } from './propertyEditors/JsonPropertyEditor.js';
|
|
4
|
+
import { NumberPropertyEditor } from './propertyEditors/NumberPropertyEditor.js';
|
|
5
|
+
import { SelectPropertyEditor } from './propertyEditors/SelectPropertyEditor.js';
|
|
6
|
+
import { TextPropertyEditor } from './propertyEditors/TextPropertyEditor.js';
|
|
7
|
+
import { BooleanPropertyEditor } from './propertyEditors/BooleanPropertyEditor.js';
|
|
8
|
+
import { ImageButtonListPropertyEditor } from './propertyEditors/ImageButtonListPropertyEditor.js';
|
|
9
|
+
import { ThicknessPropertyEditor } from "./propertyEditors/ThicknessPropertyEditor.js";
|
|
10
|
+
import { MetricsPropertyEditor } from './propertyEditors/MetricsPropertyEditor.js';
|
|
11
|
+
export class DefaultEditorTypesService {
|
|
12
|
+
getEditorForProperty(property) {
|
|
13
|
+
if (property.createEditor)
|
|
14
|
+
return property.createEditor(property);
|
|
15
|
+
switch (property.type) {
|
|
16
|
+
case "json":
|
|
17
|
+
{
|
|
18
|
+
return new JsonPropertyEditor(property);
|
|
19
|
+
}
|
|
20
|
+
case "color":
|
|
21
|
+
{
|
|
22
|
+
return new ColorPropertyEditor(property);
|
|
23
|
+
}
|
|
24
|
+
case "date":
|
|
25
|
+
{
|
|
26
|
+
return new DatePropertyEditor(property);
|
|
27
|
+
}
|
|
28
|
+
case "number":
|
|
29
|
+
{
|
|
30
|
+
return new NumberPropertyEditor(property);
|
|
31
|
+
}
|
|
32
|
+
case "list":
|
|
33
|
+
{
|
|
34
|
+
return new SelectPropertyEditor(property);
|
|
35
|
+
}
|
|
36
|
+
case "enum":
|
|
37
|
+
{
|
|
38
|
+
return new SelectPropertyEditor(property);
|
|
39
|
+
}
|
|
40
|
+
case "boolean":
|
|
41
|
+
{
|
|
42
|
+
return new BooleanPropertyEditor(property);
|
|
43
|
+
}
|
|
44
|
+
case "img-list":
|
|
45
|
+
{
|
|
46
|
+
return new ImageButtonListPropertyEditor(property);
|
|
47
|
+
}
|
|
48
|
+
case "thickness":
|
|
49
|
+
{
|
|
50
|
+
return new ThicknessPropertyEditor(property);
|
|
51
|
+
}
|
|
52
|
+
case "metrics":
|
|
53
|
+
{
|
|
54
|
+
return new MetricsPropertyEditor(property);
|
|
55
|
+
}
|
|
56
|
+
case "css-length":
|
|
57
|
+
case "string":
|
|
58
|
+
default:
|
|
59
|
+
{
|
|
60
|
+
return new TextPropertyEditor(property);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IProperty } from '../IProperty.js';
|
|
2
|
+
import { BasePropertyEditor } from './BasePropertyEditor.js';
|
|
3
|
+
import { ValueType } from '../ValueType.js';
|
|
4
|
+
export declare class GridCellPropertyEditor extends BasePropertyEditor<HTMLDivElement> {
|
|
5
|
+
static template: HTMLTemplateElement;
|
|
6
|
+
_input: HTMLInputElement;
|
|
7
|
+
constructor(property: IProperty);
|
|
8
|
+
refreshValue(valueType: ValueType, value: any): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BasePropertyEditor } from './BasePropertyEditor.js';
|
|
2
|
+
import { html } from '@node-projects/base-custom-webcomponent';
|
|
3
|
+
export class GridCellPropertyEditor extends BasePropertyEditor {
|
|
4
|
+
static template = html `
|
|
5
|
+
<div style="display: flex;">
|
|
6
|
+
|
|
7
|
+
</div>
|
|
8
|
+
`;
|
|
9
|
+
_input;
|
|
10
|
+
constructor(property) {
|
|
11
|
+
super(property);
|
|
12
|
+
}
|
|
13
|
+
refreshValue(valueType, value) {
|
|
14
|
+
debugger;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IProperty } from '../IProperty.js';
|
|
2
|
+
import { BasePropertyEditor } from './BasePropertyEditor.js';
|
|
3
|
+
import { ValueType } from '../ValueType.js';
|
|
4
|
+
export declare class JsonPropertyEditor extends BasePropertyEditor<HTMLDivElement> {
|
|
5
|
+
static template: HTMLTemplateElement;
|
|
6
|
+
_input: HTMLInputElement;
|
|
7
|
+
constructor(property: IProperty);
|
|
8
|
+
refreshValue(valueType: ValueType, value: any): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BasePropertyEditor } from './BasePropertyEditor.js';
|
|
2
|
+
import { html } from '@node-projects/base-custom-webcomponent';
|
|
3
|
+
export class JsonPropertyEditor extends BasePropertyEditor {
|
|
4
|
+
static template = html `
|
|
5
|
+
<div style="display: flex;">
|
|
6
|
+
<input id="input" type="text">
|
|
7
|
+
<button style="width: 30px;">...</button>
|
|
8
|
+
</div>
|
|
9
|
+
`;
|
|
10
|
+
_input;
|
|
11
|
+
constructor(property) {
|
|
12
|
+
super(property);
|
|
13
|
+
let el = JsonPropertyEditor.template.content.cloneNode(true);
|
|
14
|
+
this._input = el.getElementById('input');
|
|
15
|
+
this._input.onchange = (e) => this._valueChanged(this._input.value);
|
|
16
|
+
this.element = el;
|
|
17
|
+
}
|
|
18
|
+
refreshValue(valueType, value) {
|
|
19
|
+
this._input.value = value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -7,7 +7,8 @@ export declare class SelectionService implements ISelectionService {
|
|
|
7
7
|
primarySelection: IDesignItem;
|
|
8
8
|
selectedElements: IDesignItem[];
|
|
9
9
|
_designerCanvas: IDesignerCanvas;
|
|
10
|
-
|
|
10
|
+
_undoSelectionChanges: boolean;
|
|
11
|
+
constructor(designerCanvas: IDesignerCanvas, undoSelectionChanges: boolean);
|
|
11
12
|
setSelectedElements(designItems: IDesignItem[]): void;
|
|
12
13
|
_withoutUndoSetSelectedElements(designItems: IDesignItem[]): void;
|
|
13
14
|
clearSelectedElements(): void;
|
|
@@ -4,13 +4,20 @@ export class SelectionService {
|
|
|
4
4
|
primarySelection;
|
|
5
5
|
selectedElements = [];
|
|
6
6
|
_designerCanvas;
|
|
7
|
-
|
|
7
|
+
_undoSelectionChanges;
|
|
8
|
+
constructor(designerCanvas, undoSelectionChanges) {
|
|
8
9
|
this._designerCanvas = designerCanvas;
|
|
10
|
+
this._undoSelectionChanges = undoSelectionChanges;
|
|
9
11
|
}
|
|
10
12
|
setSelectedElements(designItems) {
|
|
11
13
|
if (this.selectedElements != designItems) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
if (this._undoSelectionChanges) {
|
|
15
|
+
const action = new SelectionChangedAction(this.selectedElements, designItems, this);
|
|
16
|
+
this._designerCanvas.instanceServiceContainer.undoService.execute(action);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this._withoutUndoSetSelectedElements(designItems);
|
|
20
|
+
}
|
|
14
21
|
}
|
|
15
22
|
}
|
|
16
23
|
_withoutUndoSetSelectedElements(designItems) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
2
2
|
import { IStyleDeclaration, IStyleRule, IStylesheet } from "./IStylesheetService.js";
|
|
3
3
|
import { AbstractStylesheetService } from "./AbstractStylesheetService.js";
|
|
4
|
-
type CssRuleAST
|
|
5
|
-
type CssDeclarationAST = any;
|
|
6
|
-
type CssStylesheetAST = any;
|
|
4
|
+
import type { CssDeclarationAST, CssRuleAST, CssStylesheetAST } from "@adobe/css-tools";
|
|
7
5
|
interface IRuleWithAST extends IStyleRule {
|
|
8
6
|
ast: CssRuleAST;
|
|
9
7
|
declarations: IDeclarationWithAST[];
|
|
@@ -39,7 +39,7 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
|
39
39
|
let rs = Array.from(this.getRulesFromAst(item[1].ast?.stylesheet?.rules, item[1].stylesheet, designItem))
|
|
40
40
|
.map(x => ({
|
|
41
41
|
selector: x.selectors.join(', '),
|
|
42
|
-
declarations: x.declarations.map(y => ({
|
|
42
|
+
declarations: x.declarations.filter(y => y.type == 'declaration').map(y => ({
|
|
43
43
|
name: y.property,
|
|
44
44
|
value: y.value.endsWith('!important') ? y.value.substring(0, y.value.length - 10).trimEnd() : y.value,
|
|
45
45
|
important: y.value.endsWith('!important'),
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend, css, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
import { CommandType } from '../../../commandHandling/CommandType.js';
|
|
3
|
+
class CodeViewAceCompleter {
|
|
4
|
+
getCompletions(editor, session, pos, prefix, callback) {
|
|
5
|
+
if (prefix.length === 0) {
|
|
6
|
+
callback(null, []);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
let wordList = ['t-t', 'visu-conveyor']; //TODO: get word list from custom elements
|
|
10
|
+
{
|
|
11
|
+
callback(null, wordList.map((w) => {
|
|
12
|
+
return { name: w, value: w, score: 1, meta: "tag" };
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class CodeViewAce extends BaseCustomWebComponentLazyAppend {
|
|
18
|
+
canvasElement;
|
|
19
|
+
elementsToPackages;
|
|
20
|
+
code;
|
|
21
|
+
onTextChanged = new TypedEvent();
|
|
22
|
+
_aceEditor;
|
|
23
|
+
_editor;
|
|
24
|
+
static style = css `
|
|
25
|
+
:host {
|
|
26
|
+
display: block;
|
|
27
|
+
height: 100%;
|
|
28
|
+
width: 100%;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
this.style.display = 'block';
|
|
34
|
+
this._editor = document.createElement("div");
|
|
35
|
+
this._editor.style.height = '100%';
|
|
36
|
+
this._editor.style.width = '100%';
|
|
37
|
+
this.shadowRoot.appendChild(this._editor);
|
|
38
|
+
}
|
|
39
|
+
dispose() {
|
|
40
|
+
this._aceEditor.destroy();
|
|
41
|
+
}
|
|
42
|
+
executeCommand(command) {
|
|
43
|
+
switch (command.type) {
|
|
44
|
+
case CommandType.undo:
|
|
45
|
+
this._aceEditor.execCommand('undo');
|
|
46
|
+
break;
|
|
47
|
+
case CommandType.redo:
|
|
48
|
+
this._aceEditor.execCommand('redo');
|
|
49
|
+
break;
|
|
50
|
+
case CommandType.copy:
|
|
51
|
+
let text = this._aceEditor.getCopyText();
|
|
52
|
+
this._aceEditor.execCommand("copy");
|
|
53
|
+
navigator.clipboard.writeText(text);
|
|
54
|
+
break;
|
|
55
|
+
case CommandType.paste:
|
|
56
|
+
navigator.clipboard.readText().then(text => {
|
|
57
|
+
this._aceEditor.execCommand("paste", text);
|
|
58
|
+
});
|
|
59
|
+
break;
|
|
60
|
+
case CommandType.cut:
|
|
61
|
+
text = this._aceEditor.getCopyText();
|
|
62
|
+
this._aceEditor.execCommand("cut");
|
|
63
|
+
navigator.clipboard.writeText(text);
|
|
64
|
+
break;
|
|
65
|
+
case CommandType.delete:
|
|
66
|
+
this._aceEditor.execCommand("delete");
|
|
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._aceEditor.focus();
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
oneTimeSetup() {
|
|
89
|
+
//@ts-ignore
|
|
90
|
+
let langTools = ace.require("ace/ext/language_tools");
|
|
91
|
+
langTools.addCompleter(new CodeViewAceCompleter());
|
|
92
|
+
}
|
|
93
|
+
ready() {
|
|
94
|
+
//@ts-ignore
|
|
95
|
+
this._aceEditor = ace.edit(this._editor, {
|
|
96
|
+
theme: "ace/theme/chrome",
|
|
97
|
+
mode: "ace/mode/html",
|
|
98
|
+
value: "",
|
|
99
|
+
autoScrollEditorIntoView: true,
|
|
100
|
+
fontSize: "14px",
|
|
101
|
+
showPrintMargin: false,
|
|
102
|
+
displayIndentGuides: true,
|
|
103
|
+
enableBasicAutocompletion: true,
|
|
104
|
+
enableSnippets: true,
|
|
105
|
+
enableLiveAutocompletion: true
|
|
106
|
+
});
|
|
107
|
+
//own snippet completer: http://plnkr.co/edit/6MVntVmXYUbjR0DI82Cr?p=preview
|
|
108
|
+
this._aceEditor.renderer.attachToShadowRoot();
|
|
109
|
+
let observer = new MutationObserver((m) => {
|
|
110
|
+
this._aceEditor.setAutoScrollEditorIntoView(false);
|
|
111
|
+
this._aceEditor.setAutoScrollEditorIntoView(true);
|
|
112
|
+
});
|
|
113
|
+
let config = { attributes: true, childList: true, characterData: true };
|
|
114
|
+
observer.observe(this.shadowRoot.querySelector('.ace_content'), config);
|
|
115
|
+
this._aceEditor.on('change', () => this.onTextChanged.emit(this._aceEditor.getValue()));
|
|
116
|
+
}
|
|
117
|
+
update(code) {
|
|
118
|
+
this._aceEditor.setValue(code);
|
|
119
|
+
this._aceEditor.clearSelection();
|
|
120
|
+
}
|
|
121
|
+
getText() {
|
|
122
|
+
return this._aceEditor.getValue();
|
|
123
|
+
}
|
|
124
|
+
setSelection(position) {
|
|
125
|
+
let point1 = this._aceEditor.session.getDocument().indexToPosition(position.start, 0);
|
|
126
|
+
let point2 = this._aceEditor.session.getDocument().indexToPosition(position.start + position.length, 0);
|
|
127
|
+
//@ts-ignore
|
|
128
|
+
this._aceEditor.selection.setRange({ start: point1, end: point2 });
|
|
129
|
+
//@ts-ignore
|
|
130
|
+
this._aceEditor.scrollToLine(point1.row);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
customElements.define('node-projects-code-view-ace', CodeViewAce);
|
|
@@ -0,0 +1,23 @@
|
|
|
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 CodeViewJar 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
|
+
ready(): void;
|
|
20
|
+
update(code: any): void;
|
|
21
|
+
getText(): string;
|
|
22
|
+
setSelection(position: IStringPosition): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend, css, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
import { CommandType } from '../../../commandHandling/CommandType.js';
|
|
3
|
+
export class CodeViewJar extends BaseCustomWebComponentLazyAppend {
|
|
4
|
+
canvasElement;
|
|
5
|
+
elementsToPackages;
|
|
6
|
+
code;
|
|
7
|
+
onTextChanged = new TypedEvent();
|
|
8
|
+
_aceEditor;
|
|
9
|
+
_editor;
|
|
10
|
+
static style = css `
|
|
11
|
+
:host {
|
|
12
|
+
display: block;
|
|
13
|
+
height: 100%;
|
|
14
|
+
width: 100%;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.style.display = 'block';
|
|
20
|
+
this._editor = document.createElement("div");
|
|
21
|
+
this._editor.style.height = '100%';
|
|
22
|
+
this._editor.style.width = '100%';
|
|
23
|
+
//@ts-ignore
|
|
24
|
+
if (window.importShim)
|
|
25
|
+
//@ts-ignore
|
|
26
|
+
importShim("codejar").then(x => { debugger; CodeJar(this._editor, hljs.highlightElement); });
|
|
27
|
+
else
|
|
28
|
+
//@ts-ignore
|
|
29
|
+
import("codejar").then(x => { debugger; CodeJar(this._editor, hljs.highlightElement); });
|
|
30
|
+
let jar = this.shadowRoot.appendChild(this._editor);
|
|
31
|
+
}
|
|
32
|
+
dispose() {
|
|
33
|
+
this._aceEditor.destroy();
|
|
34
|
+
}
|
|
35
|
+
executeCommand(command) {
|
|
36
|
+
switch (command.type) {
|
|
37
|
+
case CommandType.undo:
|
|
38
|
+
this._aceEditor.execCommand('undo');
|
|
39
|
+
break;
|
|
40
|
+
case CommandType.redo:
|
|
41
|
+
this._aceEditor.execCommand('redo');
|
|
42
|
+
break;
|
|
43
|
+
case CommandType.copy:
|
|
44
|
+
let text = this._aceEditor.getCopyText();
|
|
45
|
+
this._aceEditor.execCommand("copy");
|
|
46
|
+
navigator.clipboard.writeText(text);
|
|
47
|
+
break;
|
|
48
|
+
case CommandType.paste:
|
|
49
|
+
navigator.clipboard.readText().then(text => {
|
|
50
|
+
this._aceEditor.execCommand("paste", text);
|
|
51
|
+
});
|
|
52
|
+
break;
|
|
53
|
+
case CommandType.cut:
|
|
54
|
+
text = this._aceEditor.getCopyText();
|
|
55
|
+
this._aceEditor.execCommand("cut");
|
|
56
|
+
navigator.clipboard.writeText(text);
|
|
57
|
+
break;
|
|
58
|
+
case CommandType.delete:
|
|
59
|
+
this._aceEditor.execCommand("delete");
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
canExecuteCommand(command) {
|
|
64
|
+
switch (command.type) {
|
|
65
|
+
case CommandType.undo:
|
|
66
|
+
case CommandType.redo:
|
|
67
|
+
case CommandType.copy:
|
|
68
|
+
case CommandType.paste:
|
|
69
|
+
case CommandType.cut:
|
|
70
|
+
case CommandType.delete:
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
focusEditor() {
|
|
76
|
+
requestAnimationFrame(() => {
|
|
77
|
+
this.focus();
|
|
78
|
+
this._aceEditor.focus();
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
ready() {
|
|
82
|
+
//@ts-ignore
|
|
83
|
+
this._aceEditor = ace.edit(this._editor, {
|
|
84
|
+
theme: "ace/theme/chrome",
|
|
85
|
+
mode: "ace/mode/html",
|
|
86
|
+
value: "",
|
|
87
|
+
autoScrollEditorIntoView: true,
|
|
88
|
+
fontSize: "14px",
|
|
89
|
+
showPrintMargin: false,
|
|
90
|
+
displayIndentGuides: true,
|
|
91
|
+
enableBasicAutocompletion: true,
|
|
92
|
+
enableSnippets: true,
|
|
93
|
+
enableLiveAutocompletion: true
|
|
94
|
+
});
|
|
95
|
+
//own snippet completer: http://plnkr.co/edit/6MVntVmXYUbjR0DI82Cr?p=preview
|
|
96
|
+
this._aceEditor.renderer.attachToShadowRoot();
|
|
97
|
+
let observer = new MutationObserver((m) => {
|
|
98
|
+
this._aceEditor.setAutoScrollEditorIntoView(false);
|
|
99
|
+
this._aceEditor.setAutoScrollEditorIntoView(true);
|
|
100
|
+
});
|
|
101
|
+
let config = { attributes: true, childList: true, characterData: true };
|
|
102
|
+
observer.observe(this.shadowRoot.querySelector('.ace_content'), config);
|
|
103
|
+
this._aceEditor.on('change', () => this.onTextChanged.emit(this._aceEditor.getValue()));
|
|
104
|
+
}
|
|
105
|
+
update(code) {
|
|
106
|
+
this._aceEditor.setValue(code);
|
|
107
|
+
this._aceEditor.clearSelection();
|
|
108
|
+
}
|
|
109
|
+
getText() {
|
|
110
|
+
return this._aceEditor.getValue();
|
|
111
|
+
}
|
|
112
|
+
setSelection(position) {
|
|
113
|
+
let point1 = this._aceEditor.session.getDocument().indexToPosition(position.start, 0);
|
|
114
|
+
let point2 = this._aceEditor.session.getDocument().indexToPosition(position.start + position.length, 0);
|
|
115
|
+
//@ts-ignore
|
|
116
|
+
this._aceEditor.selection.setRange({ start: point1, end: point2 });
|
|
117
|
+
//@ts-ignore
|
|
118
|
+
this._aceEditor.scrollToLine(point1.row);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
customElements.define('node-projects-code-view-ace', CodeViewAce);
|
|
@@ -689,8 +689,11 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
689
689
|
di.setStyle('position', 'absolute');
|
|
690
690
|
const containerService = this.serviceContainer.getLastServiceWhere('containerService', x => x.serviceForContainer(newContainer, getComputedStyle(newContainer.element)));
|
|
691
691
|
containerService.enterContainer(newContainer, [di]);
|
|
692
|
-
|
|
693
|
-
|
|
692
|
+
const containerPos = this.getNormalizedElementCoordinates(newContainer.element);
|
|
693
|
+
const evCoord = this.getNormalizedEventCoordinates(event);
|
|
694
|
+
const pos = { x: evCoord.x - containerPos.x, y: evCoord.y - containerPos.y };
|
|
695
|
+
containerService.place(event, this, newContainer, { x: 0, y: 0 }, { x: 0, y: 0 }, pos, [di]);
|
|
696
|
+
containerService.finishPlace(event, this, newContainer, { x: 0, y: 0 }, { x: 0, y: 0 }, pos, [di]);
|
|
694
697
|
this.instanceServiceContainer.undoService.execute(new InsertAction(newContainer, newContainer.childCount, di));
|
|
695
698
|
requestAnimationFrame(() => {
|
|
696
699
|
this.instanceServiceContainer.selectionService.setSelectedElements([di]);
|
|
@@ -4,6 +4,7 @@ import { AbstractExtension } from '../AbstractExtension.js';
|
|
|
4
4
|
import { IExtensionManager } from '../IExtensionManger.js';
|
|
5
5
|
export declare class DisplayGridExtension extends AbstractExtension {
|
|
6
6
|
private _cells;
|
|
7
|
+
private _texts;
|
|
7
8
|
private _gaps;
|
|
8
9
|
private gridInformation;
|
|
9
10
|
constructor(extensionManager: IExtensionManager, designerView: IDesignerCanvas, extendedItem: IDesignItem);
|
|
@@ -3,6 +3,7 @@ import { AbstractExtension } from '../AbstractExtension.js';
|
|
|
3
3
|
import { OverlayLayer } from "../OverlayLayer.js";
|
|
4
4
|
export class DisplayGridExtension extends AbstractExtension {
|
|
5
5
|
_cells;
|
|
6
|
+
_texts;
|
|
6
7
|
_gaps;
|
|
7
8
|
gridInformation;
|
|
8
9
|
constructor(extensionManager, designerView, extendedItem) {
|
|
@@ -27,8 +28,8 @@ export class DisplayGridExtension extends AbstractExtension {
|
|
|
27
28
|
row.forEach((cell, j) => {
|
|
28
29
|
this._cells[i][j] = this._drawRect(cell.x, cell.y, cell.width, cell.height, 'svg-grid', this._cells[i][j], OverlayLayer.Background);
|
|
29
30
|
if (cell.name) {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
this._texts[i][j] = this._drawText(cell.name, cell.x, cell.y, 'svg-grid-area', this._texts[i][j], OverlayLayer.Background);
|
|
32
|
+
this._texts[i][j].setAttribute("dominant-baseline", "hanging");
|
|
32
33
|
}
|
|
33
34
|
if (event && event instanceof MouseEvent) {
|
|
34
35
|
let crd = this.designerCanvas.getNormalizedEventCoordinates(event);
|
|
@@ -48,6 +49,8 @@ export class DisplayGridExtension extends AbstractExtension {
|
|
|
48
49
|
this.gridInformation = CalculateGridInformation(this.extendedItem);
|
|
49
50
|
this._cells = new Array(this.gridInformation.cells.length);
|
|
50
51
|
this.gridInformation.cells.forEach((row, i) => this._cells[i] = new Array(row.length));
|
|
52
|
+
this._texts = new Array(this.gridInformation.cells.length);
|
|
53
|
+
this.gridInformation.cells.forEach((row, i) => this._texts[i] = new Array(row.length));
|
|
51
54
|
this._gaps = new Array(this.gridInformation.gaps.length);
|
|
52
55
|
}
|
|
53
56
|
}
|