HTMLでの縦中横の書き方がいろいろある。そもそも縦書きの書き方があまり固まっていないのだろうが。電書協の書き方を変換する。html2aozoraでspanとdiv以外の変換をできたが、今度はspanの変換したい。リストから一括変換ができれば追加が楽。
縦中横
//<span class="tcy">22</span>
rules.tcy = {
filter: function (node, options) {
return (
node.nodeName === 'SPAN' &&
node.getAttribute('class') === 'tcy'
)
},
replacement: function (content, node, options) {
return content + '[#「'+ content + '」は縦中横]'
}
}
縦横を動的に切り替えるために、body classを削除したり追加したりを試したがうまくいかなかった。 www.tiny.cloud
tinymce.PluginManager.add('tateyoko', function(editor, url) {
var tateyoko = function () {
var selectClass = editor.dom.select("body")
var checkClass = selectClass.classList.contains("vrtl");
if (checkClass = true) {
editor.dom.removeClass(editor.dom.select('body'), 'vrtl' );
editor.dom.addClass(editor.dom.select("body"), "hltr");
console.log("focus, offline class removed, online class added")
} else {
editor.dom.removeClass(editor.dom.select('body'), 'hltr' );
editor.dom.addClass(editor.dom.select("body"), "vrtl");
console.log("focus, online class added")
}
}
/* Add a button that opens a window */
editor.ui.registry.addButton('tateyoko', {
text:'縦横',
onAction: function () {
/* Open window */
tateyoko();
}
});
/* Adds a menu item, which can then be included in any menu via the menu/menubar configuration */
editor.ui.registry.addMenuItem('tateyoko', {
text: '縦横',
onAction: function() {
/* Open window */
tateyoko();
}
});
/* Return the metadata for the help plugin */
return {
getMetadata: function () {
return {
name: '縦横',
url: 'https://99nyorituryo.hatenablog.com/'
};
}
};
});