ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

"TypeError: e.getAncestors is not a function" is thrown by a custom inline editor build

Open davidpolberger opened this issue 8 years ago • 5 comments

Is this a bug report or feature request? (choose one)

🐞 Bug report

💻 Version of CKEditor

v1.0.0-beta.2

📋 Steps to reproduce

  1. $ mkdir ck-test
  2. $ cd ck-test
  3. $ git clone -b stable https://github.com/ckeditor/ckeditor5-build-inline.git
  4. $ git clone -b stable https://github.com/ckeditor/ckeditor5-editor-inline.git
  5. $ cd ckeditor5-build-inline/
  6. Edit package.json to replace this line: @ckeditor/ckeditor5-editor-inline": "^1.0.0-beta.2" ...with: "@ckeditor/ckeditor5-editor-inline": "../ckeditor5-editor-inline/",
  7. $ npm install
  8. $ npm run build
  9. $ google-chrome sample/index.html

✅ Expected result

The editor works.

❎ Actual result

The editor throws an exception when converting the view to the model, in the Schema constructor ("context is not defined"):

index.html:36 TypeError: e.getAncestors is not a function
    at new zg (schema.js:1134)
    at Lg.on (schema.js:201)
    at Lg.fire (emittermixin.js:195)
    at Lg.(anonymous function) [as checkChild] (file://[...]/ck-test/ckeditor5-build-inline/build/ckeditor.js:5:126428)
    at ul (paragraph.js:198)
    at jg.n.upcastDispatcher.on (paragraph.js:87)
    at jg.fire (emittermixin.js:195)
    at jg._convertItem (upcastdispatcher.js:212)
    at jg._convertChildren (upcastdispatcher.js:245)
    at jg.<anonymous> (upcast-converters.js:340)

📃 Other details that might be useful

We're trying to update our custom headless builds from the second alpha to the second beta of CKEditor 5. We're attempting to modify the inline editor to become headless, but we can't even get a custom check-out of the inline editor to work. (If step six is omitted above, everything works.)

davidpolberger avatar Apr 11 '18 00:04 davidpolberger

Hm... WFM:

image

Which version of npm do you have? I have some suspicion that the local ckeditor5-editor-inline pkg wasn't installed correctly.

I'm on npm 4.6.1

Reinmar avatar Apr 11 '18 08:04 Reinmar

Thanks, @Reinmar. I was using npm 5.6.0 (which is the version installed by Fedora 27, which bundles nodejs 8.11.1, the current LTS release). For now, I have downgraded to nodejs 7.10.1 and npm 4.2.0 through n. Everything works well now.

davidpolberger avatar Apr 11 '18 22:04 davidpolberger

npm 5 is known to cause troubles to pretty much everyone. However, I'm still worried about what's actually going on there. I have some suspicions that it comes to duplication of one or more packages, but we'd need to check that.

Anyway, the biggest issue that we have now is that the editor blows up when certain packages get duplicated (mainly – the engine). Of course, this situation is also bad for the code size too, but crashes are certainly more problematic.

One thing we're planning to do is https://github.com/ckeditor/ckeditor5/issues/667 – it shouldn't be necessary to import anything when writing a typical plugin.

The second thing will be to secure the utils package which may also cause issues (due to the emitter mixin and observables).

I'm closing your issue, but we'll certainly work on gradually improving this situation.

Reinmar avatar Apr 12 '18 07:04 Reinmar

Thanks for your quick response, Piotr. Perhaps the documentation should mention that npm 5 is not supported, at least not when creating custom builds? (I see that there are Lerna issues as well.)

davidpolberger avatar Apr 12 '18 13:04 davidpolberger

Hm... I thought we had the note there, but it turns out we mentioned that in https://docs.ckeditor.com/ckeditor5/latest/framework/guides/contributing/development-environment.html#requirements. I'll add it in https://docs.ckeditor.com/ckeditor5/latest/builds/guides/development/custom-builds.html and https://docs.ckeditor.com/ckeditor5/latest/builds/guides/integration/advanced-setup.html. Thanks!

Reinmar avatar Apr 12 '18 13:04 Reinmar