发布于 

Confluence安装Drawio插件

之前画图习惯了用processOn,确实很方便,而且还有多人协作模式,可惜文件数量太有限了,买了一年会员,后面还涨价了,只好另寻出路。
也有在confluence写文档的习惯,然而每次processOn的文件都需要手动截图贴到confluence上,还要留个链接跳转到processOn上以便继续编辑。
跟其他人做协同办公时就很苦恼,想找个更好的解决方案,将文档、绘图和协同办公整合。

后面试用了drawio,有一说一,在使用细节上还是不如processOn方便,不过好在完全免费。
然而drawio的文件存储是个问题,在多人协同的时候,如何共享文件?
试用了gitlab、github、onedrive等方式,其实都不太方便,一是受限于储存本身的访问,在国内访问不稳定,一是需要多人共同持有这些存储的账号,最后,也不方便与confluence整合。
好在,drawio本身提供了confluence插件,试用后感觉良好,可以直接在页面插入drawio编辑框,保存后也可以直接页面查看绘图,在协同办公角度,这已经是比processOn完美的方案了。
可惜,该插件只提供了30天试用期。因此,记录绕过此限制的方案,仅做记录和技术分享,请大家有能力的还是支持正版。

  1. 下载插件文件 drawio-confluence-plugin-9.5.8.obr
  2. 在ide中新建个类DrawioLicenseManager,它import的两个类同样创建包名和对应类即可。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    package com.mxgraph.confluence.plugins.util;

    import com.atlassian.confluence.license.LicenseService;
    import com.atlassian.upm.api.license.PluginLicenseManager;

    public class DrawioLicenseManager {
    private PluginLicenseManager pluginLicenseManager;
    private LicenseService licenseService;

    public DrawioLicenseManager(PluginLicenseManager pluginLicenseManager, LicenseService licenseService) {
    this.pluginLicenseManager = pluginLicenseManager;
    this.licenseService = licenseService;
    }

    public boolean isDevLicense() {
    /*try {
    LicenseType lt = this.licenseService.retrieve().getLicenseType();
    return lt.compareTo(LicenseType.DEVELOPER) == 0 || lt.compareTo(LicenseType.TESTING) == 0;
    } catch (Throwable var2) {
    return false;
    }*/

    return false;
    }

    public DrawioLicenseManager.LicenseStatus getLicenseStatus() {
    /*Option<PluginLicense> licOpt = this.pluginLicenseManager.getLicense();
    if (this.isDevLicense()) {
    return DrawioLicenseManager.LicenseStatus.OK;
    } else if (!licOpt.isDefined()) {
    return DrawioLicenseManager.LicenseStatus.NO_LICENSE;
    } else {
    PluginLicense license = (PluginLicense)licOpt.get();
    if (license.isEvaluation()) {
    DateTime evalExpDate = (DateTime)license.getExpiryDate().get();
    return evalExpDate.isBefore(DateTime.now().minusWeeks(1)) ? DrawioLicenseManager.LicenseStatus.EVAL_EXPIRED : DrawioLicenseManager.LicenseStatus.EVAL_LICENSE;
    } else {
    if (license.getError().isDefined()) {
    if (((LicenseError)license.getError().get()).equals(LicenseError.USER_MISMATCH)) {
    return DrawioLicenseManager.LicenseStatus.USER_MISMATCH;
    }
    if (((LicenseError)license.getError().get()).equals(LicenseError.VERSION_MISMATCH)) {
    return DrawioLicenseManager.LicenseStatus.VERSION_MISMATCH;
    }
    }
    return DrawioLicenseManager.LicenseStatus.OK;
    }
    }*/

    return DrawioLicenseManager.LicenseStatus.OK;
    }

    public static enum LicenseStatus {
    NO_LICENSE,
    EVAL_LICENSE,
    EVAL_EXPIRED,
    USER_MISMATCH,
    VERSION_MISMATCH,
    OK;

    private LicenseStatus() {
    }
    }
    }
  3. 编译,在target目录下生成DrawioLicenseManager.class文件
  4. 使用压缩工具,将DrawioLicenseManager.class替换步骤1中下载的obr包中的对应包下对应文件
  5. 使用管理员账号登录confluence,找到插件管理 -> 上传插件 -> 选择步骤4中的obr包,点击上传

现在进入confluence随意一个页面,点击编辑,选择插入,即可看到draw.io Diagram, 插入后即可在上面进行绘图并保存。
再进入插件管理, 可以看到draw.io Confluence Plugin,状态是免费试用,虽然下面写着试用30天,但实践证明超过了30天仍然可以试用