Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with ESM #1029

Closed
julianpoemp opened this issue Oct 16, 2023 · 7 comments
Closed

Issues with ESM #1029

julianpoemp opened this issue Oct 16, 2023 · 7 comments

Comments

@julianpoemp
Copy link

Jodit Version: 4.0.0-beta.89

Browser: all
OS: all
Is React App: False

Code: See https://github.com/julianpoemp/jodit-ts-import-bug/blob/main/src/app/app.component.ts . You can clone the repository and call npm start to run local web server.

Expected behavior:
Jodit Editor generated by ESM build should have the same functionality like that one from the other builds (e.g. es2021). For example if I set two buttons "bold" and "underline" I expect Jodit to show the buttons with icons.

Actual behavior:
Bildschirmfoto 2023-10-16 um 11 16 49

For both editors the exact same configurations were set. As you can see there are three visible points missing:

  1. Missing icons.
  2. Missing status bar.
  3. Missing placeholder.
@xdan
Copy link
Owner

xdan commented Oct 21, 2023

Hello, thanks for the problem
1 This is an error
2.3 Since not all plugins are included in the esm build, you should enable all required plugins yourself https://github.com/xdan/jodit#esm-modules

@julianpoemp
Copy link
Author

Hello @xdan,

thank you for your response. I was able to inject the "stat" and "placeholder" plugins so these features are working now. Only one further question: Do Angular/react users need to import autobind-decorator? I didn't import it to my example app and Jodit still works:

import {Component, OnInit} from '@angular/core';
import {Config} from 'jodit/esm/config';
import "jodit/esm/plugins/stat/stat.js"
import "jodit/esm/plugins/placeholder/placeholder.js"
import {Jodit} from 'jodit';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
  ngOnInit(){
    Jodit.make('#editor', {
      width: 600,
      height: 400,
      buttons: ["bold", "underline"],
      textIcons: false
    } as Config);
  }
}

@xdan
Copy link
Owner

xdan commented Oct 21, 2023

Because autobind-decorator is the only non-dev dependency and it comes with Jodit https://github.com/xdan/jodit/blob/main/package.json#L50

I've added "stat" and "placeholder" to the basic list so you don't have to include them yourself.

@julianpoemp
Copy link
Author

Still issue with v4 beta 98. I debugged it and found out, that somehow the ESM JS files from affected plugins like "bold" or "underline" are not injected. For example "bold": a breakpoint here:

pluginSystem.add('bold', bold);
does not trigger. If I do the same with "font" (which icon is visible) the breakpoint triggers. So I think bold.js is not imported correctly.

Further more it seems that Jodit can't set the icon because the name is empty ("") in makeIcon from

const clearName = name.replace(/[^a-zA-Z0-9]/g, '_');

For now I debugged the ESM build itself. Perhaps I find time to dive in this repository.

@julianpoemp
Copy link
Author

the issue with missing icons for "bold" and "underline" still exists in beta 105. Perhaps there is a missing "bold" item in array here:

const allowPluginsInESM = new Set(

I would have tested it myself but I didn't get an environment running that allows me to test the newly built esm version.

@xdan
Copy link
Owner

xdan commented Nov 14, 2023

Hi, yes, just add bold in your build

import "jodit/esm/plugins/bold/bold.js"

@julianpoemp
Copy link
Author

Hi @xdan, it works, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants