Skip to content

Commit

Permalink
update(tune): cast it into boolean instead
Browse files Browse the repository at this point in the history
  • Loading branch information
dependentmadani committed Jul 24, 2024
1 parent 5ce4814 commit 6699206
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
66 changes: 66 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Editor.js with ImageTool</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest/dist/editor.css">
</head>
<body>
<div id="editorjs"></div>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/header@latest"></script>
<script src="./dist/image.umd.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const editor = new EditorJS({
holder: 'editorjs',
tools: {
header: {
class: Header,
inlineToolbar: ['link'],
config: {
placeholder: 'Enter a header'
},
shortcut: 'CMD+SHIFT+H'
},
image: {
class: ImageTool,
config: {
endpoints: {
byFile: 'http://localhost:3000/uploadFile', // Your backend file uploader endpoint
byUrl: 'http://localhost:3000/fetchUrl', // Your endpoint that provides file by URL
},
field: 'image', // Form field name for the image file
types: 'image/*', // Image file types
}
}
},
data: {
blocks: [
{
type: "header",
data: {
text: "Welcome to Editor.js",
level: 2
}
},
{
type: "image",
data: {
file: {
url: "http://localhost:5500/dev/.tmp/b623408975649d125bec4bf02.png" // Replace with your image URL
},
caption: "Sample image",
withBorder: true,
withBackground: false,
stretched: false
}
}
]
}
});
});
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export default class ImageTool implements BlockTool {
*/
private tuneToggled(tuneName: keyof ImageToolData): void {
// inverse tune state
this.setTune(tuneName, this._data[tuneName] !== undefined ? true : false);
this.setTune(tuneName, !(this._data[tuneName] as boolean));
}

/**
Expand Down

0 comments on commit 6699206

Please sign in to comment.