gpt4 book ai didi

css - 阿罗哈编辑器 : Add new style (aloha-button) in aloha-multisplit-expanded box

转载 作者:太空宇宙 更新时间:2023-11-03 19:04:03 25 4
gpt4 key购买 nike

如何在 aloha-multi split-expanded 框中添加新的 aloha-button。 (我想要添加无限数量的样式的能力。当然,不是通过管理员,而是硬编码)

最佳答案

为 Aloha 编辑器添加样式:我将在这里展示如何添加名为“meg”的简单样式

  1. 为 sites\all\libraries\aloha\aloha\plugins\common\format\nls 文件中的按钮添加定义到“root”。"button.meg.tooltip":"Meg 格式说明"
  2. 在 sites\all\libraries\aloha\aloha\plugins\common\format\lib\format-plugin.js 添加到“config”数组中的“default button configuration”,类名,this方式:

    配置:[‘strong’、‘meg’、‘em’……]

  3. 在“initButtons”函数中添加初始化样式按钮的实现:在 switch(button) 下,为新样式添加“case”:

    注意:'span' 标签用于实现带有中性标签的普通 css 类。

  4. 将类“span.meg”定义为特殊样式:在您的 css 主文件(drupal 站点主题的 css)中添加“span.meg”类:

    span.meg {
    color: green; }
  5. 刷新您的站点进行重建,并在 float aloha 中使用新样式

示例代码

// Additional special styles
case 'charm-meg':
that.multiSplitItems.push({
'name' : button,
'tooltip' : i18n.t('button.' + button + '.tooltip'),
'iconClass' : 'aloha-button ' + i18n.t('aloha-button-' + button),
'markup' : jQuery('<span class=' + button + '></span>'),
'click' : function () {
var
markup = jQuery('<span class=' + button + '></span>'),
rangeObject = Aloha.Selection.rangeObject,
foundMarkup,
selectedCells = jQuery('.aloha-cell-selected');

// formating workaround for table plugin
if ( selectedCells.length > 0 ) {
var cellMarkupCounter = 0;
selectedCells.each( function () {
var cellContent = jQuery(this).find('div'),
cellMarkup = cellContent.find(button);

if ( cellMarkup.length > 0 ) {
// unwrap all found markup text
// <td><b>text</b> foo <b>bar</b></td>
// and wrap the whole contents of the <td> into <b> tags
// <td><b>text foo bar</b></td>
cellMarkup.contents().unwrap();
cellMarkupCounter++;
}
cellContent.contents().wrap('<span class=' + button + '></span>');
});

// remove all markup if all cells have markup
if ( cellMarkupCounter == selectedCells.length ) {
selectedCells.find(button).contents().unwrap();
}
return false;
}
// formating workaround for table plugin

// check whether the markup is found in the range (at the start of the range)
foundMarkup = rangeObject.findMarkup(function() {
return this.nodeName.toLowerCase() == markup.get(0).nodeName.toLowerCase();
}, Aloha.activeEditable.obj);

if ( foundMarkup ) {
// remove the markup
if (rangeObject.isCollapsed()) {
// when the range is collapsed, we remove exactly the one DOM element
GENTICS.Utils.Dom.removeFromDOM(foundMarkup, rangeObject, true);
} else {
// the range is not collapsed, so we remove the markup from the range
GENTICS.Utils.Dom.removeMarkup(rangeObject, markup, Aloha.activeEditable.obj);
}
} else {
// when the range is collapsed, extend it to a word
if (rangeObject.isCollapsed()) {
GENTICS.Utils.Dom.extendToWord(rangeObject);
}

// add the markup
GENTICS.Utils.Dom.addMarkup(rangeObject, markup);
}
// select the modified range
rangeObject.select();
return false;
},
'tooltip' : i18n.t('<span class=' + button + '></span>'),
'toggle' : true
});
break;

关于css - 阿罗哈编辑器 : Add new style (aloha-button) in aloha-multisplit-expanded box,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11032972/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com