use tinyMCE with VUEJS 2 without apikey - vue.js

I would like to use TinyMCE locally and avoid having to provide an API Key. For the moment I use the following code:
Install TinyMCE for vueJS 2.x:
npm install --save "#tinymce/tinymce-vue#^3"
When installed, I use this:
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<editor
api-key="no-api-key"
:init="{
height: 500,
menubar: false,
plugins: [
'advlist autolink lists link image charmap print preview anchor',
'searchreplace visualblocks code fullscreen',
'insertdatetime media table paste code help wordcount'
],
toolbar:
'undo redo | formatselect | bold italic backcolor | \
alignleft aligncenter alignright alignjustify | \
bullist numlist outdent indent | removeformat | help'
}"
/>
</div>
</template>
<script>
import Editor from '#tinymce/tinymce-vue'
export default {
name: 'app',
components: {
'editor': Editor
}
}
</script>

The TinyMCE Vue wrapper will rely on our Cloud platform to pull TinyMCE if TinyMCE is not already loaded into the page/application.
The simplest approach is the self host TinyMCE and place a script tag in the head of the main HTML page to load TinyMCE. This will make the tinymce global object available at all times in all components. Alternatively you can import TinyMCE in the component(s) that need it. As long at the tinymce global is there before you try to create an editor component there will be no attempt to use the Cloud delivered version of TinyMCE.
Step 6 of the quick start guide covers this specific capability:
https://www.tiny.cloud/docs/integrations/vue/#tinymcevuejsintegrationquickstartguide

Related

How to force component to render on client in quasar framework?

I have an ssr app and a text editor component that uses vue-codemirror. To my knowledge, this can't be used in ssr and the page fails to load with the error "navigator is not defined." This makes sense because the navigator wont exist until the document is ready.
I read in the docs that <q-no-ssr /> is used for forcing a component to be rendered on the client only. I tried wrapping my text editor component in a <q-no-ssr /> tag but am still running into the "navigator is not defined" error.
The text editor I am using is quasar tiptap.
Here is what I have tried:
<q-no-ssr>
<quasar-tiptap
v-bind="options"
#update="onUpdate"
/>
</q-no-ssr>
What am I missing?
Create a boot file: quasar new boot tiptap
tiptap.js
import Vue from 'vue'
import { QuasarTiptapPlugin, RecommendedExtensions } from 'quasar-tiptap'
import "quasar-tiptap/lib/index.css";
Vue.use(QuasarTiptapPlugin, {
language: 'en-us',
spellcheck: true
})
reference boot file in quasar.conf.js
boot: [
'axios',
{path: 'tiptap', server: false} //render only on client
],
use component wherever you want in your application:
<div>
<quasar-tiptap
ref="transcript"
v-bind="options"
#update="onUpdate"
#annotation="handleAnnotation($event)"
/>
</div>

Cannot load fonts in Laravel 5.7 & Vue 2 project using Element UI & iView UI Toolkit

I recently installed laravel v5.7 and vue 2. I then installed Element UI
and iView UI Toolkit, everything works perfectly, but anything that uses icons in any iView UI component shows square blocks, but i want the result to look like the documentation where i the alert has an icon. I have searched and tried many solutions but none worked e.g)
What I've done so far
Editting the .htaccess file according to this article
Installed Laravel Cors
Confirmed that the fonts exist in "/fonts/vendor/iview/dist/styles" after running npm run watch
Cleared my cache, history, everything.
5) Checked that the css file is being referenced properly.
6) Checked that the css if referencing the fonts properly. Here is a snippet of the css file.
Tested the application on Chrome, Firefox and Opera, same issue
#font-face{font-family:Ionicons;src:url(/fonts/vendor/iview/dist/styles/ionicons.ttf?f3b7f5f07111637b7f12c1a4d499d056) format("truetype"),url(/fonts/vendor/iview/dist/styles/ionicons.woff?39f116d33948df9636a310075244b857) format("woff"),url(/fonts/vendor/iview/dist/styles/ionicons.svg?3f5fdc44d1e78a861fee03f2d8a59c60#Ionicons) format("svg");
What i have in app.js
/**
* First we will load all of this project's JavaScript dependencies which
* include Vue and Vue Resource. This gives a great starting point for
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap');
/**
* Next, we will create a fresh Vue application instance and attach it to
* the body of the page. From here, you may begin adding components to
* the application, or feel free to tweak this setup for your needs.
*/
import Vue from 'vue'
import App from './App.vue';
// Global event manager, to emit changes/updates
// such as when user has logged in e.g) auth.js
window.Event = new Vue;
// Import Element UI Kit
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import locale from 'element-ui/lib/locale/lang/en';
Vue.use(ElementUI, { locale });
// Import IView UI Kit
import iView from 'iview';
import 'iview/dist/styles/iview.css';
Vue.use(iView);
// Import Vue Router for custom routes and navigation
import VueRouter from 'vue-router';
import router from './routes.js';
Vue.use(VueRouter)
const app = new Vue({
el: '#app',
// Render the main app view
render: h => h(App),
// For our custom routes
router
});
A snippet of what i have in the vue template
<template>
<el-row :gutter="20">
<Alert show-icon>An info prompt</Alert>
<Alert type="success" show-icon>A success prompt</Alert>
<Alert type="warning" show-icon>A warning prompt</Alert>
<Alert type="error" show-icon>An error prompt</Alert>
<Alert show-icon>
An info prompt
<template slot="desc">Content of prompt. Content of prompt. Content of prompt. Content of prompt. </template>
</Alert>
<Alert type="success" show-icon>
A success prompt
<span slot="desc">Content of prompt. Content of prompt. Content of prompt. Content of prompt. </span>
</Alert>
<Alert type="warning" show-icon>
A warning prompt
<template slot="desc">
Content of prompt. Content of prompt. Content of prompt.
</template>
</Alert>
<Alert type="error" show-icon>
An error prompt
<span slot="desc">
Custom error description copywriting.
</span>
</Alert>
<Alert show-icon>
Custom icon
<Icon type="ios-bulb-outline" slot="icon"></Icon>
<template slot="desc">Custom icon copywriting. Custom icon copywriting. Custom icon copywriting. </template>
</Alert>
</el-row>
</template>
<script>
export default {
data(){
return {
}
}
}
</script>
Page after refresh - Network Tab
Page after refresh - Console log Tab
Page after refresh - Elements Tab, the css that is pulling the fonts
The font folder
What i noticed.
The funny thing is that only the Element UI fonts seems to work. I also tried installing font-awesome fonts, and had no success.
OTHER IMPORTANT NOTES
I'm developing on Virtual Host
I'm developing offline using xammp
Found the problem. It had to do with one of my style sheets. I found this code: html, *, body { font-family: 'Helvetica', 'Arial', 'sans-serif' !important; font-weight: 400; font-size: 12px; text-rendering: optimizeLegibility !important; -webkit-font-smoothing: antialiased !important; } The issue was the "html, *, body": { font-family: 'Helvetica', 'Arial', 'sans-serif' !important; } part. If you notice the font family is applied to everything, i guess it then replaces even my icon references. When i removed that. The icons started showing again.

Font Awesome Webpack Import not rendering Icons

I've tried to follow the documentation on Font Awesome. I have the pro version and have configured NPM for it. I'm using webpack to compile but I'm having issues with it actually rendering. What am I doing wrong?
Here is my app.js
import { library } from '#fortawesome/fontawesome-svg-core'
import { fas } from '#fortawesome/pro-solid-svg-icons'
import { far } from '#fortawesome/pro-regular-svg-icons'
import { fal } from '#fortawesome/pro-light-svg-icons'
import { fab } from '#fortawesome/free-brands-svg-icons'
library.add(fas, far, fal, fab);
I just dumped the following FA icons into my index file
<i class="fas fa-question-circle"></i> <!-- solid style of the question circle icon -->
<i class="far fa-question-circle"></i> <!-- regular style of the question circle icon -->
<i class="fal fa-question-circle"></i> <!-- light style of the question circle icon -->
<i class="fab fa-facebook"></i> <!-- facebook brand icon-->
<i class="fab fa-facebook-f"></i> <!-- facebook "f" brand icon-->
It doesn't seem to do anything with the icons and I don't have any errors compiling. What am I doing wrong?
I'm not a Webpack expert by any means, but there's a little more configuration than just a simple import in order to get Font Awesome to work.
Now this may have changed with FA 5, but I would hope this method is still valid.
This post sums it up quite nicely and is pretty much identical to my current configuration:
Webpack 2 and Font-Awesome Icon Importing
The article has the following (in case the link goes dead):
You'll need a few prerequisite items:
npm install webpack file-loader css-loader sass-loader node-sass
--save-dev
And FA, which you probably already have:
npm install font-awesome --save
** Note: your paths may vary from mine **
In my Webpack module rules I setup to drop the FA assets into a fonts directory:
module: {
rules: [{
test: /\.(eot|ttf|otf)(\?.*)?$/,
loader: 'file-loader',
options: {
limit: 10000,
name: '[name].[ext]',
outputPath: '/fonts/', // where the fonts will go
publicPath: '/assets' // override the default path
}
}]
Once you have all the configurations set, you need to import FA into your main stylesheet:
$fa-font-path: "~font-awesome/fonts";
#import '~font-awesome/scss/font-awesome.scss';
You should then see the assets being pulled into when you run your Webpack build.
I figured out that loading svg-core was the issue. The expected behavior was for the tags to be automatically replaced. Since I was loading svg-core autoReplaceSvg was disabled.
Using the #fortawesome/fontawesome-svg-core package disables autoReplaceSvg and observeMutations by default.
Font Awesome API -> Configuration

Style error when importing element ui into nuxt

I'm trying to import element UI into Nuxt.js and on their twitter account they linked to glitch (https://glitch.com/edit/#!/nuxt-element-ui?path=layouts/default.vue:1:0) that has the important files listed. In the default.vue you it has this listed
<template>
<div>
<nuxt/>
</div>
</template>
<style src="element-ui/lib/theme-default/index.css"></style>
I imported element ui into my nuxt project by running:
npm i element-ui --save nuxt
searched for index.css in the folder and copy-pasted that link as a source to the style src (node_modules\element-ui\lib\theme-chalk\index.css) for the default.vue file but I am getting an error that it can not locate it.
I also tried to use the cdn style file from element ui's website:
https://unpkg.com/element-ui/lib/theme-chalk/index.css
Both of them are resulting in "Module not found"
What am I doing wrong? Any other place that has anything listed on how to import element ui into nuxt?
Global CSS should be defined in css section of nuxt.config
e.g.
module.exports = {
css: [
{ src: '~/assets/index.css', lang: 'scss' },
],
}
and CDN stylesheet should be defined in head.links
head: {
link: [
{ rel: 'stylesheet', href: 'https://unpkg.com/element-ui/lib/theme-chalk/index.css' },
],
},
Read:
https://nuxtjs.org/api/configuration-css
https://nuxtjs.org/api/configuration-head
Inside your style, you can import it like this:
<style>
#import '~element-ui/lib/theme-default/index.css'
</style>
But you can also import it directly from your javascript:
import 'element-ui/lib/theme-default/index.css';

how do i resize tinymce after changin font-size?

Issue : when i have changed the font-size like 38pt, the text goes out of the editor.
I am using tinymce 4.0.
This is my script to load tinymce
<script type="text/javascript">
tinymce.init({
selector: "div#textareasDiv",
theme: "modern",
inline: true,
plugins: [ "textcolor,table"],
toolbar1: " bold italic underline | alignleft aligncenter alignright alignjustify | forecolor backcolor | fontselect | fontsizeselect",
image_advtab: true,
menubar: false,
fixed_toolbar_container: "#toolbarCon"
});
</script>
and
<div id="textareasDiv"></div>
<div id="toolbarCon"></div>
and
<style>
#textareasDiv { padding:2px 5px;width:170px;height:80px;background:transparent;word-wrap: break-word; }
</style>
And I am trying to get its outerHeight so that i can make change on it :
setup : function(ed)
{
ed.on('change', function(e)
{
alert($(this.getContainer()).outerHeight());
});
}
But it gives me nothing.
How can i resize tinymce editor after changing font-size? and How can make this textareasDiv draggable?
HERE IS THE FIDDLE
You seem to be missing overflow in the <textarea> CSS definitions.
You may like to add it an set it to auto, which is the most common usage for it. Other options for overflow are: scroll, overflow-x, overflow-y, or hidden, depending on what result you are trying to achieve.
More about it here: https://www.w3schools.com/css/css_overflow.asp