Skip to content

Commit

Permalink
copy button added
Browse files Browse the repository at this point in the history
  • Loading branch information
calumk committed Jan 24, 2024
1 parent 37b3919 commit 6979594
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 84 deletions.
2 changes: 1 addition & 1 deletion dist/editorjs-codeCup.bundle.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions example/example_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ let example_data = {
code: "<script>console.log(1)</script>",
language: "javascript",
showlinenumbers: true,
showCopyButton: false,
},
},
{
Expand All @@ -38,6 +39,7 @@ let example_data = {
code: "// example\n// This is an example of codecup! \n <script>TEST</script> \n <div> Hello World </div>",
language: "javascript",
showlinenumbers: true,
showCopyButton: true,
},
},
{
Expand Down
66 changes: 11 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@calumk/editorjs-codecup",
"description": "Codecup, for EditorJS",
"version": "1.0.6",
"version": "1.1.0",
"author": "Calum Knott",
"repository": "https://github.com/calumk/editorjs-codecup",
"license": "MIT",
Expand All @@ -10,7 +10,7 @@
"build": "webpack --mode production"
},
"dependencies": {
"@calumk/codecup": "^1.6.4"
"@calumk/codecup": "^1.8.1"
},
"devDependencies": {
"css-loader": "^6.7.1",
Expand Down
12 changes: 7 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ var editor = EditorJS({
## Data Format
The data imported/exported from the block is as follows:

| Name | Description |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| code | The code that is displayed in the editor, with line breaks |
| language (optional) | The programming language |
| showlinenumbers (optional) | Will show/hide the line numbers (Default true)
| Name | Description |
| -------------------------- | ---------------------------------------------------------- |
| code | The code that is displayed in the editor, with line breaks |
| language (optional) | The programming language |
| showlinenumbers (optional) | Will show/hide the line numbers (Default true) |
| showCopyButton (optional) | will show/hide the copy button (Defauly true) |
| | |


Since language and linenumbers are optional, existing ```code``` blocks can safley use this plugin
Expand Down
27 changes: 6 additions & 21 deletions src/codecup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,9 @@
import style from './codecup.css'
import icon from './codecup.svg';

// import Prism from 'prismjs';

// import "prismjs-components-importer/esm"; // ALL - Massivly Increases Bundle size!

// import "prismjs-components-importer/esm/prism-iecst"; // Structured Text
// import "prismjs-components-importer/esm/prism-markdown";
// import "prismjs-components-importer/esm/prism-json";
// import "prismjs-components-importer/esm/prism-python";
// import "prismjs-components-importer/esm/prism-bash";


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

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




// console.log(Prism.languages)



class EditorJsCodeCup {
Expand Down Expand Up @@ -101,6 +83,7 @@
this.data.code = (data.code === undefined) ? '// Hello World' : data.code;
this.data.language = (data.language === undefined) ? 'plain' : data.language;
this.data.showlinenumbers = (data.showlinenumbers === undefined) ? true : data.showlinenumbers;
this.data.showCopyButton = (data.showCopyButton === undefined) ? true : data.showCopyButton;
this.data.editorInstance = {}

// console.log(this.data)
Expand Down Expand Up @@ -152,7 +135,8 @@
this.data.editorInstance = new codecup(editorElem, {
language: this.data.language,
lineNumbers : this.data.showlinenumbers,
readonly : this.readOnly
readonly : this.readOnly,
copyButton : this.data.showCopyButton,
});

// console.log(this.data.editorInstance)
Expand All @@ -166,7 +150,7 @@
});


this.data.editorInstance.addLanguage(this.data.language, Prism.languages[this.data.language]);
// this.data.editorInstance.addLanguage(this.data.language, Prism.languages[this.data.language]);
this.data.editorInstance.updateCode(this.data.code);

// console.log(this.data.code)
Expand Down Expand Up @@ -300,7 +284,8 @@
let resp = {
code : this.data.editorInstance.getCode(),
language : this.data.language,
showlinenumbers : this.data.showlinenumbers
showlinenumbers : this.data.showlinenumbers,
showCopyButton : this.data.showCopyButton
};

return resp
Expand Down

0 comments on commit 6979594

Please sign in to comment.