npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cuxml

v1.0.6

Published

A tool to help use ribbon UI for your WPS Office Client JS add-in project.

Downloads

24

Readme

cuxml

CU: 'Can Use' or 'customUI', whatever……

What is it?

  1. 可以将 customUI XML 设置的回调函数转成 JavaScript 函数,以便于在 WPS Office JS插件中使用,当然只是些简单的模版,复杂的还是需要自己写。

    Can convert the callback functions of customUI XML settings to JavaScript functions, so that they can be used in WPS Office JS plug-ins. Of course, it is just some simple templates, and complex ones need to be written by yourself.

  2. 根据 CustomUI Ribbon 元素的布局规则和标准,帮助你快速粗略地检查 XML 文件是否符合规范。simple types

    According to the layout rules and standards of CustomUI Ribbon elements, help you quickly and roughly check whether the XML file conforms to the specification.

Only the namespace of Simple types in the http://schemas.microsoft.com/office/2006/01/customui are supported. It's may be support for customUI 2007/2010…… also.

示例 Example

XML file:

 <group id="test1" label="test1" getVisible="onthing"></group>

输出到 JS 文件:

Out callback function to JS file:

cuxml callback test.xml test.js -w

不出意外的话,你会得到这样的结果:

normally, you will get the result:

/**
* @param {RibbonUI} ctrl 你不需要关心这个参数,它代表一个菜单控件元素对象。比如 button、group 等。
* @note 
*  - 这是控件的回调函数,你不应该调用这个函数。
*  - 通用模版而已,你可以根据需要自行修改。
*  - 这里的回调函数都是异步的,你不应该在这里写长耗时同步的代码,否则可能会导致 UI 卡死。(AI 说的)
*  
*  Time: Fri Apr 14 2023 01:43:09 GMT+0800 (China Standard Time)
*/
function onthing(ctrl){

    // 以下代码只是通用模版,你可以根据需要自行修改
    // 通过 ctrl.Id 来判断当前元素
    // use ctrl.Id to judge the current element

    switch(ctrl.Id){
        // xmlPath: customUI[0]>ribbon[0]>tabs[0]>tab[0]>group[2]
        case "test1":
            break;
        default:
            break;
    };

    // 避免 UI 报错,总是返回 true
    // Need return true

    return true;
}

Command

  1. Run in Your WPS Office JS Plugin Project directory.

    npx cuxml # if support npx

    or

    node ./node_modules/cuxml/index.js # last choice……

更多命令行参数请查看 --help 选项. More command line parameters, please check the --help option.

注意

输出结果到文件时,保险起见,最好输出到临时文件,避免覆盖你已经写好的文件。

最新更新

  1. check, 仅输出有'问题'的 Element。
  2. callback :
    • id 为空的 Element 会被忽略。
    • 匹配属性的回调函数返回值类型,在注释中标明。
    • JS 函数的注释中,添加了回调函数对应的 XML 元素属性。
    • 生成的 JS 函数只有一个参数,即 RibbonUI 对象。不必添加多余的参数,目前 WPS Office Client 传参数时只有一个!
      // RibbonUI 对象成员大概如下:
      {
          Id: "test1", // 当前元素的 id 属性
          content:{...},
          Tag: "",// 如果你在 XML 中设置了 tag 属性,这里就会有值。
      }

Bug

  1. 可预见的: 如果 XML 中的回调函数名称带有" . "连接符,生成的 JS 代码会有语法错误。

    Predictable: If the callback function name in XML contains a "." connection symbol, the generated JS code will have a syntax error.

    这种情况,cuxml 可能不适合用来批量生成 JS 回调函数。

    In this case, cuxml may not be suitable for generating JS callback functions in batches.

    example:

    <group id="test1" label="test1" getVisible="on.thing"></group>

    output:

    function on.thing(ctrl){
        // ...
    }

    是的, 我们能解决这个问题,但是,JS 函数的调用和声明方式是多变的,比如:

    <group id="test1" label="test1" getVisible="onthing"></group>
    // cuxml 能将其转换为 function nothing(ctrl){};
    // 实际上也许你偏向于这种写法: let nothing = function(ctrl){};
    // 又或者它实际可能是:sync function nothing(ctrl){};

    类似以下的写法,cuxml 可能无法准确的转换

    <group id="test1" getVisible="myRibbon.nothing"></group>
    <group id="test1" getVisible="a.b.c.nothing"></group>
    <group id="test1" getVisible="new nothing"></group>

    所以……如果你需要将 XML 中的诸如以上的回调函数转换为 JS 函数,也许你得自己写一些代码了。