【问题标题】:Paste elements to another graph in Rappid?将元素粘贴到 Rappid 中的另一个图表?
【发布时间】:2018-12-05 16:16:04
【问题描述】:

我正在构建一个使用 JointsJS + Rappid 操作图表的管理工具。我正在尝试将粘贴元素从一张纸 A 复制到另一张纸 B(位于不同的浏览器选项卡上),但我面临以下问题:

  • 我可以将一组元素从 A 复制粘贴到 B(这很好)
  • 我什至可以粘贴几次(还是不错的)
  • 但如果我从 A 复制另一组元素并尝试将其粘贴到 B 中,则会粘贴前一组,而不是新的一组
  • 我仍然可以将元素从 A 粘贴到 A 中,将 B 粘贴到 B 中,但不能再从一个粘贴到另一个。

似乎Kitchen Sink Rappid demo 中的这种行为是相同的:如果我在演示中打开 2 个选项卡,我将面临完全相同的问题。您可以通过使用演示应用打开 2 个选项卡轻松重现它。

这是我的一段代码(直接取自 Rappid 演示):

this.clipboard = new joint.ui.Clipboard();
this.selection = new joint.ui.Selection({
    paper: this.paper,
    handles: App.config.selection.handles,
    collection: new Backbone.Collection
});

this.keyboard = new joint.ui.Keyboard();
this.keyboard.on({
    'ctrl+c': function () {
        // Copy all selected elements and their associated links.
        this.clipboard.copyElements(this.selection.collection, this.graph);
    },
    'ctrl+v': function () {
        var pastedCells = this.clipboard.pasteCells(this.graph, {
            translate: {dx: 20, dy: 20},
            useLocalStorage: true
        });
        var elements = _.filter(pastedCells, function (cell) {
            return cell.isElement();
        });
        // Make sure pasted elements get selected immediately. This makes the UX better as
        // the user can immediately manipulate the pasted elements.
        this.selection.collection.reset(elements);
    },
}

在 Rappid 文档中,声明:

"此外,剪贴板还可以从一张纸上复制单元格并 将它们粘贴到另一个。但是,目标的确定 纸留给应用层。”

我没有完全理解第二句话(“但是……”结束)。

我监控了本地存储,发现两篇论文可能使用相同的存储条目,这让我觉得图间粘贴是托管的。

在这个阶段,我正在努力寻找是否:

  • 我的代码应该执行图间复制粘贴,
  • 我做错了什么,
  • Rappid 中存在一个错误(考虑到这个行为在官方演示中是相同的)。

感谢您的帮助。

【问题讨论】:

    标签: jointjs rappid


    【解决方案1】:

    我从 Rappid 工作人员那里得到了答复,这是 Rappid 中的一个错误,正在修复中。

    该修复将嵌入下一个版本(可能是 2.5)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多