Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

릴리즈 2.3.0 이상

Load the text information that corresponds with the given regular expression from Synap Editor.


Parameters:

NameTypeDescription
regexObjectRegular expression for the text to load



Return:

TypeAttributeDescription
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로 사용하여 북마크 삽입.


Example:

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);
});
  • 생성된 북마크 활용하여 목차 하이퍼링크 생성 가능




  • No labels