264 lines
8.0 KiB
JavaScript
264 lines
8.0 KiB
JavaScript
import React from "react";
|
|
import { CKEditor } from "@ckeditor/ckeditor5-react";
|
|
import Editor from "@/vendor/ckeditor5/build/ckeditor";
|
|
|
|
function ViewEditor(props) {
|
|
const maxHeight = props.maxHeight || 600; // Default max height 600px
|
|
|
|
return (
|
|
<div className="ckeditor-view-wrapper">
|
|
<CKEditor
|
|
editor={Editor}
|
|
data={props.initialData}
|
|
disabled={true}
|
|
config={{
|
|
isReadOnly: true,
|
|
content_style: `
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
font-size: 14px;
|
|
line-height: 1.6;
|
|
color: #111;
|
|
background: #fff;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
p {
|
|
margin: 0.5em 0;
|
|
}
|
|
h1, h2, h3, h4, h5, h6 {
|
|
margin: 1em 0 0.5em 0;
|
|
}
|
|
ul, ol {
|
|
margin: 0.5em 0;
|
|
padding-left: 2em;
|
|
}
|
|
blockquote {
|
|
margin: 1em 0;
|
|
padding: 0.5em 1em;
|
|
border-left: 4px solid #d1d5db;
|
|
background-color: #f9fafb;
|
|
}
|
|
`,
|
|
height: props.height || 400,
|
|
removePlugins: ["Title"],
|
|
}}
|
|
/>
|
|
<style jsx>{`
|
|
.ckeditor-view-wrapper {
|
|
border-radius: 6px;
|
|
overflow: hidden;
|
|
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1),
|
|
0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
|
}
|
|
|
|
.ckeditor-view-wrapper :global(.ck.ck-editor__main) {
|
|
min-height: ${props.height || 400}px;
|
|
max-height: ${maxHeight}px;
|
|
}
|
|
|
|
.ckeditor-view-wrapper :global(.ck.ck-editor__editable) {
|
|
min-height: ${(props.height || 400) - 50}px;
|
|
max-height: ${maxHeight - 50}px;
|
|
overflow-y: auto !important;
|
|
scrollbar-width: thin;
|
|
scrollbar-color: #cbd5e1 #f1f5f9;
|
|
background-color: #fdfdfd;
|
|
border: 1px solid #d1d5db;
|
|
border-radius: 6px;
|
|
color: #111;
|
|
}
|
|
|
|
/* 🌙 Dark mode support */
|
|
:global(.dark) .ckeditor-view-wrapper :global(.ck.ck-editor__editable) {
|
|
background-color: #111 !important;
|
|
color: #f9fafb !important;
|
|
border-color: #374151;
|
|
}
|
|
|
|
:global(.dark) .ckeditor-view-wrapper h1,
|
|
:global(.dark) .ckeditor-view-wrapper h2,
|
|
:global(.dark) .ckeditor-view-wrapper h3,
|
|
:global(.dark) .ckeditor-view-wrapper h4,
|
|
:global(.dark) .ckeditor-view-wrapper h5,
|
|
:global(.dark) .ckeditor-view-wrapper h6 {
|
|
color: #f9fafb !important;
|
|
}
|
|
|
|
:global(.dark) .ckeditor-view-wrapper blockquote {
|
|
background-color: #1f2937 !important;
|
|
border-left: 4px solid #374151 !important;
|
|
color: #f3f4f6 !important;
|
|
}
|
|
|
|
/* Custom scrollbar styling */
|
|
.ckeditor-view-wrapper
|
|
:global(.ck.ck-editor__editable::-webkit-scrollbar) {
|
|
width: 8px;
|
|
}
|
|
|
|
.ckeditor-view-wrapper
|
|
:global(.ck.ck-editor__editable::-webkit-scrollbar-track) {
|
|
background: #f1f5f9;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.ckeditor-view-wrapper
|
|
:global(.ck.ck-editor__editable::-webkit-scrollbar-thumb) {
|
|
background: #cbd5e1;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.ckeditor-view-wrapper
|
|
:global(.ck.ck-editor__editable::-webkit-scrollbar-thumb:hover) {
|
|
background: #94a3b8;
|
|
}
|
|
|
|
/* 🌙 Dark mode scrollbar */
|
|
:global(.dark)
|
|
.ckeditor-view-wrapper
|
|
:global(.ck.ck-editor__editable::-webkit-scrollbar-track) {
|
|
background: #1f2937;
|
|
}
|
|
|
|
:global(.dark)
|
|
.ckeditor-view-wrapper
|
|
:global(.ck.ck-editor__editable::-webkit-scrollbar-thumb) {
|
|
background: #4b5563;
|
|
}
|
|
|
|
:global(.dark)
|
|
.ckeditor-view-wrapper
|
|
:global(.ck.ck-editor__editable::-webkit-scrollbar-thumb:hover) {
|
|
background: #6b7280;
|
|
}
|
|
|
|
/* Read-only specific styling */
|
|
.ckeditor-view-wrapper :global(.ck.ck-editor__editable.ck-read-only) {
|
|
cursor: default;
|
|
}
|
|
|
|
/* Hide toolbar */
|
|
.ckeditor-view-wrapper :global(.ck.ck-toolbar) {
|
|
display: none !important;
|
|
}
|
|
`}</style>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default ViewEditor;
|
|
|
|
// import React from "react";
|
|
// import { CKEditor } from "@ckeditor/ckeditor5-react";
|
|
// import Editor from "ckeditor5-custom-build";
|
|
|
|
// function ViewEditor(props) {
|
|
// const maxHeight = props.maxHeight || 600;
|
|
|
|
// return (
|
|
// <div className="ckeditor-view-wrapper">
|
|
// <CKEditor
|
|
// editor={Editor}
|
|
// data={props.initialData}
|
|
// disabled={true}
|
|
// config={{
|
|
// // toolbar: [],
|
|
// isReadOnly: true,
|
|
// // Add content styling configuration for read-only mode
|
|
// content_style: `
|
|
// body {
|
|
// font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
// font-size: 14px;
|
|
// line-height: 1.6;
|
|
// color: #333;
|
|
// margin: 0;
|
|
// padding: 0;
|
|
// }
|
|
// p {
|
|
// margin: 0.5em 0;
|
|
// }
|
|
// h1, h2, h3, h4, h5, h6 {
|
|
// margin: 1em 0 0.5em 0;
|
|
// }
|
|
// ul, ol {
|
|
// margin: 0.5em 0;
|
|
// padding-left: 2em;
|
|
// }
|
|
// blockquote {
|
|
// margin: 1em 0;
|
|
// padding: 0.5em 1em;
|
|
// border-left: 4px solid #d1d5db;
|
|
// background-color: #f9fafb;
|
|
// }
|
|
// `,
|
|
// // Editor appearance settings
|
|
// height: props.height || 400,
|
|
// removePlugins: ['Title'],
|
|
// }}
|
|
// />
|
|
// <style jsx>{`
|
|
// .ckeditor-view-wrapper {
|
|
// border-radius: 6px;
|
|
// overflow: hidden;
|
|
// box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
|
// }
|
|
|
|
// .ckeditor-view-wrapper :global(.ck.ck-editor__main) {
|
|
// min-height: ${props.height || 400}px;
|
|
// max-height: ${maxHeight}px;
|
|
// }
|
|
|
|
// .ckeditor-view-wrapper :global(.ck.ck-editor__editable) {
|
|
// min-height: ${(props.height || 400) - 50}px;
|
|
// max-height: ${maxHeight - 50}px;
|
|
// overflow-y: auto !important;
|
|
// scrollbar-width: thin;
|
|
// scrollbar-color: #cbd5e1 #f1f5f9;
|
|
// background-color:rgb(253, 253, 253);
|
|
// border: 1px solid #d1d5db;
|
|
// border-radius: 6px;
|
|
// }
|
|
|
|
// /* Custom scrollbar styling for webkit browsers */
|
|
// .ckeditor-view-wrapper :global(.ck.ck-editor__editable::-webkit-scrollbar) {
|
|
// width: 8px;
|
|
// }
|
|
|
|
// .ckeditor-view-wrapper :global(.ck.ck-editor__editable::-webkit-scrollbar-track) {
|
|
// background: #f1f5f9;
|
|
// border-radius: 4px;
|
|
// }
|
|
|
|
// .ckeditor-view-wrapper :global(.ck.ck-editor__editable::-webkit-scrollbar-thumb) {
|
|
// background: #cbd5e1;
|
|
// border-radius: 4px;
|
|
// }
|
|
|
|
// .ckeditor-view-wrapper :global(.ck.ck-editor__editable::-webkit-scrollbar-thumb:hover) {
|
|
// background: #94a3b8;
|
|
// }
|
|
|
|
// /* Ensure content doesn't overflow */
|
|
// .ckeditor-view-wrapper :global(.ck.ck-editor__editable .ck-content) {
|
|
// overflow: hidden;
|
|
// }
|
|
|
|
// /* Read-only specific styling */
|
|
// .ckeditor-view-wrapper :global(.ck.ck-editor__editable.ck-read-only) {
|
|
// background-color: #f8fafc;
|
|
// color: #4b5563;
|
|
// cursor: default;
|
|
// }
|
|
|
|
// /* Hide toolbar for view-only mode */
|
|
// .ckeditor-view-wrapper :global(.ck.ck-toolbar) {
|
|
// display: none !important;
|
|
// }
|
|
// `}</style>
|
|
// </div>
|
|
// );
|
|
// }
|
|
|
|
// export default ViewEditor;
|