我也尝试了同样的事情。最终我找到了一个解决方案,现在在这里分享给大家,希望能对其他人有所帮助。
<script type="text/javascript">
var config = {
toolbar: [],
removePlugins : 'pastetext,clipboard'
};
var editor = CKEDITOR.appendTo('ckeditor', config);
editor.on( 'instanceReady', function(e) {
var e = e.editor;
e.addCommand("cv_claimant_Birthdate", {
exec: function(e) {
e.insertText("\{\!claimant.Birthdate\}");
}
});
e.addCommand("cv_claimant_Name", {
exec: function(e) {
e.insertText("\{\!claimant.Name\}");
}
});
e.addCommand("cv_claim_Name", {
exec: function(e) {
e.insertText("\{\!claim.Name\}");
}
});
e.addCommand("cv_claim_CreatedDate", {
exec: function(e) {
e.insertText("\{\!claim.CreatedDate\}");
}
});
e.contextMenu.addListener(function(element, selection) {
return {
cv: CKEDITOR.TRISTATE_ON
};
});
e.addMenuGroup("cv", 500);
e.addMenuGroup("cv_people", 100);
e.addMenuGroup("cv_claim", 200);
e.addMenuItems({
cv: {
label: "Insert Merge Field",
group: "cv",
getItems: function() {
return {
cv_claimant: CKEDITOR.TRISTATE_OFF,
cv_claim: CKEDITOR.TRISTATE_OFF,
};
}
},
cv_claimant: {
label: "Claimant Person (claimant)",
group: "cv_people",
getItems: function() {
return {
cv_claimant_Birthdate: CKEDITOR.TRISTATE_OFF,
cv_claimant_Name: CKEDITOR.TRISTATE_OFF,
};
}
},
cv_claimant_Birthdate: {
label: "Birthdate (Birthdate: date)",
group: "cv_people",
command: "cv_claimant_Birthdate"
},
cv_claimant_Name: {
label: "Full Name (Name: string)",
group: "cv_people",
command: "cv_claimant_Name"
},
cv_claim: {
label: "Claim (claim)",
group: "cv_claim",
getItems: function() {
return {
cv_claim_CreatedDate: CKEDITOR.TRISTATE_OFF,
cv_claim_Name: CKEDITOR.TRISTATE_OFF,
};
}
},
cv_claim_Name: {
label: "Claim Number (Name: string)",
group: "cv_claim",
command: "cv_claim_Name"
},
cv_claim_CreatedDate: {
label: "Created Date (CreatedDate: datetime)",
group: "cv_claim",
command: "cv_claim_CreatedDate"
},
});
});
</script>
if (editor.addMenuItems) {
之前):editor.removeMenuItem('cut'); editor.removeMenuItem('copy'); editor.removeMenuItem('paste');
- Sean Kendle