@teselagen/ove 0.7.3-beta.6 → 0.7.3

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.
@@ -4,7 +4,6 @@ import {
4
4
  getAminoAcidStringFromSequenceString
5
5
  } from "@teselagen/sequence-utils";
6
6
  import { getSequenceWithinRange } from "@teselagen/range-utils";
7
- import * as ClipboardJS from "clipboard";
8
7
  import { compose } from "redux";
9
8
  import {
10
9
  getReverseComplementSequenceAndAnnotations,
@@ -599,11 +598,10 @@ function VectorInteractionHOC(Component /* options */) {
599
598
  this.props;
600
599
  const { isProtein } = sequenceData;
601
600
  const makeTextCopyable = (transformFunc, className, action = "copy") => {
602
- return new ClipboardJS(`.${className}`, {
603
- action: () => action,
604
- text: () => {
605
- const { selectionLayer, editorName, store } = this.props;
606
- const { sequenceData, copyOptions } =
601
+ document.querySelectorAll(`.${className}`).forEach(element => {
602
+ element.addEventListener("click", async () => {
603
+ const { editorName, store } = this.props;
604
+ const { sequenceData, copyOptions, selectionLayer } =
607
605
  store.getState().VectorEditor[editorName];
608
606
 
609
607
  const selectedSeqData = getSequenceDataBetweenRange(
@@ -623,24 +621,36 @@ function VectorInteractionHOC(Component /* options */) {
623
621
  }
624
622
  }
625
623
  );
624
+
626
625
  const sequenceDataToCopy = transformFunc(
627
626
  selectedSeqData,
628
627
  sequenceData
629
628
  );
630
629
  this.sequenceDataToCopy = sequenceDataToCopy;
630
+
631
+ const textToCopy =
632
+ sequenceDataToCopy.textToCopy || sequenceDataToCopy.sequence;
633
+
634
+ try {
635
+ await navigator.clipboard.writeText(textToCopy);
636
+ } catch (err) {
637
+ console.error("Failed to copy text:", err);
638
+ }
639
+
631
640
  if (action === "copy") {
632
641
  document.body.addEventListener("copy", this.handleCopy);
633
642
  } else {
634
643
  document.body.addEventListener("cut", this.handleCut);
635
644
  }
645
+
636
646
  if (window.Cypress) {
637
647
  window.Cypress.textToCopy = sequenceDataToCopy.textToCopy;
638
648
  window.Cypress.seqDataToCopy = sequenceDataToCopy;
639
649
  }
640
- return sequenceDataToCopy.textToCopy || sequenceDataToCopy.sequence;
641
- }
650
+ });
642
651
  });
643
652
  };
653
+
644
654
  const aaCopy = {
645
655
  text: "Copy AA Sequence",
646
656
  className: "openVeCopyAA",
@@ -659,8 +669,6 @@ function VectorInteractionHOC(Component /* options */) {
659
669
  }, className);
660
670
  }
661
671
  };
662
- // TODO: maybe stop using Clipboard.js and unify clipboard handling with
663
- // a more versatile approach
664
672
  return [
665
673
  ...(readOnly || disableBpEditing
666
674
  ? []
@@ -0,0 +1 @@
1
+ export function useFormValue(formName: any, field: any): any;
@@ -1,6 +1,6 @@
1
1
  import { default as React } from '../../../../node_modules/react';
2
- export default Clipboard;
3
- declare class Clipboard extends React.Component<any, any, any> {
2
+ export default Keyboard;
3
+ declare class Keyboard extends React.Component<any, any, any> {
4
4
  static defaultProps: {
5
5
  className: string;
6
6
  };