Meteor에서 ContentEditable의 기본 서식있는 텍스트 편집 기능을 구현하려고하는데 execCommand에 문제가 있습니다. 실행 취소 및 다시 실행 명령은 제대로 작동하지만 굵게 및 기울임 꼴과 같은 다른 모든 명령은 작동하지 않으며 오류가 발생하지 않습니다. 코드는 일반 페이지처럼 잘 작동합니다 (템플릿 및 이벤트와 같은 Meteor에 대한 명백한 적용을 수행했습니다).Meteor의 ExecCommand가 작동하지 않습니다.
내 HTML :
if (Meteor.isClient) {
Template.buttons.events({
"click #bold": function() { // Toggles bold on/off for the selection or at the insertion point
document.execCommand("bold", false, "null");
},
"click #italic": function() { // Toggles italics on/off for the selection or at the insertion point
document.execCommand("italic", false, "null");
},
"click #undo": function() { // Undoes the last executed command.
document.execCommand('undo', false, "null");
}
)};
}
는 누군가가 알고 :
<body>
{{> buttons}}
<div id="editor" class="textZone" contenteditable="true"></div>
</body>
<template name="buttons">
<div id="rtfOptions">
<div class="separate">
<div class="rtfOption" id="undo">undo</div>
<div class="rtfOption" id="redo">redo</div>
</div>
<div class="separate">
<div class="rtfOption" id="bold">bold</div>
<div class="rtfOption" id="italic">italic</div>
</div>
</div>
</template>
내 이벤트 (. 단지 2 비 작업 + 작동으로 실행 취소는 거의 같은 나머지 부분에 관해서는) 발행물? 그것은 문서 또는 범위와 관련이 있습니까?
' "널 (null)"'잘못된 것입니다. 따옴표없이 'null'이어야합니다. 그러나, 나는 그것이 어떤 차이를 만들지 모르겠다. 에디터가 에디터 내용에 iframe을 사용하고 있습니까? –
아니요, 별 차이가 없습니다. 나는 이전에 null과 마찬가지로 그것을 가지고 있었고, 그것이 단순히 내 linter 때문에 그것이 었는지 테스트하고있었습니다. iframe을 사용하고 있지 않으며 특별히 원하지 않습니다. – mesosteros
확인. 그것이 왜 작동하지 않을지에 대한 명백한 이유는 없습니다. –