Skip to content

Commit

Permalink
Merge pull request #13 from thisnugroho/fix/pasting-text-contains-image
Browse files Browse the repository at this point in the history
Fix: pasting text contains image
  • Loading branch information
rahmanramsi authored Feb 1, 2023
2 parents 6d07da5 + 596b50a commit 31e9213
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 34 deletions.
2 changes: 1 addition & 1 deletion resources/dist/js/editor.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions resources/dist/js/editor.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*! For license information please see editor.js.LICENSE.txt */

/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

/**
* CodeTool for Editor.js
*
Expand Down
63 changes: 30 additions & 33 deletions resources/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,31 @@ document.addEventListener("alpine:init", () => {
instance: null,
state: state,
tools: tools,
uploadImage: function (blob) {
return new Promise((resolve) => {
this.$wire.upload(
`componentFileAttachments.${statePath}`,
blob,
(uploadedFilename) => {
this.$wire
.getComponentFileAttachmentUrl(statePath)
.then((url) => {
if (!url) {
return resolve({
success: 0,
});
}
return resolve({
success: 1,
file: {
url: url,
},
});
});
}
);
});
},
init() {
let enabledTools = {};

Expand All @@ -33,40 +58,12 @@ document.addEventListener("alpine:init", () => {
class: ImageTool,
config: {
uploader: {
uploadByFile: (file) => {
return new Promise((resolve) => {
this.$wire.upload(
`componentFileAttachments.${statePath}`,
file,
(uploadedFilename) => {
this.$wire
.getComponentFileAttachmentUrl(statePath)
.then((url) => {
if (!url) {
return resolve({
success: 0,
});
}
return resolve({
success: 1,
file: {
url: url,
},
});
});
}
);
});
},

uploadByFile: (file) => this.uploadImage(file),
uploadByUrl: (url) => {
return this.$wire.loadImageFromUrl(url).then((result) => {
return {
success: 1,
file: {
url: result,
},
};
return new Promise(async (resolve) => {
return fetch(url)
.then((res) => res.blob())
.then((blob) => resolve(this.uploadImage(blob)));
});
},
},
Expand Down

0 comments on commit 31e9213

Please sign in to comment.