「選択した文字列を文書からすべて削除」の版間の差分
ナビゲーションに移動
検索に移動
実装方法をJavaScriptではなくMeryのReplaceに変更(改行コードが変わってしまう問題を防ぐため) |
検索ハイライトが変わってしまうことを防ぐため実装方法をMeryのReplaceからJavaScriptのsplit, joinに変更 |
||
| 11行目: | 11行目: | ||
var selection = document.selection.Text; | var selection = document.selection.Text; | ||
if (selection != "") { | if (selection != "") { | ||
document.selection. | document.selection.SelectAll(); | ||
document.selection.Text = document.selection.Text.split(selection).join(""); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 更新履歴 == | == 更新履歴 == | ||
* 2023/10/29 検索ハイライトが変わってしまうことを防ぐため実装方法をMeryのReplaceからJavaScriptのsplit, joinに変更 | |||
* 2023/10/28 初版 | * 2023/10/28 初版 | ||
2023年10月29日 (日) 20:57時点における版
概要
選択した文字列を文書からすべて削除するマクロです。置換ダイアログを開いて置換しても同じことができますが、こちらだと1アクションで実行できます。
ソースコード
#title="選択した文字列を文書からすべて削除"
/**
* 選択した文字列を文書からすべて削除するマクロ
*/
var selection = document.selection.Text;
if (selection != "") {
document.selection.SelectAll();
document.selection.Text = document.selection.Text.split(selection).join("");
}
更新履歴
- 2023/10/29 検索ハイライトが変わってしまうことを防ぐため実装方法をMeryのReplaceからJavaScriptのsplit, joinに変更
- 2023/10/28 初版
スポンサーリンク