index.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title th:text="${title}"></title>
  6. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  7. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
  8. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
  9. <style>
  10. .btn-submit{
  11. margin-top: 15px;
  12. display:flex;
  13. justify-content:flex-end;
  14. width:100%;
  15. padding-right:15px;
  16. }
  17. .document-editor {
  18. border: 1px solid var(--ck-color-base-border);
  19. border-radius: var(--ck-border-radius);
  20. /* Set vertical boundaries for the document editor. */
  21. max-height: 700px;
  22. /* This element is a flex container for easier rendering. */
  23. display: flex;
  24. flex-flow: column nowrap;
  25. }
  26. .document-editor__toolbar {
  27. /* Make sure the toolbar container is always above the editable. */
  28. z-index: 1;
  29. /* Create the illusion of the toolbar floating over the editable. */
  30. box-shadow: 0 0 5px hsla( 0,0%,0%,.2 );
  31. /* Use the CKEditor CSS variables to keep the UI consistent. */
  32. border-bottom: 1px solid var(--ck-color-toolbar-border);
  33. }
  34. /* Adjust the look of the toolbar inside of the container. */
  35. .document-editor__toolbar .ck-toolbar {
  36. border: 0;
  37. border-radius: 0;
  38. }
  39. /* Make the editable container look like the inside of a native word processor app. */
  40. .document-editor__editable-container {
  41. padding: calc( 2 * var(--ck-spacing-large) );
  42. background: var(--ck-color-base-foreground);
  43. /* Make it possible to scroll the "page" of the edited content. */
  44. overflow-y: scroll;
  45. }
  46. .ck-editor__editable {
  47. /* Set the dimensions of the "page". */
  48. width: 25.8cm;
  49. min-height: 21cm;
  50. /* Keep the "page" off the boundaries of the container. */
  51. padding: 1cm 2cm 2cm;
  52. border: 1px hsl( 0,0%,82.7% ) solid;
  53. border-radius: var(--ck-border-radius);
  54. background: white;
  55. /* The "page" should cast a slight shadow (3D illusion). */
  56. box-shadow: 0 0 5px hsla( 0,0%,0%,.1 );
  57. /* Center the "page". */
  58. margin: 0 auto;
  59. }
  60. /* Override the page's width in the "Examples" section which is wider. */
  61. .main__content-wide .document-editor__editable-container .document-editor__editable.ck-editor__editable {
  62. width: 18cm;
  63. }
  64. /* Set the default font for the "page" of the content. */
  65. .document-editor .ck-content,
  66. .document-editor .ck-heading-dropdown .ck-list .ck-button__label {
  67. font: 16px/1.6 "Helvetica Neue", Helvetica, Arial, sans-serif;
  68. }
  69. /* Adjust the headings dropdown to host some larger heading styles. */
  70. .document-editor .ck-heading-dropdown .ck-list .ck-button__label {
  71. line-height: calc( 1.7 * var(--ck-line-height-base) * var(--ck-font-size-base) );
  72. min-width: 6em;
  73. }
  74. /* Scale down all heading previews because they are way too big to be presented in the UI.
  75. Preserve the relative scale, though. */
  76. .document-editor .ck-heading-dropdown .ck-list .ck-heading_heading1 .ck-button__label,
  77. .document-editor .ck-heading-dropdown .ck-list .ck-heading_heading2 .ck-button__label {
  78. transform: scale(0.8);
  79. transform-origin: left;
  80. }
  81. /* Set the styles for "Heading 1". */
  82. .document-editor .ck-content h2,
  83. .document-editor .ck-heading-dropdown .ck-heading_heading1 .ck-button__label {
  84. font-size: 2.18em;
  85. font-weight: normal;
  86. }
  87. .document-editor .ck-content h2 {
  88. line-height: 1.37em;
  89. padding-top: .342em;
  90. margin-bottom: .142em;
  91. }
  92. /* Set the styles for "Heading 2". */
  93. .document-editor .ck-content h3,
  94. .document-editor .ck-heading-dropdown .ck-heading_heading2 .ck-button__label {
  95. font-size: 1.75em;
  96. font-weight: normal;
  97. color: hsl( 203, 100%, 50% );
  98. }
  99. .document-editor .ck-heading-dropdown .ck-heading_heading2.ck-on .ck-button__label {
  100. color: var(--ck-color-list-button-on-text);
  101. }
  102. /* Set the styles for "Heading 2". */
  103. .document-editor .ck-content h3 {
  104. line-height: 1.86em;
  105. padding-top: .171em;
  106. margin-bottom: .357em;
  107. }
  108. /* Set the styles for "Heading 3". */
  109. .document-editor .ck-content h4,
  110. .document-editor .ck-heading-dropdown .ck-heading_heading3 .ck-button__label {
  111. font-size: 1.31em;
  112. font-weight: bold;
  113. }
  114. .document-editor .ck-content h4 {
  115. line-height: 1.24em;
  116. padding-top: .286em;
  117. margin-bottom: .952em;
  118. }
  119. /* Make the block quoted text serif with some additional spacing. */
  120. .document-editor .ck-content blockquote {
  121. font-family: Georgia, serif;
  122. margin-left: calc( 2 * var(--ck-spacing-large) );
  123. margin-right: calc( 2 * var(--ck-spacing-large) );
  124. }
  125. @media only screen and (max-width: 960px) {
  126. /* Because on mobile 2cm paddings are to big. */
  127. .document-editor__editable-container .document-editor__editable.ck-editor__editable {
  128. padding: 1.5em;
  129. }
  130. }
  131. @media only screen and (max-width: 1200px) {
  132. .main__content-wide .document-editor__editable-container .document-editor__editable.ck-editor__editable {
  133. width: 100%;
  134. }
  135. }
  136. /* Style document editor a'ka Google Docs.*/
  137. @media only screen and (min-width: 1360px) {
  138. .main .main__content.main__content-wide {
  139. padding-right: 0;
  140. }
  141. }
  142. @media only screen and (min-width: 1600px) {
  143. .main .main__content.main__content-wide {
  144. width: 24cm;
  145. }
  146. .main .main__content.main__content-wide .main__content-inner {
  147. width: auto;
  148. margin: 0 50px;
  149. }
  150. /* Keep "page" look based on viewport width. */
  151. .main__content-wide .document-editor__editable-container .document-editor__editable.ck-editor__editable {
  152. width: 60%;
  153. }
  154. }
  155. </style>
  156. </head>
  157. <body>
  158. <h1><span th:text="${heading}"></span></h1>
  159. <form method="post", th:action="@{/}" th:object="${documentContent}">
  160. <input type="hidden" th:field="*{id}">
  161. <input type="hidden" th:field="*{generatedId}">
  162. <div class="document-editor">
  163. <div class="document-editor__toolbar"></div>
  164. <div class="document-editor__editable-container">
  165. <textarea class="document-editor__editable" th:field="*{value}">
  166. <!-- Editor content is inserted here. -->
  167. <span th:text="${content}"></span>
  168. </textarea>
  169. </div>
  170. </div>
  171. <div class="btn-submit">
  172. <input type="submit" class="btn btn-default btn-lg" value="Submit">
  173. </div>
  174. </form>
  175. <!--
  176. https://ckeditor.com/docs/ckeditor5/latest/features/images/image-upload/ckbox.html
  177. -->
  178. <script src="https://cdn.ckbox.io/CKBox/1.3.2/ckbox.js"></script>
  179. <!--
  180. The "super-build" of CKEditor 5 served via CDN contains a large set of plugins and multiple editor types.
  181. See https://ckeditor.com/docs/ckeditor5/latest/installation/getting-started/quick-start.html#running-a-full-featured-editor-from-cdn
  182. -->
  183. <script src="https://cdn.ckeditor.com/ckeditor5/36.0.1/super-build/ckeditor.js"></script>
  184. <!--
  185. Uncomment to load the Spanish translation
  186. <script src="https://cdn.ckeditor.com/ckeditor5/36.0.1/super-build/translations/es.js"></script>
  187. -->
  188. <script>
  189. // This sample still does not showcase all CKEditor 5 features (!)
  190. // Visit https://ckeditor.com/docs/ckeditor5/latest/features/index.html to browse all the features.
  191. CKEDITOR.ClassicEditor.create( document.querySelector( '.document-editor__editable' ), {
  192. // https://ckeditor.com/docs/ckeditor5/latest/features/toolbar/toolbar.html#extended-toolbar-configuration-format
  193. toolbar: {
  194. items: [
  195. 'ckbox', 'uploadImage', '|',
  196. 'exportPDF','exportWord', '|',
  197. 'importWord', '|',
  198. 'comment', 'trackChanges', 'revisionHistory', '|',
  199. 'findAndReplace', 'selectAll', '|',
  200. 'bold', 'italic', 'strikethrough', 'underline', 'removeFormat', '|',
  201. 'bulletedList', 'numberedList', 'todoList', '|',
  202. 'outdent', 'indent', '|',
  203. 'undo', 'redo',
  204. '-',
  205. 'heading', '|',
  206. 'fontSize', 'fontFamily', 'fontColor', 'fontBackgroundColor', 'highlight', '|',
  207. 'alignment', '|',
  208. 'link', 'blockQuote', 'insertTable', 'mediaEmbed', 'codeBlock', 'htmlEmbed', '|',
  209. 'specialCharacters', 'horizontalLine', 'pageBreak', '|',
  210. // Intentionally skipped buttons to keep the toolbar smaller, feel free to enable them:
  211. // 'code', 'subscript', 'superscript', 'textPartLanguage', '|',
  212. // ** To use source editing remember to disable real-time collaboration plugins **
  213. // 'sourceEditing'
  214. ],
  215. shouldNotGroupWhenFull: true
  216. },
  217. // Changing the language of the interface requires loading the language file using the <script> tag.
  218. // language: 'es',
  219. list: {
  220. properties: {
  221. styles: true,
  222. startIndex: true,
  223. reversed: true
  224. }
  225. },
  226. // https://ckeditor.com/docs/ckeditor5/latest/features/headings.html#configuration
  227. heading: {
  228. options: [
  229. { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
  230. { model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
  231. { model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
  232. { model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' },
  233. { model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' },
  234. { model: 'heading5', view: 'h5', title: 'Heading 5', class: 'ck-heading_heading5' },
  235. { model: 'heading6', view: 'h6', title: 'Heading 6', class: 'ck-heading_heading6' }
  236. ]
  237. },
  238. // https://ckeditor.com/docs/ckeditor5/latest/features/font.html#configuring-the-font-family-feature
  239. fontFamily: {
  240. options: [
  241. 'default',
  242. 'Arial, Helvetica, sans-serif',
  243. 'Courier New, Courier, monospace',
  244. 'Georgia, serif',
  245. 'Lucida Sans Unicode, Lucida Grande, sans-serif',
  246. 'Tahoma, Geneva, sans-serif',
  247. 'Times New Roman, Times, serif',
  248. 'Trebuchet MS, Helvetica, sans-serif',
  249. 'Verdana, Geneva, sans-serif'
  250. ],
  251. supportAllValues: true
  252. },
  253. // https://ckeditor.com/docs/ckeditor5/latest/features/font.html#configuring-the-font-size-feature
  254. fontSize: {
  255. options: [ 10, 12, 14, 'default', 18, 20, 22 ],
  256. supportAllValues: true
  257. },
  258. // Be careful with the setting below. It instructs CKEditor to accept ALL HTML markup.
  259. // https://ckeditor.com/docs/ckeditor5/latest/features/general-html-support.html#enabling-all-html-features
  260. // htmlSupport: {
  261. // allow: [
  262. // {
  263. // name: /.*/,
  264. // attributes: true,
  265. // classes: true,
  266. // styles: true
  267. // }
  268. // ]
  269. // },
  270. // Be careful with enabling previews
  271. // https://ckeditor.com/docs/ckeditor5/latest/features/html-embed.html#content-previews
  272. htmlEmbed: {
  273. showPreviews: true
  274. },
  275. // https://ckeditor.com/docs/ckeditor5/latest/features/mentions.html#configuration
  276. mention: {
  277. feeds: [
  278. {
  279. marker: '@',
  280. feed: [
  281. '@apple', '@bears', '@brownie', '@cake', '@cake', '@candy', '@canes', '@chocolate', '@cookie', '@cotton', '@cream',
  282. '@cupcake', '@danish', '@donut', '@dragée', '@fruitcake', '@gingerbread', '@gummi', '@ice', '@jelly-o',
  283. '@liquorice', '@macaroon', '@marzipan', '@oat', '@pie', '@plum', '@pudding', '@sesame', '@snaps', '@soufflé',
  284. '@sugar', '@sweet', '@topping', '@wafer', '@alfi'
  285. ],
  286. minimumCharacters: 1
  287. }
  288. ]
  289. },
  290. // https://ckeditor.com/docs/ckeditor5/latest/features/editor-placeholder.html#using-the-editor-configuration
  291. placeholder: 'Welcome to CKEditor 5!',
  292. // Used by real-time collaboration
  293. cloudServices: {
  294. // Be careful - do not use the development token endpoint on production systems!
  295. tokenUrl: 'https://95909.cke-cs.com/token/dev/31dad7RDKRwJrbhYZUOta7rT67FW5j53zqFh?limit=10',
  296. webSocketUrl: 'wss://95909.cke-cs.com/ws'
  297. },
  298. collaboration: {
  299. // Modify the channelId to simulate editing different documents
  300. // https://ckeditor.com/docs/ckeditor5/latest/features/collaboration/real-time-collaboration/real-time-collaboration-integration.html#the-channelid-configuration-property
  301. channelId: 'document-id-2'
  302. },
  303. // https://ckeditor.com/docs/ckeditor5/latest/features/collaboration/annotations/annotations-custom-configuration.html#sidebar-configuration
  304. sidebar: {
  305. container: document.querySelector( '#sidebar' )
  306. },
  307. // https://ckeditor.com/docs/ckeditor5/latest/features/collaboration/real-time-collaboration/users-in-real-time-collaboration.html#users-presence-list
  308. presenceList: {
  309. container: document.querySelector( '#presence-list-container' )
  310. },
  311. // Add configuration for the comments editor if the Comments plugin is added.
  312. // https://ckeditor.com/docs/ckeditor5/latest/features/collaboration/annotations/annotations-custom-configuration.html#comment-editor-configuration
  313. /* comments: {
  314. editorConfig: {
  315. extraPlugins: CKEDITOR.ClassicEditor.builtinPlugins.filter( plugin => {
  316. // Use e.g. Ctrl+B in the comments editor to bold text.
  317. return [ 'Bold', 'Italic', 'Underline', 'List', 'Autoformat', 'Mention' ].includes( plugin.pluginName );
  318. } ),
  319. // Combine mentions + Webhooks to notify users about new comments
  320. // https://ckeditor.com/docs/cs/latest/guides/webhooks/events.html
  321. mention: {
  322. feeds: [
  323. {
  324. marker: '@',
  325. feed: [
  326. '@Baby Doe', '@Joe Doe', '@Jane Doe', '@Jane Roe', '@Richard Roe'
  327. ],
  328. minimumCharacters: 1
  329. }
  330. ]
  331. },
  332. }
  333. }, */
  334. // Do not include revision history configuration if you do not want to integrate it.
  335. // Remember to remove the 'revisionHistory' button from the toolbar in such a case.
  336. /* revisionHistory: {
  337. editorContainer: document.querySelector( '#editor-container' ),
  338. viewerContainer: document.querySelector( '#revision-viewer-container' ),
  339. viewerEditorElement: document.querySelector( '#revision-viewer-editor' ),
  340. viewerSidebarContainer: document.querySelector( '#revision-viewer-sidebar' ),
  341. }, */
  342. // https://ckeditor.com/docs/ckeditor5/latest/features/images/image-upload/ckbox.html
  343. ckbox: {
  344. // Be careful - do not use the development token endpoint on production systems!
  345. tokenUrl: 'https://95909.cke-cs.com/token/dev/31dad7RDKRwJrbhYZUOta7rT67FW5j53zqFh?limit=10'
  346. },
  347. // License key is required only by the Pagination plugin and non-realtime Comments/Track changes.
  348. licenseKey: 'R6gmTn3ENgbwV0S8ykY5ECgcDEA+WXk+Ykv/bsGF4gRDWQ2wVNfaJHW50w==',
  349. removePlugins: [
  350. // Before enabling Pagination plugin, make sure to provide proper configuration and add relevant buttons to the toolbar
  351. // https://ckeditor.com/docs/ckeditor5/latest/features/pagination/pagination.html
  352. 'Pagination',
  353. // Intentionally disabled, file uploads are handled by CKBox
  354. 'Base64UploadAdapter',
  355. // Intentionally disabled, file uploads are handled by CKBox
  356. 'CKFinder',
  357. // Intentionally disabled, file uploads are handled by CKBox
  358. 'EasyImage',
  359. // Requires additional license key
  360. 'WProofreader',
  361. // Incompatible with real-time collaboration
  362. 'SourceEditing',
  363. // Careful, with the Mathtype plugin CKEditor will not load when loading this sample
  364. // from a local file system (file://) - load this site via HTTP server if you enable MathType
  365. 'MathType',
  366. // If you would like to adjust enabled collaboration features:
  367. 'RealTimeCollaborativeComments',
  368. 'RealTimeCollaborativeTrackChanges',
  369. 'RealTimeCollaborativeRevisionHistory',
  370. 'PresenceList',
  371. 'Comments',
  372. 'TrackChanges',
  373. 'TrackChangesData',
  374. 'RevisionHistory'
  375. ]
  376. } )
  377. .then( editor => {
  378. window.editor = editor;
  379. // Example implementation to switch between different types of annotations according to the window size.
  380. // https://ckeditor.com/docs/ckeditor5/latest/features/collaboration/annotations/annotations-display-mode.html
  381. /* const annotationsUIs = editor.plugins.get( 'AnnotationsUIs' );
  382. const sidebarElement = document.querySelector( '.sidebar' );
  383. let currentWidth;
  384. function refreshDisplayMode() {
  385. // Check the window width to avoid the UI switching when the mobile keyboard shows up.
  386. if ( window.innerWidth === currentWidth ) {
  387. return;
  388. }
  389. currentWidth = window.innerWidth;
  390. if ( currentWidth < 1000 ) {
  391. sidebarElement.classList.remove( 'narrow' );
  392. sidebarElement.classList.add( 'hidden' );
  393. annotationsUIs.switchTo( 'inline' );
  394. }
  395. else if ( currentWidth < 1300 ) {
  396. sidebarElement.classList.remove( 'hidden' );
  397. sidebarElement.classList.add( 'narrow' );
  398. annotationsUIs.switchTo( 'narrowSidebar' );
  399. }
  400. else {
  401. sidebarElement.classList.remove( 'hidden', 'narrow' );
  402. annotationsUIs.switchTo( 'wideSidebar' );
  403. }
  404. }
  405. editor.ui.view.listenTo( window, 'resize', refreshDisplayMode );
  406. refreshDisplayMode(); */
  407. const toolbarContainer = document.querySelector( '.document-editor__toolbar' );
  408. toolbarContainer.appendChild( editor.ui.view.toolbar.element );
  409. return editor;
  410. } )
  411. .catch( error => {
  412. console.error( 'There was a problem initializing the editor.', error );
  413. } );
  414. </script>
  415. </body>
  416. </html>