Skip to content

Commit

Permalink
Added fix for clipboard commands when there are multiple editors on a…
Browse files Browse the repository at this point in the history
… page to resolve TeselaGen#24
  • Loading branch information
ryan-stackwave committed Feb 15, 2024
1 parent 5471bff commit 9494907
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/ove/src/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,10 @@ const noSelection = ({ selectionLayer = {} }) =>
!(selectionLayer.start > -1 && selectionLayer.end > -1) &&
"Selection Required";

const triggerClipboardCommand = type => {
const wrapper = document.querySelector(".veVectorInteractionWrapper");
const triggerClipboardCommand = (type, props) => {
const wrapper = document.querySelector(
`#${props.editorName} .veVectorInteractionWrapper`
);
if (!wrapper) {
return window.toastr.info(`Cannot trigger a ${type} in the current view`);
}
Expand Down Expand Up @@ -395,8 +397,8 @@ const editCommandDefs = {
(props.readOnly && readOnlyDisabledTooltip) ||
props.sequenceLength === 0,
isHidden: props => props.readOnly || props.disableBpEditing,
handler: () => {
triggerClipboardCommand("cut");
handler: props => {
triggerClipboardCommand("cut", props);
},
hotkey: "mod+x"
},
Expand All @@ -417,15 +419,15 @@ const editCommandDefs = {
copy: {
isDisabled: props => props.sequenceLength === 0,

handler: () => triggerClipboardCommand("copy"),
handler: props => triggerClipboardCommand("copy", props),
hotkey: "mod+c"
},

paste: {
isDisabled: props => props.readOnly && readOnlyDisabledTooltip,
isHidden: props => props.readOnly || props.disableBpEditing,

handler: () => triggerClipboardCommand("paste"),
handler: props => triggerClipboardCommand("paste", props),
hotkey: "mod+v"
},

Expand Down

0 comments on commit 9494907

Please sign in to comment.