Skip to content

Instantly share code, notes, and snippets.

@asm256
Last active August 29, 2015 14:08
Show Gist options
  • Save asm256/957c8f15c48e39aac881 to your computer and use it in GitHub Desktop.
Save asm256/957c8f15c48e39aac881 to your computer and use it in GitHub Desktop.
引用符付き貼付け
$ curl https://gist.githubusercontent.com/asm256/957c8f15c48e39aac881/raw/42ac1afad81dd234f1b6b91ce3ee7f936c63554c/quote_paste.patch | git apply

で適用できます

diff --git a/chaika/chrome/content/chaika/post/quote_paste.js b/chaika/chrome/content/chaika/post/quote_paste.js
new file mode 100644
index 0000000..3d83a96
--- /dev/null
+++ b/chaika/chrome/content/chaika/post/quote_paste.js
@@ -0,0 +1,13 @@
+//コレ参照してるコードが他にないような気がする
+Components.utils.import("resource://chaika-modules/ChaikaClipboard.js");
+
+function quotation_paste_txt(){
+ var ct = ChaikaClipboard.getString();
+ return '>' + ct.split('\n').join("\n>");
+}
+function quotation_paste(){
+ var insertTextbox = document.getElementById(document.getElementById("aaPanel").getAttribute("insertTextbox"));
+ var leftValue = insertTextbox.value.substring(0, insertTextbox.selectionStart);
+ var rightValue = insertTextbox.value.substring(insertTextbox.selectionEnd);
+ insertTextbox.value = leftValue + quotation_paste_txt() + rightValue;
+}
\ No newline at end of file
diff --git a/chaika/chrome/content/chaika/post/wizard.xul b/chaika/chrome/content/chaika/post/wizard.xul
index bd29c92..d63172e 100644
--- a/chaika/chrome/content/chaika/post/wizard.xul
+++ b/chaika/chrome/content/chaika/post/wizard.xul
@@ -18,6 +18,7 @@
<script type="application/javascript" src="chrome://chaika/content/post/wizard.js"/>
<script type="application/javascript" src="chrome://chaika/content/post/post.js"/>
<script type="application/javascript" src="chrome://chaika/content/post/trip.js"/>
+<script type="application/javascript" src="chrome://chaika/content/post/quote_paste.js"/>
<stack id="titleHeaderContainer">
<label id="titleHeader" crop="center" value=""/>
@@ -74,6 +75,9 @@
label="不具合報告テンプレート(詳細)の挿入"
oncommand="FormPage.insertBugReportTemplate(true);" />
<menuseparator />
+ <menuitem id="insertQPaste"
+ label="引用符付き貼り付け"
+ oncommand="quotation_paste()" />
<menuitem id="insertAAMenu"
label="AA・定型文の挿入"
oncommand="AAPanel.openPopup(this.parentNode.parentNode)" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment