Skip to content

Commit

Permalink
投稿者がRubyを使えない問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
fumikito committed Dec 20, 2014
1 parent 815c137 commit 2379381
Show file tree
Hide file tree
Showing 18 changed files with 538 additions and 366 deletions.
20 changes: 20 additions & 0 deletions mce/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'compass/import-once/activate'
# Require any additional compass plugins here.

# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "scss"
images_dir = "img"
javascripts_dir = "js"
fonts_dir = "fonts"

output_style = :nested

# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true

line_comments = false
color_output = false

preferred_syntax = :scss
18 changes: 1 addition & 17 deletions mce/css/noruby_admin.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions mce/css/ruby.css
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
@charset "UTF-8";
/*
*
*/

.panel_wrapper #general_panel{height:auto;}
.panel_wrapper #general_panel{height:auto}body{margin:0}body form{padding:0 10px}
148 changes: 144 additions & 4 deletions mce/editor_plugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,144 @@
(function(){tinymce.create("tinymce.plugins.yomigana",{getInfo:function(){return{longname:"Yomigana",author:"Takahashi Fumiki",authorurl:"http://hametuha.co.jp",infourl:"http://hametuha.co.jp",version:"1.0"};},init:function(editor,url){editor.addCommand("Ruby",function(){editor.focus();editor.ieBookmark=editor.selection.getBookmark(1);editor.windowManager.open({file:url+"/ruby.php",width:350,height:150,inline:1},{plugin_url:url});});editor.addButton("ruby",{title:"yomigana_dlg.rubyTitle",cmd:"Ruby",image:url+"/img/ruby.gif"});editor.addCommand('inlineQ',function(){editor.focus();editor.ieBookmark=editor.selection.getBookmark(1);editor.windowManager.open({file:url+'/q.php',width:350,height:150,inline:1},{plugin_url:url});});editor.addButton("q",{title:"yomigana_dlg.qTitle",cmd:'inlineQ',image:url+'/img/q.png'});editor.addCommand("Small",function(){var target=this.selection.getNode();if(target.nodeName=='SMALL'){var txt=document.createTextNode(target.innerHTML);this.dom.replace(txt,target,false);}else if(this.selection.getContent().length>0){var newDom=this.dom.create('small');this.dom.setHTML(newDom,this.selection.getContent());this.selection.setNode(newDom);}});editor.addButton("small",{title:"yomigana_dlg.smallTitle",cmd:'Small',image:url+'/img/small.png'});editor.addCommand('DL',function(){var startNode=this.selection.getStart();var endNode=this.selection.getEnd();var wrapper;if(this.dom.getParent(startNode,'DL')){wrapper=this.dom.getParent(startNode,'DL');}else if(this.selection.getNode().tagName=='DL'){wrapper=this.selection.getNode();}
if(wrapper){for(i=0,l=wrapper.childNodes.length;i<l;i++){var p=document.createElement('p');p.innerHTML=wrapper.childNodes[i].innerHTML;this.dom.insertAfter(p,wrapper);}
this.dom.remove(wrapper);}else{if(this.selection.getContent().length>0){var dl=this.dom.create('dl');if(startNode==endNode){this.dom.rename(startNode,'dt');dl.appendChild(startNode);this.selection.setNode(dl);}else{var currentNode=startNode;var d=this.dom;for(i=0;true;){this.dom.add(dl,(i%2==0?'DT':'DD'),{},currentNode.innerHTML);i++;if(currentNode==endNode||!(currentNode=this.dom.getNext(currentNode,function(node){return node&&d.isBlock(node);}))||i>100){break;}}}
this.selection.setNode(dl);}}});editor.addButton("dl",{title:"yomigana_dlg.dlTitle",cmd:"DL",image:url+'/img/dl.png'});editor.onNodeChange.add(function(e,d,g,f){g=e.dom.getParent(g,"RUBY,SMALL,Q,DL");d.setDisabled("ruby",f);d.setActive("ruby",0);d.setDisabled("small",f);d.setActive("small",0);d.setDisabled("q",f);d.setActive("q",0);if(g){do{d.setDisabled(g.nodeName.toLowerCase(),0);d.setActive(g.nodeName.toLowerCase(),1);}while(g=g.parentNode);}});}});tinymce.PluginManager.add("yomigana",tinymce.plugins.yomigana);})();
(function(){


tinymce.create("tinymce.plugins.yomigana",{

getInfo:function(){
return{
longname:"Yomigana",
author:"Takahashi Fumiki",
authorurl:"http://takahashifumiki.com",
infourl:"https://wordpress.org/plugins/wp-yomigana/",
version:"1.0"
};
},

init:function(editor,url){
//ルビ
editor.addCommand("Ruby",function(){
editor.focus();
editor.ieBookmark = editor.selection.getBookmark(1);
editor.windowManager.open(
{
file: url + "/ruby.php",
width: 350,
height:150,
inline: 1
},
{
plugin_url: url
}
);
});
editor.addButton("ruby",{
title:"yomigana_dlg.rubyTitle",
cmd:"Ruby",
image: url + "/img/ruby.gif"
});
//qタグ
editor.addCommand('inlineQ', function(){
editor.focus();
editor.ieBookmark = editor.selection.getBookmark(1);
editor.windowManager.open({
file: url + '/q.php',
width: 350,
height: 150,
inline: 1
},{
plugin_url: url
});
});
editor.addButton("q", {
title: "yomigana_dlg.qTitle",
cmd: 'inlineQ',
image: url + '/img/q.png'
});
//small
editor.addCommand("Small", function(){
var target = this.selection.getNode();
if(target.nodeName == 'SMALL'){
//ノード名がSmallだったら外す
var txt = document.createTextNode(target.innerHTML);
this.dom.replace(txt, target, false);
}else if(this.selection.getContent().length > 0){
//一文字以上選択されていたらsmallでWrapする
var newDom = this.dom.create('small');
this.dom.setHTML(newDom, this.selection.getContent());
this.selection.setNode(newDom);
}
});
editor.addButton("small",{
title: "yomigana_dlg.smallTitle",
cmd: 'Small',
image: url + '/img/small.png'
});
editor.addCommand('DL', function(){
var startNode = this.selection.getStart();
var endNode = this.selection.getEnd();
var wrapper;
if(this.dom.getParent(startNode, 'DL')){
wrapper = this.dom.getParent(startNode, 'DL');
}else if(this.selection.getNode().tagName == 'DL'){
wrapper = this.selection.getNode();
}
if(wrapper){
//親がDL
for(i = 0, l = wrapper.childNodes.length; i < l; i++){
var p = document.createElement('p');
p.innerHTML = wrapper.childNodes[i].innerHTML;
this.dom.insertAfter(p, wrapper);
}
this.dom.remove(wrapper);
}else{
//まだDLじゃない
if(this.selection.getContent().length > 0){
var dl = this.dom.create('dl');
if(startNode == endNode){
//一つの要素が選択されている
this.dom.rename(startNode, 'dt');
dl.appendChild(startNode);
this.selection.setNode(dl);
}else{
//2つ以上の要素が選択されている
var currentNode = startNode;
var d = this.dom;
for(i = 0; true;){
this.dom.add(dl, (i % 2 == 0 ? 'DT' : 'DD'), {}, currentNode.innerHTML);
i++;
if(currentNode == endNode || !(currentNode = this.dom.getNext(currentNode, function(node){
return node && d.isBlock(node);
})) || i > 100){
break;
}
}
}
this.selection.setNode(dl);
}
}
});
editor.addButton("dl",{
title: "yomigana_dlg.dlTitle",
cmd: "DL",
image: url + '/img/dl.png'
});
//キャレットの移動
editor.onNodeChange.add(function(e,d,g,f){
g = e.dom.getParent(g,"RUBY,SMALL,Q,DL");
d.setDisabled("ruby",f);
d.setActive("ruby",0);
d.setDisabled("small",f);
d.setActive("small",0);
d.setDisabled("q",f);
d.setActive("q",0);
if(g){
do{
d.setDisabled(g.nodeName.toLowerCase(),0);
d.setActive(g.nodeName.toLowerCase(),1);
}while(g = g.parentNode);
}
});
}
});

tinymce.PluginManager.add("yomigana",tinymce.plugins.yomigana);
})();
1 change: 1 addition & 0 deletions mce/editor_plugin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

144 changes: 0 additions & 144 deletions mce/editor_plugin_src.js

This file was deleted.

Binary file modified mce/img/q.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified mce/img/small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions mce/q.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//WordPressの初期化
require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))).DIRECTORY_SEPARATOR."wp-load.php");

$tiny_mce_inc_dir = is_ssl() ? preg_replace("/^http:/", "https:", get_bloginfo("url")) : get_bloginfo("url");
$tiny_mce_inc_dir .= "/wp-includes/js/tinymce/";
$tiny_mce_inc_dir = home_url('/wp-includes/js/tinymce/');

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
Expand Down
3 changes: 1 addition & 2 deletions mce/ruby.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//WordPressの初期化
require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))).DIRECTORY_SEPARATOR."wp-load.php");

$tiny_mce_inc_dir = is_ssl() ? preg_replace("/^http:/", "https:", get_bloginfo("url")) : get_bloginfo("url");
$tiny_mce_inc_dir .= "/wp-includes/js/tinymce/";
$tiny_mce_inc_dir = home_url('/wp-includes/js/tinymce/');

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
Expand Down
Loading

0 comments on commit 2379381

Please sign in to comment.