Hello World!
This is bold






ddd
show code
まず、document.getSelection()でselectionオブジェクトを取得する。

let selection=document.getSelection();

selectionは複数の可能性がある。selectionの数を知るには、selection.rangeCountを使用する。

selection.rangeCount

selectionのrangeCountが0以上の場合は、rangeを取得できる。
以下の例では最初のrangeを取得する。

if(selection.rangeCount>0){
	const range=selection.getRangeAt(0);