dimitrov-adrian/directus-extension-editorjs-interface

addTokenToURL breaking change in v9.0.0-rc.92

Closed this issue ยท 6 comments

addTokenToURL is no longer available though inject('system') after #7668. Would suggest a fix, but am still investigating where it can be picked from in rc92.

  • @directus/extension-sdk is now @directus/extensions-sdk
  • const api = inject("api") instead of inject("system")
  • manually copied definitions of addQueryToPath(), getToken() and addTokenToURL()
  • got occasional errors on some instances. didn't get to the root of it, but setting readOnly to false and distabling toggling seems to have fixed the issue
  • WIP branch

@definiteIymaybe thanks, would you mind, if I open PR from your branch and go with the changes?

Sure, Adrian. Honestly I was shy to suggest a PR cuz I basically was learning to create extensions based on your code โ€“ and this was the first breaking change managed to fix by myself.

Also I didn't want to change much โ€“ my eslint+prettier have opinions :) Not sure how to solve this for the future. Maybe you could add style configs? Please let me know if I can be of any help.

Sorry, for my delay.

You shouldn't be shy to suggest ;) ! About the styling, this is something I am in considering too, since don't want to include prettier/eslint config with the extension, but won't include directus as a dep.

Anyway, thanks for the PR, it seems that it fixes the things. I was just on par with the readonly switch, since didn't succeed in reproducing it (do you have scenario that reproduces it?)

Thank, Adrian.

Not sure I 100% understood you regarding the style configs. In the end the extension is just what rollup would build. As I understand โ€“ you could even drop directus-extension and just have your own fully cusomizable rollup.config.js. Including the style configs was just my first idea to ensure consistency. Surely it's completely up to you.

On the readonly thing: I don't have a a firm case, but here is what my problem was: when open some collection items, the editors content is not rendered, showing just a narrow empty input field which does have text content:
image
I only have 1 per collection item.(I may have custom css for minimum textarea height).

Here is what I get when I click on such field
image
Going through them I saw that some items / editor fields are not affected by this bug. When went to the db, I see that those that are prone to this issues have "version":"2.22.2". The ones that have "version":"2.22.1" seem to be ok. But this is not confirmed. Just an observation for now.

Edit: Just to clarify โ€“ removing the toggle fixes the issue (so you would need to put back the toggler if you would want to try to reproduce):

editorjsInstance.value.isReady.then(() => {
	editorjsInstance.value.readOnly.toggle(newVal);
});

Yes, got it. It seems that if first come disabled, then toggling caused the issue. So it completely valid case for example in bulk editing mode. Anyway, until fix from editorjs, I had added a workaround with css pointer events disabling.

About the styling, I had in mind, a shared eslint/stylielint/prettier through the @directus/extensions-sdk so use more standardized approach from directus, but it seems there is no such yet.

@definiteIymaybe thanks!