编辑器按钮模块
此模块允许向编辑器添加按钮,这些按钮作用于同一应用的另一个模块。
编辑器按钮位置:
header-right:编辑器标题栏的右上角header-left:编辑器标题栏的左上角menu:编辑器主菜单中的应用菜单translation-toolbar:带有当前翻译操作的工具栏strings-menu:当前选定字符串的菜单
按钮可以执行以下操作之一:
panel 和 modal 类型在每个位置都可用。 event 类型在 translation-toolbar 和 strings-menu 位置可用。
panel 或 event 按钮仅在其目标模块也声明的编辑器模式中出现,因此请将按钮的 modes 保持在目标模块的范围内。 modal 按钮仅取决于其自身的 modes。
标题栏位置和翻译工具栏各自最多显示四个按钮,其余的在更多应用操作下拉菜单中可用。在 assets 模式下,按钮在 header-right、header-left 和 menu 位置可用。在移动端,按钮在 menu、translation-toolbar 和 strings-menu 位置可用,翻译工具栏一次显示一个按钮。
编辑器按钮也列在编辑器的命令面板中,每个按钮都可以在帮助 > 键盘快捷键中分配键盘快捷键。
您可以将此模块的访问权限授予以下用户类别之一:
对于 Crowdin:
- 仅限我自己(即项目所有者)
- 本人、项目管理员和开发者
- 所有项目成员
- 选定用户
对于 Crowdin 企业版:
- 仅限组织管理员
- 组织管理员、项目管理员和开发者
- 组织项目中的所有用户
- 选定用户
按钮在编辑器的右侧面板中打开指定的模块。
{ "modules": { "editor-button": [ { "key": "editor-button-key", "name": "Name of Editor Button", "logo": "/editor-button-logo.png", "modes": [ "translate" ], "options": { "location": "header-right", "type": "panel", "module": "editor-panel-module-key", "weight": 10 } } ], "editor-right-panel": [ { "key": "editor-panel-module-key", "name": "New Panel", "modes": [ "translate" ], "url": "/editor-page" } ] }}按钮在模态对话框中打开指定的模块。
{ "modules": { "editor-button": [ { "key": "editor-button-key", "name": "Name of Editor Button", "modes": [ "translate" ], "options": { "location": "menu", "type": "modal", "module": "modal-module-key" } } ], "modal": [ { "key": "modal-module-key", "name": "New Modal", "url": "/path/to/modal/module" } ] }}按钮向指定的模块发送 editor.button.click 事件而不打开它。
{ "modules": { "editor-button": [ { "key": "editor-button-key", "name": "Name of Editor Button", "modes": [ "translate" ], "options": { "location": "translation-toolbar", "type": "event", "module": "editor-panel-module-key" } } ], "editor-right-panel": [ { "key": "editor-panel-module-key", "name": "New Panel", "modes": [ "translate" ], "url": "/editor-page" } ] }}事件载荷取决于按钮的位置。有关对象结构,请参见支持的事件。
key | 类型: 必需: 是 描述: Crowdin 应用内的模块标识符。 |
name | 类型: 必需: 是 描述: 显示在按钮工具提示中以及菜单中项目标签的用户可读名称。 |
logo | 类型: 描述: 按钮图标的相对 URL。 |
modes | 类型: 必填: 是 允许的值: 描述: 模块将在其中可用的编辑器模式列表。 |
options.location | 类型: 必需: 是 允许值: 描述: 编辑器中添加按钮的位置。 |
options.type | 类型: 必需: 是 允许值: 描述: 此按钮将执行的操作类型。 |
options.module | 类型: 必需: 是 描述: 按钮所作用模块的 |
options.weight | 类型: 描述: 同一位置中按钮相对于其他按钮的顺序。值较低的按钮排在前面:在标题栏和翻译工具栏中靠左,在菜单中靠上。 |
environments | 类型: 允许值: 描述: 可安装该模块的环境集合。 |
应用可以在编辑器打开时更新自己的按钮:设置图标、添加徽章、覆盖工具提示或使按钮处于非活动状态。使用 AP.editor.updateButton 方法应用更改,使用 AP.editor.resetButton 将按钮恢复到清单中声明的状态。