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

Commit 21d5874

Browse files
Added go,ts,java to languages list
1 parent c6ad65a commit 21d5874

File tree

4 files changed

+43
-60
lines changed

4 files changed

+43
-60
lines changed

dist/editorjs-codeflask.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 5 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
{
2-
"name": "@calumk/editorjs-codeflask",
2+
"name": "@samandar.boymurodov/editorjs-codeflask",
33
"description": "Codeflask, for EditorJS",
4-
"version": "1.0.9",
5-
4+
"version": "1.0.10",
65
"author": "Calum Knott",
7-
"repository": "https://github.com/calumk/editorjs-codeflask",
6+
"repository": "https://github.com/samandar-boymurodov/editorjs-codeflask",
87
"license": "MIT",
9-
108
"main": "./dist/editorjs-codeflask.bundle.js",
119
"scripts": {
12-
"build": "webpack --mode production"
10+
"build": "webpack --mode production",
11+
"build:dev": "webpack --mode development --watch"
1312
},
14-
1513
"dependencies": {
1614
"codeflask": "^1.4.1",
1715
"nice-select2": "^2.0.0",

src/codeflask.js

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
* @author Calum Knott ([email protected])
66
* @license The MIT License (MIT)
77
*/
8-
8+
99
/**
1010
* @typedef {object} EditorJsCodeFlaskConfig
1111
* @property {string} placeholder - placeholder for the empty EditorJsCodeFlask
1212
* @property {boolean} preserveBlank - Whether or not to keep blank EditorJsCodeFlasks when saving editor data
1313
*/
14-
14+
1515
/**
1616
* @typedef {Object} EditorJsCodeFlaskData
1717
* @description Tool's input and output data format
@@ -23,27 +23,25 @@
2323

2424
import Prism from 'prismjs';
2525

26+
// Additional languages
27+
import "prismjs/components/prism-java"
28+
import "prismjs/components/prism-go"
29+
import "prismjs/components/prism-typescript"
30+
2631
// import "prismjs-components-importer/esm"; // ALL - Massivly Increases Bundle size!
2732

2833
import "prismjs-components-importer/esm/prism-iecst"; // Structured Text
29-
import "prismjs-components-importer/esm/prism-markdown";
30-
import "prismjs-components-importer/esm/prism-json";
34+
import "prismjs-components-importer/esm/prism-markdown";
35+
import "prismjs-components-importer/esm/prism-json";
3136
import "prismjs-components-importer/esm/prism-python";
3237
import "prismjs-components-importer/esm/prism-bash";
33-
38+
3439

3540
import CodeFlask from 'codeflask';
3641

3742
import NiceSelect from "nice-select2/dist/js/nice-select2";
3843
import NiceSelectStyle from "nice-select2/dist/css/nice-select2.css";
3944

40-
41-
42-
43-
// console.log(Prism.languages)
44-
45-
46-
4745
class EditorJsCodeFlask {
4846
/**
4947
* Default placeholder for EditorJsCodeFlask Tool
@@ -58,7 +56,7 @@
5856
static get enableLineBreaks() {
5957
return true;
6058
}
61-
59+
6260
/**
6361
* Render plugin`s main Element and fill it with saved data
6462
*
@@ -72,18 +70,18 @@
7270
// console.log(data)
7371
this.api = api;
7472
this.readOnly = readOnly;
75-
73+
7674
this._CSS = {
7775
block: this.api.styles.block,
7876
wrapper: 'ce-EditorJsCodeFlask',
7977
settingsButton: this.api.styles.settingsButton,
8078
settingsButtonActive: this.api.styles.settingsButtonActive,
8179
};
82-
80+
8381
if (!this.readOnly) {
8482
this.onKeyUp = this.onKeyUp.bind(this);
8583
}
86-
84+
8785
/**
8886
* Placeholder for EditorJsCodeFlask if it is first Block
8987
* @type {string}
@@ -94,7 +92,7 @@
9492

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

97-
95+
9896

9997
// let x = (x === undefined) ? your_default_value : x;
10098
this.data = {}
@@ -106,7 +104,7 @@
106104
// console.log(this.data)
107105

108106
}
109-
107+
110108
/**
111109
* Check if text content is empty and set empty string to inner html.
112110
* We need this because some browsers (e.g. Safari) insert <br> into empty contenteditanle elements
@@ -117,15 +115,15 @@
117115
if (e.code !== 'Backspace' && e.code !== 'Delete') {
118116
return;
119117
}
120-
118+
121119
const {textContent} = this._element;
122-
120+
123121
if (textContent === '') {
124122
this._element.innerHTML = '';
125123
}
126124
}
127125

128-
126+
129127
/**
130128
* Return Tool's view
131129
*
@@ -145,8 +143,8 @@
145143
this._element.appendChild(editorElem)
146144
this._element.appendChild(langdisplay)
147145

148-
this.data.editorInstance = new CodeFlask(editorElem, {
149-
language: this.data.language,
146+
this.data.editorInstance = new CodeFlask(editorElem, {
147+
language: this.data.language,
150148
lineNumbers : this.data.showlinenumbers,
151149
readonly : this.readOnly
152150
});
@@ -232,7 +230,7 @@
232230

233231
settingsContainer.appendChild(languagesSelect);
234232
new NiceSelect(languagesSelect, {searchable : true, placeholder : "Language..."});
235-
233+
236234
// settingsContainer.appendChild(settingsButton);
237235

238236
return settingsContainer;
@@ -249,12 +247,13 @@
249247

250248
_updateLanguage = (lang) => {
251249
this.data.language = lang
252-
this._element.querySelector('.editorjs-codeFlask_LangDisplay').innerHTML = this.data.language
253-
this.data.editorInstance.updateLanguage(this.data.language)
250+
this._element.querySelector('.editorjs-codeFlask_LangDisplay').innerHTML = lang
251+
this.data.editorInstance.addLanguage(lang, Prism.languages[lang])
252+
this.data.editorInstance.updateLanguage(lang)
254253
}
255-
256254

257-
255+
256+
258257
/**
259258
* Extract Tool's data from the view
260259
* @param {HTMLDivElement} toolsContent - EditorJsCodeFlask tools rendered view
@@ -267,10 +266,10 @@
267266
language : this.data.language,
268267
showlinenumbers : this.data.showlinenumbers
269268
};
270-
269+
271270
return resp
272271
}
273-
272+
274273
/**
275274
* Returns true to notify the core that read-only mode is supported
276275
*
@@ -280,7 +279,7 @@
280279
return true;
281280
}
282281

283-
282+
284283
/**
285284
* Icon and title for displaying at the Toolbox
286285
*
@@ -293,5 +292,5 @@
293292
};
294293
}
295294
}
296-
297-
export { EditorJsCodeFlask as default }
295+
296+
export { EditorJsCodeFlask as default }

0 commit comments

Comments
 (0)