活字格8.0新功能解密:三十三、设计器 - 插件API增强
本帖最后由 Timothy.Xu 于 2022-3-7 16:23 编辑这个功能可能就高深一点,虽然不是每位格友都立马能用起来,不过我相信一定能给各位大牛一个满意的答案;P
在新版本里,我们对活字格的插件API进行了扩展,主要是增加了一些特性(Attribute)和接口(Interface)。
举例子来说,通过新的CustomCommandObjectAttribute特性,我们可以很方便地给我们的插件去添加一些自定义的命令:
public object MyCommand { get; set; }这个是Javascript语言的一个实现示例片段:
class MyPlugin extends Forguncy.Plugin.CellTypeBase {
createContent() {
var container = $("<div id='" + this.ID + "'>Custom Cell</div>");
container.on("click", () => {
this.executeCustomCommandObject(this.CellElement.CellType.MyCommand);
});
return container;
}
}
Forguncy.Plugin.CellTypeHelper.registerCellType("MyPlugin.MyPlugin, MyPlugin", MyPlugin);
再举一个例子,通过实现新的ISupportReadOnly接口,自定义单元格就被允许在设置单元格属性命令中设置为只读:
class MyCellType : ISupportReadOnly
{
public bool ReadOnly { get; set; }
}
同样放上实现后的代码片段:
class MyCellType extends Forguncy.Plugin.CellTypeBase{
setReadOnly(value) {
super.setReadOnly(value);
}
}
这些功能其实也是希望大家在开发插件的时候,能够让自定义插件更贴近活字格原生单元格/命令的使用模式,让插件的功能和活字格原生功能统一起来~:itwn:
页:
[1]