mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
Pasting and duplicating nodes (#902)
* Pasting and duplicating nodes * Rebind duplication * Update selection on duplicate
This commit is contained in:
parent
8f4f7b3cf1
commit
af001f8db6
8 changed files with 119 additions and 2 deletions
|
@ -300,7 +300,7 @@ import { defineComponent, nextTick } from "vue";
|
|||
|
||||
import type { IconName } from "@/utility-functions/icons";
|
||||
|
||||
import type { FrontendNodeLink } from "@/wasm-communication/messages";
|
||||
import { UpdateNodeGraphSelection, FrontendNodeLink } from "@/wasm-communication/messages";
|
||||
|
||||
import LayoutCol from "@/components/layout/LayoutCol.vue";
|
||||
import LayoutRow from "@/components/layout/LayoutRow.vue";
|
||||
|
@ -721,6 +721,10 @@ export default defineComponent({
|
|||
const outputPort2 = document.querySelectorAll(`[data-port="output"]`)[6] as HTMLDivElement | undefined;
|
||||
const inputPort2 = document.querySelectorAll(`[data-port="input"]`)[3] as HTMLDivElement | undefined;
|
||||
if (outputPort2 && inputPort2) this.createWirePath(outputPort2, inputPort2.getBoundingClientRect(), true, false);
|
||||
|
||||
this.editor.subscriptions.subscribeJsMessage(UpdateNodeGraphSelection, (updateNodeGraphSelection) => {
|
||||
this.selected = updateNodeGraphSelection.selected;
|
||||
});
|
||||
},
|
||||
components: {
|
||||
IconLabel,
|
||||
|
|
|
@ -262,6 +262,8 @@ export function createInputManager(editor: Editor, container: HTMLElement, dialo
|
|||
item.getAsString((text) => {
|
||||
if (text.startsWith("graphite/layer: ")) {
|
||||
editor.instance.pasteSerializedData(text.substring(16, text.length));
|
||||
} else if (text.startsWith("graphite/nodes: ")) {
|
||||
editor.instance.pasteSerializedNodes(text.substring(16, text.length));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -33,11 +33,17 @@ export class UpdateNodeGraph extends JsMessage {
|
|||
@Type(() => FrontendNodeLink)
|
||||
readonly links!: FrontendNodeLink[];
|
||||
}
|
||||
|
||||
export class UpdateNodeTypes extends JsMessage {
|
||||
@Type(() => FrontendNode)
|
||||
readonly nodeTypes!: FrontendNodeType[];
|
||||
}
|
||||
|
||||
export class UpdateNodeGraphSelection extends JsMessage {
|
||||
@Type(() => BigInt)
|
||||
readonly selected!: bigint[];
|
||||
}
|
||||
|
||||
export class UpdateNodeGraphVisibility extends JsMessage {
|
||||
readonly visible!: boolean;
|
||||
}
|
||||
|
@ -1407,6 +1413,7 @@ export const messageMakers: Record<string, MessageMaker> = {
|
|||
UpdateMouseCursor,
|
||||
UpdateNodeGraph,
|
||||
UpdateNodeGraphBarLayout,
|
||||
UpdateNodeGraphSelection,
|
||||
UpdateNodeTypes,
|
||||
UpdateNodeGraphVisibility,
|
||||
UpdateOpenDocumentsList,
|
||||
|
|
|
@ -627,6 +627,13 @@ impl JsEditorHandle {
|
|||
self.dispatch(message);
|
||||
}
|
||||
|
||||
/// Pastes the nodes based on serialized data
|
||||
#[wasm_bindgen(js_name = pasteSerializedNodes)]
|
||||
pub fn paste_serialized_nodes(&self, serialized_nodes: String) {
|
||||
let message = NodeGraphMessage::PasteNodes { serialized_nodes };
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
/// Notifies the backend that the user double clicked a node
|
||||
#[wasm_bindgen(js_name = doubleClickNode)]
|
||||
pub fn double_click_node(&self, node: u64) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue