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

Version 1 Next »

릴리즈 2.3.0 이상

Synap Editor에서 정규식에 맞는 텍스트 정보를 가져 옵니다.


Parameters:

NameTypeDescription
regexObject가져올 텍스트 정규식



Return:

TypeAttributeDescription
Array[
    { id: "paragraphId1", text: "+제1조(목적)" },
    { id: "paragraphId2", text: "+제2조(정의)" },
    ....
]
text가 위치한 paragraph id와 텍스트



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