0
나는 tinymce에서 다음 닫는 태그의 끝 뒤에 텍스트를 삽입하려고합니다. 예를 들어. <p>This is <span>This is a s|pan</span>paragraph</p>
. '|' 내 커서 위치가 표시되면 '</span>|'
뒤에 커서를 놓아야합니다.tinymce에서 노드 끝을 찾는 방법은 무엇입니까?
나는 tinymce에서 다음 닫는 태그의 끝 뒤에 텍스트를 삽입하려고합니다. 예를 들어. <p>This is <span>This is a s|pan</span>paragraph</p>
. '|' 내 커서 위치가 표시되면 '</span>|'
뒤에 커서를 놓아야합니다.tinymce에서 노드 끝을 찾는 방법은 무엇입니까?
다음은 무엇을해야하는지에 대한 개요입니다 : 당신은 실제로 작동하도록 the API docs을 사용할 수 있습니다
// get a reference to the Editor instance
// (depending on your scenario, this may come from a different place)
var editor = tinymce.activeEditor;
// get the node your cursor is in - the one you want to insert after
var endNode = editor.selection.getEnd();
// move the selection after the current node
editor.selection.select(endNode).collapse(false);
// insert your content
editor.selection.setContent("abc");
. 위에서 쓴 내용은 문서를 엄격하게 기반으로합니다. 지금은 테스트 할 시간이 없으므로 플러그 앤 플레이가 아닐 것입니다.
감사합니다. @Alin Purcaru ... 세 번째 줄에 사소한 변화가 있습니다. 'editor.selection.collapse();'는 나를 위해 일했습니다. –
예, 세 번째 줄은 실제로 두 줄이어야합니다 : 'editor.selection.select (endNode); editor.selection.collapse (false);' – mroncetwice