Closed cipchk closed 7 years ago
不知为什么作者都没有维护了,好几个项目都用。
这里我用的requirejs,虽然支持非AMD格式的JS,但是xhEditor要让他支持还需要一点手术刀。
主要是原来根据是script[src*=xheditor]来判断editor的根目录,因为这里涉及到资源加载。但是如果按AMD的方式来加载肯定无法获取正确值。
以下是我做了修改部分,目前都正常使用功能。
$('script[src*=xheditor]').each(function(){ var s=this.src; if(s.match(/xheditor[^\/]*\.js/i)){editorRoot=s.replace(/[\?#].*$/, '').replace(/(^|[\/\\])[^\/]*$/, '$1');return false;} }); // editorRoot 编辑器根目录,为了支持AMD,尝试直接通过HTML中查找 if (!editorRoot) { editorRoot = $('.xheditor_config').first().attr('data-editorRoot'); }
页面需要加入
<textarea name="intro" id="intro" class="xheditor_config" data-editorroot="/r/libs/xheditor/"></textarea>
不知为什么作者都没有维护了,好几个项目都用。
这里我用的requirejs,虽然支持非AMD格式的JS,但是xhEditor要让他支持还需要一点手术刀。
主要是原来根据是script[src*=xheditor]来判断editor的根目录,因为这里涉及到资源加载。但是如果按AMD的方式来加载肯定无法获取正确值。
以下是我做了修改部分,目前都正常使用功能。
页面需要加入
<textarea name="intro" id="intro" class="xheditor_config" data-editorroot="/r/libs/xheditor/"></textarea>