在前端使用TYPO3 ckeditor

4

是否可以在TYPO3(8.7.11)前端使用与其相同的ckeditor?我需要在用户表单中实现一个编辑器,我希望前端用户能够看到与后台显示完全相同的结果——因此我需要使用相同的编辑器。

有没有一种方法可以在不安装第二个ckeditor插件的情况下使用相同的编辑器?也许有什么函数可以轻松地将其包含进来或者其他什么东西?


CKEditor.js在这里:sysext/rte_ckeditor/Resources/Public/JavaScript/Contrib/ckeditor.js。我不知道如何在前端实现它。我尝试通过控制器来实现,但失败了。如果你找到了解决方案,请告诉我。;) - MonTea
1个回答

0
如果您已经配置了CK-Editor,那么在您的模板中创建类似于以下内容应该只是一个小问题:
    <html lang="en">
        <head>
            <meta charset="utf-8">
            <title>A Simple Page with CKEditor</title>
            <!-- Make sure the path to CKEditor is correct. -->
            <script src="../ckeditor.js"></script>
        </head>
        <body>
            <form>
                <textarea name="editor1" id="editor1" rows="10" cols="80">
                    This is my textarea to be replaced with CKEditor.
                </textarea>
                <script>
                    // Replace the <textarea id="editor1"> with a CKEditor
                    // instance, using default configuration.
                    CKEDITOR.replace( 'editor1' );
                </script>
            </form>
        </body>
    </html>

ckeditor.js应该位于您的Typo3源文件夹中: typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/Contrib/ckeditor.js

代码示例取自CKEditor 4文档,可在此处找到: https://ckeditor.com/docs/ckeditor4/latest/guide/index.html

编辑:

在我自己测试这段代码后,我发现它不起作用,因为缺少CKEditor的Typo3安装style.js-file,其中包括样式定义。

我从这里下载了CKEditor的标准版本: https://ckeditor.com/ckeditor-4/download/ 并将style.js-file(位于根目录下)插入到与我的ckeditor.js位于同一目录中。

添加文件后,包括此代码:

        <script src="/typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/Contrib/ckeditor.js"></script>
        <form>
                <textarea name="editor1" id="editor1" rows="10" cols="80">
                    This is my textarea to be replaced with CKEditor.
                </textarea>
            <script>
                // Replace the <textarea id="editor1"> with a CKEditor
                // instance, using default configuration.
                CKEDITOR.replace( 'editor1' );
            </script>
        </form>

在任何模板中都应该添加 ck-editor。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接