即使添加了css参考,也有完全相同的问题。最后转到他们的演示页面并复制他们的源代码以初始化 aloha 以使其工作。
<link href="/Scripts/aloha/css/aloha.css" type="text/css" rel="stylesheet" />
<script>
var Aloha = window.Aloha || (window.Aloha = {});
Aloha.settings = {
locale: 'en',
plugins: {
format: {
config: ['b', 'i', 'p', 'sub', 'sup', 'del', 'title', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'removeFormat'],
editables: {
// no formatting allowed for title
'#title': []
}
},
link: {
editables: {
// No links in the title.
'#title': []
}
},
list: {
editables: {
// No lists in the title.
'#title': []
}
},
image: {
'fixedAspectRatio': true,
'maxWidth': 1024,
'minWidth': 10,
'maxHeight': 786,
'minHeight': 10,
'globalselector': '.global',
'ui': {
'oneTab': false
},
editables: {
// No images in the title.
'#title': []
}
}
},
sidebar: {
disabled: true
}
};
</script>
<script type="text/javascript" src="/Scripts/aloha/lib/aloha.js"
data-aloha-plugins="common/format,
common/table,
common/list,
common/link,
common/highlighteditables,
common/block,
common/undo,
common/contenthandler,
common/paste,
common/commands,
common/abbr,
extra/browser,
extra/linkbrowser"></script>
<!-- turn an element into editable Aloha continuous text -->
<script type="text/javascript">
Aloha.ready(function () {
Aloha.require(['aloha', 'aloha/jquery'], function (Aloha, $) {
$('.edit').aloha();
});
});
</script>
附带说明一下,尽管就地编辑功能很棒,但最终还是没有使用此编辑器。主要是库相当大,甚至缩小到超过 1MB,并且在测试期间发现了一些古怪的行为(很可能是因为该项目仍处于开发的早期阶段)。我测试的版本是 0.20.10。