return this.lastContent;
}
- insertImage() {
+ showImageInsert() {
+ // TODO
const cursorPos = this.editor.cm.getCursor('from');
/** @type {ImageManager} **/
const imageManager = window.$components.first('image-manager');
}, 'gallery');
}
+ insertImage() {
+ // TODO
+ const selectedText = this.editor.cm.getSelection();
+ const newText = ``;
+ const cursorPos = this.editor.cm.getCursor('from');
+ this.editor.cm.replaceSelection(newText);
+ this.editor.cm.setCursor(cursorPos.line, cursorPos.ch + newText.length -1);
+ }
+
insertLink() {
+ // TODO
const cursorPos = this.editor.cm.getCursor('from');
const selectedText = this.editor.cm.getSelection() || '';
const newText = `[${selectedText}]()`;
}
showImageManager() {
+ // TODO
const cursorPos = this.editor.cm.getCursor('from');
/** @type {ImageManager} **/
const imageManager = window.$components.first('image-manager');
// Show the popup link selector and insert a link when finished
showLinkSelector() {
+ // TODO
const cursorPos = this.editor.cm.getCursor('from');
/** @type {EntitySelectorPopup} **/
const selector = window.$components.first('entity-selector-popup');
// Show draw.io if enabled and handle save.
startDrawing() {
+ // TODO
const url = this.editor.config.drawioUrl;
if (!url) return;
}
insertDrawing(image, originalCursor) {
+ // TODO
const newText = `<div drawio-diagram="${image.id}"><img src="${image.url}"></div>`;
this.editor.cm.focus();
this.editor.cm.replaceSelection(newText);
// Show draw.io if enabled and handle save.
editDrawing(imgContainer) {
+ // TODO
const drawioUrl = this.editor.config.drawioUrl;
if (!drawioUrl) {
return;
}
handleDrawingUploadError(error) {
+ // TODO
if (error.status === 413) {
window.$events.emit('error', this.editor.config.text.serverUploadLimit);
} else {
// Make the editor full screen
fullScreen() {
+ // TODO
const container = this.editor.config.container;
const alreadyFullscreen = container.classList.contains('fullscreen');
container.classList.toggle('fullscreen', !alreadyFullscreen);
// Scroll to a specified text
scrollToText(searchText) {
+ // TODO
if (!searchText) {
return;
}
}
focus() {
+ // TODO
this.editor.cm.focus();
}
* @param {String} content
*/
insertContent(content) {
+ // TODO
this.editor.cm.replaceSelection(content);
}
* @param {String} content
*/
prependContent(content) {
+ // TODO
const cursorPos = this.editor.cm.getCursor('from');
const newContent = content + '\n' + this.editor.cm.getValue();
this.editor.cm.setValue(newContent);
* @param {String} content
*/
appendContent(content) {
+ // TODO
const cursorPos = this.editor.cm.getCursor('from');
const newContent = this.editor.cm.getValue() + '\n' + content;
this.editor.cm.setValue(newContent);
* @param {String} content
*/
replaceContent(content) {
+ // TODO
this.editor.cm.setValue(content);
}
* @param {String} replace
*/
findAndReplaceContent(search, replace) {
+ // TODO
const text = this.editor.cm.getValue();
const cursor = this.editor.cm.listSelections();
this.editor.cm.setValue(text.replace(search, replace));
* @param {String} newStart
*/
replaceLineStart(newStart) {
+ // TODO
const cursor = this.editor.cm.getCursor();
let lineContent = this.editor.cm.getLine(cursor.line);
const lineLen = lineContent.length;
* @param {String} end
*/
wrapLine(start, end) {
+ // TODO
const cursor = this.editor.cm.getCursor();
const lineContent = this.editor.cm.getLine(cursor.line);
const lineLen = lineContent.length;
* @param {String} end
*/
wrapSelection(start, end) {
+ // TODO
const selection = this.editor.cm.getSelection();
if (selection === '') return this.wrapLine(start, end);
}
replaceLineStartForOrderedList() {
+ // TODO
const cursor = this.editor.cm.getCursor();
const prevLineContent = this.editor.cm.getLine(cursor.line - 1) || '';
const listMatch = prevLineContent.match(/^(\s*)(\d)([).])\s/) || [];
* Creates a callout block if none existing, and removes it if cycling past the danger type.
*/
cycleCalloutTypeAtSelection() {
+ // TODO
const selectionRange = this.editor.cm.listSelections()[0];
const lineContent = this.editor.cm.getLine(selectionRange.anchor.line);
const lineLength = lineContent.length;
* @param {File} file
*/
uploadImage(file) {
+ // TODO
if (file === null || file.type.indexOf('image') !== 0) return;
let ext = 'png';
* @param {Number} posY
*/
insertTemplate(templateId, posX, posY) {
+ // TODO
const cursorPos = this.editor.cm.coordsChar({left: posX, top: posY});
this.editor.cm.setCursor(cursorPos);
window.$http.get(`/templates/${templateId}`).then(resp => {
* @param {File[]} images
*/
insertClipboardImages(images) {
+ // TODO
const cursorPos = this.editor.cm.coordsChar({left: event.pageX, top: event.pageY});
this.editor.cm.setCursor(cursorPos);
for (const image of images) {