@node-projects/web-component-designer 0.0.141 → 0.0.143
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 +10 -2
- package/dist/elements/helper/ArrangeHelper.d.ts +2 -2
- package/dist/elements/helper/ArrangeHelper.js +49 -23
- package/dist/elements/helper/ElementHelper.d.ts +1 -0
- package/dist/elements/helper/ElementHelper.js +3 -0
- package/dist/elements/services/ServiceContainer.js +2 -2
- package/dist/elements/services/htmlWriterService/HtmlWriterService.d.ts +1 -0
- package/dist/elements/services/htmlWriterService/HtmlWriterService.js +14 -8
- package/dist/elements/services/manifestParsers/WebcomponentManifestParserService.d.ts +3 -2
- package/dist/elements/services/manifestParsers/WebcomponentManifestParserService.js +5 -2
- package/dist/elements/services/modelCommandService/DefaultModelCommandService.js +6 -6
- package/dist/elements/services/propertiesService/services/AbstractPolymerLikePropertiesService.d.ts +8 -0
- package/dist/elements/services/propertiesService/services/AbstractPolymerLikePropertiesService.js +47 -0
- package/dist/elements/services/propertiesService/services/AbstractPropertiesService.d.ts +20 -0
- package/dist/elements/services/propertiesService/services/AbstractPropertiesService.js +162 -0
- package/dist/elements/services/propertiesService/services/BaseCustomWebComponentPropertiesService.d.ts +2 -2
- package/dist/elements/services/propertiesService/services/BaseCustomWebComponentPropertiesService.js +2 -2
- package/dist/elements/services/propertiesService/services/CommonPropertiesService.d.ts +2 -12
- package/dist/elements/services/propertiesService/services/CommonPropertiesService.js +2 -81
- package/dist/elements/services/propertiesService/services/CssPropertiesService.d.ts +2 -11
- package/dist/elements/services/propertiesService/services/CssPropertiesService.js +3 -72
- package/dist/elements/services/propertiesService/services/ListPropertiesService.d.ts +3 -2
- package/dist/elements/services/propertiesService/services/ListPropertiesService.js +5 -2
- package/dist/elements/services/propertiesService/services/Lit2PropertiesService.d.ts +2 -2
- package/dist/elements/services/propertiesService/services/Lit2PropertiesService.js +2 -2
- package/dist/elements/services/propertiesService/services/LitElementPropertiesService.d.ts +2 -2
- package/dist/elements/services/propertiesService/services/LitElementPropertiesService.js +2 -2
- package/dist/elements/services/propertiesService/services/NativeElementsPropertiesService.js +6 -0
- package/dist/elements/services/propertiesService/services/PolymerPropertiesService.d.ts +2 -2
- package/dist/elements/services/propertiesService/services/PolymerPropertiesService.js +2 -2
- package/dist/elements/services/propertiesService/services/UnkownElementPropertiesService.d.ts +4 -4
- package/dist/elements/services/propertiesService/services/UnkownElementPropertiesService.js +95 -50
- package/dist/elements/services/propertiesService/services/WebcomponentManifestPropertiesService.d.ts +3 -2
- package/dist/elements/services/propertiesService/services/WebcomponentManifestPropertiesService.js +5 -2
- package/dist/elements/widgets/codeView/code-view-monaco copy.d.ts +25 -0
- package/dist/elements/widgets/codeView/code-view-monaco copy.js +119 -0
- package/dist/elements/widgets/codeView/code-view-simple.d.ts +23 -0
- package/dist/elements/widgets/codeView/code-view-simple.js +55 -0
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextExtension.d.ts +9 -2
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextExtension.js +20 -4
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextWithStyloExtension.d.ts +4 -1
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextWithStyloExtension.js +10 -1
- package/dist/elements/widgets/designerView/extensions/ExtensionManager.d.ts +2 -1
- package/dist/elements/widgets/designerView/extensions/ExtensionManager.js +4 -0
- package/dist/elements/widgets/designerView/extensions/IExtensionManger.d.ts +2 -1
- package/dist/elements/widgets/designerView/tools/TextTool.d.ts +4 -1
- package/dist/elements/widgets/designerView/tools/TextTool.js +31 -15
- package/dist/elements/widgets/designerView/tools/toolBar/DesignerToolbar.d.ts +3 -0
- package/dist/elements/widgets/designerView/tools/toolBar/DesignerToolbar.js +18 -0
- package/dist/elements/widgets/designerView/tools/toolBar/popups/DrawToolPopup.js +54 -2
- package/dist/elements/widgets/paletteView/paletteView.js +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
import { CommandType } from '../../../commandHandling/CommandType';
|
|
3
|
+
export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
4
|
+
dispose() {
|
|
5
|
+
this._monacoEditor.dispose();
|
|
6
|
+
}
|
|
7
|
+
canvasElement;
|
|
8
|
+
elementsToPackages;
|
|
9
|
+
code;
|
|
10
|
+
onTextChanged = new TypedEvent();
|
|
11
|
+
_monacoEditor;
|
|
12
|
+
_editor;
|
|
13
|
+
static style = css `
|
|
14
|
+
:host {
|
|
15
|
+
display: block;
|
|
16
|
+
height: 100%;
|
|
17
|
+
width: 100%;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
static template = html `
|
|
21
|
+
<div id="container" style="width: 100%; height: 100%; position: absolute;"></div>
|
|
22
|
+
`;
|
|
23
|
+
executeCommand(command) {
|
|
24
|
+
switch (command.type) {
|
|
25
|
+
case CommandType.undo:
|
|
26
|
+
this._monacoEditor.trigger('source', 'undo', null);
|
|
27
|
+
break;
|
|
28
|
+
case CommandType.redo:
|
|
29
|
+
this._monacoEditor.trigger('source', 'redo', null);
|
|
30
|
+
break;
|
|
31
|
+
case CommandType.copy:
|
|
32
|
+
this._monacoEditor.trigger('source', 'editor.action.clipboardCopyAction', null);
|
|
33
|
+
break;
|
|
34
|
+
case CommandType.paste:
|
|
35
|
+
this._monacoEditor.trigger('source', 'editor.action.clipboardPasteAction', null);
|
|
36
|
+
break;
|
|
37
|
+
case CommandType.cut:
|
|
38
|
+
break;
|
|
39
|
+
case CommandType.delete:
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
canExecuteCommand(command) {
|
|
44
|
+
switch (command.type) {
|
|
45
|
+
case CommandType.undo:
|
|
46
|
+
case CommandType.redo:
|
|
47
|
+
case CommandType.copy:
|
|
48
|
+
case CommandType.paste:
|
|
49
|
+
case CommandType.cut:
|
|
50
|
+
case CommandType.delete:
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
async ready() {
|
|
56
|
+
let style;
|
|
57
|
+
//@ts-ignore
|
|
58
|
+
if (window.importShim)
|
|
59
|
+
//@ts-ignore
|
|
60
|
+
style = await importShim("monaco-editor/min/vs/editor/editor.main.css", { assert: { type: 'css' } });
|
|
61
|
+
else
|
|
62
|
+
//@ts-ignore
|
|
63
|
+
style = await import("monaco-editor/min/vs/editor/editor.main.css", { assert: { type: 'css' } });
|
|
64
|
+
this.shadowRoot.adoptedStyleSheets = [style.default, this.constructor.style];
|
|
65
|
+
this._editor = this._getDomElement('container');
|
|
66
|
+
//@ts-ignore
|
|
67
|
+
require.config({ paths: { 'vs': 'node_modules/monaco-editor/min/vs' } });
|
|
68
|
+
//@ts-ignore
|
|
69
|
+
require(['vs/editor/editor.main'], () => {
|
|
70
|
+
//@ts-ignore
|
|
71
|
+
this._monacoEditor = monaco.editor.create(this._editor, {
|
|
72
|
+
automaticLayout: true,
|
|
73
|
+
value: this.code,
|
|
74
|
+
language: 'html',
|
|
75
|
+
minimap: {
|
|
76
|
+
size: 'fill'
|
|
77
|
+
},
|
|
78
|
+
fixedOverflowWidgets: true
|
|
79
|
+
});
|
|
80
|
+
this._monacoEditor.layout();
|
|
81
|
+
let changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
|
|
82
|
+
this.onTextChanged.emit(this._monacoEditor.getValue());
|
|
83
|
+
});
|
|
84
|
+
this._monacoEditor.onDidChangeModel(e => {
|
|
85
|
+
changeContentListener.dispose();
|
|
86
|
+
changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
|
|
87
|
+
this.onTextChanged.emit(this._monacoEditor.getValue());
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
focusEditor() {
|
|
93
|
+
requestAnimationFrame(() => {
|
|
94
|
+
this.focus();
|
|
95
|
+
this._monacoEditor.focus();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
activated() {
|
|
99
|
+
if (this._monacoEditor)
|
|
100
|
+
this._monacoEditor.layout();
|
|
101
|
+
}
|
|
102
|
+
update(code) {
|
|
103
|
+
this.code = code;
|
|
104
|
+
if (this._monacoEditor) {
|
|
105
|
+
this._monacoEditor.setValue(code);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
getText() {
|
|
109
|
+
return this._monacoEditor.getValue();
|
|
110
|
+
}
|
|
111
|
+
setSelection(position) {
|
|
112
|
+
let model = this._monacoEditor.getModel();
|
|
113
|
+
let point1 = model.getPositionAt(position.start);
|
|
114
|
+
let point2 = model.getPositionAt(position.start + position.length);
|
|
115
|
+
this._monacoEditor.setSelection({ startLineNumber: point1.lineNumber, startColumn: point1.column, endLineNumber: point2.lineNumber, endColumn: point2.column });
|
|
116
|
+
setTimeout(() => this._monacoEditor.revealLine(point1.lineNumber), 20);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
customElements.define('node-projects-code-view-monaco', CodeViewMonaco);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
import { ICodeView } from "./ICodeView";
|
|
3
|
+
import { IActivateable } from '../../../interfaces/IActivateable';
|
|
4
|
+
import { IStringPosition } from '../../services/htmlWriterService/IStringPosition';
|
|
5
|
+
import { IUiCommandHandler } from '../../../commandHandling/IUiCommandHandler';
|
|
6
|
+
import { IUiCommand } from '../../../commandHandling/IUiCommand';
|
|
7
|
+
export declare class CodeViewSimple extends BaseCustomWebComponentConstructorAppend implements ICodeView, IActivateable, IUiCommandHandler {
|
|
8
|
+
dispose(): void;
|
|
9
|
+
canvasElement: HTMLElement;
|
|
10
|
+
elementsToPackages: Map<string, string>;
|
|
11
|
+
onTextChanged: TypedEvent<string>;
|
|
12
|
+
private _text;
|
|
13
|
+
static readonly style: CSSStyleSheet;
|
|
14
|
+
static readonly template: HTMLTemplateElement;
|
|
15
|
+
executeCommand(command: IUiCommand): void;
|
|
16
|
+
canExecuteCommand(command: IUiCommand): boolean;
|
|
17
|
+
ready(): Promise<void>;
|
|
18
|
+
focusEditor(): void;
|
|
19
|
+
activated(): void;
|
|
20
|
+
update(code: any): void;
|
|
21
|
+
getText(): string;
|
|
22
|
+
setSelection(position: IStringPosition): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
export class CodeViewSimple extends BaseCustomWebComponentConstructorAppend {
|
|
3
|
+
dispose() {
|
|
4
|
+
}
|
|
5
|
+
canvasElement;
|
|
6
|
+
elementsToPackages;
|
|
7
|
+
onTextChanged = new TypedEvent();
|
|
8
|
+
_text;
|
|
9
|
+
static style = css `
|
|
10
|
+
:host {
|
|
11
|
+
display: block;
|
|
12
|
+
height: 100%;
|
|
13
|
+
width: 100%;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
textarea {
|
|
17
|
+
height: 100%;
|
|
18
|
+
width: 100%;
|
|
19
|
+
resize: none;
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
static template = html `
|
|
25
|
+
<div id="container" style="width: 100%; height: 100%; position: absolute;">
|
|
26
|
+
<textarea id="text"></textarea>
|
|
27
|
+
</div>
|
|
28
|
+
`;
|
|
29
|
+
executeCommand(command) {
|
|
30
|
+
}
|
|
31
|
+
canExecuteCommand(command) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
async ready() {
|
|
35
|
+
this._text = this._getDomElement('text');
|
|
36
|
+
}
|
|
37
|
+
focusEditor() {
|
|
38
|
+
requestAnimationFrame(() => {
|
|
39
|
+
this.focus();
|
|
40
|
+
this._text.focus();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
activated() {
|
|
44
|
+
}
|
|
45
|
+
update(code) {
|
|
46
|
+
this._text.value = code;
|
|
47
|
+
}
|
|
48
|
+
getText() {
|
|
49
|
+
return this._text.value;
|
|
50
|
+
}
|
|
51
|
+
setSelection(position) {
|
|
52
|
+
this._text.setSelectionRange(position.start, position.start + position.length);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
customElements.define('node-projects-code-view-simple', CodeViewSimple);
|
|
@@ -2,16 +2,23 @@ import { IDesignItem } from "../../../../item/IDesignItem";
|
|
|
2
2
|
import { IDesignerCanvas } from "../../IDesignerCanvas";
|
|
3
3
|
import { AbstractExtension } from "../AbstractExtension.js";
|
|
4
4
|
import { IExtensionManager } from "../IExtensionManger";
|
|
5
|
-
export declare
|
|
5
|
+
export declare type handlesPointerEvent = {
|
|
6
|
+
handlesPointerEvent(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare class EditTextExtension extends AbstractExtension implements handlesPointerEvent {
|
|
9
|
+
private static template;
|
|
6
10
|
private _contentEditedBound;
|
|
7
11
|
private _blurBound;
|
|
8
|
-
private static template;
|
|
9
12
|
private _blurTimeout;
|
|
13
|
+
private _foreignObject;
|
|
14
|
+
private _focusBound;
|
|
10
15
|
constructor(extensionManager: IExtensionManager, designerView: IDesignerCanvas, extendedItem: IDesignItem);
|
|
11
16
|
extend(): void;
|
|
12
17
|
refresh(): void;
|
|
13
18
|
dispose(): void;
|
|
19
|
+
handlesPointerEvent(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): boolean;
|
|
14
20
|
_contentEdited(): void;
|
|
15
21
|
_blur(): void;
|
|
22
|
+
_focus(): void;
|
|
16
23
|
_formatSelection(type: string): void;
|
|
17
24
|
}
|
|
@@ -3,8 +3,6 @@ import { AbstractExtension } from "../AbstractExtension.js";
|
|
|
3
3
|
import { ExtensionType } from "../ExtensionType.js";
|
|
4
4
|
import { OverlayLayer } from "../OverlayLayer.js";
|
|
5
5
|
export class EditTextExtension extends AbstractExtension {
|
|
6
|
-
_contentEditedBound;
|
|
7
|
-
_blurBound;
|
|
8
6
|
static template = html `
|
|
9
7
|
<div style="height: 24px; display: flex;">
|
|
10
8
|
<button data-command="bold" style="pointer-events: all; height: 24px; width: 24px; padding: 0; font-weight: 900;">b</button>
|
|
@@ -13,11 +11,16 @@ export class EditTextExtension extends AbstractExtension {
|
|
|
13
11
|
<button data-command="strikeThrough" style="pointer-events: all; height: 24px; width: 24px; padding: 0;"><del>s</del></button>
|
|
14
12
|
</div>
|
|
15
13
|
`;
|
|
14
|
+
_contentEditedBound;
|
|
15
|
+
_blurBound;
|
|
16
16
|
_blurTimeout;
|
|
17
|
+
_foreignObject;
|
|
18
|
+
_focusBound;
|
|
17
19
|
constructor(extensionManager, designerView, extendedItem) {
|
|
18
20
|
super(extensionManager, designerView, extendedItem);
|
|
19
21
|
this._contentEditedBound = this._contentEdited.bind(this);
|
|
20
22
|
this._blurBound = this._blur.bind(this);
|
|
23
|
+
this._focusBound = this._focus.bind(this);
|
|
21
24
|
}
|
|
22
25
|
extend() {
|
|
23
26
|
//todo -> check what to do with extensions, do not loose edit on mouse click,...
|
|
@@ -27,13 +30,13 @@ export class EditTextExtension extends AbstractExtension {
|
|
|
27
30
|
//this.extensionManager.removeExtension(this.extendedItem, ExtensionType.Selection);
|
|
28
31
|
this.extendedItem.element.setAttribute('contenteditable', '');
|
|
29
32
|
this.extendedItem.element.addEventListener('input', this._contentEditedBound);
|
|
30
|
-
this.extendedItem.element.addEventListener('blur', this._blurBound);
|
|
31
33
|
this.extendedItem.element.focus();
|
|
32
34
|
this.designerCanvas.eatEvents = this.extendedItem.element;
|
|
33
35
|
let itemRect = this.extendedItem.element.getBoundingClientRect();
|
|
34
36
|
const elements = EditTextExtension.template.content.cloneNode(true);
|
|
35
37
|
elements.querySelectorAll('button').forEach(x => x.onclick = () => this._formatSelection(x.dataset['command']));
|
|
36
|
-
|
|
38
|
+
const foreignObject = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
|
|
39
|
+
this._foreignObject = foreignObject;
|
|
37
40
|
foreignObject.setAttribute('x', '' + (itemRect.x - this.designerCanvas.containerBoundingRect.x) / this.designerCanvas.scaleFactor);
|
|
38
41
|
foreignObject.setAttribute('y', '' + ((itemRect.y - this.designerCanvas.containerBoundingRect.y) / this.designerCanvas.scaleFactor - 30));
|
|
39
42
|
foreignObject.setAttribute('width', '96');
|
|
@@ -42,6 +45,8 @@ export class EditTextExtension extends AbstractExtension {
|
|
|
42
45
|
this.overlayLayerView.addOverlay(foreignObject, OverlayLayer.Foregorund);
|
|
43
46
|
this.overlays.push(foreignObject);
|
|
44
47
|
this.designerCanvas.clickOverlay.style.pointerEvents = 'none';
|
|
48
|
+
this.extendedItem.element.addEventListener('blur', this._blurBound);
|
|
49
|
+
this.extendedItem.element.addEventListener('focus', this._focusBound);
|
|
45
50
|
}
|
|
46
51
|
refresh() {
|
|
47
52
|
this.dispose();
|
|
@@ -55,6 +60,11 @@ export class EditTextExtension extends AbstractExtension {
|
|
|
55
60
|
this.extendedItem.updateChildrenFromNodesChildren();
|
|
56
61
|
this.designerCanvas.clickOverlay.style.pointerEvents = 'auto';
|
|
57
62
|
}
|
|
63
|
+
handlesPointerEvent(designerCanvas, event, currentElement) {
|
|
64
|
+
let p = event.composedPath();
|
|
65
|
+
const stylo = this._foreignObject.querySelector('stylo-editor');
|
|
66
|
+
return p.indexOf(stylo) >= 0;
|
|
67
|
+
}
|
|
58
68
|
_contentEdited() {
|
|
59
69
|
//todo -> save???
|
|
60
70
|
//this.extendedItem.content = this.extendedItem.element.innerHTML;
|
|
@@ -69,6 +79,12 @@ export class EditTextExtension extends AbstractExtension {
|
|
|
69
79
|
}, 150);
|
|
70
80
|
}
|
|
71
81
|
}
|
|
82
|
+
_focus() {
|
|
83
|
+
if (this._blurTimeout) {
|
|
84
|
+
clearTimeout(this._blurTimeout);
|
|
85
|
+
this._blurTimeout = null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
72
88
|
_formatSelection(type) {
|
|
73
89
|
if (this._blurTimeout)
|
|
74
90
|
clearTimeout(this._blurTimeout);
|
package/dist/elements/widgets/designerView/extensions/EditText/EditTextWithStyloExtension.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { IDesignItem } from "../../../../item/IDesignItem";
|
|
|
2
2
|
import { IDesignerCanvas } from "../../IDesignerCanvas";
|
|
3
3
|
import { AbstractExtension } from "../AbstractExtension.js";
|
|
4
4
|
import { IExtensionManager } from "../IExtensionManger";
|
|
5
|
-
|
|
5
|
+
import { handlesPointerEvent } from "./EditTextExtension";
|
|
6
|
+
export declare class EditTextWithStyloExtension extends AbstractExtension implements handlesPointerEvent {
|
|
6
7
|
private _contentEditedBound;
|
|
7
8
|
private _blurBound;
|
|
8
9
|
private static template;
|
|
@@ -11,9 +12,11 @@ export declare class EditTextWithStyloExtension extends AbstractExtension {
|
|
|
11
12
|
private _rect2;
|
|
12
13
|
private _rect3;
|
|
13
14
|
private _rect4;
|
|
15
|
+
private _foreignObject;
|
|
14
16
|
constructor(extensionManager: IExtensionManager, designerView: IDesignerCanvas, extendedItem: IDesignItem);
|
|
15
17
|
extend(): void;
|
|
16
18
|
private _drawClickOverlayRects;
|
|
19
|
+
handlesPointerEvent(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): boolean;
|
|
17
20
|
refresh(): void;
|
|
18
21
|
dispose(): void;
|
|
19
22
|
_clickOutside(e: any): void;
|
package/dist/elements/widgets/designerView/extensions/EditText/EditTextWithStyloExtension.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { html } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
import { TextTool } from "../../tools/TextTool";
|
|
2
3
|
import { AbstractExtension } from "../AbstractExtension.js";
|
|
3
4
|
import { ExtensionType } from "../ExtensionType.js";
|
|
4
5
|
import { OverlayLayer } from "../OverlayLayer.js";
|
|
@@ -13,6 +14,7 @@ export class EditTextWithStyloExtension extends AbstractExtension {
|
|
|
13
14
|
_rect2;
|
|
14
15
|
_rect3;
|
|
15
16
|
_rect4;
|
|
17
|
+
_foreignObject;
|
|
16
18
|
constructor(extensionManager, designerView, extendedItem) {
|
|
17
19
|
super(extensionManager, designerView, extendedItem);
|
|
18
20
|
import('@papyrs/stylo/dist/esm/loader.js').then(d => d.defineCustomElements());
|
|
@@ -24,8 +26,10 @@ export class EditTextWithStyloExtension extends AbstractExtension {
|
|
|
24
26
|
this.extendedItem.element.addEventListener('blur', this._blurBound);
|
|
25
27
|
this.extendedItem.element.focus();
|
|
26
28
|
this.designerCanvas.eatEvents = this.extendedItem.element;
|
|
29
|
+
this.designerCanvas.serviceContainer.globalContext.tool = new TextTool(true);
|
|
27
30
|
const elements = EditTextWithStyloExtension.template.content.cloneNode(true);
|
|
28
|
-
|
|
31
|
+
const foreignObject = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
|
|
32
|
+
this._foreignObject = foreignObject;
|
|
29
33
|
foreignObject.setAttribute('x', '0');
|
|
30
34
|
foreignObject.setAttribute('y', '0');
|
|
31
35
|
foreignObject.setAttribute('width', '100%');
|
|
@@ -58,6 +62,11 @@ export class EditTextWithStyloExtension extends AbstractExtension {
|
|
|
58
62
|
this._rect3 = this._drawRect(normalized.x + normalized.width, 0, this.designerCanvas.containerBoundingRect.width, this.designerCanvas.containerBoundingRect.height, 'svg-transparent', this._rect3, OverlayLayer.Normal);
|
|
59
63
|
this._rect4 = this._drawRect(0, normalized.y + normalized.height, this.designerCanvas.containerBoundingRect.width, this.designerCanvas.containerBoundingRect.height, 'svg-transparent', this._rect4, OverlayLayer.Normal);
|
|
60
64
|
}
|
|
65
|
+
handlesPointerEvent(designerCanvas, event, currentElement) {
|
|
66
|
+
let p = event.composedPath();
|
|
67
|
+
const stylo = this._foreignObject.querySelector('stylo-editor');
|
|
68
|
+
return p.indexOf(stylo) >= 0;
|
|
69
|
+
}
|
|
61
70
|
refresh() {
|
|
62
71
|
this.dispose();
|
|
63
72
|
}
|
|
@@ -2,13 +2,14 @@ import { IDesignItem } from "../../../item/IDesignItem";
|
|
|
2
2
|
import { IDesignerCanvas } from "../IDesignerCanvas";
|
|
3
3
|
import { ExtensionType } from './ExtensionType';
|
|
4
4
|
import { IExtensionManager } from "./IExtensionManger";
|
|
5
|
+
import { IDesignerExtension } from "./IDesignerExtension";
|
|
5
6
|
export declare class ExtensionManager implements IExtensionManager {
|
|
6
7
|
designerCanvas: IDesignerCanvas;
|
|
7
8
|
designItemsWithExtentions: Set<IDesignItem>;
|
|
8
9
|
constructor(designerCanvas: IDesignerCanvas);
|
|
9
10
|
private _contentChanged;
|
|
10
11
|
private _selectedElementsChanged;
|
|
11
|
-
applyExtension(designItem: IDesignItem, extensionType: ExtensionType, recursive?: boolean):
|
|
12
|
+
applyExtension(designItem: IDesignItem, extensionType: ExtensionType, recursive?: boolean): IDesignerExtension[];
|
|
12
13
|
applyExtensions(designItems: IDesignItem[], extensionType: ExtensionType, recursive?: boolean): void;
|
|
13
14
|
removeExtension(designItem: IDesignItem, extensionType?: ExtensionType): void;
|
|
14
15
|
removeExtensions(designItems: IDesignItem[], extensionType?: ExtensionType): void;
|
|
@@ -47,6 +47,7 @@ export class ExtensionManager {
|
|
|
47
47
|
applyExtension(designItem, extensionType, recursive = false) {
|
|
48
48
|
if (designItem && designItem.nodeType == NodeType.Element) {
|
|
49
49
|
const extProv = this.designerCanvas.serviceContainer.designerExtensions.get(extensionType);
|
|
50
|
+
let extensions = [];
|
|
50
51
|
if (extProv) {
|
|
51
52
|
for (let e of extProv) {
|
|
52
53
|
if (e.shouldExtend(this, this.designerCanvas, designItem)) {
|
|
@@ -56,6 +57,7 @@ export class ExtensionManager {
|
|
|
56
57
|
const ext = e.getExtension(this, this.designerCanvas, designItem);
|
|
57
58
|
try {
|
|
58
59
|
ext.extend();
|
|
60
|
+
extensions.push(ext);
|
|
59
61
|
}
|
|
60
62
|
catch (err) {
|
|
61
63
|
console.error(err);
|
|
@@ -71,7 +73,9 @@ export class ExtensionManager {
|
|
|
71
73
|
this.applyExtension(d, extensionType, recursive);
|
|
72
74
|
}
|
|
73
75
|
}
|
|
76
|
+
return extensions;
|
|
74
77
|
}
|
|
78
|
+
return null;
|
|
75
79
|
}
|
|
76
80
|
applyExtensions(designItems, extensionType, recursive = false) {
|
|
77
81
|
if (designItems) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { IDesignItem } from "../../../item/IDesignItem";
|
|
2
2
|
import { ExtensionType } from './ExtensionType';
|
|
3
|
+
import { IDesignerExtension } from "./IDesignerExtension";
|
|
3
4
|
export interface IExtensionManager {
|
|
4
|
-
applyExtension(designItem: IDesignItem, extensionType: ExtensionType, recursive?: boolean):
|
|
5
|
+
applyExtension(designItem: IDesignItem, extensionType: ExtensionType, recursive?: boolean): IDesignerExtension[];
|
|
5
6
|
applyExtensions(designItems: IDesignItem[], extensionType: ExtensionType, recursive?: boolean): any;
|
|
6
7
|
removeExtension(designItem: IDesignItem, extensionType?: ExtensionType): any;
|
|
7
8
|
removeExtensions(designItems: IDesignItem[], extensionType?: ExtensionType): any;
|
|
@@ -2,10 +2,13 @@ import { ServiceContainer } from '../../../services/ServiceContainer.js';
|
|
|
2
2
|
import { IDesignerCanvas } from '../IDesignerCanvas';
|
|
3
3
|
import { ITool } from './ITool';
|
|
4
4
|
export declare class TextTool implements ITool {
|
|
5
|
-
|
|
5
|
+
private _textEditExtensions;
|
|
6
|
+
constructor(editExistingText?: boolean);
|
|
6
7
|
activated(serviceContainer: ServiceContainer): void;
|
|
7
8
|
dispose(): void;
|
|
8
9
|
readonly cursor = "text";
|
|
10
|
+
private _textCreated;
|
|
11
|
+
private _editExistingText;
|
|
9
12
|
pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): void;
|
|
10
13
|
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
11
14
|
}
|
|
@@ -3,31 +3,47 @@ import { DesignItem } from '../../../item/DesignItem.js';
|
|
|
3
3
|
import { InsertAction } from '../../../services/undoService/transactionItems/InsertAction.js';
|
|
4
4
|
import { ExtensionType } from '../extensions/ExtensionType.js';
|
|
5
5
|
export class TextTool {
|
|
6
|
-
|
|
6
|
+
_textEditExtensions;
|
|
7
|
+
constructor(editExistingText) {
|
|
8
|
+
if (editExistingText)
|
|
9
|
+
this._editExistingText = true;
|
|
7
10
|
}
|
|
8
11
|
activated(serviceContainer) {
|
|
12
|
+
this._textCreated = false;
|
|
9
13
|
}
|
|
10
14
|
dispose() {
|
|
11
15
|
}
|
|
12
16
|
cursor = 'text';
|
|
17
|
+
_textCreated = false;
|
|
18
|
+
_editExistingText = false;
|
|
13
19
|
pointerEventHandler(designerCanvas, event, currentElement) {
|
|
14
20
|
const currentPoint = designerCanvas.getNormalizedEventCoordinates(event);
|
|
15
21
|
switch (event.type) {
|
|
16
22
|
case EventNames.PointerDown:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
span.focus();
|
|
30
|
-
}
|
|
23
|
+
if (!this._textCreated && !this._editExistingText) {
|
|
24
|
+
this._textCreated = true;
|
|
25
|
+
const span = document.createElement('span');
|
|
26
|
+
const di = DesignItem.createDesignItemFromInstance(span, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
27
|
+
di.setStyle('position', 'absolute');
|
|
28
|
+
di.setStyle('left', currentPoint.x + 'px');
|
|
29
|
+
di.setStyle('top', currentPoint.y + 'px');
|
|
30
|
+
designerCanvas.instanceServiceContainer.undoService.execute(new InsertAction(designerCanvas.rootDesignItem, designerCanvas.rootDesignItem.childCount, di));
|
|
31
|
+
//todo: Maybe we could also remove the eatEvents property
|
|
32
|
+
//TODO - don't apply doubleclick extension (maybe it is not the doubleclick one) - apply edit text extesion directly
|
|
33
|
+
//should we configure the editTextExtension anywhere??
|
|
34
|
+
this._textEditExtensions = designerCanvas.extensionManager.applyExtension(di, ExtensionType.Doubleclick);
|
|
35
|
+
setTimeout(() => { span.focus(); }, 50);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
for (let e of this._textEditExtensions) {
|
|
39
|
+
if (e.handlesPointerEvent) {
|
|
40
|
+
const ret = e.handlesPointerEvent(designerCanvas, event, currentElement);
|
|
41
|
+
if (!ret) {
|
|
42
|
+
designerCanvas.serviceContainer.globalContext.finishedWithTool(this);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
31
47
|
break;
|
|
32
48
|
}
|
|
33
49
|
}
|
|
@@ -13,4 +13,7 @@ export declare class DesignerToolbar extends BaseCustomWebComponentConstructorAp
|
|
|
13
13
|
initialize(serviceContainer: ServiceContainer, designerView: DesignerView): void;
|
|
14
14
|
showPopup(designerToolbarButton: DesignerToolbarButton): void;
|
|
15
15
|
setTool(tool: string): void;
|
|
16
|
+
setStrokeColor(color: string): void;
|
|
17
|
+
setFillBrush(color: string): void;
|
|
18
|
+
setStrokeThickness(input: string): void;
|
|
16
19
|
}
|
|
@@ -64,5 +64,23 @@ export class DesignerToolbar extends BaseCustomWebComponentConstructorAppend {
|
|
|
64
64
|
}
|
|
65
65
|
this._designerView.designerCanvas.executeCommand({ type: CommandType.setTool, parameter: tool });
|
|
66
66
|
}
|
|
67
|
+
setStrokeColor(color) {
|
|
68
|
+
if (this._popupContainer.children.length) {
|
|
69
|
+
this._popupContainer.innerHTML = '';
|
|
70
|
+
}
|
|
71
|
+
this._designerView.designerCanvas.executeCommand({ type: CommandType.setStrokeColor, parameter: color });
|
|
72
|
+
}
|
|
73
|
+
setFillBrush(color) {
|
|
74
|
+
if (this._popupContainer.children.length) {
|
|
75
|
+
this._popupContainer.innerHTML = '';
|
|
76
|
+
}
|
|
77
|
+
this._designerView.designerCanvas.executeCommand({ type: CommandType.setFillBrush, parameter: color });
|
|
78
|
+
}
|
|
79
|
+
setStrokeThickness(input) {
|
|
80
|
+
if (this._popupContainer.children.length) {
|
|
81
|
+
this._popupContainer.innerHTML = '';
|
|
82
|
+
}
|
|
83
|
+
this._designerView.designerCanvas.executeCommand({ type: CommandType.setStrokeThickness, parameter: input });
|
|
84
|
+
}
|
|
67
85
|
}
|
|
68
86
|
customElements.define('node-projects-designer-toolbar', DesignerToolbar);
|
|
@@ -3,7 +3,7 @@ import { assetsPath } from "../../../../../../Constants.js";
|
|
|
3
3
|
export class DrawToolPopup extends BaseCustomWebComponentConstructorAppend {
|
|
4
4
|
static style = css `
|
|
5
5
|
.container {
|
|
6
|
-
width:
|
|
6
|
+
width: 220px;
|
|
7
7
|
min-height: 200px;
|
|
8
8
|
color: white;
|
|
9
9
|
background-color: rgb(64, 64, 64);
|
|
@@ -25,7 +25,33 @@ export class DrawToolPopup extends BaseCustomWebComponentConstructorAppend {
|
|
|
25
25
|
.tools {
|
|
26
26
|
display: flex;
|
|
27
27
|
flex-wrap: wrap;
|
|
28
|
-
|
|
28
|
+
margin-bottom: 5px;
|
|
29
|
+
}
|
|
30
|
+
.inputs{
|
|
31
|
+
float: left;
|
|
32
|
+
margin-top: 5px;
|
|
33
|
+
align-items: center;
|
|
34
|
+
}
|
|
35
|
+
.input {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
margin-top: 5px;
|
|
39
|
+
}
|
|
40
|
+
.text {
|
|
41
|
+
margin-left: 5px;
|
|
42
|
+
font-size: 14px;
|
|
43
|
+
}
|
|
44
|
+
.strokecolor{
|
|
45
|
+
float: both;
|
|
46
|
+
}
|
|
47
|
+
.fillbrush{
|
|
48
|
+
float: both;
|
|
49
|
+
}
|
|
50
|
+
.strokethickness{
|
|
51
|
+
float: both;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
`;
|
|
29
55
|
static template = html `
|
|
30
56
|
<div class="container">
|
|
31
57
|
<header><h2 id="title" style="margin: 0;">Draw</h2></header>
|
|
@@ -37,6 +63,20 @@ export class DrawToolPopup extends BaseCustomWebComponentConstructorAppend {
|
|
|
37
63
|
<div class="tool" data-command="setTool" data-command-parameter="DrawEllipsis" title="Draw Ellipsis" style="background-image: url('${assetsPath}images/layout/DrawEllipTool.svg');"></div>
|
|
38
64
|
<div class="tool" data-command="setTool" data-command-parameter="PickColor" title="Pick Color" style="background-image: url('${assetsPath}images/layout/ColorPickerTool.svg');"></div>
|
|
39
65
|
</div>
|
|
66
|
+
<div class="inputs">
|
|
67
|
+
<div class="input">
|
|
68
|
+
<input id="strokecolor" class="strokecolor" type="color" title="stroke color" value="#000000" style="padding: 0; width:31px; height:31px;">
|
|
69
|
+
<text class="text">Stroke Color</text>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="input">
|
|
72
|
+
<input id="fillbrush" class="fillbrush" type="color" title="fill brush" value="#ffffff" style="padding: 0; width:31px; height:31px;">
|
|
73
|
+
<text class="text">Fill Brush</text>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="input">
|
|
76
|
+
<input id="strokethickness" class="strokethickness" type="range" title="stroke thickness" min="1" max="20" value="3" style="padding: 0; width:80px; height:20px; margin-right: 5px;">
|
|
77
|
+
<text class="text">Stroke Thickness</text>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
40
80
|
</main>
|
|
41
81
|
</div>`;
|
|
42
82
|
constructor() {
|
|
@@ -45,6 +85,18 @@ export class DrawToolPopup extends BaseCustomWebComponentConstructorAppend {
|
|
|
45
85
|
let div = e;
|
|
46
86
|
div.onclick = () => this.getRootNode().host.setTool(div.dataset['commandParameter']);
|
|
47
87
|
}
|
|
88
|
+
if (this.shadowRoot.querySelector("input.strokecolor")) {
|
|
89
|
+
let input = this._getDomElement("strokecolor");
|
|
90
|
+
input.onchange = () => this.getRootNode().host.setStrokeColor(input.value);
|
|
91
|
+
}
|
|
92
|
+
if (this.shadowRoot.querySelector("input.fillbrush")) {
|
|
93
|
+
let input = this._getDomElement("fillbrush");
|
|
94
|
+
input.onchange = () => this.getRootNode().host.setFillBrush(input.value);
|
|
95
|
+
}
|
|
96
|
+
if (this.shadowRoot.querySelector("input.strokethickness")) {
|
|
97
|
+
let input = this._getDomElement("strokethickness");
|
|
98
|
+
input.onchange = () => this.getRootNode().host.setStrokeThickness(input.value);
|
|
99
|
+
}
|
|
48
100
|
}
|
|
49
101
|
}
|
|
50
102
|
customElements.define('node-projects-designer-drawtool-popup', DrawToolPopup);
|
package/dist/index.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export * from "./elements/services/propertiesService/services/LitElementProperti
|
|
|
90
90
|
export * from "./elements/services/propertiesService/services/NativeElementsPropertiesService.js";
|
|
91
91
|
export * from "./elements/services/propertiesService/services/SVGElementsPropertiesService.js";
|
|
92
92
|
export * from "./elements/services/propertiesService/services/PolymerPropertiesService.js";
|
|
93
|
-
export * from "./elements/services/propertiesService/services/
|
|
93
|
+
export * from "./elements/services/propertiesService/services/AbstractPropertiesService.js";
|
|
94
94
|
export * from "./elements/services/propertiesService/services/WebcomponentManifestPropertiesService.js";
|
|
95
95
|
export * from "./elements/services/propertiesService/services/AttributesPropertiesService.js";
|
|
96
96
|
export * from "./elements/services/propertiesService/PropertyType.js";
|
|
@@ -215,6 +215,7 @@ export type { ICodeView } from "./elements/widgets/codeView/ICodeView.js";
|
|
|
215
215
|
export * from "./elements/widgets/codeView/code-view-monaco.js";
|
|
216
216
|
export * from "./elements/widgets/codeView/code-view-ace.js";
|
|
217
217
|
export * from "./elements/widgets/codeView/code-view-code-mirror.js";
|
|
218
|
+
export * from "./elements/widgets/codeView/code-view-simple.js";
|
|
218
219
|
export * from "./elements/documentContainer.js";
|
|
219
220
|
export * from "./enums/EventNames.js";
|
|
220
221
|
export * from "./enums/PointerActionType.js";
|