Git Product home page Git Product logo

Comments (9)

bigben446 avatar bigben446 commented on June 20, 2024 2

建了一个zotero-wps插件开发项目,感兴趣的同学一起去那边交流吧,争取早日搞定zotero的wps插件。zotero-wps插件开发的交流QQ群:1029775161,https://github.com/l0o0/Zotero-WPS

from translators_cn.

Lemmingh avatar Lemmingh commented on June 20, 2024 1

造一个 Zotero WPS Integration,确实超纲。


Zotero Word for Windows Integration 是一个跟 JavaScript 几乎没有关系的古董。

Zotero.dotm 是用 VBA 写的 Word Template,仅实现 Ribbon 菜单以及从 Word 发消息到 Zotero。

而主体是一个用 Visual C++/MFC 写的库,调用 Word Interop API 来实现引文管理功能。

这导致它不能在 WPS 上正常工作。


如果要支持 WPS,则需调用 WPS 文字 API。文档在 WPS 开放平台 > 开发文档 > WPS 客户端开发 > WPS 基础接口 > 文字 API 参考。

简单翻了一下 Zotero Connector 以及其他 Zotero integration plugin,感觉 WPS 加载项确实可以实现相关功能。

从 Zotero 拉取数据是大头。

目前就找到这么多。

如果哪位有兴趣,可以试一下。


如果不行,那么只好也走 OLE Automation。搜到几篇古老的文章,或许可参考:

from translators_cn.

lon91ong avatar lon91ong commented on June 20, 2024 1

造一个 Zotero WPS Integration,确实超纲。

Zotero Word for Windows Integration 是一个跟 JavaScript 几乎没有关系的古董。

Zotero.dotm 是用 VBA 写的 Word Template,仅实现 Ribbon 菜单以及从 Word 发消息到 Zotero。

而主体是一个用 Visual C++/MFC 写的库,调用 Word Interop API 来实现引文管理功能。

从 Zotero 拉取数据是大头。

从 Zotero 拉取数据是大头, 这个大头感觉不太准确, 从Zotero取数据毕竟VBA都已经实现了, 直接照着用JS重写即可, 真正的大头应该是用JS解析数据并实现用 Visual C++/MFC 写的库的功能

在WPS已经实现了JS宏JS加载项的前提下, 上述功能的实现不能说是"轻而易举", 起码够得上"水到渠成"
需要的是 或者独立代发经验丰富的大佬动手 或者有项目开发经验的大佬规划和领导...


以上, 最后一段可能有点"想当然"的意味, 请多见谅!

from translators_cn.

lon91ong avatar lon91ong commented on June 20, 2024 1

@Lemmingh 是我理解的肤浅了, 刚刚用WPS打开Zotero.dotm查看源代码, 确实如你所言
但是用这种方案的话, 许多Zotero已经实现的工作必须都用JS加载项重做了, 比如: 丰富的引文格式, 工作量不是一般的大

from translators_cn.

Lemmingh avatar Lemmingh commented on June 20, 2024 1

丰富的引文格式

关键在 Custom endpoint handler 能做什么。

上面提到了 BBT,它在 Connector Server 上实现了许多 endpoint。按这个思路,利用 Zotero plugin,仍然可以让 Zotero 完成排版,最后 WPS 加载项这边拉取呈现和 metadata,再嵌入文档。(在 Word 上,是 Zotero 走 IA 把这些东西写进文档。)

但我不清楚 Zotero 5.0.71 增加的安全限制是怎么回事。如果是测 UA,可以想办法绕过。

from translators_cn.

l0o0 avatar l0o0 commented on June 20, 2024

这个目前超纲了,我也是刚学JS没多久的新人。

from translators_cn.

lon91ong avatar lon91ong commented on June 20, 2024

刚刚试着看看Zotero.dotm中的VBA代码, 用Word2016打开提示"功能锁定"-"工程不可查看", 换WPS2019打开, 直接随便看
注明了使用GNU共享协议, 有两个模块, Zotero和ZoteroRibbon, 代码超简单:

' Zotero功能的精华

Sub ZoteroCommand(cmd As String, bringToFront As Boolean)
    Dim cds As COPYDATASTRUCT
    #If VBA7 Then
        Dim ThWnd As LongPtr
    #Else
        Dim ThWnd As Long
    #End If
    Dim a$, args$, name$
    Dim i As Long
    Dim ignore As Long
    Dim sBuffer$
    Dim lLength As Long
    Dim buf() As Byte
    
    ' Try various names for Firefox
    Dim appNames(5)
    appNames(1) = "Zotero"
    appNames(2) = "Firefox"
    appNames(3) = "Browser"
    appNames(4) = "firefox-dev"
    For i = 1 To 4
        ThWnd = FindWindow(appNames(i) & "MessageWindow", vbNullString)
        If ThWnd <> 0 Then
            Exit For
        End If
    Next
    If ThWnd = 0 Then
        MsgBox ("Word could not communicate with Zotero. Please ensure Zotero is running and try again. If this problem persists, see https://www.zotero.org/support/word_processor_plugin_troubleshooting")
        Exit Sub
    End If
    
    ' Allow Firefox to bring a window to the front
    If bringToFront Then Call SetForegroundWindow(ThWnd)
    
    ' Get path to active document
    If ActiveDocument.Path <> "" Then
        name$ = ActiveDocument.Path & Application.PathSeparator & ActiveDocument.name
    Else
        name$ = ActiveDocument.name
    End If
    
    ' Set up command line arguments
    name$ = Replace(name$, """", """""")
    args$ = "-silent -ZoteroIntegrationAgent WinWord -ZoteroIntegrationCommand " & cmd & " -ZoteroIntegrationDocument """ & name$ & """"
    a$ = "firefox.exe " & args$ & Chr$(0) & "C:\"
    
    ' Do some UTF-8 magic
    lLength = WideCharToMultiByte(CP_UTF8, 0, StrPtr(a$), -1, ByVal 0, 0, 0, 0)
    ReDim buf(lLength) As Byte
    Call WideCharToMultiByte(CP_UTF8, 0, StrPtr(a$), -1, buf(1), lLength, 0, 0)
    
    ' Send message to Firefox
    cds.dwData = 1
    cds.cbData = lLength
    cds.lpData = VarPtr(buf(1))
    i = SendMessage(ThWnd, WM_COPYDATA, 0, cds)
    
    ' Handle error
    If Err.LastDllError = 5 Then
        If Dir("C:\Program Files\Mozilla Firefox\firefox.exe") <> "" Then
            Call Shell("""C:\Program Files\Mozilla Firefox\firefox.exe"" " & args$, vbNormalFocus)
        ElseIf Dir("C:\Program Files (x86)\Mozilla Firefox\firefox.exe") <> "" Then
            Call Shell("""C:\Program Files (x86)\Mozilla Firefox\firefox.exe"" " & args$, vbNormalFocus)
        End If
    End If
End Sub

用JS重写的话, 就卡在了FindWindow这种系统API的操作函数, 需要用另外的工具实现

from translators_cn.

Lemmingh avatar Lemmingh commented on June 20, 2024

Zotero Word for Windows Integration 的那个 Zotero.dotm 仅仅是个 Ribbon,点一下就向 Zotero 发个指令,其他什么功能都没有。

所有逻辑都是在 Zotero 中实现的。

我理解的它的架构:

+------------------+    +------------------+
|  Microsoft Word  |    |      Zotero      |
|                  |    |                  |
| +-------------+  |    | +-------------+  |
| | Zotero.dotm |-------->|   Citation  |  |
| +-------------+  |    | |   handler   |  |
|                  |    | +-------------+  |
|                  |    |        ↕         |
| +-------------+  |    | +-------------+  |
| |   Document  |  |    | |   Glue JS   |  |
| +-------------+  |    | +-------------+  |
|        ↕         |    |        ↕         |
| +-------------+  |    | +-------------+  |
| | Interop API |<------->|    Native   |  |
| +-------------+  |    | +-------------+  |
|                  |    |                  |
+------------------+    +------------------+

"Zotero" pulls from and pushes to "Microsoft Word".


而做 WPS Integration,我认为应当采取这种方案:

+------------------+    +------------------+
|       WPS        |    |      Zotero      |
|                  |    |                  |
| +-------------+  |    | +-------------+  |
| |   Ribbon    |  |    | |   Citation  |  |
| |      /      |  |    | |   handler   |  |
| |   TaskPane  |  |    | +-------------+  |
| +-------------+  |    |        ↕         |
|        ↑         |    | +-------------+  |
|        |         |    | |   Custom    |  |
|        ↓         |    | |   endpoint  |  |
| +-------------+  |    | |   handler   |  |
| | Plugin host |<---+  | +-------------+  |
| +-------------+  | |  |        ↕         |
|        ↕         | |  | +-------------+  |
| +-------------+  | +--->|  Connector  |  |
| |   Document  |  |    | |   server    |  |
| +-------------+  |    | +-------------+  |
|                  |    |                  |
+------------------+    +------------------+

"WPS" pulls from "Zotero".

from translators_cn.

l0o0 avatar l0o0 commented on June 20, 2024

目前有同学向wps发邮件,希望开发插件。wps也回应了,希望能早点出来。如果着急可以一起发邮件催一催

有同学收到WPS的消息是他们已经提供文档了,不负责开发🙃

from translators_cn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.