Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Diagram Community Logo
  1. Home
  2. GoJS
  3. Proper Copy-Pasting of Disconnected Links in GoJS

Proper Copy-Pasting of Disconnected Links in GoJS

Scheduled Pinned Locked Moved GoJS
1 Posts 1 Posters 58 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • KubaSCK Offline
    KubaSCK Offline
    KubaSC
    wrote on last edited by
    #1

    Problem 🐛

    In GoJS, when we try to perform a copy-paste operation on partially or fully disconnected links, they are not pasted onto the diagram.

    11.png

    Solution

    To enable pasting of such links, set the property:

    diagram.toolManager.draggingTool.dragsLink = true;
    

    This property allows links to be dragged, which may not be desirable in the project. To ensure that only copy/paste works, simply add the following code in the CommandHandler:

    override pasteFromClipboard(): go.Set<go.Part> {
        const oldDragsLink = this.diagram.toolManager.draggingTool.dragsLink;
        this.diagram.toolManager.draggingTool.dragsLink = true;
        const pastedParts = super.pasteFromClipboard();
        this.diagram.toolManager.draggingTool.dragsLink = oldDragsLink;
    }
    

    After overriding this method, both partially and fully disconnected links should be correctly pasted onto the diagram. 🎉

    2.png

    1 Reply Last reply
    2

    • Login

    • Don't have an account? Register

    Powered by NodeBB Contributors
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups