如何使用jQuery将TypeKit字体加载到CKEditor实例中

cra*_*ver 0 javascript jquery typekit ckeditor

我正在尝试通过jQuery将TypeKit字体加载到CKEditor的实例中.这是我的代码:

$('.ck-blog textarea').ckeditor(function () {
    CKEDITOR.scriptLoader.load(
      "http://use.typekit.com/zku8fnp.js", 
      function (success) { 
        Typekit.load(); 
        alert(success); }, 
      null, 
      true);
},
{
    resize_enabled: false,
    skin: 'kama',
    height: '500px',
    toolbarCanCollapse: false,
    toolbar_Full: toolbar,
    forcePasteAsPlainText: true,
    autoGrow_onStartup: true,
    templates_replaceContent: false,
    extraPlugins: 'autogrow,wordcount',
    removePlugins: 'resize',
    contentsCss: '/areas/admin/content/css/ckeditor-blog.css',
    templates_files: ['/areas/admin/scripts/ckeditor-templates.js'],
    autoParagraph: false
});
Run Code Online (Sandbox Code Playgroud)

在TypeKit应该加载后我得到了成功警报,但我没有看到字体加载.知道我可能做错了吗?

小智 12

这是我在通过互联网挖掘3小时后成功组装的:

CKEDITOR.on(
    'instanceReady',
    function(ev) {
        var $script = document.createElement('script'),
            $editor_instance = CKEDITOR.instances[ev.editor.name];

        $script.src = '//use.typekit.com/MYKEY.js';
        $script.onload = function() {
            try{$editor_instance.window.$.Typekit.load();}catch(e){}
        };

        $editor_instance.document.getHead().$.appendChild($script);
    }
);
Run Code Online (Sandbox Code Playgroud)

这里的诀窍是使用来自iframe的CKEditor的"窗口"对象.