link: function (scope, element, attrs) {
function tinyMceSetup(editor) {
- editor.on('ExecCommand change NodeChange ObjectResized', (e) => {
+ editor.on('ExecCommand change input NodeChange ObjectResized', (e) => {
let content = editor.getContent();
$timeout(() => {
scope.mceModel = content;
});
editor.on('keydown', (event) => {
- scope.$emit('editor-keydown', event);
+ if (event.keyCode === 83 && (navigator.platform.match("Mac") ? event.metaKey : event.ctrlKey)) {
+ event.preventDefault();
+ scope.$emit('save-draft', event);
+ }
});
editor.on('init', (e) => {
extraKeys[`${metaKey}-7`] = function(cm) {wrapSelection('\n```\n', '\n```');};
extraKeys[`${metaKey}-8`] = function(cm) {wrapSelection('`', '`');};
extraKeys[`Shift-${metaKey}-E`] = function(cm) {wrapSelection('`', '`');};
- extraKeys[`${metaKey}-9`] = function(cm) {wrapSelection('<p class="callout info">', '</div>');};
+ extraKeys[`${metaKey}-9`] = function(cm) {wrapSelection('<p class="callout info">', '</p>');};
cm.setOption('extraKeys', extraKeys);
// Update data on content change
}
cm.replaceRange(newLineContent, {line: cursor.line, ch: 0}, {line: cursor.line, ch: lineLen});
- cm.setCursor({line: cursor.line, ch: cursor.ch + (newLineContent.length - lineLen)});
+ cm.setCursor({line: cursor.line, ch: cursor.ch + start.length});
}
function wrapSelection(start, end) {
let selection = cm.getSelection();
if (selection === '') return wrapLine(start, end);
+
let newSelection = selection;
let frontDiff = 0;
let endDiff = 0;