0

我正在使用 CKEditor 4.4.5 及其插件 Stylesheet Parser 4.4,但我从样式下拉列表中得到空列表。

为了让我的问题更容易理解,请尝试以下代码(从其示例站点下载:http ://sdk.ckeditor.com/samples/styles.html ):

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="robots" content="noindex, nofollow">
    <title>Stylesheet Parser plugin</title>
    <script src="http://cdn.ckeditor.com/4.5.2/standard-all/ckeditor.js"></script>
</head>

<body>

    <textarea cols="80" id="editor2" name="editor2" rows="10" >&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;
    </textarea>

    <script>
        CKEDITOR.replace( 'editor2', {
            extraPlugins: 'stylesheetparser',
            height: 300,

            // Custom stylesheet for editor content.
            contentsCss: [ 'http://sdk.ckeditor.com/samples/assets/stylesheetparser/stylesheetparser.css' ],

            // Do not load the default Styles configuration.
            stylesSet: []

        } );
    </script>
</body>

</html>

它真的不起作用。但是该站点上的示例运行良好。我还找到了另一个示例站点: http ://ckeditor.com/ckeditor_4.3_beta/samples/plugins/stylesheetparser/stylesheetparser.html

我试图从这个演示站点复制所有源代码,但没有成功。

其他人有同样的问题吗?我怎样才能使上面的代码工作?它基本上使用来自 CDN 站点的源代码,所以我认为源代码的版本并不重要。

4

2 回答 2

0

你应该试试这个版本:http ://ckeditor.com/addon/stylesheetparser-fixed 官方插件很久以前就有一些问题,但他们似乎不打算修复它们。

于 2015-11-09T22:28:31.287 回答
0

此问题是由跨域请求引起的。CSS 文件位于 HTTP 服务器中,我的应用程序使用端口号运行。因此它们被视为跨域请求。

我还测试了本地文件中的 HTML 页面和 CSS 文件。但是,file://...path 在 Chrome 中仍被视为跨域请求,但 FF 和 IE 可以正常工作。

当我在服务器上尝试这个时,它可以在 Chrome 上正常工作。不幸的是,似乎没有办法让跨域请求在 Chrome 和 Firefox 中工作。

于 2015-11-10T21:11:05.147 回答