use ckeditor content styles also for read only notes, tooltips and book notes

This commit is contained in:
zadam 2020-04-08 21:38:11 +02:00
parent 34b8979016
commit f3b84e5185
9 changed files with 187 additions and 188 deletions

View File

@ -1,9 +1,9 @@
/* /*
* !!!!!!! This stylesheet is heavily modified compared to the original for similarity with in-editor look !!!!!!! * !!!!!!! This stylesheet is heavily modified compared to the original for similarity with in-editor look !!!!!!!
* This is used for printing and tar HTML export * This is used for printing and tar HTML export
*
* CKEditor 5 (v15.0.0) content styles. * CKEditor 5 (v17.0.0) content styles.
* Generated on Wed, 27 Nov 2019 13:26:13 GMT. * Generated on Fri, 13 Mar 2020 13:27:10 GMT.
* For more information, check out https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/content-styles.html * For more information, check out https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/content-styles.html
*/ */
@ -16,204 +16,71 @@
--ck-highlight-pen-red: #e91313; --ck-highlight-pen-red: #e91313;
--ck-image-style-spacing: 1.5em; --ck-image-style-spacing: 1.5em;
--ck-todo-list-checkmark-size: 16px; --ck-todo-list-checkmark-size: 16px;
font-family: Arial, Sans-Serif;
} }
/* ckeditor5-list/theme/todolist.css */ /* ckeditor5-image/theme/imageresize.css */
.todo-list { .ck-content .image.image_resized {
list-style: none; max-width: 100%;
}
/* ckeditor5-list/theme/todolist.css */
.todo-list li {
margin-bottom: 5px;
}
/* ckeditor5-list/theme/todolist.css */
.todo-list li .todo-list {
margin-top: 5px;
}
/* ckeditor5-list/theme/todolist.css */
.todo-list .todo-list__label > input {
-webkit-appearance: none;
display: inline-block;
position: relative;
width: var(--ck-todo-list-checkmark-size);
height: var(--ck-todo-list-checkmark-size);
vertical-align: middle;
border: 0;
left: -25px;
margin-right: -15px;
right: 0;
margin-left: 0;
}
/* ckeditor5-list/theme/todolist.css */
.todo-list .todo-list__label > input::before {
display: block; display: block;
position: absolute;
box-sizing: border-box; box-sizing: border-box;
content: ''; }
/* ckeditor5-image/theme/imageresize.css */
.ck-content .image.image_resized img {
width: 100%; width: 100%;
height: 100%;
border: 1px solid hsl(0, 0%, 20%);
border-radius: 2px;
transition: 250ms ease-in-out box-shadow, 250ms ease-in-out background, 250ms ease-in-out border;
} }
/* ckeditor5-list/theme/todolist.css */ /* ckeditor5-image/theme/imageresize.css */
.todo-list .todo-list__label > input::after { .ck-content .image.image_resized > figcaption {
display: block; display: block;
position: absolute;
box-sizing: content-box;
pointer-events: none;
content: '';
left: calc( var(--ck-todo-list-checkmark-size) / 3 );
top: calc( var(--ck-todo-list-checkmark-size) / 5.3 );
width: calc( var(--ck-todo-list-checkmark-size) / 5.3 );
height: calc( var(--ck-todo-list-checkmark-size) / 2.6 );
border-style: solid;
border-color: transparent;
border-width: 0 calc( var(--ck-todo-list-checkmark-size) / 8 ) calc( var(--ck-todo-list-checkmark-size) / 8 ) 0;
transform: rotate(45deg);
} }
/* ckeditor5-list/theme/todolist.css */ /* ckeditor5-basic-styles/theme/code.css */
.todo-list .todo-list__label > input[checked]::before { .ck-content code {
border-color: hsl(126, 64%, 41%); background-color: hsla(0, 0%, 78%, 0.3);
} padding: .15em;
/* ckeditor5-list/theme/todolist.css */ border-radius: 2px;
.todo-list .todo-list__label > input[checked]::after {
border-color: hsl(126, 64%, 41%);
}
/* ckeditor5-list/theme/todolist.css */
.todo-list .todo-list__label .todo-list__label__description {
vertical-align: middle;
} }
/* ckeditor5-image/theme/image.css */ /* ckeditor5-image/theme/image.css */
.image { .ck-content .image {
display: table; display: table;
clear: both; clear: both;
text-align: center; text-align: center;
margin: 1em auto; margin: 1em auto;
} }
/* ckeditor5-image/theme/image.css */ /* ckeditor5-image/theme/image.css */
.image > img { .ck-content .image > img {
display: block; display: block;
margin: 0 auto; margin: 0 auto;
max-width: 100%; max-width: 100%;
min-width: 50px; min-width: 50px;
} }
/* ckeditor5-block-quote/theme/blockquote.css */
blockquote {
overflow: hidden;
padding-right: 1.5em;
padding-left: 1.5em;
margin-left: 0;
margin-right: 0;
font-style: italic;
border-left: solid 5px hsl(0, 0%, 80%);
}
/* ckeditor5-block-quote/theme/blockquote.css */
.ck-content[dir="rtl"] blockquote {
border-left: 0;
border-right: solid 5px hsl(0, 0%, 80%);
}
/* ckeditor5-image/theme/imageresize.css */
.image.image_resized {
max-width: 100%;
display: block;
box-sizing: border-box;
}
/* ckeditor5-image/theme/imageresize.css */
.image.image_resized img {
width: 100%;
}
/* ckeditor5-image/theme/imageresize.css */
.image.image_resized > figcaption {
display: block;
}
/* ckeditor5-image/theme/imagestyle.css */ /* ckeditor5-image/theme/imagestyle.css */
.image-style-side, .ck-content .image-style-side,
.image-style-align-left, .ck-content .image-style-align-left,
.image-style-align-center, .ck-content .image-style-align-center,
.image-style-align-right { .ck-content .image-style-align-right {
max-width: 50%; max-width: 50%;
} }
/* ckeditor5-image/theme/imagestyle.css */ /* ckeditor5-image/theme/imagestyle.css */
.image-style-side { .ck-content .image-style-side {
float: right; float: right;
margin-left: var(--ck-image-style-spacing); margin-left: var(--ck-image-style-spacing);
} }
/* ckeditor5-image/theme/imagestyle.css */ /* ckeditor5-image/theme/imagestyle.css */
.image-style-align-left { .ck-content .image-style-align-left {
float: left; float: left;
margin-right: var(--ck-image-style-spacing); margin-right: var(--ck-image-style-spacing);
} }
/* ckeditor5-image/theme/imagestyle.css */ /* ckeditor5-image/theme/imagestyle.css */
.image-style-align-center { .ck-content .image-style-align-center {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
} }
/* ckeditor5-image/theme/imagestyle.css */ /* ckeditor5-image/theme/imagestyle.css */
.image-style-align-right { .ck-content .image-style-align-right {
float: right; float: right;
margin-left: var(--ck-image-style-spacing); margin-left: var(--ck-image-style-spacing);
} }
/* ckeditor5-media-embed/theme/mediaembed.css */
.media {
clear: both;
margin: 1em 0;
display: block;
min-width: 15em;
}
/* ckeditor5-table/theme/table.css */
.table {
display: table;
margin: 0;
}
/* ckeditor5-table/theme/table.css */
.table table {
border-collapse: collapse;
border-spacing: 0;
border: 1px double hsl(0, 0%, 70%);
}
/* ckeditor5-table/theme/table.css */
.table table td,
.table table th {
min-width: 2em;
padding: .4em;
border: 1px solid #d9d9d9;
}
/* ckeditor5-table/theme/table.css */
.table table th {
font-weight: bold;
background-color: #f5f5f5;
text-align: left;
}
/* ckeditor5-highlight/theme/highlight.css */
.marker-yellow {
background-color: var(--ck-highlight-marker-yellow);
}
/* ckeditor5-highlight/theme/highlight.css */
.marker-green {
background-color: var(--ck-highlight-marker-green);
}
/* ckeditor5-highlight/theme/highlight.css */
.marker-pink {
background-color: var(--ck-highlight-marker-pink);
}
/* ckeditor5-highlight/theme/highlight.css */
.marker-blue {
background-color: var(--ck-highlight-marker-blue);
}
/* ckeditor5-highlight/theme/highlight.css */
.pen-red {
color: var(--ck-highlight-pen-red);
background-color: transparent;
}
/* ckeditor5-highlight/theme/highlight.css */
.pen-green {
color: var(--ck-highlight-pen-green);
background-color: transparent;
}
/* ckeditor5-page-break/theme/pagebreak.css */ /* ckeditor5-page-break/theme/pagebreak.css */
.page-break { .ck-content .page-break {
position: relative; position: relative;
clear: both; clear: both;
padding: 5px 0; padding: 5px 0;
@ -222,14 +89,14 @@ blockquote {
justify-content: center; justify-content: center;
} }
/* ckeditor5-page-break/theme/pagebreak.css */ /* ckeditor5-page-break/theme/pagebreak.css */
.page-break::after { .ck-content .page-break::after {
content: ''; content: '';
position: absolute; position: absolute;
border-bottom: 2px dashed hsl(0, 0%, 77%); border-bottom: 2px dashed hsl(0, 0%, 77%);
width: 100%; width: 100%;
} }
/* ckeditor5-page-break/theme/pagebreak.css */ /* ckeditor5-page-break/theme/pagebreak.css */
.page-break__label { .ck-content .page-break__label {
position: relative; position: relative;
z-index: 1; z-index: 1;
padding: .3em .6em; padding: .3em .6em;
@ -248,14 +115,122 @@ blockquote {
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none;
} }
/* ckeditor5-basic-styles/theme/code.css */ /* ckeditor5-block-quote/theme/blockquote.css */
code { .ck-content blockquote {
background-color: hsla(0, 0%, 78%, 0.3); overflow: hidden;
padding: .15em; padding-right: 1.5em;
padding-left: 1.5em;
margin-left: 0;
margin-right: 0;
font-style: italic;
border-left: solid 5px hsl(0, 0%, 80%);
}
/* ckeditor5-block-quote/theme/blockquote.css */
.ck-content[dir="rtl"] blockquote {
border-left: 0;
border-right: solid 5px hsl(0, 0%, 80%);
}
/* ckeditor5-media-embed/theme/mediaembed.css */
.ck-content .media {
clear: both;
margin: 1em 0;
display: block;
min-width: 15em;
}
/* ckeditor5-table/theme/table.css */
.ck-content .table {
margin: 1em auto;
display: table;
}
/* ckeditor5-table/theme/table.css */
.ck-content .table table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
height: 100%;
border: 1px double hsl(0, 0%, 70%);
}
/* ckeditor5-table/theme/table.css */
.ck-content .table table td,
.ck-content .table table th {
min-width: 2em;
padding: .4em;
border-color: hsl(0, 0%, 75%);
}
/* ckeditor5-table/theme/table.css */
.ck-content .table table th {
font-weight: bold;
background: hsla(0, 0%, 0%, 5%);
}
/* ckeditor5-list/theme/todolist.css */
.ck-content .todo-list {
list-style: none;
}
/* ckeditor5-list/theme/todolist.css */
.ck-content .todo-list li {
margin-bottom: 5px;
}
/* ckeditor5-list/theme/todolist.css */
.ck-content .todo-list li .todo-list {
margin-top: 5px;
}
/* ckeditor5-list/theme/todolist.css */
.ck-content .todo-list .todo-list__label > input {
-webkit-appearance: none;
display: inline-block;
position: relative;
width: var(--ck-todo-list-checkmark-size);
height: var(--ck-todo-list-checkmark-size);
vertical-align: middle;
border: 0;
left: -25px;
margin-right: -15px;
right: 0;
margin-left: 0;
}
/* ckeditor5-list/theme/todolist.css */
.ck-content .todo-list .todo-list__label > input::before {
display: block;
position: absolute;
box-sizing: border-box;
content: '';
width: 100%;
height: 100%;
border: 1px solid hsl(0, 0%, 20%);
border-radius: 2px; border-radius: 2px;
transition: 250ms ease-in-out box-shadow, 250ms ease-in-out background, 250ms ease-in-out border;
}
/* ckeditor5-list/theme/todolist.css */
.ck-content .todo-list .todo-list__label > input::after {
display: block;
position: absolute;
box-sizing: content-box;
pointer-events: none;
content: '';
left: calc( var(--ck-todo-list-checkmark-size) / 3 );
top: calc( var(--ck-todo-list-checkmark-size) / 5.3 );
width: calc( var(--ck-todo-list-checkmark-size) / 5.3 );
height: calc( var(--ck-todo-list-checkmark-size) / 2.6 );
border-style: solid;
border-color: transparent;
border-width: 0 calc( var(--ck-todo-list-checkmark-size) / 8 ) calc( var(--ck-todo-list-checkmark-size) / 8 ) 0;
transform: rotate(45deg);
}
/* ckeditor5-list/theme/todolist.css */
.ck-content .todo-list .todo-list__label > input[checked]::before {
background: hsl(126, 64%, 41%);
border-color: hsl(126, 64%, 41%);
}
/* ckeditor5-list/theme/todolist.css */
.ck-content .todo-list .todo-list__label > input[checked]::after {
border-color: hsl(0, 0%, 100%);
}
/* ckeditor5-list/theme/todolist.css */
.ck-content .todo-list .todo-list__label .todo-list__label__description {
vertical-align: middle;
} }
/* ckeditor5-image/theme/imagecaption.css */ /* ckeditor5-image/theme/imagecaption.css */
.image > figcaption { .ck-content .image > figcaption {
display: table-caption; display: table-caption;
caption-side: bottom; caption-side: bottom;
word-break: break-word; word-break: break-word;
@ -265,15 +240,41 @@ code {
font-size: .75em; font-size: .75em;
outline-offset: -1px; outline-offset: -1px;
} }
/* ckeditor5-highlight/theme/highlight.css */
.ck-content .marker-yellow {
background-color: var(--ck-highlight-marker-yellow);
}
/* ckeditor5-highlight/theme/highlight.css */
.ck-content .marker-green {
background-color: var(--ck-highlight-marker-green);
}
/* ckeditor5-highlight/theme/highlight.css */
.ck-content .marker-pink {
background-color: var(--ck-highlight-marker-pink);
}
/* ckeditor5-highlight/theme/highlight.css */
.ck-content .marker-blue {
background-color: var(--ck-highlight-marker-blue);
}
/* ckeditor5-highlight/theme/highlight.css */
.ck-content .pen-red {
color: var(--ck-highlight-pen-red);
background-color: transparent;
}
/* ckeditor5-highlight/theme/highlight.css */
.ck-content .pen-green {
color: var(--ck-highlight-pen-green);
background-color: transparent;
}
/* ckeditor5-horizontal-line/theme/horizontalline.css */ /* ckeditor5-horizontal-line/theme/horizontalline.css */
hr { .ck-content hr {
border-width: 1px 0 0; border-width: 1px 0 0;
border-style: solid; border-style: solid;
border-color: hsl(0, 0%, 37%); border-color: hsl(0, 0%, 37%);
margin: 0; margin: 0;
} }
/* ckeditor5-code-block/theme/codeblock.css */ /* ckeditor5-code-block/theme/codeblock.css */
pre { .ck-content pre {
padding: 1em; padding: 1em;
color: #353535; color: #353535;
background: hsla(0, 0%, 78%, 0.3); background: hsla(0, 0%, 78%, 0.3);
@ -287,24 +288,18 @@ pre {
min-width: 200px; min-width: 200px;
} }
/* ckeditor5-code-block/theme/codeblock.css */ /* ckeditor5-code-block/theme/codeblock.css */
pre code { .ck-content pre code {
background: unset; background: unset;
padding: 0; padding: 0;
border-radius: 0; border-radius: 0;
} }
.ck-widget__selection-handle {
display: none;
}
@media print { @media print {
/* ckeditor5-page-break/theme/pagebreak.css */ /* ckeditor5-page-break/theme/pagebreak.css */
.page-break { .ck-content .page-break {
padding: 0; padding: 0;
} }
/* ckeditor5-page-break/theme/pagebreak.css */ /* ckeditor5-page-break/theme/pagebreak.css */
.page-break::after { .ck-content .page-break::after {
display: none; display: none;
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@ async function getRenderedContent(note) {
if (type === 'text') { if (type === 'text') {
const fullNote = await server.get('notes/' + note.noteId); const fullNote = await server.get('notes/' + note.noteId);
$rendered = $("<div>").html(fullNote.content); $rendered = $('<div class="ck-content">').html(fullNote.content);
} }
else if (type === 'code') { else if (type === 'code') {
const fullNote = await server.get('notes/' + note.noteId); const fullNote = await server.get('notes/' + note.noteId);

View File

@ -59,7 +59,8 @@ async function mouseEnterHandler() {
boundary: 'window', boundary: 'window',
title: html, title: html,
html: true, html: true,
template: '<div class="tooltip note-tooltip" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>' template: '<div class="tooltip note-tooltip" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>',
sanitize: false
}); });
$(this).tooltip('show'); $(this).tooltip('show');
@ -123,9 +124,7 @@ async function renderTooltip(note, noteComplement) {
} }
if (note.type === 'text' && !utils.isHtmlEmpty(noteComplement.content)) { if (note.type === 'text' && !utils.isHtmlEmpty(noteComplement.content)) {
// surround with <div> for a case when note's content is pure text (e.g. "[protected]") which content += '<div class="ck-content">' + noteComplement.content + '</div>';
// then fails the jquery non-empty text test
content += '<div>' + noteComplement.content + '</div>';
} }
else if (note.type === 'code' && noteComplement.content && noteComplement.content.trim()) { else if (note.type === 'code' && noteComplement.content && noteComplement.content.trim()) {
content += $("<pre>") content += $("<pre>")

View File

@ -227,7 +227,8 @@ export default class NoteDetailWidget extends TabAwareWidget {
await libraryLoader.requireLibrary(libraryLoader.PRINT_THIS); await libraryLoader.requireLibrary(libraryLoader.PRINT_THIS);
this.$widget.find('.note-detail-printable:visible').printThis({ this.$widget.find('.note-detail-printable:visible').printThis({
header: $("<h2>").text(this.note && this.note.title).prop('outerHTML') , header: $("<h2>").text(this.note && this.note.title).prop('outerHTML'),
footer: "<script>document.body.className += ' ck-content';</script>",
importCSS: false, importCSS: false,
loadCSS: [ loadCSS: [
"libraries/codemirror/codemirror.css", "libraries/codemirror/codemirror.css",

View File

@ -24,11 +24,11 @@ const TPL = `
} }
</style> </style>
<div class="alert alert-warning"> <div class="alert alert-warning no-print">
Read only text view is shown. <a href="#" class="edit-note">Click here</a> to edit the note. Read only text view is shown. <a href="#" class="edit-note">Click here</a> to edit the note.
</div> </div>
<div class="note-detail-readonly-text-content"></div> <div class="note-detail-readonly-text-content ck-content"></div>
</div> </div>
`; `;

View File

@ -59,6 +59,8 @@
<link href="libraries/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="libraries/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="libraries/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="libraries/bootstrap/js/bootstrap.bundle.min.js"></script>
<link href="libraries/ckeditor/ckeditor-content.css" rel="stylesheet">
<!-- Include Fancytree skin and library --> <!-- Include Fancytree skin and library -->
<link href="libraries/fancytree/skin-win8/ui.fancytree.min.css" rel="stylesheet"> <link href="libraries/fancytree/skin-win8/ui.fancytree.min.css" rel="stylesheet">
<script src="libraries/fancytree/jquery.fancytree-all-deps.min.js"></script> <script src="libraries/fancytree/jquery.fancytree-all-deps.min.js"></script>

View File

@ -38,6 +38,8 @@
<link href="libraries/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="libraries/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="libraries/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="libraries/bootstrap/js/bootstrap.bundle.min.js"></script>
<link href="libraries/ckeditor/ckeditor-content.css" rel="stylesheet">
<script src="javascripts/mobile.js" crossorigin type="module"></script> <script src="javascripts/mobile.js" crossorigin type="module"></script>
<link href="stylesheets/themes.css" rel="stylesheet"> <link href="stylesheets/themes.css" rel="stylesheet">