找回密码
 立即注册

QQ登录

只需一步,快速开始

Timothy.Xu 讲师达人认证 悬赏达人认证 活字格认证
论坛元老   /  发表于:2022-3-7 16:23  /   查看:2760  /  回复:0
本帖最后由 Timothy.Xu 于 2022-3-7 16:23 编辑

这个功能可能就高深一点,虽然不是每位格友都立马能用起来,不过我相信一定能给各位大牛一个满意的答案
image.png377080687.png

在新版本里,我们对活字格的插件API进行了扩展,主要是增加了一些特性(Attribute)和接口(Interface)。
举例子来说,通过新的CustomCommandObjectAttribute特性,我们可以很方便地给我们的插件去添加一些自定义的命令:
  1. [CustomCommandObject]
  2. public object MyCommand { get; set; }
复制代码
这个是Javascript语言的一个实现示例片段:
  1. class MyPlugin extends Forguncy.Plugin.CellTypeBase {
  2.     createContent() {
  3.         var container = $("<div id='" + this.ID + "'>Custom Cell</div>");
  4.         container.on("click", () => {
  5.             this.executeCustomCommandObject(this.CellElement.CellType.MyCommand);
  6.         });
  7.         return container;
  8.     }
  9. }
  10. Forguncy.Plugin.CellTypeHelper.registerCellType("MyPlugin.MyPlugin, MyPlugin", MyPlugin);
复制代码
再举一个例子,通过实现新的ISupportReadOnly接口,自定义单元格就被允许在设置单元格属性命令中设置为只读:

image.png481796874.png
  1. class MyCellType : ISupportReadOnly
  2. {
  3.     public bool ReadOnly { get; set; }
  4. }
复制代码


同样放上实现后的代码片段:
  1. class MyCellType extends Forguncy.Plugin.CellTypeBase{
  2.     setReadOnly(value) {
  3.         super.setReadOnly(value);
  4.     }
  5. }
复制代码
这些功能其实也是希望大家在开发插件的时候,能够让自定义插件更贴近活字格原生单元格/命令的使用模式,让插件的功能和活字格原生功能统一起来~

评分

参与人数 1满意度 +5 收起 理由
13794930121 + 5

查看全部评分

0 个回复

您需要登录后才可以回帖 登录 | 立即注册
返回顶部