Пользовательские наборы CKEditor в customconfig.js не применяются - PullRequest
0 голосов
/ 12 октября 2018

Я хочу запустить CKEditor 4 в моем приложении WinForms.Итак, я этот класс (на основе кода C #, который я нашел, с адаптацией к моим собственным потребностям):

<Runtime.InteropServices.ComVisible(True)> Public Class SmartEditor
    Inherits WebBrowser

    Private WithEvents MyForm As Form
    Private Shared ReadOnly ckeditor_config As String
    Private Shared ReadOnly ckeditor_page As String

    Shared Sub New()
        ckeditor_page = IO.Path.Combine(IO.Path.GetTempPath, "ckeditor_page.html")
        IO.File.WriteAllText(ckeditor_page, My.Resources.ckeditor_page)
        ckeditor_config = IO.Path.Combine(IO.Path.GetTempPath, "ckeditor_config.js")
        IO.File.WriteAllText(ckeditor_config, My.Resources.ckeditor_config)
    End Sub

    Public Sub New()
        ObjectForScripting = Me
        ScriptErrorsSuppressed = Not Debugger.IsAttached
        WebBrowserShortcutsEnabled = False
        IsWebBrowserContextMenuEnabled = False
        AllowWebBrowserDrop = False
    End Sub

    Public Property Content As String
        Get
            If Not DesignMode Then
                Try
                    Return Document.InvokeScript("getContent").ToString
                Catch ex As Exception
                    Return ""
                End Try
            Else
                Return ""
            End If
        End Get
        Set(value As String)
            Try
                If Not DesignMode Then
                    Document.InvokeScript("setContent", New String() {value})
                End If
            Catch ex As Exception
            End Try
        End Set
    End Property

    Protected Overrides Sub OnParentChanged(e As EventArgs)
        MyBase.OnParentChanged(e)
        MyForm = FindForm()
    End Sub

    Private Sub MyForm_Shown(sender As Object, e As EventArgs) Handles MyForm.Shown
        Navigate(New Uri(ckeditor_page))
    End Sub
End Class

Теперь загружены файлы html и js:


ckeditor_page.html

<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="utf-8">
    <title>CKEditor</title>
    <script type="text/javascript" src="https://cdn.ckeditor.com/4.10.1/standard/ckeditor.js"></script>
    <script type="text/javascript">
        function getContent() { return CKEDITOR.instances.myeditor.getData(); }
        function setContent(content) { CKEDITOR.instances.myeditor.setData(content); }
    </script>
</head>
<body>
    <textarea name="myeditor"></textarea>
    <script type="text/javascript">
        CKEDITOR.replace('myeditor', {
            customConfig: 'ckeditor_config.js',
            on: {
                'instanceReady': function (evt) {
                    evt.editor.execCommand('maximize');
                }
            }
        });
    </script>
</body>
</html>

ckeditor_config.js

CKEDITOR.editorConfig = function (config) {
    config.toolbarGroups = [
        { name: 'styles', groups: ['styles'] },
        { name: 'basicstyles', groups: ['basicstyles', 'cleanup'] },
        { name: 'links', groups: ['links'] },
        { name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align', 'bidi', 'paragraph'] },
        '/',
        { name: 'clipboard', groups: ['clipboard', 'undo'] },
        { name: 'editing', groups: ['find', 'selection', 'spellchecker', 'editing'] },
        { name: 'forms', groups: ['forms'] },
        { name: 'document', groups: ['mode', 'document', 'doctools'] },
        { name: 'insert', groups: ['insert'] },
        { name: 'colors', groups: ['colors'] },
        { name: 'tools', groups: ['tools'] },
        { name: 'others', groups: ['others'] }
    ];
    config.removeButtons = 'Source,Save,NewPage,Preview,Templates,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Styles,Format,Language,BidiRtl,BidiLtr,CreateDiv,Flash,Smiley,Iframe,ShowBlocks';
};

Однако моя панель инструментов настраиваетсяне применяются.Что бы я тут делал не так?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...