GithubHelp home page GithubHelp logo

Toolbar for images about medium-editor HOT 8 CLOSED

yabwe avatar yabwe commented on July 21, 2024
Toolbar for images

from medium-editor.

Comments (8)

linkesch avatar linkesch commented on July 21, 2024 2

I made jQuery plugin for uploading and handling images, you can try it here: http://orthes.github.io/medium-editor-images-plugin/

Inspired of course by medium.com, but extended with native HTML5 drag&drop.

from medium-editor.

daviferreira avatar daviferreira commented on July 21, 2024

I think it should be a different JavaScript (like Medium.com) because the toolbar works with selections.

from medium-editor.

dmitric avatar dmitric commented on July 21, 2024

I recently implemented something like this for fun as proof of concept.

The idea is, if you mouseover an empty p, you should show a link to click to upload an image, and replace that p element with an img element with src of the image you just uploaded.

Here's a bit of css, html, jquery goop that could inspire you. I used the InkFilePicker to make the job easier and had a hidden element with id "upload-image" that was in the same container element as ".editable". It' s not perfect, but it's simple.

HTML

<div class="html-editor-container">
<div id="contents" class="editable post-content container" data-placeholder="Type your story">
  {% raw post_content.get("contents") if post_content.get("contents") else "" %}
</div>
<div id="upload-image"><a>add image</a></div>
</div>

CSS

#upload-image {
      display:none;
      top:0;left:0;
}

JS

$(".editable").on("mouseover", "p", function(e){
    var $this = $(this);
    var $upload = $("#upload-image");
    if ($this.text().trim().length == 0) {
      $upload.css("left", $this.offset().left - 75);
      $upload.css("top", $this.position().top + parseFloat($(this).css('marginTop'), 10) - 20);
      $upload.off("click").on("click", function(event){
        event.preventDefault();
        filepicker.pickAndStore({
          mimetypes: ["image/*"],
          multiple: false,
          services:["COMPUTER","URL","FLICKR", "INSTAGRAM", "DROPBOX", "FACEBOOK", "GMAIL"],
        },{
          path: '{{upload_path}}',
          access: "public"
        },
        function(InkBlobs){
          var InkBlob = InkBlobs[0];
          console.log(InkBlob.url);
          $this.after("<img src='"+ InkBlob.url + "' >")
          $this.remove();
          $upload.hide();
          if (autoSave) {
            saveAll();
          }
        },
        function(FPError){

        });
      });
      $upload.show();
    } else {
      $upload.hide();
    }
    return $this;
  });

from medium-editor.

CTres avatar CTres commented on July 21, 2024

I know that it has been ruled out on scope of project, but supporting image
upload would set this toolbar above and better than any other solution, and
creates a lightweight yet all in one solution that would be extremely
elegant.

On Monday, October 7, 2013, Dmitri Cherniak wrote:

I recently implemented something like this for fun as proof of concept.

The idea is, if you mouseover an empty p, you should show a link to click
to upload an image, and replace that p element with an img element with src
of the image you just uploaded.

Here's a bit of css, html, jquery goop that could inspire you. I used the
InkFilePicker to make the job easier and had a hidden element with id
"upload-image" that was in the same container element as ".editable". It' s
not perfect, but it's simple.

HTML

{% raw post_content.get("contents") if post_content.get("contents") else "" %}
add image

CSS

#upload-image {
display:none;
top:0;left:0;
}

JS

$(".editable").on("mouseover", "p", function(e){
var $this = $(this);
var $upload = $("#upload-image");
if ($this.text().trim().length == 0) {
$upload.css("left", $this.offset().left - 75);
$upload.css("top", $this.position().top + parseFloat($(this).css('marginTop'), 10) - 20);
$upload.off("click").on("click", function(event){
event.preventDefault();
filepicker.pickAndStore({
mimetypes: ["image/*"],
multiple: false,
services:["COMPUTER","URL","FLICKR", "INSTAGRAM", "DROPBOX", "FACEBOOK", "GMAIL"],
},{
path: '{{upload_path}}',
access: "public"
},
function(InkBlobs){
var InkBlob = InkBlobs[0];
console.log(InkBlob.url);
$this.after("")
$this.remove();
$upload.hide();
if (autoSave) {
saveAll();
}
},
function(FPError){

    });
  });
  $upload.show();
} else {
  $upload.hide();
}
return $this;

});


Reply to this email directly or view it on GitHubhttps://github.com//issues/29#issuecomment-25782747
.

Colin Treseler
+46 (0) 72-361-60-63
Twitter: @CTres
http://ctres.github.io
www.linkedin.com/in/ctres

from medium-editor.

dmitric avatar dmitric commented on July 21, 2024

I very much disagree @CTres.

Where does the image get uploaded to? Is that a parameter? Do we need to then specify a protocol for the server side component? Do we need to specify a calIback to what happens after it's done and uploaded?

What happens if there's an error? Is selecting text a good UI/UX to start uploading an image? I don't think so, but what happens to the selected text if there is an upload button on the toolbar? There a lots of little details that require thought and abstraction to put into a framework. Try it out for yourself and I think you'll see.

from medium-editor.

daviferreira avatar daviferreira commented on July 21, 2024

That is great explanation, @dmitric, thanks 👍

I started playing on a different script for image uploads and also ended up using http://filepicker.io/, it works great. And yeah, is that simple to implement, but there are a lot of details to take care of.

from medium-editor.

daviferreira avatar daviferreira commented on July 21, 2024

Hey @orthes, that is awesome. Gonna add a link into the project' README. Cheers 🍻

from medium-editor.

linkesch avatar linkesch commented on July 21, 2024

Thanks, @daviferreira. And even more thanks for MediumEditor itself. I love it!

from medium-editor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.