Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Created drawView() which returns new EditorJsCodeFlask Block's view #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/editorjs-codeflask.bundle.js

Large diffs are not rendered by default.

30 changes: 20 additions & 10 deletions src/codeflask.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

this._preserveBlank = config.preserveBlank !== undefined ? config.preserveBlank : false;

this._element; // used to hold the wrapper div, as a point of reference
// this._element; // used to hold the wrapper div, as a point of reference



Expand All @@ -105,6 +105,8 @@

// console.log(this.data)

this._element = this.drawView();

}

/**
Expand All @@ -125,25 +127,23 @@
}
}


/**
* Return Tool's view
*
* Creates a new EditorJsCodeFlask Block's view and returns it.
*
* @returns {HTMLDivElement}
*/
render() {

this._element = document.createElement('div');
this._element.classList.add('editorjs-codeFlask_Wrapper')
drawView() {
const wrapper = document.createElement('div');
wrapper.classList.add('editorjs-codeFlask_Wrapper')
let editorElem = document.createElement('div');
editorElem.classList.add('editorjs-codeFlask_Editor')
let langdisplay = document.createElement('div');
langdisplay.classList.add('editorjs-codeFlask_LangDisplay')

langdisplay.innerHTML = this.data.language

this._element.appendChild(editorElem)
this._element.appendChild(langdisplay)
wrapper.appendChild(editorElem)
wrapper.appendChild(langdisplay)

this.data.editorInstance = new CodeFlask(editorElem, {
language: this.data.language,
Expand All @@ -161,6 +161,16 @@
this.data.editorInstance.addLanguage(this.data.language, Prism.languages[this.data.language]);
this.data.editorInstance.updateCode(this.data.code);

return wrapper;
}


/**
* Return Tool's view
*
* @returns {HTMLDivElement}
*/
render() {
return this._element
}

Expand Down