Add template with inline styles to ckeditor
Add template with inline styles to ckeditor
I'm trying to add this html to ckeditor template
Firstly, in assets/javascripts/ckeditor/config.js with
config.allowedContent = true;
I allowed style tags
And then, In assets/javascripts/ckeditor/plugins/templates/templates/default.js
I added the following code
<style>
.body {color:#474d5d; font-size: 13px;}
h1 {font-size:18px; font-weight: 400;text-align:center}
h2 {color:#233974; font-weight:700; font-size:14px;border-bottom:2px solid #233974;}
h2 img {width:15px; margin-right: 5px;}
li {margin-bottom: 10px;}
ul.exp, ul.formacion{margin-bottom: 40px;}
.company{border:0px solid black; float:right; margin-bottom:0px; margin-left:0px; margin-right:0px; margin-top:0px; width:150px}
.img-formacion {width: 20px;}
.position{text-align:center; font-size:18px; margin-bottom: 40px;}
.CV {clear:both; text-align:center; font-size:18px;}
.n_1{margin-top: 10px;}
</style>
Curriculum Vitae
[Name]
[Position]
EXPERIENCIA PROFESIONAL
- [desde mes año-hasta mes año] [Empresa] / [Cargo]
- Proyecto [nombreproyecto]:
- Descripción tareas 1
- Lista de tecnologías utilizadas
FORMACIÓN
- [Titulación]. [Centro]. [desde fecha – hasta fecha].
- Formación adicional: Nota: Cursos fuera del ámbito académico
- [Mes Año] – [Título curso]. [Centro Educativo]. [Localidad]. Horas: [numerohoras].
- Certificaciones
- [Mes Año] – [Título certificación].
IDIOMAS
- [nombreidioma]
- Nivel Hablado: [Fluido / Alto / Medio / Bajo]
- Nivel Escrito: [Fluido / Alto / Medio / Bajo
The default.js (with last template4 Curriculum') it will have:
/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
// Register a templates definition set named "default".
CKEDITOR.addTemplates( 'default', {
// The name of sub folder which hold the shortcut preview images of the
// templates.
imagesPath: CKEDITOR.getUrl( CKEDITOR.plugins.getPath( 'templates' ) + 'templates/images/' ),
// The templates definitions.
templates: [ {
title: 'Image and Title',
image: 'template1.gif',
description: 'One main image with a title and text that surround the image.',
html: '<h3>' +
// Use src=" " so image is not filtered out by the editor as incorrect (src is required).
'<img src=" " alt="" style="margin-right: 10px" height="100" width="100" align="left" />' +
'Type the title here' +
'</h3>' +
'<p>' +
'Type the text here' +
'</p>'
},
{
title: 'Strange Template',
image: 'template2.gif',
description: 'A template that defines two columns, each one with a title, and some text.',
html: '<table cellspacing="0" cellpadding="0" style="width:100%" border="0">' +
'<tr>' +
'<td style="width:50%">' +
'<h3>Title 1</h3>' +
'</td>' +
'<td></td>' +
'<td style="width:50%">' +
'<h3>Title 2</h3>' +
'</td>' +
'</tr>' +
'<tr>' +
'<td>' +
'Text 1' +
'</td>' +
'<td></td>' +
'<td>' +
'Text 2' +
'</td>' +
'</tr>' +
'</table>' +
'<p>' +
'More text goes here.' +
'</p>'
},
{
title: 'Text and Table',
image: 'template3.gif',
description: 'A title with some text and a table.',
html: '
' +
'' +
'Title goes here' +
'
' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'Table title' +
'
' +
'' +
'Type the text here' +
'
' +
'
'
},
{
title: 'Curriculum',
image: 'template4.gif',
description: 'Experience, Education, Languajes',
html: '<style>' +
'.body {color:#474d5d; font-size: 13px;}' +
'h1 {font-size:18px; font-weight: 400;text-align:center}' +
'h2 {color:#233974; font-weight:700; font-size:14px;border-bottom:2px solid #233974;}' +
'h2 img {width:15px; margin-right: 5px;}' +
'li {margin-bottom: 10px;}' +
'ul.exp, ul.formacion{margin-bottom: 40px;}' +
'.company{border:0px solid black; float:right; margin-bottom:0px; margin-left:0px; margin-right:0px; margin-top:0px; width:150px}' +
'.img-formacion {width: 20px;}' +
'.position{text-align:center; font-size:18px; margin-bottom: 40px;}' +
'.CV {clear:both; text-align:center; font-size:18px;}' +
'.n_1{margin-top: 10px;}' +
'</style>' +
'' +
'Curriculum Vitae
' +
'[Name]
' +
'[Position]
' +
'' +
'EXPERIENCIA PROFESIONAL' +
'
' +
'' +
'- [desde mes año-hasta mes año] [Empresa] / [Cargo]' +
'' +
'- Proyecto [nombreproyecto]:' +
'' +
'- Descripción tareas 1
' +
'- Lista de tecnologías utilizadas
' +
'
' +
' ' +
'
' +
' ' +
'
' +
''+
'FORMACIÓN' +
'
' +
'' +
'- [Titulación]. [Centro]. [desde fecha – hasta fecha].' +
' ' +
'- Formación adicional: Nota: Cursos fuera del ámbito académico' +
'' +
'- [Mes Año] – [Título curso]. [Centro Educativo]. [Localidad]. Horas: [numerohoras].' +
' ' +
'
' +
' ' +
'- Certificaciones' +
'' +
'- [Mes Año] – [Título certificación].' +
' ' +
'
' +
' ' +
'
' +
'' +
'IDIOMAS' +
'
' +
'' +
'- [nombreidioma]' +
'' +
'- Nivel Hablado: [Fluido / Alto / Medio / Bajo]
' +
'- Nivel Escrito: [Fluido / Alto / Medio / Bajo
' +
'
' +
' ' +
'
' +
''
} ]
} );
The problem is that when I'm in the editor I see the html perfectly but When I save:
The part between the style tags looks like:
Styles are lost because they are not saved correctly
<p>.body {color:#474d5d; font-size: 13px;}h1 {font-size:18px; font-
weight: 400;text-align:center}h2 {color:#233974; font-weight:700;
font-size:14px;border-bottom:2px solid #233974;}h2 img {width:15px;
margin-right: 5px;}li {margin-bottom: 10px;}ul.exp,
ul.formacion{margin-bottom:40px;}.company{border:0px solid black;
float:right; margin-bottom:0px;
margin-left:0px; margin-right:0px; margin-top:0px; width:150px}.img-
formacion {width: 20px;}.position{text-align:center; font-size:18px;
margin-bottom: 40px;}.CV {clear:both; text-align:center; font-
size:18px;}.n_1{margin-top: 10px;}</p>
<div class="body">
<p class="CV">Curriculum Vitae</p>
<h1>[Name]</h1>
<p class="position">[Position]</p>
<h2>EXPERIENCIA PROFESIONAL</h2>
<ul class="exp">
<li>[<strong>desde mes año-hasta mes año] [Empresa] / [Cargo]</strong>
<ul>
<li class="n_1"><strong>Proyecto</strong> [nombreproyecto]:
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Comments
Post a Comment