jakiestfu / Medium.js

A tiny JavaScript library for making contenteditable beautiful (Like Medium's editor)
http://jakiestfu.github.io/Medium.js/
4.39k stars 403 forks source link

2.0 alpha - Uncaught TypeError: Cannot read property 'rangePrototype' of null #146

Closed VictorienTardif closed 9 years ago

VictorienTardif commented 9 years ago

I wanted to try the pre-release 2.0 alpha but I can't even initialize an editor, just calling new Medium() is returning "Uncaught TypeError: Cannot read property 'rangePrototype' of null" ?

robertleeplummerjr commented 9 years ago

Did you run bower install before instantiation?

VictorienTardif commented 9 years ago

I installed it via npm, calling directly the tarball. As it seems to be a problem with rangy, I took a look at the bower.json file and the package.json file > is it possible that the problem results from a different version of rangy used in the package.json file? Thank you!

VictorienTardif commented 9 years ago

Well, as I'm not experimented I'm not sure to understand how this should work, but, it seems that var rangy = w['rangy'] || null (wrapper.js) returns null, while rangy has been installed by npm the same way as it was in the 1.0 release. I see nothing different here.

I just don't understand why it did work in the previous release and not now?

VictorienTardif commented 9 years ago

I'm so sorry, I can't explain it but simply npm uninstall / npm install fixed it... I'll just close it ang go cry.

robertleeplummerjr commented 9 years ago

*cries w/ Victorien

On Thu, Apr 2, 2015 at 12:07 PM, Victorien notifications@github.com wrote:

I'm so sorry, I can't explain it but simply npm uninstall / npm install fixed it... I'll just close it ang go cry.

— Reply to this email directly or view it on GitHub https://github.com/jakiestfu/Medium.js/issues/146#issuecomment-88960591.

Robert Plummer

markentingh commented 9 years ago

I am getting the same error.... I'm not even initializing medium, I just included medium.js on my web page & it returns the same error. I then tried including medium.min.js instead, got the same error.

Stack trace starts on line 2508 > 2517 > 2538

I simply used git clone to copy this project. Guess I need bower to download dependencies.... I no likey dependencies.

robertleeplummerjr commented 9 years ago

Did you include rangy and undo? (ie "bower install")?

On Fri, Apr 10, 2015 at 6:35 PM, markentingh notifications@github.com wrote:

I am getting the same error.... I'm not even initializing medium, I just included medium.js on my web page & it returns the same error. I then tried including medium.min.js instead, got the same error.

Stack trace starts on line 2508 > 2517 > 2538

— Reply to this email directly or view it on GitHub https://github.com/jakiestfu/Medium.js/issues/146#issuecomment-91709483.

Robert Plummer

orbanbotond commented 8 years ago

+1

fegg commented 8 years ago

me too....but have not solution

broothie commented 8 years ago

So I too was getting this error while trying to get Medium.js from the rawgit CDN, and realized that I was missing the dependencies (my fault, it's clearly noted that the dependencies are required on the Medium.js website). I was able to get it working from rawgit CDNs with the following in my <head>:

<!-- JS for Medium -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/rangy/1.3.0/rangy-core.min.js" defer></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/rangy/1.3.0/rangy-classapplier.min.js" defer></script>
<script type="text/javascript" src="https://cdn.rawgit.com/jzaefferer/undo/master/undo.js" defer></script>
<script type="text/javascript" src="https://cdn.rawgit.com/jakiestfu/Medium.js/master/medium.min.js" defer></script>
<!-- CSS for Medium -->
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/jakiestfu/Medium.js/master/medium.css"/>

Strangely, while I finally got Medium.js to work via CDN by including medium.min.js with all of its dependencies, I was able to get it working by serving only medium.min.js from my application server, even though both files had come from the same place.