Skip to content

Commit 6979594

Browse files
committed
copy button added
1 parent 37b3919 commit 6979594

File tree

6 files changed

+29
-84
lines changed

6 files changed

+29
-84
lines changed

dist/editorjs-codeCup.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.

example/example_data.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ let example_data = {
3030
code: "<script>console.log(1)</script>",
3131
language: "javascript",
3232
showlinenumbers: true,
33+
showCopyButton: false,
3334
},
3435
},
3536
{
@@ -38,6 +39,7 @@ let example_data = {
3839
code: "// example\n// This is an example of codecup! \n <script>TEST</script> \n <div> Hello World </div>",
3940
language: "javascript",
4041
showlinenumbers: true,
42+
showCopyButton: true,
4143
},
4244
},
4345
{

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@calumk/editorjs-codecup",
33
"description": "Codecup, for EditorJS",
4-
"version": "1.0.6",
4+
"version": "1.1.0",
55
"author": "Calum Knott",
66
"repository": "https://github.com/calumk/editorjs-codecup",
77
"license": "MIT",
@@ -10,7 +10,7 @@
1010
"build": "webpack --mode production"
1111
},
1212
"dependencies": {
13-
"@calumk/codecup": "^1.6.4"
13+
"@calumk/codecup": "^1.8.1"
1414
},
1515
"devDependencies": {
1616
"css-loader": "^6.7.1",

readme.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ var editor = EditorJS({
5050
## Data Format
5151
The data imported/exported from the block is as follows:
5252

53-
| Name | Description |
54-
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
55-
| code | The code that is displayed in the editor, with line breaks |
56-
| language (optional) | The programming language |
57-
| showlinenumbers (optional) | Will show/hide the line numbers (Default true)
53+
| Name | Description |
54+
| -------------------------- | ---------------------------------------------------------- |
55+
| code | The code that is displayed in the editor, with line breaks |
56+
| language (optional) | The programming language |
57+
| showlinenumbers (optional) | Will show/hide the line numbers (Default true) |
58+
| showCopyButton (optional) | will show/hide the copy button (Defauly true) |
59+
| | |
5860

5961

6062
Since language and linenumbers are optional, existing ```code``` blocks can safley use this plugin

src/codecup.js

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,9 @@
2121
import style from './codecup.css'
2222
import icon from './codecup.svg';
2323

24-
// import Prism from 'prismjs';
25-
26-
// import "prismjs-components-importer/esm"; // ALL - Massivly Increases Bundle size!
27-
28-
// 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";
31-
// import "prismjs-components-importer/esm/prism-python";
32-
// import "prismjs-components-importer/esm/prism-bash";
33-
3424

3525
import codecup from '@calumk/codecup/dist/codecup.bundle.js';
3626

37-
// import NiceSelect from "nice-select2/dist/js/nice-select2";
38-
// import NiceSelectStyle from "nice-select2/dist/css/nice-select2.css";
39-
40-
41-
42-
43-
// console.log(Prism.languages)
44-
4527

4628

4729
class EditorJsCodeCup {
@@ -101,6 +83,7 @@
10183
this.data.code = (data.code === undefined) ? '// Hello World' : data.code;
10284
this.data.language = (data.language === undefined) ? 'plain' : data.language;
10385
this.data.showlinenumbers = (data.showlinenumbers === undefined) ? true : data.showlinenumbers;
86+
this.data.showCopyButton = (data.showCopyButton === undefined) ? true : data.showCopyButton;
10487
this.data.editorInstance = {}
10588

10689
// console.log(this.data)
@@ -152,7 +135,8 @@
152135
this.data.editorInstance = new codecup(editorElem, {
153136
language: this.data.language,
154137
lineNumbers : this.data.showlinenumbers,
155-
readonly : this.readOnly
138+
readonly : this.readOnly,
139+
copyButton : this.data.showCopyButton,
156140
});
157141

158142
// console.log(this.data.editorInstance)
@@ -166,7 +150,7 @@
166150
});
167151

168152

169-
this.data.editorInstance.addLanguage(this.data.language, Prism.languages[this.data.language]);
153+
// this.data.editorInstance.addLanguage(this.data.language, Prism.languages[this.data.language]);
170154
this.data.editorInstance.updateCode(this.data.code);
171155

172156
// console.log(this.data.code)
@@ -300,7 +284,8 @@
300284
let resp = {
301285
code : this.data.editorInstance.getCode(),
302286
language : this.data.language,
303-
showlinenumbers : this.data.showlinenumbers
287+
showlinenumbers : this.data.showlinenumbers,
288+
showCopyButton : this.data.showCopyButton
304289
};
305290

306291
return resp

0 commit comments

Comments
 (0)