froala / vue-froala-wysiwyg

Vue component for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
632 stars 86 forks source link

Allow local registration of plugin to avoid bloating main.js file #226

Open olemarius opened 1 year ago

olemarius commented 1 year ago

It should be possible to import Froala in a component instead of installing it globally.

import VueFroala from 'vue-froala-wysiwyg'; only provide the install method. This means that the only way to dynamically load a component locally is by dynamically installing the plugin globally like this:

<script lang="ts" setup>
import { getCurrentInstance } from 'vue';
const vueInstance = getCurrentInstance();
vueInstance?.appContext.app.use(VueFroala);
</script>
<template>
   <froala ... /> 
</template>
ItMaga commented 6 months ago

One more workaround for the case

let Froala;
let FroalaView;

const fakeApp = {
  component(name, component) {
    if (name === 'Froala') {
      Froala = component;
    }
    if (name === 'FroalaView') {
      FroalaView = component;
    }
  }
}
VueFroala.install(fakeApp);

export { Froala, FroalaView };