mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 17:14:05 -08:00
31dd01f9cb
* N8N-3029 Add Node Type for Wokrflow Stickies/Notes * N8N-3029 Update Content, Update Aliasses * N8N-3030 Created N8N Sticky Component in Design System * N8N-3030 Fixed Code spaccing Sticky Component * N8N-3030 Fixed Code spaccing StickyStories Component * N8N-3030 Fixed Code spaccing Markdown Component * N8N-3030 Added Sticky Colors Pallete into Storybook, Update Color Variables for Sticky Component * N8N-3030 Added Unfocus Event * N8N-3030 Update Default Placeholder, Markdown Styles, Fixed Edit State, Added Text to EditState, Fixed Height of Area, Turned off Resize of textarea * N8N-3030 Update Sticky Overflow, Update Hover States, Updated Markdown Overflow * N8N-3030, N8N-3031 - Add Resize to Sticky, Created N8n-Resize component * N8N-3031 Fixed Importing Components in Editor-ui * N8N-3031 Fixed Resize Component, Fixed Gradient * N8N-3030, N8N-3031 Update Note Description * N8N-3032 Hotfix Building Storybook * N8N-3032 - Select Behaviour, Changes in Resize Component, Emit on Width/Height/Top/Left Change * N8N-3032 Update Resize Component to emmit left/top, Update Dynamic Resize on Selected Background * N8N-3032 Updated / Dragging vs Resizing, prevent open Modal for stickies * N8N-3032 Added ID props to n8n-sticky // dynamic id for multi resizing in NodeView * N8N-3033 Add dynamic size Tooltip on Sticky * N8N-3033 Updated Z-index for Sticky Component * N8N-3033 Updated N8N-Resize Component, Fixed SelectedBackround for Sticky Component * N8N-3033 Refactor * N8N-3033 Focus/Defocus on TextArea * N8N-3033 Fixed Resizing on NW Point * N8N-3030 Save content in vuex on input change * N8N-3033 Fixed Resizer, Save Width and Height in Vue * N8N-3033 Hide Sticky Footer on small height/width * N8N-3033 Fixed Resizer * N8N-3033 Dynamic Z-index for Stickies * N8N-3033 Dynamic Z-index for Stickies * N8N-3033 Removed static z-index for select sticky class * N8N-3034 Added Telemetry * N8N-3030 Formatter * N8N-3030 Format code * N8N-3030 Fixed Selecting Stickies * N8N-3033 Fixed Notifications * N8N-3030 Added new paddings for Default Stickies * N8N-3033 Prevent Scrolling NodeView when Sticky is in Edit mode and Mouse is Over the TextArea * N8N-3030 Prevent double clicking to switch state of Sticky component in Edit Mode * N8N-3033 Fixed Z-index of Stickies * N8N-3033 Prevent delete node when in EditMode * N8N-3030 Prevent Delete Button to delete the Sticky while in Edit Mode * N8N-3030 Change EditMode (emit) on keyboard shortucts, update Markdown Links & Images, Added new props * N8N-3030 Sticky Component - No padding when hiding footer text * N8N-3033 Fix Resizing enter into Edit Mode * N8N-3033 Selecting different nodes - exit the edit mode * N8N-3033 Auto Select Text in text-area by default - Sticky Component * N8N-3033 Prevent Default behaviour for CTRL + X, CTRL + A when Sticky is Active && inEditMode * N8N-3033 Refactor Resizer, Refactor Sticky, Update zIndex inEditMode * N8N-3033 Updated Default Text // Node-base, Storybook * N8N-3033 Add Resizing in EditMode - Components update * N8N-3033 Fixed Footer - Show/Hide on Resize in EditMode * N8N-3033 Fix ActiveSticky on Init * N8N-3033 Refactor Sticky in Vuex, Fixed Init Sticky Tweaks, Prevent Modal Openning, Save on Keyboard shortcuts * Stickies - Update Note node with new props * N8N-3030 Updated Default Note text, Update the Markdown Link * N8N-3030 CMD-C does not copy the text fix * N8N-3030 Fix Max Zoom / Zoom out shortcuts disabled in editState * N8N-3030 Z-index fixed during Edit Mode typing * N8N-3030 Prevent Autoselect Text in Stickies if the text is not default * N8N-3030 Fixed ReadOnly Bugs / Prevent showing Tooltip, Resizing * N8N-3030 Added Sticky Creator Button * N8N-3030 Update Icon / Sticky Creator Button * N8N-3033 Update Sticky Icon / StickyCreator Button * update package lock * 🔩 update note props * 🚿 clean props * 🔧 linting * 🔧 fix spacing * remove resize component * remove resize component * ✂ clean up sticky * revert back to height width * revert back to height/width * replace zindex property * replace default text property * use i18n to translate * update package lock * move resize * clean up how height/width are set * fix resize for sticky to support left/top * clean up resize * fix lasso/highlight bug * remove unused props * fix zoom to fit * fix padding for demo view * fix readonly * remove iseditable, use active state * clean up keyboard events * chang button size, no edit on insert * scale resizing correctly * make active on resize * fix select on resize/move * use outline icon * allow for multiple line breaks * fix multi line bug * fix edit mode outline * keep edit open as one resizes * respect multiple spaces * fix scrolling bug * clean up hover impl * clean up references to note * disable for rename * fix drifting while drag * fix mouse cursor on resize * fix sticky min height * refactor resize into component * fix pulling too far bug * fix delete/cut all bug * fix padding bottom * fix active change on resize * add transition to button * Fix sticky markdown click * add solid fa icon * update node graph, telemetry event * add snapping * change alt text * update package lock * fix bug in button hover * add back transition * clean up resize * add grid size as param * remove breaks * clean up markdown * lint fixes * fix spacing * clean up markdown colors * clean up classes in resize * clean up resize * update sticky story * fix spacing * clean up classes * revert change * revert change * revert change * clean up sticky component * remove unused component * remove unnessary data * remove unnessary data * clean up actions * clean up sticky size * clean up unnessary border style * fix bug * replace sticky note name * update description * remove support for multi spaces * update tracking name * update telemetry reqs * fix enter bug * update alt text * update sticky notes doc url * fix readonly bug * update class name * update quote marks Co-authored-by: SchnapsterDog <olivertrajceski@yahoo.com>
289 lines
7 KiB
Vue
289 lines
7 KiB
Vue
<template>
|
|
<div class="sticky-wrapper" :style="stickyPosition">
|
|
<div
|
|
:class="{'sticky-default': true, 'touch-active': isTouchActive, 'is-touch-device': isTouchDevice}"
|
|
:style="stickySize"
|
|
>
|
|
<div class="select-sticky-background" v-show="isSelected" />
|
|
<div
|
|
class="sticky-box"
|
|
:data-name="data.name"
|
|
:ref="data.name"
|
|
@click.left="mouseLeftClick"
|
|
v-touch:start="touchStart"
|
|
v-touch:end="touchEnd"
|
|
>
|
|
<n8n-sticky
|
|
:content.sync="node.parameters.content"
|
|
:height="node.parameters.height"
|
|
:width="node.parameters.width"
|
|
:scale="nodeViewScale"
|
|
:id="nodeIndex"
|
|
:readOnly="isReadOnly"
|
|
:defaultText="defaultText"
|
|
:editMode="isActive && !isReadOnly"
|
|
:gridSize="gridSize"
|
|
@input="onInputChange"
|
|
@edit="onEdit"
|
|
@resizestart="onResizeStart"
|
|
@resize="onResize"
|
|
@resizeend="onResizeEnd"
|
|
/>
|
|
</div>
|
|
|
|
<div v-show="showActions" class="sticky-options no-select-on-click">
|
|
<div v-touch:tap="deleteNode" class="option" :title="$locale.baseText('node.deleteNode')" >
|
|
<font-awesome-icon icon="trash" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import Vue from 'vue';
|
|
|
|
import mixins from 'vue-typed-mixins';
|
|
import { externalHooks } from '@/components/mixins/externalHooks';
|
|
import { nodeBase } from '@/components/mixins/nodeBase';
|
|
import { nodeHelpers } from '@/components/mixins/nodeHelpers';
|
|
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
|
|
import { getStyleTokenValue, isNumber, isString } from './helpers';
|
|
import { INodeUi, XYPosition } from '@/Interface';
|
|
|
|
import {
|
|
INodeTypeDescription,
|
|
} from 'n8n-workflow';
|
|
|
|
export default mixins(externalHooks, nodeBase, nodeHelpers, workflowHelpers).extend({
|
|
name: 'Sticky',
|
|
props: {
|
|
nodeViewScale: {
|
|
type: Number,
|
|
},
|
|
gridSize: {
|
|
type: Number,
|
|
},
|
|
},
|
|
computed: {
|
|
defaultText (): string {
|
|
if (!this.nodeType) {
|
|
return '';
|
|
}
|
|
const properties = this.nodeType.properties;
|
|
const content = properties.find((property) => property.name === 'content');
|
|
|
|
return content && isString(content.default) ? content.default : '';
|
|
},
|
|
isSelected (): boolean {
|
|
return this.$store.getters.getSelectedNodes.find((node: INodeUi) => node.name === this.data.name);
|
|
},
|
|
nodeType (): INodeTypeDescription | null {
|
|
return this.data && this.$store.getters.nodeType(this.data.type, this.data.typeVersion);
|
|
},
|
|
node (): INodeUi | undefined { // same as this.data but reactive..
|
|
return this.$store.getters.nodesByName[this.name] as INodeUi | undefined;
|
|
},
|
|
position (): XYPosition {
|
|
if (this.node) {
|
|
return this.node.position;
|
|
} else {
|
|
return [0, 0];
|
|
}
|
|
},
|
|
height(): number {
|
|
return this.node && isNumber(this.node.parameters.height)? this.node.parameters.height : 0;
|
|
},
|
|
width(): number {
|
|
return this.node && isNumber(this.node.parameters.width)? this.node.parameters.width : 0;
|
|
},
|
|
stickySize(): object {
|
|
const returnStyles: {
|
|
[key: string]: string | number;
|
|
} = {
|
|
height: this.height + 'px',
|
|
width: this.width + 'px',
|
|
};
|
|
|
|
return returnStyles;
|
|
},
|
|
stickyPosition (): object {
|
|
const returnStyles: {
|
|
[key: string]: string | number;
|
|
} = {
|
|
left: this.position[0] + 'px',
|
|
top: this.position[1] + 'px',
|
|
zIndex: this.isActive ? 9999999 : -1 * Math.floor((this.height * this.width) / 1000),
|
|
};
|
|
|
|
return returnStyles;
|
|
},
|
|
showActions(): boolean {
|
|
return !(this.hideActions || this.isReadOnly || this.workflowRunning || this.isResizing);
|
|
},
|
|
workflowRunning (): boolean {
|
|
return this.$store.getters.isActionActive('workflowRunning');
|
|
},
|
|
},
|
|
data () {
|
|
return {
|
|
isResizing: false,
|
|
isTouchActive: false,
|
|
};
|
|
},
|
|
methods: {
|
|
deleteNode () {
|
|
Vue.nextTick(() => {
|
|
// Wait a tick else vue causes problems because the data is gone
|
|
this.$emit('removeNode', this.data.name);
|
|
});
|
|
},
|
|
onEdit(edit: boolean) {
|
|
if (edit && !this.isActive && this.node) {
|
|
this.$store.commit('setActiveNode', this.node.name);
|
|
}
|
|
else if (this.isActive && !edit) {
|
|
this.$store.commit('setActiveNode', null);
|
|
}
|
|
},
|
|
onInputChange(content: string) {
|
|
this.setParameters({content});
|
|
},
|
|
onResizeStart() {
|
|
this.isResizing = true;
|
|
if (!this.isSelected && this.node) {
|
|
this.$emit('nodeSelected', this.node.name, false, true);
|
|
}
|
|
const nodeIndex = this.$store.getters.getNodeIndex(this.data.name);
|
|
const nodeIdName = `node-${nodeIndex}`;
|
|
this.instance.destroyDraggable(nodeIdName); // todo
|
|
},
|
|
onResize({height, width, dX, dY}: { width: number, height: number, dX: number, dY: number }) {
|
|
if (!this.node) {
|
|
return;
|
|
}
|
|
if (dX !== 0 || dY !== 0) {
|
|
this.setPosition([this.node.position[0] + (dX || 0), this.node.position[1] + (dY || 0)]);
|
|
}
|
|
|
|
this.setParameters({ height, width });
|
|
},
|
|
onResizeEnd() {
|
|
this.isResizing = false;
|
|
this.__makeInstanceDraggable(this.data);
|
|
},
|
|
setParameters(params: {content?: string, height?: number, width?: number}) {
|
|
if (this.node) {
|
|
const nodeParameters = {
|
|
content: isString(params.content) ? params.content : this.node.parameters.content,
|
|
height: isNumber(params.height) ? params.height : this.node.parameters.height,
|
|
width: isNumber(params.width) ? params.width : this.node.parameters.width,
|
|
};
|
|
|
|
const updateInformation = {
|
|
name: this.node.name,
|
|
value: nodeParameters,
|
|
};
|
|
|
|
this.$store.commit('setNodeParameters', updateInformation);
|
|
}
|
|
},
|
|
setPosition(position: XYPosition) {
|
|
if (!this.node) {
|
|
return;
|
|
}
|
|
|
|
const updateInformation = {
|
|
name: this.node.name,
|
|
properties: {
|
|
position,
|
|
},
|
|
};
|
|
|
|
this.$store.commit('updateNodeProperties', updateInformation);
|
|
},
|
|
touchStart () {
|
|
if (this.isTouchDevice === true && this.isMacOs === false && this.isTouchActive === false) {
|
|
this.isTouchActive = true;
|
|
setTimeout(() => {
|
|
this.isTouchActive = false;
|
|
}, 2000);
|
|
}
|
|
},
|
|
},
|
|
});
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.sticky-wrapper {
|
|
position: absolute;
|
|
|
|
.sticky-default {
|
|
position: absolute;
|
|
|
|
.sticky-box {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
&.touch-active,
|
|
&:hover {
|
|
.sticky-options {
|
|
display: flex;
|
|
cursor: pointer;
|
|
}
|
|
}
|
|
|
|
.sticky-options {
|
|
display: none;
|
|
justify-content: flex-start;
|
|
position: absolute;
|
|
top: -25px;
|
|
left: -8px;
|
|
height: 26px;
|
|
font-size: 0.9em;
|
|
text-align: left;
|
|
z-index: 10;
|
|
color: #aaa;
|
|
text-align: center;
|
|
|
|
.option {
|
|
width: 28px;
|
|
display: inline-block;
|
|
|
|
&.touch {
|
|
display: none;
|
|
}
|
|
|
|
&:hover {
|
|
color: $--color-primary;
|
|
}
|
|
}
|
|
}
|
|
|
|
&.is-touch-device .sticky-options {
|
|
left: -25px;
|
|
width: 150px;
|
|
|
|
.option.touch {
|
|
display: initial;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.select-sticky-background {
|
|
display: block;
|
|
position: absolute;
|
|
background-color: hsla(var(--color-foreground-base-h), var(--color-foreground-base-s), var(--color-foreground-base-l), 60%);
|
|
border-radius: var(--border-radius-xlarge);
|
|
overflow: hidden;
|
|
height: calc(100% + 16px);
|
|
width: calc(100% + 16px);
|
|
left: -8px;
|
|
top: -8px;
|
|
z-index: 0;
|
|
}
|
|
</style>
|