n457 / Uncolored

(Un)colored — Next generation desktop rich content editor that saves documents with themes. HTML & Markdown compatible. For Windows, OS X & Linux. — http://n457.github.io/Uncolored/
Apache License 2.0
776 stars 51 forks source link

Dropping external assets in the app change app view #5

Closed n457 closed 7 years ago

n457 commented 7 years ago

Dropping external assets in the application open the asset in a new view (webpage) in the app, and triggers the closing event of the app.

Screenshot of the bug : image

clementlamoureux commented 7 years ago

You may look at this Stackoverflow suggestion : http://stackoverflow.com/questions/31670803/prevent-electron-app-from-redirecting-when-dragdropping-items-in-window

n457 commented 7 years ago

Hey @clementlamoureux, waddup ? ;)

Your link did help to definitely solve this major issue 🎉

The marked answer of the stackoverflow topic wasn't the solution : we need the user to be able to drag & drop elements (like images) from the editor to the editor. the marked answer code prevent that as well.

BUT, the piece of code I needed was :

MainWindow.webContents.on('will-navigate', (Event) => {
  Event.preventDefault();
  return false;
});

In the main process, it prevent the app from changing its current view.

Thanks a lot.

Now, it creates another minor thing : I need to clear external editor-compatible elements when they're dropped into the editor.

clementlamoureux commented 7 years ago

Fine @n457 ! That's the solution :) Great project btw !

n457 commented 7 years ago

Thanks 👍

n457 commented 7 years ago

Drag & drop feature disabled for external assets only due to possible XSS attack through the app & the document.