Coder Social home page Coder Social logo

Jodit and Tributejs about jodit HOT 8 CLOSED

einarhuseby avatar einarhuseby commented on July 23, 2024
Jodit and Tributejs

from jodit.

Comments (8)

xdan avatar xdan commented on July 23, 2024

Hi try this https://github.com/jodit/jodit-tributejs

from jodit.

einarhuseby avatar einarhuseby commented on July 23, 2024

Thanks @xdan!

I've also been looking at the events listing and is it possible to use the configuration option events to accomplish the same?

Something along:

config = {
events: (event) => {
   if (event === 'beforeEnter') {
      ...
   }
}

Maybe you could give an example of using the events option?

from jodit.

xdan avatar xdan commented on July 23, 2024
var editor = new Jodit('#editor', {
   events: {
       beforeEnter: function (event) {
           if (tribute.isActive) {
               return true; // prevent enter plugin but not prevent default behavior
           }
       }
   }
});

// or

editor.events.on('beforeEnter', function (event) {
   if (tribute.isActive) {
       return true; // prevent enter plugin but not prevent default behavior
   }
});

from jodit.

einarhuseby avatar einarhuseby commented on July 23, 2024

Thanks again @xdan!

However, the only event I'm able to make work is afterInit. Haven't tried all events, but a fair amount.

I'm using jodit-angular, have not tried pure ts.

from jodit.

xdan avatar xdan commented on July 23, 2024

Unfortunately i don't know how return value from EventEmitter in Angular

<jodit-editor #editor (onBeforeEnter)="handleEvent($event)"></jodit-editor>

and

export class AppComponent {
  title = 'app';
  handleEvent() {
    console.log('triggered');
    return false;
  }
}

It is triggered but not return false

from jodit.

einarhuseby avatar einarhuseby commented on July 23, 2024

For that approach, events via jodit-angular, I think you could solve it by passing a callback from Jodit which then is called in handleEvent with the return value.

But I'm a bit puzzled why the afterInit works but not the other events. Anyway, I updated jodit-angular and tried the last approach but with the same results as in your example.

I then tested the options approach again (with the latest version of jodit-angular) - and now it works! I have not tried replicating by doing a reinstall of the previous jodit-angular version, but the following configuration works for afterInit and beforeEnter with [email protected], [email protected] and [email protected]:

Template:

<jodit-editor  #editor id="jodit-id" [config]="joditConfig" [defaultValue]="content.body" ></jodit-editor>

Component:

 this.joditConfig = {
      buttons: 'paragraph, bold,strikethrough,underline,italic,|, \
                superscript,subscript,|, \
                ul,ol,|, \
                outdent,indent,|, \
                brush,|, \
                image,video,table,link,|, \
                align,undo,redo,\n,cut,hr,eraser,copyformat,|, \
                symbol,selectall,source, fullsize',
      imageDefaultWidth: 400,
      height: 600,
      events: {
        beforeEnter: (event) => {
          if (this.tribute.isActive) {
            return true; // prevent enter plugin but not prevent default behavior
          }
        },
        afterInit: (event, jodit) => {
          this.tribute.attach(document.getElementsByClassName('jodit_wysiwyg'));
          // this.jodit = jodit; // get editor instance
          return true;
        },
      }
    };

from jodit.

einarhuseby avatar einarhuseby commented on July 23, 2024

Ok, replicated and can confirm that [email protected] do not work while [email protected] do!

Ref: jodit/jodit-angular#5

from jodit.

einarhuseby avatar einarhuseby commented on July 23, 2024

Also, (onChange)="handleChange($event)" seems to only fire once in [email protected] when having events defined in options.

Removing (onChange)="handleChange($event)" from the template and defining change event in options works but angular throws an error on init because (I guess) change fires on the [defaultValue]="content.body".

The easiest way around this is to make sure you do not assign the new value on the first change being fired.

from jodit.

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.