Load the text information that corresponds with the given regular expression from Synap Editor.
Parameters:
Name | Type | Description |
---|---|---|
regex | Object | Regular expression for the text to load |
Return:
Type | Attribute | Description |
---|---|---|
Array | [ { id: "paragraphId1", text: "+Article 1 (Purpose)" }, { id: "paragraphId2", text: "+Article 2 (Definition)" }, .... ] | paragraph id of the paragraph in which the text is located and the text |
Example:
var textInfoList = editor.getTextByRegex(/\+제\d+조\([가-힣\s\d\w]+\)/g); |
getTextByRegex 활용하여 북마크 삽입 예제
문단 Id 기준으로 캐럿을 이동시키는 "setCaretById" Selection API를 활용하여 캐럿을 이동시키며, "insertBookmark" 북마크 삽입 EDIT API로 정규식으로 찾아낸 text를 bookmark Id로 사용하여 북마크 삽입.
var textInfoList = editor.getTextByRegex(/\+제\d+조\([가-힣\s\d\w]+\)/g); /* return value [ { id: "paragraphId1", text: "+제1조(목적)" }, { id: "paragraphId2", text: "+제2조(정의)" }, .... ] */ textInfoList.forEach(textInfo => { editor.execCommand('setCaretById', textInfo.id); editor.execCommand('insertBookmark', textInfo.text); }); |