Under the Bridge

a Picture of the Late Him

MT4.1:CustomEditorButton2 プラグイン

2008年3月 2日 16:39 | Writer: yoshi | 記事本文 | コメント(2) | トラックバック(0)

twitter見てて、便利そうなプラグインを見つけました。発信者はaklaswad さん。

blog.aklaswad.com:CustomEditorButton2 出来ました。

要はMTのエディタのボタンを増やすのですね。MT4.1専用とのことです。

わたしはここの日記とかはマークアップとかしないんですが、記事を書くときは段落とかリストとかマークアップします。このプラグインを見て、ん~。私がよく使うpタグとdlリストが無いので、追加してみました。

なお、dlはdl、dt、ddを空タグで出力します。

name: Custom Editor Button 2
id: Custom Editor Button 2
key: CustomrEditorButton2
author_link: http://blog.aklaswad.com/
author_name: aklaswad
description: add user buttons to cms entry/page editor.
version: 0.1
plugin_link: http://blog.aklaswad.com/mtplugins/customeditorbutton2/
applications:
    cms:
        methods:
            save_ceb_prefs: $CustomEditorButton2::CustomEditorButton2::save_prefs
callbacks:
    MT::App::CMS::template_output.edit_entry: $CustomEditorButton2::CustomEditorButton2::transformer
buttons:
    codeblock:
        image: images/codeblock.png
        title: wrap selection with 'code' tag
        code: |
            function ceb_codeblock ( text ) {
                return '<code>' + text + '</code>';
            }
    prebutton:
        image: images/pre.png
        title: wrap selection with 'pre' tag
        code: |
            function ceb_prebutton ( text ) {
                return '<pre>' + text + '</pre>';
            }

    pbutton:
        image: images/p.png
        title: wrap selection with 'p' tag
        code: |
            function ceb_pbutton ( text ) {
                return '<p>' + text + '</p>';
            }
    dlbutton:
        image: images/dl.png
        title: insert blank 'dl dt dd' tag
        code: |
            function ceb_dlbutton ( text ) {
                return  '<dl>\n' +'<dt></dt>\n' +'<dd></dd>\n' +'</dl>\n';
            }
    insertbutton:
        image: images/ins.png
        title: wrap selection with 'ins' tag
        code: |
            function getISO8601String(){
                function zp(num){
                    if(num < 10){num = '0' + num;}
                    return num;
                }
                var d,yy,mm,dd,hr,mn,sc,tz,isotime;
                d = new Date();
                yy = d.getFullYear();
                mm = zp(d.getMonth()+1);
                dd = zp(d.getDate());
                hr = zp(d.getHours());
                mn = zp(d.getMinutes());
                sc = zp(d.getSeconds());
                tz = zp(( d.getHours() - d.getUTCHours() + 24 ) % 24);
                return yy + '-' + mm + '-' + dd + 'T' + hr + ':' + mn + ':' + sc + '+' + tz + ':00';
            }

            function ceb_insertbutton ( text ) {
                return '<ins datetime="' + getISO8601String() + '">' + text + '</ins>';
            }
    deletebutton:
        image: images/del.png
        title: wrap selection with 'del' tag
        code: |
            function ceb_deletebutton ( text ) {
                return '<del datetime="' + getISO8601String() + '">' + text + '</del>';
            }

感想

ユーザが機能拡張できる点が、素晴らしいですね。長い文字列をイッパツで入れるコードスニペット機能などに拡張することもできますね。ドロップダウンリストは2アクション、ボタンは1アクションですから、その優位性は上。

わたしはボタンの絵を描くとかいう細かい作業がちょっとアレなんで、ボタンではなくテキストリンクでもいいかなー?という点が、要望といえば要望です。

あと、CustomEditorButton2ライブラリ的なものがあると(要はいろんなサンプルですね)、自力で機能拡張できるユーザは楽ができますね。わたしはもしそういう場があれば貢献したいと思います。

2008/03/02 追記

pタグとかは手で入れれば(実は)そっちのほうが早いんだけど、dlタグはdl dt /dt dd /dd /dl って、面倒なんです。この空タグを入力できるように改造したんですが、これが便利。よく使うがなかなか暗記できない長いコードが入るように改造してみようかと思案中。config.yaml本体を改造せずに*.mtmlファイルなんかを外部ファイルとして追加してライブラリ化できると安全そう(でももしかすると製作者の意図を外れているかも知れない)

トラックバック(0)

このブログ記事を参照しているブログ一覧: MT4.1:CustomEditorButton2 プラグイン

このブログ記事に対するトラックバックURL:

コメント(2)

aklaswad (2008年3月 3日 12:35)

ご紹介ありがとうございます。dl/dt/ddはあると便利ですよねー。
ボタンの追加は、本体のconfig.yamlを弄らずに、別プラグインから出来るようになってます。
作成方法はこちらにまとめてます。色々拡張していくつもりです。
http://blog.aklaswad.com/mtplugins/writting-custom-button-plugins.html
何か作ったら教えてくださいー。

yoshi (2008年3月 3日 19:19)

こんにちは。
普段私はキーボードのみでタグ打っています。昨日はこの機能を用いてdl/dt/ddで実際使ってみましたが、かなり便利でした。

>ボタンの追加は、本体のconfig.yamlを弄らずに、別プラグインから出来るようになってます。
すいません、よく読んでおりませんでした。
熟読してトライします。

何か作ったらフィードバックしますので。

コメントする






Categories
Entries
Feed
スポンサードリンク

parts

フィードメーター - Under the Bridge

あわせて読みたい

なかのひと

2008 yoshi(apstar)