1

我一直在使用 Aloha Editor 创建一个简单编辑器的示例,但我还没有成功地让它在 Opera 中工作。菜单不出现,文本区域不可编辑。

在所有其他浏览器中似乎工作正常,但有时 Chrome 需要刷新页面才能工作。

这是相关的 HTML 代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link href="//cdn.aloha-editor.org/latest/css/aloha.css" rel="stylesheet" media="screen" />
</head>
<body>
    <textarea id="content"></textarea>
    <script src="//cdn.aloha-editor.org/latest/lib/require.js"></script>
    <script src="//cdn.aloha-editor.org/latest/lib/aloha.js" data-aloha-plugins="common/ui,common/format,common/table,common/list,common/link,common/block,common/undo,common/contenthandler,common/paste"></script>
    <script src="notes.js"></script>
</body>
</html>

这是 javascript 代码(在notes.js 中):

var Aloha = window.Aloha || ( window.Aloha = {} );
Aloha.settings = { sidebar: { disabled: true } };

Aloha.ready(function () {

    Aloha.jQuery('#content').aloha();

});

提前感谢您的想法!

4

1 回答 1

1

在阅读了 Inshallah 的评论后,我正在回答我自己的问题。

问题是应该在包含 Aloha 之前设置javascript 变量AlohaAloha.settings 。

HTML 代码

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link href="//cdn.aloha-editor.org/latest/css/aloha.css" rel="stylesheet" media="screen" />
</head>
<body>
    <textarea id="content"></textarea>
    <script src="//cdn.aloha-editor.org/latest/lib/require.js"></script>
    <script>
        var Aloha = window.Aloha || ( window.Aloha = {} );
        Aloha.settings = { sidebar: { disabled: true } };
    </script>
    <script src="//cdn.aloha-editor.org/latest/lib/aloha.js" data-aloha-plugins="common/ui,common/format,common/table,common/list,common/link,common/block,common/undo,common/contenthandler,common/paste"></script>
    <script src="notes.js"></script>
</body>
</html>

Javascript 代码(在notes.js 中

Aloha.ready(function () {
    Aloha.jQuery('#content').aloha();
});
于 2012-09-09T20:01:34.487 回答