{"id":2373,"date":"2015-08-21T11:21:37","date_gmt":"2015-08-21T03:21:37","guid":{"rendered":"http:\/\/blog.hoyo.idv.tw\/?p=2373"},"modified":"2015-09-10T15:27:26","modified_gmt":"2015-09-10T07:27:26","slug":"ckeditor-4-%e4%b9%8b%e5%88%9d%e6%ad%a5%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/blog.hoyo.idv.tw\/?p=2373","title":{"rendered":"CKEditor 4.5.3 \u4e4b\u521d\u6b65\u4f7f\u7528"},"content":{"rendered":"<h2>\u70ba\u4ec0\u9ebc\u662f\u00a0CKEditor ?<\/h2>\n<ol>\n<li>\u73fe\u5728\u9084\u6709\u5728\u7dad\u8b77<\/li>\n<li>\u56e0\u70ba\u9084\u6709\u5728\u7dad\u8b77\u6240\u4ee5\u61c9\u8a72\u6709\u5716\u6a94\u62d6\u66f3\u4e0a\u50b3\u529f\u80fd<\/li>\n<li>\u771f\u7684\u6709\u5716\u6a94\u62d6\u66f3\u4e0a\u50b3\u529f\u80fd \u2192 \u8b9a\u00a0<a href=\"http:\/\/sdk.ckeditor.com\/samples\/fileupload.html#uploading-dropped-and-pasted-images\">live demo<\/a><\/li>\n<\/ol>\n<p>\u4e0b\u8f09\u53ca demo \u8acb\u5230\u5b98\u7db2\uff1a<a href=\"http:\/\/ckeditor.com\/\">CKEditor<\/a><\/p>\n<p>--<\/p>\n<h2>\u5982\u4f55\u4f7f\u7528<\/h2>\n<p>\u4e0b\u8f09\u89e3\u58d3\u7e2e<\/p>\n<pre class=\"lang:java decode:true \">&lt;script src=\"\/???\/ckeditor\/ckeditor.js\"&gt;&lt;\/script&gt;<\/pre>\n<p>\u5230\u00a0ckeditor\/samples\/toolbarconfigurator\/index.html \u81ea\u8a02\u5de5\u5177\u5217<\/p>\n<p>\u5c07\u8a2d\u5b9a\u503c\u53d6\u4ee3 config.js \u6a94\u6848<\/p>\n<p>--<\/p>\n<h2>\u4f7f\u7528 Ajax \u4e0a\u50b3\u90fd\u662f\u672a\u66f4\u65b0\u524d\u7684\u8cc7\u6599\u554f\u984c<\/h2>\n<p>\u5728\u4e0a\u50b3\u524d\u5957\u7528\u4ee5\u4e0b\u7a0b\u5f0f<\/p>\n<pre class=\"lang:js decode:true\">for ( instance in CKEDITOR.instances ) CKEDITOR.instances[instance].updateElement();<\/pre>\n<p>--<\/p>\n<h2>\u62d6\u66f3\u5716\u6a94\u81f3\u7de8\u8f2f\u5340<\/h2>\n<p>\u57fa\u672c\u77e5\u8b58\u3001\u89c0\u5ff5\u5efa\u7acb\uff1a<a href=\"http:\/\/docs.cksource.com\/CKEditor_3.x\/Developers_Guide\/File_Browser_(Uploader)\">File Browser\/Uploader<\/a><\/p>\n<p>\u524d\u7aef\u7684\u7a0b\u5f0f\u90fd\u53ef\u4ee5\u76f4\u63a5\u5f9e\u5b98\u7db2\u4e0b\u8f09\uff0c\u552f\u4e00\u9700\u8981\u81ea\u5df1\u6e96\u5099\u7684\u53ea\u6709\u5716\u6a94\u4e0a\u50b3\u5f8c\u56de\u50b3\u7684\u7a0b\u5f0f\uff0c\u5927\u6982\u662f\u9577\u9019\u6a23\uff1a<\/p>\n<pre class=\"lang:default decode:true\">class Upload {\r\n\r\n    function __construct()\r\n    {\r\n        $ResizeWidth = 780;\r\n        $ResizeHeight = 780;\r\n        $id = $_GET['id'];\r\n\r\n        $Upload_dir =  '..\/..\/Upload\/'. $id;\r\n        if ( !is_dir( $Upload_dir ) ) mkdir($Upload_dir);\r\n\r\n        $SourceFile = $_FILES['upload']['tmp_name'];\r\n        list($width, $height, $type, $attr) = getimagesize($SourceFile);\r\n\r\n        # \u5132\u5b58\u7684\u8def\u5f91\u6a94\u540d\r\n        $fn = explode('.', $_FILES['upload']['name']);\r\n        array_pop($fn);\r\n        $FileName = implode('.', $fn);\r\n\r\n        # \u4e0a\u50b3\u5716\u6a94 \u5bec\u6216\u9ad8 \u5927\u65bc\u91cd\u65b0\u53d6\u6a23\u8a2d\u5b9a\r\n        if ( $width &gt; $ResizeWidth || $height &gt; $ResizeHeight ) {\r\n            $si = new SimpleImage();\r\n            $si-&gt;load($SourceFile)-&gt;best_fit($ResizeWidth, $ResizeHeight)-&gt;save($Upload_dir.'\/'.$FileName.'.png');\r\n        }\r\n        else {\r\n            move_uploaded_file($SourceFile, $Upload_dir.'\/'.$FileName.'.png');\r\n        }\r\n\r\n        $return = array(\"uploaded\"=&gt;true, \"fileName\"=&gt;$FileName.'.png', \"url\"=&gt;\"\/photo.php?id={$id}&amp;N=\".$FileName);\r\n        echo json_encode($return);\r\n    }\r\n}\r\n<\/pre>\n<p><strong>\u9577\u9019\u6a23\u7684\u6839\u64da\uff1f<\/strong><\/p>\n<p>\u76f4\u63a5\u5f9e\u5b98\u7db2\u7bc4\u4f8b \u2192\u00a0<a href=\"http:\/\/sdk.ckeditor.com\/samples\/fileupload.html\">File Upload<\/a>\u00a0\uff0c\u5728 Chrome \u7684 F12 \u8ffd\u8e64\u5f97\u5230\u4e0a\u50b3\u5f8c\u9700\u8981\u56de\u50b3 json<\/p>\n<pre class=\"lang:default decode:true\">{\r\n\"fileName\":\"\\u4e2d\\u6587_\\u5927\\u5bb6_aa_~!.png\",\r\n\"uploaded\":1,\"error\":{\"number\":207,\"message\":\"The uploaded file was renamed to \\u0022\\u4e2d\\u6587_\\u5927\\u5bb6_aa_~!.png\\u0022.\"},\r\n\"url\":\"\\\/userfiles\\\/files\\\/%E4%B8%AD%E6%96%87_%E5%A4%A7%E5%AE%B6_aa_~!.png\"\r\n}\r\n<\/pre>\n<p>\u786c\u8981\u770b\u5b98\u65b9\u6587\u4ef6\u7684\u8a71\uff0c\u5728\u9019\u88e1 \u2192\u00a0<a href=\"http:\/\/docs.ckeditor.com\/#!\/guide\/dev_file_upload\">Uploading Dropped or Pasted Files<\/a><\/p>\n<p>--<\/p>\n<h2>\u5be6\u969b\u904b\u7528\u7684\u60c5\u6cc1<\/h2>\n<ul>\n<li>\u76ee\u524d 2015.8.26 CKEditor \u7684\u7248\u672c\u70ba 4.5.3<\/li>\n<li>\u9810\u8a08\u9054\u6210\u529f\u80fd\n<ul>\n<li>\u57fa\u672c\u6587\u5b57\u7de8\u8f2f\u3001\u683c\u5f0f\u4fee\u6539<\/li>\n<li>\u9644\u52a0\u5716\u6a94\n<ul>\n<li>\u6a94\u6848\u62d6\u66f3\u76f4\u63a5\u4e0a\u50b3\u9644\u52a0<\/li>\n<li>\u8907\u88fd\u3001\u8cbc\u4e0a\u4e0a\u50b3\u9644\u52a0 (\u76ee\u524d\u53ea\u652f\u63f4 Firefox\uff0c\u627e\u5c0b\u5176\u4ed6\u65b9\u6848)<\/li>\n<li>\u5df2\u4e0a\u50b3\u53ef\u700f\u89bd\u5f8c\u9644\u52a0\u4e0d\u9808\u91cd\u65b0\u4e0a\u50b3<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>\u4f7f\u7528 Plugins<\/h3>\n<ul>\n<li>autogrow : \u7de8\u8f2f\u5340\u4e0d\u662f\u56fa\u5b9a\u5c3a\u5bf8<\/li>\n<li>uploadimage : \u62d6\u66f3\u6a94\u6848\u9032\u7de8\u8f2f\u5340\u5373\u53ef\u4e0a\u50b3<\/li>\n<li>image2 : \u8b93\u5716\u7247\u53ef\u79fb\u52d5\u4ee5\u53ca\u6539\u8b8a\u5927\u5c0f<\/li>\n<\/ul>\n<h2>\u81ea\u8a02 Plugin : \u4ee5\u700f\u89bd\u5716\u6a94\u9ede\u9078\u5f8c\u76f4\u63a5\u63d2\u5165\u70ba\u4f8b<\/h2>\n<p>\u53c3\u8003\u8cc7\u6599<\/p>\n<ul>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/11212460\/inserting-html-into-ckeditor-from-popup-window\">Inserting HTML into CKeditor from popup window<\/a><\/li>\n<li><a href=\"http:\/\/blog.hsin.tw\/2011\/ckeditor-upload-image\/\">[CKEditor] \u589e\u52a0\u4e0a\u50b3\u5716\u7247\u529f\u80fd<\/a>\u00a0(\u9019\u500b\u7528\u5728\u5716\u7247\u6309\u9215\u5167\u7684\u300c\u700f\u89bd\u4f3a\u670d\u5668\u300d\uff0c\u6700\u5f8c\u63d2\u5165\u5716\u7247\u7684 Javascript \u4e0d\u540c)<\/li>\n<\/ul>\n<p>\u6e96\u5099\u597d\u4ee5\u4e0b\u6750\u6599<\/p>\n<ul>\n<li>\u4e0b\u8f09\u5b98\u65b9\u7684 custom plugin :\u00a0<a href=\"http:\/\/sdk.ckeditor.com\/samples\/timestamp.html\">Timestamp Plugin<\/a><\/li>\n<li>\u00a0\u700f\u89bd\u5716\u5eab\u7684\u7a0b\u5f0f<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>\u64cd\u4f5c\u6d41\u7a0b\u9577\u9019\u6a23<\/p>\n<ol>\n<li>\u5f9e\u5de5\u5177\u5217\u9ede\u9078\u700f\u89bd\u5716\u5eab\u6309\u9215\uff0c\u5f48\u51fa\u4e00\u500b\u700f\u89bd\u5716\u5eab\u5b50\u8996\u7a97<\/li>\n<li>\u9078\u53d6\u5f8c\u9ede\u9078\u5716\u7247<\/li>\n<li>\u5c07\u5716\u7247\u63d2\u5165\u7de8\u8f2f\u5340\uff0c\u95dc\u9589\u700f\u89bd\u5716\u5eab\u8996\u7a97 (\u5be6\u969b\u7a0b\u5f0f\u6d41\u7a0b\u70ba\u76f8\u53cd)<\/li>\n<\/ol>\n<p>\u5be6\u969b\u4e0a\u7684\u64cd\u4f5c\u5c31\u662f\u6309\u4e00\u4e0b\u5de5\u5177\u5217\u6309\u9215\uff0c\u7136\u5f8c\u6309\u4e00\u4e0b\u5716\u7247\u9019\u5169\u4e0b<\/p>\n<p><strong>\u95dc\u9375\u9ede<\/strong><\/p>\n<pre class=\"lang:js decode:true \">window.opener.CKEDITOR.instances['id_NOTE'].insertHtml('ccc');<\/pre>\n<p>--<\/p>\n<p>&nbsp;<\/p>\n<h2>\u7de8\u8f2f\u6642\u548c\u524d\u7aef\u986f\u793a\u76f8\u540c CSS \u7d50\u679c<\/h2>\n<p>config.js<\/p>\n<pre class=\"lang:default decode:true\">config.contentsCss = '..\/..\/css\/modern-business.css';<\/pre>\n<p>&nbsp;<\/p>\n<p>--<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"2373\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;3,530&nbsp;total views<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u70ba\u4ec0\u9ebc\u662f\u00a0CKEditor ?...<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"2373\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;3,530&nbsp;total views<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[180],"tags":[186,68,188,53,187],"_links":{"self":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/2373"}],"collection":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2373"}],"version-history":[{"count":17,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/2373\/revisions"}],"predecessor-version":[{"id":2513,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/2373\/revisions\/2513"}],"wp:attachment":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}