Tridion 命令扩展如何找出它扩展的命令? [英] How can a Tridion command extension find out the command it extends?

查看:18
本文介绍了Tridion 命令扩展如何找出它扩展的命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Tridion 的用户界面允许您扩展特定命令,这是修改某些现有命令行为的好方法.在编辑器的配置文件中,这是通过这样的部分完成的:

Tridion's user interface allows you to extend specific commands, which is a great way to modify the behavior of certain existing commands. In the configuration file of the editor this is done with a section like this:

<ext:commands>
  <ext:command name="TextUnderline" extendingcommand="MyTextUnderline"/>
  <ext:command name="TextStrikethrough" extendingcommand="MyTextStrikethrough"/>

我正在开发一个通用命令扩展类,可用于修改许多命令的行为:

I am working on a generic command extension class that can be used to modify the behavior of a number of commands:

<ext:commands>
  <ext:command name="TextUnderline" extendingcommand="MyCommandExtension"/>
  <ext:command name="TextStrikethrough" extendingcommand="MyCommandExtension"/>

所以在第二个配置片段中,我们有相同的 MyCommandExtension 扩展 TextUnderlineTextStrikethrough.

So in this second configuration fragment, we have the same MyCommandExtension extending both TextUnderline and TextStrikethrough.

但是现在在我的 MyCommandExtension 的 JavaScript 中,我如何确定最初触发的是哪个命令?

But now in the JavaScript for my MyCommandExtension, how can I determine which command was originally fired?

MyCommandExtension.prototype.isAvailable = function (selection, pipeline) {
  ...
  console.log(this.properties.name);
  ...
};

在这种情况下,this.properties.name 将被记录为一个不太有用但完全正确的:

In this scenario the this.properties.name will be logged as a less-than-useful-but-completely-correct:

禁用命令"

我怀疑该信息在 pipeline 参数中的某处可用,但还没有找到.

I suspect that the information is available somewhere in the pipeline parameter, but haven't found it yet.

如何从 MyCommandExtension 中找出原始命令?

How can I find out the original command from MyCommandExtension?

推荐答案

简短回答:我不能.

我不得不做类似的事情,最终不得不扩展各种命令并将当前"命令设置为我的_execute"调用的一部分(所以我现在调用 _execute(selection, pipeline, originalCommand) 用于我的命令.

I had to do something similar, and ended up having to extend various commands and set the "current" command as part of my "_execute" call (so I would now call _execute(selection, pipeline, originalCommand) for my command.

N

这篇关于Tridion 命令扩展如何找出它扩展的命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆