mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Use CKEditor 5 for description editing.
This commit is contained in:
parent
a4f07e9b82
commit
63b7e0458c
11 changed files with 527 additions and 75 deletions
190
assets/ckeditor/html_full.js
Normal file
190
assets/ckeditor/html_full.js
Normal file
|
@ -0,0 +1,190 @@
|
|||
/**
|
||||
* @license Copyright (c) 2014-2022, CKSource Holding sp. z o.o. All rights reserved.
|
||||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
||||
*/
|
||||
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor.js';
|
||||
import Alignment from '@ckeditor/ckeditor5-alignment/src/alignment.js';
|
||||
import Autoformat from '@ckeditor/ckeditor5-autoformat/src/autoformat.js';
|
||||
import Base64UploadAdapter from '@ckeditor/ckeditor5-upload/src/adapters/base64uploadadapter.js';
|
||||
import BlockQuote from '@ckeditor/ckeditor5-block-quote/src/blockquote.js';
|
||||
import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold.js';
|
||||
import Code from '@ckeditor/ckeditor5-basic-styles/src/code.js';
|
||||
import CodeBlock from '@ckeditor/ckeditor5-code-block/src/codeblock.js';
|
||||
import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials.js';
|
||||
import FindAndReplace from '@ckeditor/ckeditor5-find-and-replace/src/findandreplace.js';
|
||||
import FontBackgroundColor from '@ckeditor/ckeditor5-font/src/fontbackgroundcolor.js';
|
||||
import FontColor from '@ckeditor/ckeditor5-font/src/fontcolor.js';
|
||||
import FontFamily from '@ckeditor/ckeditor5-font/src/fontfamily.js';
|
||||
import FontSize from '@ckeditor/ckeditor5-font/src/fontsize.js';
|
||||
import GeneralHtmlSupport from '@ckeditor/ckeditor5-html-support/src/generalhtmlsupport.js';
|
||||
import Heading from '@ckeditor/ckeditor5-heading/src/heading.js';
|
||||
import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight.js';
|
||||
import HorizontalLine from '@ckeditor/ckeditor5-horizontal-line/src/horizontalline.js';
|
||||
import HtmlComment from '@ckeditor/ckeditor5-html-support/src/htmlcomment.js';
|
||||
import HtmlEmbed from '@ckeditor/ckeditor5-html-embed/src/htmlembed.js';
|
||||
import Image from '@ckeditor/ckeditor5-image/src/image.js';
|
||||
import ImageResize from '@ckeditor/ckeditor5-image/src/imageresize.js';
|
||||
import ImageStyle from '@ckeditor/ckeditor5-image/src/imagestyle.js';
|
||||
import ImageToolbar from '@ckeditor/ckeditor5-image/src/imagetoolbar.js';
|
||||
import ImageUpload from '@ckeditor/ckeditor5-image/src/imageupload.js';
|
||||
import Indent from '@ckeditor/ckeditor5-indent/src/indent.js';
|
||||
import IndentBlock from '@ckeditor/ckeditor5-indent/src/indentblock.js';
|
||||
import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic.js';
|
||||
import Link from '@ckeditor/ckeditor5-link/src/link.js';
|
||||
import LinkImage from '@ckeditor/ckeditor5-link/src/linkimage.js';
|
||||
import List from '@ckeditor/ckeditor5-list/src/list.js';
|
||||
import ListProperties from '@ckeditor/ckeditor5-list/src/listproperties.js';
|
||||
import Markdown from '@ckeditor/ckeditor5-markdown-gfm/src/markdown.js';
|
||||
import MediaEmbed from '@ckeditor/ckeditor5-media-embed/src/mediaembed.js';
|
||||
import MediaEmbedToolbar from '@ckeditor/ckeditor5-media-embed/src/mediaembedtoolbar.js';
|
||||
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph.js';
|
||||
import PasteFromOffice from '@ckeditor/ckeditor5-paste-from-office/src/pastefromoffice.js';
|
||||
import RemoveFormat from '@ckeditor/ckeditor5-remove-format/src/removeformat.js';
|
||||
import SourceEditing from '@ckeditor/ckeditor5-source-editing/src/sourceediting.js';
|
||||
import SpecialCharacters from '@ckeditor/ckeditor5-special-characters/src/specialcharacters.js';
|
||||
import SpecialCharactersArrows from '@ckeditor/ckeditor5-special-characters/src/specialcharactersarrows.js';
|
||||
import SpecialCharactersCurrency from '@ckeditor/ckeditor5-special-characters/src/specialcharacterscurrency.js';
|
||||
import SpecialCharactersEssentials from '@ckeditor/ckeditor5-special-characters/src/specialcharactersessentials.js';
|
||||
import SpecialCharactersLatin from '@ckeditor/ckeditor5-special-characters/src/specialcharacterslatin.js';
|
||||
import SpecialCharactersMathematical from '@ckeditor/ckeditor5-special-characters/src/specialcharactersmathematical.js';
|
||||
import SpecialCharactersText from '@ckeditor/ckeditor5-special-characters/src/specialcharacterstext.js';
|
||||
import Strikethrough from '@ckeditor/ckeditor5-basic-styles/src/strikethrough.js';
|
||||
import Subscript from '@ckeditor/ckeditor5-basic-styles/src/subscript.js';
|
||||
import Superscript from '@ckeditor/ckeditor5-basic-styles/src/superscript.js';
|
||||
import Table from '@ckeditor/ckeditor5-table/src/table.js';
|
||||
import TableCaption from '@ckeditor/ckeditor5-table/src/tablecaption.js';
|
||||
import TableCellProperties from '@ckeditor/ckeditor5-table/src/tablecellproperties';
|
||||
import TableColumnResize from '@ckeditor/ckeditor5-table/src/tablecolumnresize.js';
|
||||
import TableProperties from '@ckeditor/ckeditor5-table/src/tableproperties';
|
||||
import TableToolbar from '@ckeditor/ckeditor5-table/src/tabletoolbar.js';
|
||||
import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline.js';
|
||||
import WordCount from '@ckeditor/ckeditor5-word-count/src/wordcount.js';
|
||||
import EditorWatchdog from '@ckeditor/ckeditor5-watchdog/src/editorwatchdog.js';
|
||||
|
||||
class Editor extends ClassicEditor {}
|
||||
|
||||
// Plugins to include in the build.
|
||||
Editor.builtinPlugins = [
|
||||
Alignment,
|
||||
Autoformat,
|
||||
Base64UploadAdapter,
|
||||
BlockQuote,
|
||||
Bold,
|
||||
Code,
|
||||
CodeBlock,
|
||||
Essentials,
|
||||
FindAndReplace,
|
||||
FontBackgroundColor,
|
||||
FontColor,
|
||||
FontFamily,
|
||||
FontSize,
|
||||
GeneralHtmlSupport,
|
||||
Heading,
|
||||
Highlight,
|
||||
HorizontalLine,
|
||||
HtmlComment,
|
||||
HtmlEmbed,
|
||||
Image,
|
||||
ImageResize,
|
||||
ImageStyle,
|
||||
ImageToolbar,
|
||||
ImageUpload,
|
||||
Indent,
|
||||
IndentBlock,
|
||||
Italic,
|
||||
Link,
|
||||
LinkImage,
|
||||
List,
|
||||
ListProperties,
|
||||
MediaEmbed,
|
||||
MediaEmbedToolbar,
|
||||
Paragraph,
|
||||
PasteFromOffice,
|
||||
RemoveFormat,
|
||||
SourceEditing,
|
||||
SpecialCharacters,
|
||||
SpecialCharactersArrows,
|
||||
SpecialCharactersCurrency,
|
||||
SpecialCharactersEssentials,
|
||||
SpecialCharactersLatin,
|
||||
SpecialCharactersMathematical,
|
||||
SpecialCharactersText,
|
||||
Strikethrough,
|
||||
Subscript,
|
||||
Superscript,
|
||||
Table,
|
||||
TableCaption,
|
||||
TableCellProperties,
|
||||
TableColumnResize,
|
||||
TableProperties,
|
||||
TableToolbar,
|
||||
Underline,
|
||||
WordCount
|
||||
];
|
||||
|
||||
// Editor configuration.
|
||||
Editor.defaultConfig = {
|
||||
toolbar: {
|
||||
items: [
|
||||
'heading',
|
||||
'alignment',
|
||||
'|',
|
||||
'bold',
|
||||
'italic',
|
||||
'underline',
|
||||
'strikethrough',
|
||||
'subscript',
|
||||
'superscript',
|
||||
'removeFormat',
|
||||
'highlight',
|
||||
'|',
|
||||
'fontBackgroundColor',
|
||||
'fontColor',
|
||||
'fontSize',
|
||||
'|',
|
||||
'fontFamily',
|
||||
'link',
|
||||
'bulletedList',
|
||||
'numberedList',
|
||||
'outdent',
|
||||
'indent',
|
||||
'|',
|
||||
'specialCharacters',
|
||||
'horizontalLine',
|
||||
'|',
|
||||
'imageUpload',
|
||||
'blockQuote',
|
||||
'insertTable',
|
||||
'mediaEmbed',
|
||||
'code',
|
||||
'codeBlock',
|
||||
'htmlEmbed',
|
||||
'|',
|
||||
'undo',
|
||||
'redo',
|
||||
'findAndReplace',
|
||||
'sourceEditing',
|
||||
]
|
||||
},
|
||||
language: 'en',
|
||||
image: {
|
||||
toolbar: [
|
||||
'imageTextAlternative',
|
||||
'imageStyle:inline',
|
||||
'imageStyle:block',
|
||||
'imageStyle:side',
|
||||
'linkImage'
|
||||
]
|
||||
},
|
||||
table: {
|
||||
contentToolbar: [
|
||||
'tableColumn',
|
||||
'tableRow',
|
||||
'mergeTableCells',
|
||||
'tableCellProperties',
|
||||
'tableProperties'
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
export default { Editor, EditorWatchdog };
|
|
@ -3,67 +3,126 @@
|
|||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
||||
*/
|
||||
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor.js';
|
||||
import Alignment from '@ckeditor/ckeditor5-alignment/src/alignment.js';
|
||||
import Autoformat from '@ckeditor/ckeditor5-autoformat/src/autoformat.js';
|
||||
import Base64UploadAdapter from '@ckeditor/ckeditor5-upload/src/adapters/base64uploadadapter.js';
|
||||
import BlockQuote from '@ckeditor/ckeditor5-block-quote/src/blockquote.js';
|
||||
import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold.js';
|
||||
import Code from '@ckeditor/ckeditor5-basic-styles/src/code.js';
|
||||
import CodeBlock from '@ckeditor/ckeditor5-code-block/src/codeblock.js';
|
||||
import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials.js';
|
||||
import FindAndReplace from '@ckeditor/ckeditor5-find-and-replace/src/findandreplace.js';
|
||||
import FontBackgroundColor from '@ckeditor/ckeditor5-font/src/fontbackgroundcolor.js';
|
||||
import FontColor from '@ckeditor/ckeditor5-font/src/fontcolor.js';
|
||||
import FontFamily from '@ckeditor/ckeditor5-font/src/fontfamily.js';
|
||||
import FontSize from '@ckeditor/ckeditor5-font/src/fontsize.js';
|
||||
import GeneralHtmlSupport from '@ckeditor/ckeditor5-html-support/src/generalhtmlsupport.js';
|
||||
import Heading from '@ckeditor/ckeditor5-heading/src/heading.js';
|
||||
import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight.js';
|
||||
import HorizontalLine from '@ckeditor/ckeditor5-horizontal-line/src/horizontalline.js';
|
||||
import HtmlComment from '@ckeditor/ckeditor5-html-support/src/htmlcomment.js';
|
||||
import HtmlEmbed from '@ckeditor/ckeditor5-html-embed/src/htmlembed.js';
|
||||
import Image from '@ckeditor/ckeditor5-image/src/image.js';
|
||||
import ImageResize from '@ckeditor/ckeditor5-image/src/imageresize.js';
|
||||
import ImageStyle from '@ckeditor/ckeditor5-image/src/imagestyle.js';
|
||||
import ImageToolbar from '@ckeditor/ckeditor5-image/src/imagetoolbar.js';
|
||||
import ImageUpload from '@ckeditor/ckeditor5-image/src/imageupload.js';
|
||||
import Indent from '@ckeditor/ckeditor5-indent/src/indent.js';
|
||||
import IndentBlock from '@ckeditor/ckeditor5-indent/src/indentblock.js';
|
||||
import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic.js';
|
||||
import Link from '@ckeditor/ckeditor5-link/src/link.js';
|
||||
import LinkImage from '@ckeditor/ckeditor5-link/src/linkimage.js';
|
||||
import List from '@ckeditor/ckeditor5-list/src/list.js';
|
||||
import ListProperties from '@ckeditor/ckeditor5-list/src/listproperties.js';
|
||||
import Markdown from '@ckeditor/ckeditor5-markdown-gfm/src/markdown.js';
|
||||
import MediaEmbed from '@ckeditor/ckeditor5-media-embed/src/mediaembed.js';
|
||||
import MediaEmbedToolbar from '@ckeditor/ckeditor5-media-embed/src/mediaembedtoolbar.js';
|
||||
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph.js';
|
||||
import PasteFromOffice from '@ckeditor/ckeditor5-paste-from-office/src/pastefromoffice.js';
|
||||
import RemoveFormat from '@ckeditor/ckeditor5-remove-format/src/removeformat.js';
|
||||
import SourceEditing from '@ckeditor/ckeditor5-source-editing/src/sourceediting.js';
|
||||
import SpecialCharacters from '@ckeditor/ckeditor5-special-characters/src/specialcharacters.js';
|
||||
import SpecialCharactersArrows from '@ckeditor/ckeditor5-special-characters/src/specialcharactersarrows.js';
|
||||
import SpecialCharactersCurrency from '@ckeditor/ckeditor5-special-characters/src/specialcharacterscurrency.js';
|
||||
import SpecialCharactersEssentials from '@ckeditor/ckeditor5-special-characters/src/specialcharactersessentials.js';
|
||||
import SpecialCharactersLatin from '@ckeditor/ckeditor5-special-characters/src/specialcharacterslatin.js';
|
||||
import SpecialCharactersMathematical from '@ckeditor/ckeditor5-special-characters/src/specialcharactersmathematical.js';
|
||||
import SpecialCharactersText from '@ckeditor/ckeditor5-special-characters/src/specialcharacterstext.js';
|
||||
import Strikethrough from '@ckeditor/ckeditor5-basic-styles/src/strikethrough.js';
|
||||
import Subscript from '@ckeditor/ckeditor5-basic-styles/src/subscript.js';
|
||||
import Superscript from '@ckeditor/ckeditor5-basic-styles/src/superscript.js';
|
||||
import Table from '@ckeditor/ckeditor5-table/src/table.js';
|
||||
import TableCaption from '@ckeditor/ckeditor5-table/src/tablecaption.js';
|
||||
import TableCellProperties from '@ckeditor/ckeditor5-table/src/tablecellproperties';
|
||||
import TableColumnResize from '@ckeditor/ckeditor5-table/src/tablecolumnresize.js';
|
||||
import TableProperties from '@ckeditor/ckeditor5-table/src/tableproperties';
|
||||
import TableToolbar from '@ckeditor/ckeditor5-table/src/tabletoolbar.js';
|
||||
import TextTransformation from '@ckeditor/ckeditor5-typing/src/texttransformation.js';
|
||||
import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline.js';
|
||||
import WordCount from '@ckeditor/ckeditor5-word-count/src/wordcount.js';
|
||||
import EditorWatchdog from '@ckeditor/ckeditor5-watchdog/src/editorwatchdog.js';
|
||||
|
||||
import ExtendedMarkdown from "./plugins/extendedmarkdown.js";
|
||||
|
||||
class Editor extends ClassicEditor {}
|
||||
|
||||
// Plugins to include in the build.
|
||||
Editor.builtinPlugins = [
|
||||
Alignment,
|
||||
Autoformat,
|
||||
Base64UploadAdapter,
|
||||
BlockQuote,
|
||||
Bold,
|
||||
Code,
|
||||
CodeBlock,
|
||||
Essentials,
|
||||
FindAndReplace,
|
||||
FontBackgroundColor,
|
||||
FontColor,
|
||||
FontFamily,
|
||||
FontSize,
|
||||
GeneralHtmlSupport,
|
||||
Heading,
|
||||
Highlight,
|
||||
HorizontalLine,
|
||||
HtmlComment,
|
||||
HtmlEmbed,
|
||||
Image,
|
||||
ImageResize,
|
||||
ImageStyle,
|
||||
ImageToolbar,
|
||||
ImageUpload,
|
||||
Indent,
|
||||
IndentBlock,
|
||||
Italic,
|
||||
Link,
|
||||
LinkImage,
|
||||
List,
|
||||
Markdown,
|
||||
MediaEmbed,
|
||||
ListProperties,
|
||||
//MediaEmbed,
|
||||
//MediaEmbedToolbar,
|
||||
Paragraph,
|
||||
PasteFromOffice,
|
||||
RemoveFormat,
|
||||
SourceEditing,
|
||||
SpecialCharacters,
|
||||
SpecialCharactersArrows,
|
||||
SpecialCharactersCurrency,
|
||||
SpecialCharactersEssentials,
|
||||
SpecialCharactersLatin,
|
||||
SpecialCharactersMathematical,
|
||||
SpecialCharactersText,
|
||||
Strikethrough,
|
||||
Subscript,
|
||||
Superscript,
|
||||
Table,
|
||||
TableCaption,
|
||||
TableCellProperties,
|
||||
TableColumnResize,
|
||||
TableProperties,
|
||||
TableToolbar,
|
||||
TextTransformation
|
||||
Underline,
|
||||
WordCount,
|
||||
ExtendedMarkdown
|
||||
];
|
||||
|
||||
// Editor configuration.
|
||||
|
@ -71,27 +130,43 @@ Editor.defaultConfig = {
|
|||
toolbar: {
|
||||
items: [
|
||||
'heading',
|
||||
'alignment',
|
||||
'|',
|
||||
'bold',
|
||||
'italic',
|
||||
'underline',
|
||||
'strikethrough',
|
||||
'subscript',
|
||||
'superscript',
|
||||
'removeFormat',
|
||||
'highlight',
|
||||
'|',
|
||||
'fontBackgroundColor',
|
||||
'fontColor',
|
||||
'fontSize',
|
||||
'|',
|
||||
'fontFamily',
|
||||
'link',
|
||||
'bulletedList',
|
||||
'numberedList',
|
||||
'|',
|
||||
'outdent',
|
||||
'indent',
|
||||
'|',
|
||||
'specialCharacters',
|
||||
'horizontalLine',
|
||||
'|',
|
||||
'imageUpload',
|
||||
'blockQuote',
|
||||
'insertTable',
|
||||
'mediaEmbed',
|
||||
'undo',
|
||||
'redo',
|
||||
'specialCharacters',
|
||||
//'mediaEmbed',
|
||||
'code',
|
||||
'codeBlock',
|
||||
'htmlEmbed',
|
||||
'|',
|
||||
'undo',
|
||||
'redo',
|
||||
'findAndReplace',
|
||||
'sourceEditing',
|
||||
'findAndReplace'
|
||||
]
|
||||
},
|
||||
language: 'en',
|
||||
|
@ -100,16 +175,19 @@ Editor.defaultConfig = {
|
|||
'imageTextAlternative',
|
||||
'imageStyle:inline',
|
||||
'imageStyle:block',
|
||||
'imageStyle:side'
|
||||
'imageStyle:side',
|
||||
'linkImage'
|
||||
]
|
||||
},
|
||||
table: {
|
||||
contentToolbar: [
|
||||
'tableColumn',
|
||||
'tableRow',
|
||||
'mergeTableCells'
|
||||
'mergeTableCells',
|
||||
'tableCellProperties',
|
||||
'tableProperties'
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
export default Editor;
|
||||
export default { Editor, EditorWatchdog };
|
||||
|
|
|
@ -4,66 +4,63 @@
|
|||
*/
|
||||
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor.js';
|
||||
import Autoformat from '@ckeditor/ckeditor5-autoformat/src/autoformat.js';
|
||||
import BlockQuote from '@ckeditor/ckeditor5-block-quote/src/blockquote.js';
|
||||
import AutoLink from '@ckeditor/ckeditor5-link/src/autolink.js';
|
||||
import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold.js';
|
||||
import Code from '@ckeditor/ckeditor5-basic-styles/src/code.js';
|
||||
import CodeBlock from '@ckeditor/ckeditor5-code-block/src/codeblock.js';
|
||||
import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials.js';
|
||||
import FindAndReplace from '@ckeditor/ckeditor5-find-and-replace/src/findandreplace.js';
|
||||
import GeneralHtmlSupport from '@ckeditor/ckeditor5-html-support/src/generalhtmlsupport.js';
|
||||
import Heading from '@ckeditor/ckeditor5-heading/src/heading.js';
|
||||
import Image from '@ckeditor/ckeditor5-image/src/image.js';
|
||||
import ImageStyle from '@ckeditor/ckeditor5-image/src/imagestyle.js';
|
||||
import ImageToolbar from '@ckeditor/ckeditor5-image/src/imagetoolbar.js';
|
||||
import ImageUpload from '@ckeditor/ckeditor5-image/src/imageupload.js';
|
||||
import Indent from '@ckeditor/ckeditor5-indent/src/indent.js';
|
||||
import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight.js';
|
||||
import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic.js';
|
||||
import Link from '@ckeditor/ckeditor5-link/src/link.js';
|
||||
import List from '@ckeditor/ckeditor5-list/src/list.js';
|
||||
import Markdown from '@ckeditor/ckeditor5-markdown-gfm/src/markdown.js';
|
||||
import MediaEmbed from '@ckeditor/ckeditor5-media-embed/src/mediaembed.js';
|
||||
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph.js';
|
||||
import PasteFromOffice from '@ckeditor/ckeditor5-paste-from-office/src/pastefromoffice.js';
|
||||
import RemoveFormat from '@ckeditor/ckeditor5-remove-format/src/removeformat.js';
|
||||
import SourceEditing from '@ckeditor/ckeditor5-source-editing/src/sourceediting.js';
|
||||
import SpecialCharacters from '@ckeditor/ckeditor5-special-characters/src/specialcharacters.js';
|
||||
import SpecialCharactersArrows from '@ckeditor/ckeditor5-special-characters/src/specialcharactersarrows.js';
|
||||
import SpecialCharactersCurrency from '@ckeditor/ckeditor5-special-characters/src/specialcharacterscurrency.js';
|
||||
import SpecialCharactersEssentials from '@ckeditor/ckeditor5-special-characters/src/specialcharactersessentials.js';
|
||||
import SpecialCharactersLatin from '@ckeditor/ckeditor5-special-characters/src/specialcharacterslatin.js';
|
||||
import SpecialCharactersMathematical from '@ckeditor/ckeditor5-special-characters/src/specialcharactersmathematical.js';
|
||||
import Table from '@ckeditor/ckeditor5-table/src/table.js';
|
||||
import TableToolbar from '@ckeditor/ckeditor5-table/src/tabletoolbar.js';
|
||||
import TextTransformation from '@ckeditor/ckeditor5-typing/src/texttransformation.js';
|
||||
import SpecialCharactersText from '@ckeditor/ckeditor5-special-characters/src/specialcharacterstext.js';
|
||||
import Strikethrough from '@ckeditor/ckeditor5-basic-styles/src/strikethrough.js';
|
||||
import Subscript from '@ckeditor/ckeditor5-basic-styles/src/subscript.js';
|
||||
import Superscript from '@ckeditor/ckeditor5-basic-styles/src/superscript.js';
|
||||
import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline.js';
|
||||
import EditorWatchdog from '@ckeditor/ckeditor5-watchdog/src/editorwatchdog.js';
|
||||
|
||||
import ExtendedMarkdownInline from "./plugins/extendedMarkdownInline";
|
||||
import SingleLinePlugin from "./plugins/singleLine";
|
||||
|
||||
class Editor extends ClassicEditor {}
|
||||
|
||||
// Plugins to include in the build.
|
||||
Editor.builtinPlugins = [
|
||||
Autoformat,
|
||||
BlockQuote,
|
||||
AutoLink,
|
||||
Bold,
|
||||
Code,
|
||||
CodeBlock,
|
||||
Essentials,
|
||||
FindAndReplace,
|
||||
GeneralHtmlSupport,
|
||||
Heading,
|
||||
Image,
|
||||
ImageStyle,
|
||||
ImageToolbar,
|
||||
ImageUpload,
|
||||
Indent,
|
||||
Highlight,
|
||||
Italic,
|
||||
Link,
|
||||
List,
|
||||
Markdown,
|
||||
MediaEmbed,
|
||||
Paragraph,
|
||||
PasteFromOffice,
|
||||
RemoveFormat,
|
||||
SourceEditing,
|
||||
SpecialCharacters,
|
||||
SpecialCharactersArrows,
|
||||
SpecialCharactersCurrency,
|
||||
SpecialCharactersEssentials,
|
||||
SpecialCharactersLatin,
|
||||
SpecialCharactersMathematical,
|
||||
Table,
|
||||
TableToolbar,
|
||||
TextTransformation
|
||||
SpecialCharactersText,
|
||||
Strikethrough,
|
||||
Subscript,
|
||||
Superscript,
|
||||
Underline,
|
||||
Essentials,
|
||||
|
||||
ExtendedMarkdownInline,
|
||||
SingleLinePlugin,
|
||||
];
|
||||
|
||||
// Editor configuration.
|
||||
|
@ -72,33 +69,24 @@ Editor.defaultConfig = {
|
|||
items: [
|
||||
'bold',
|
||||
'italic',
|
||||
'underline',
|
||||
'strikethrough',
|
||||
'subscript',
|
||||
'superscript',
|
||||
'removeFormat',
|
||||
'highlight',
|
||||
'|',
|
||||
'link',
|
||||
'specialCharacters',
|
||||
'code',
|
||||
'specialCharacters',
|
||||
'|',
|
||||
'undo',
|
||||
'redo',
|
||||
'|',
|
||||
'findAndReplace',
|
||||
'sourceEditing',
|
||||
'sourceEditing'
|
||||
]
|
||||
},
|
||||
language: 'en',
|
||||
image: {
|
||||
toolbar: [
|
||||
'imageTextAlternative',
|
||||
'imageStyle:inline',
|
||||
'imageStyle:block',
|
||||
'imageStyle:side'
|
||||
]
|
||||
},
|
||||
table: {
|
||||
contentToolbar: [
|
||||
'tableColumn',
|
||||
'tableRow',
|
||||
'mergeTableCells'
|
||||
]
|
||||
}
|
||||
language: 'en'
|
||||
};
|
||||
|
||||
export default Editor;
|
||||
export default { Editor, EditorWatchdog };
|
||||
|
|
34
assets/ckeditor/plugins/extendedMarkdown.js
Normal file
34
assets/ckeditor/plugins/extendedMarkdown.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { Plugin } from 'ckeditor5/src/core';
|
||||
import GFMDataProcessor from '@ckeditor/ckeditor5-markdown-gfm/src/gfmdataprocessor';
|
||||
|
||||
const ALLOWED_TAGS = [
|
||||
//Common elements
|
||||
'sup',
|
||||
'sub',
|
||||
];
|
||||
|
||||
/**
|
||||
* The GitHub Flavored Markdown (GFM) plugin with added HTML tags, which are kept in the output. (inline mode)
|
||||
*
|
||||
*/
|
||||
export default class ExtendedMarkdown extends Plugin {
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
constructor( editor ) {
|
||||
super( editor );
|
||||
|
||||
editor.data.processor = new GFMDataProcessor( editor.data.viewDocument );
|
||||
for (const tag of ALLOWED_TAGS) {
|
||||
editor.data.processor.keepHtml(tag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
static get pluginName() {
|
||||
return 'Markdown';
|
||||
}
|
||||
}
|
40
assets/ckeditor/plugins/extendedMarkdownInline.js
Normal file
40
assets/ckeditor/plugins/extendedMarkdownInline.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { Plugin } from 'ckeditor5/src/core';
|
||||
import GFMDataProcessor from '@ckeditor/ckeditor5-markdown-gfm/src/gfmdataprocessor';
|
||||
|
||||
const ALLOWED_TAGS = [
|
||||
//Common elements
|
||||
'sup',
|
||||
'sub',
|
||||
'u',
|
||||
'kbd',
|
||||
'mark',
|
||||
'ins',
|
||||
'small',
|
||||
'abbr',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* The GitHub Flavored Markdown (GFM) plugin with added HTML tags, which are kept in the output. (inline mode)
|
||||
*
|
||||
*/
|
||||
export default class ExtendedMarkdownInline extends Plugin {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
constructor( editor ) {
|
||||
super( editor );
|
||||
|
||||
editor.data.processor = new GFMDataProcessor( editor.data.viewDocument );
|
||||
for (const tag of ALLOWED_TAGS) {
|
||||
editor.data.processor.keepHtml(tag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
static get pluginName() {
|
||||
return 'Markdown';
|
||||
}
|
||||
}
|
29
assets/ckeditor/plugins/singleLine.js
Normal file
29
assets/ckeditor/plugins/singleLine.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
||||
|
||||
export default class SingleLinePlugin extends Plugin {
|
||||
init() {
|
||||
const editor = this.editor;
|
||||
const view = editor.editing.view;
|
||||
const viewDocument = view.document;
|
||||
|
||||
//Listen to enter presses
|
||||
this.listenTo( viewDocument, 'enter', ( evt, data ) => {
|
||||
//If user presses enter, prevent the enter action
|
||||
evt.stop();
|
||||
}, { priority: 'high' } );
|
||||
|
||||
//And clipboard pastes
|
||||
this.listenTo( viewDocument, 'clipboardInput', ( evt, data ) => {
|
||||
let dataTransfer = data.dataTransfer;
|
||||
|
||||
//Clean text input (replace newlines with spaces)
|
||||
let input = dataTransfer.getData("text");
|
||||
let cleaned = input.replace(/\r?\n/g, ' ');
|
||||
|
||||
//We can not use the dataTransfer.setData method because the old object is somehow protected
|
||||
data.dataTransfer = new DataTransfer();
|
||||
data.dataTransfer.setData("text", cleaned);
|
||||
|
||||
}, { priority: 'high' } );
|
||||
}
|
||||
}
|
|
@ -2,6 +2,10 @@ import {Controller} from "@hotwired/stimulus";
|
|||
|
||||
import { default as FullEditor } from "../../ckeditor/markdown_full";
|
||||
import { default as SingleLineEditor} from "../../ckeditor/markdown_single_line";
|
||||
import { default as HTMLEditor } from "../../ckeditor/html_full";
|
||||
|
||||
import EditorWatchdog from '@ckeditor/ckeditor5-watchdog/src/editorwatchdog';
|
||||
|
||||
|
||||
/* stimulusFetch: 'lazy' */
|
||||
export default class extends Controller {
|
||||
|
@ -13,23 +17,46 @@ export default class extends Controller {
|
|||
|
||||
if(output_format == 'markdown') {
|
||||
if(mode == 'full') {
|
||||
EDITOR_TYPE = FullEditor;
|
||||
EDITOR_TYPE = FullEditor['Editor'];
|
||||
} else if(mode == 'single_line') {
|
||||
EDITOR_TYPE = SingleLineEditor;
|
||||
EDITOR_TYPE = SingleLineEditor['Editor'];
|
||||
}
|
||||
} else if(output_format == 'html') {
|
||||
EDITOR_TYPE = HTMLEditor['Editor'];
|
||||
} else {
|
||||
console.error("Unknown output format: " + output-format);
|
||||
return;
|
||||
}
|
||||
|
||||
this.editor = EDITOR_TYPE.create(this.element, {
|
||||
|
||||
})
|
||||
EDITOR_TYPE.create(this.element)
|
||||
.then(editor => {
|
||||
if(this.element.disabled) {
|
||||
editor.enableReadOnlyMode("readonly");
|
||||
}
|
||||
|
||||
console.log(editor);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
/* const watchdog = new EditorWatchdog();
|
||||
watchdog.setCreator((elementOrData, editorConfig) => {
|
||||
return EDITOR_TYPE.create(elementOrData, editorConfig)
|
||||
.then(editor => {
|
||||
if(this.element.disabled) {
|
||||
editor.enableReadOnlyMode("readonly");
|
||||
}
|
||||
|
||||
console.log(editor);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
});
|
||||
|
||||
watchdog.create(this.element, {
|
||||
|
||||
});*/
|
||||
}
|
||||
}
|
10
package.json
10
package.json
|
@ -24,6 +24,7 @@
|
|||
"build": "encore production --progress"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ckeditor/ckeditor5-alignment": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-autoformat": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-basic-styles": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-block-quote": "^34.2.0",
|
||||
|
@ -33,7 +34,11 @@
|
|||
"@ckeditor/ckeditor5-editor-classic": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-essentials": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-find-and-replace": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-font": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-heading": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-highlight": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-horizontal-line": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-html-embed": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-html-support": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-image": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-indent": "^34.2.0",
|
||||
|
@ -43,11 +48,14 @@
|
|||
"@ckeditor/ckeditor5-media-embed": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-paragraph": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-paste-from-office": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-remove-format": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-source-editing": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-special-characters": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-table": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-theme-lark": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-typing": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-upload": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-watchdog": "^34.2.0",
|
||||
"@ckeditor/ckeditor5-word-count": "^34.2.0",
|
||||
"@types/typeahead": "^0.11.32",
|
||||
"@zxing/library": "^0.19.1",
|
||||
"bootbox": "^5.4.0",
|
||||
|
|
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||
namespace App\Form;
|
||||
|
||||
use App\Entity\LabelSystem\LabelOptions;
|
||||
use App\Form\Type\RichTextEditorType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
@ -100,13 +101,13 @@ class LabelOptionsType extends AbstractType
|
|||
],
|
||||
]);
|
||||
|
||||
$builder->add('lines', CKEditorType::class, [
|
||||
$builder->add('lines', RichTextEditorType::class, [
|
||||
'label' => 'label_profile.lines.label',
|
||||
'empty_data' => '',
|
||||
'output_format' => 'html',
|
||||
'attr' => [
|
||||
'rows' => 4,
|
||||
],
|
||||
'config_name' => 'label_config',
|
||||
]);
|
||||
|
||||
$builder->add('additional_css', TextareaType::class, [
|
||||
|
|
|
@ -18,7 +18,7 @@ class RichTextEditorType extends AbstractType
|
|||
$resolver->setAllowedValues('mode', ['full', 'single_line']);
|
||||
|
||||
$resolver->setDefault('output_format', 'markdown');
|
||||
$resolver->setAllowedValues('output_format', ['markdown']);
|
||||
$resolver->setAllowedValues('output_format', ['markdown', 'html']);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
|
|
57
yarn.lock
57
yarn.lock
|
@ -898,6 +898,13 @@
|
|||
"@babel/helper-validator-identifier" "^7.18.6"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@ckeditor/ckeditor5-alignment@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-alignment/-/ckeditor5-alignment-34.2.0.tgz#e9a59d138c8f2c17d51c5cb71c5ebae4316ed424"
|
||||
integrity sha512-LpkTL67oaqB2ADLwBPXIFM2iqWSZnCG8OhEjjs7Piuyy7aUudShkbhKwqAhvb37b+MiGYCwuz/HnJlIWAD407Q==
|
||||
dependencies:
|
||||
ckeditor5 "^34.2.0"
|
||||
|
||||
"@ckeditor/ckeditor5-autoformat@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-autoformat/-/ckeditor5-autoformat-34.2.0.tgz#183c53922d47ed3dd5d4307f4c4339402c8b2500"
|
||||
|
@ -1030,6 +1037,13 @@
|
|||
ckeditor5 "^34.2.0"
|
||||
lodash-es "^4.17.15"
|
||||
|
||||
"@ckeditor/ckeditor5-font@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-font/-/ckeditor5-font-34.2.0.tgz#8fa3f440a888f33f8b3bccad22e806d753fa9048"
|
||||
integrity sha512-hSTxD0D+ad8yNsyM8a3SXvqes7oQah1PEcC3CG3jXmVnVjikWd+iAL959R2UnkJBSY5AZKgF3MCFC69pBIBdxQ==
|
||||
dependencies:
|
||||
ckeditor5 "^34.2.0"
|
||||
|
||||
"@ckeditor/ckeditor5-heading@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-heading/-/ckeditor5-heading-34.2.0.tgz#a935f5d2fe038bc0182f608fd751e283d5396705"
|
||||
|
@ -1037,6 +1051,27 @@
|
|||
dependencies:
|
||||
ckeditor5 "^34.2.0"
|
||||
|
||||
"@ckeditor/ckeditor5-highlight@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-highlight/-/ckeditor5-highlight-34.2.0.tgz#4872791b6cc0d67563f93f523a83ba0ad4907a62"
|
||||
integrity sha512-v194GQBYSm0jk39R4m0nC49Vg/1iX/HZjWeyP3fnmRzBsXxT+6u2oRsvYmxM1JGa/L1B80N94KrNiTrdvWUpsQ==
|
||||
dependencies:
|
||||
ckeditor5 "^34.2.0"
|
||||
|
||||
"@ckeditor/ckeditor5-horizontal-line@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-horizontal-line/-/ckeditor5-horizontal-line-34.2.0.tgz#8d4df63a48d6684b010e8c33334635b126602915"
|
||||
integrity sha512-BblqWFHOGB4fcKsHm6uH8gkvKA3+76hEBauovqOQLzgAvfC4zNpvcOVrt24hoF7b818Iisgea88eslljL4yX7A==
|
||||
dependencies:
|
||||
ckeditor5 "^34.2.0"
|
||||
|
||||
"@ckeditor/ckeditor5-html-embed@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-html-embed/-/ckeditor5-html-embed-34.2.0.tgz#9f113e62eeffe2554fc0de1fe4134dbf59038e97"
|
||||
integrity sha512-T6x8zKGbAwyzGDkILf4HQmHUiryAwMtmXykaCdfOw9w2abEtZAYJnGr9gvPnZcpyYXxIi3sEw9fPJmvNMub9jg==
|
||||
dependencies:
|
||||
ckeditor5 "^34.2.0"
|
||||
|
||||
"@ckeditor/ckeditor5-html-support@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-html-support/-/ckeditor5-html-support-34.2.0.tgz#d51350389ddcd18c939bbd60eb07aad997f71b2c"
|
||||
|
@ -1112,6 +1147,13 @@
|
|||
dependencies:
|
||||
ckeditor5 "^34.2.0"
|
||||
|
||||
"@ckeditor/ckeditor5-remove-format@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-remove-format/-/ckeditor5-remove-format-34.2.0.tgz#a61cb3ad3f5690deb87013f2f30a84347972b40d"
|
||||
integrity sha512-3eYXu5SUusnoqllEJnXN2mvtJW26W73ntNxEj+5JTdZ5TxvZurqSUJM00GQuDXdoyZN52SOFz980rgbszegMEg==
|
||||
dependencies:
|
||||
ckeditor5 "^34.2.0"
|
||||
|
||||
"@ckeditor/ckeditor5-select-all@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-select-all/-/ckeditor5-select-all-34.2.0.tgz#49ca1e239dda9d6045716ebd6707a4cf1a8a6203"
|
||||
|
@ -1195,6 +1237,13 @@
|
|||
dependencies:
|
||||
lodash-es "^4.17.15"
|
||||
|
||||
"@ckeditor/ckeditor5-watchdog@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-watchdog/-/ckeditor5-watchdog-34.2.0.tgz#f156c752ea8fc3107a1b94badc03376a22fdafb8"
|
||||
integrity sha512-Sz4nOdhy8C7n4ffi/OkkRQQFfTZUKZjSzeDis1+ooxxgj/4/+X8pAZszaz+LtG7+lqUyc7YfTtitMUqXivHhfA==
|
||||
dependencies:
|
||||
lodash-es "^4.17.15"
|
||||
|
||||
"@ckeditor/ckeditor5-widget@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-widget/-/ckeditor5-widget-34.2.0.tgz#0df140bc4c40287251cf5f5a970f616bdbd470e3"
|
||||
|
@ -1208,6 +1257,14 @@
|
|||
"@ckeditor/ckeditor5-utils" "^34.2.0"
|
||||
lodash-es "^4.17.15"
|
||||
|
||||
"@ckeditor/ckeditor5-word-count@^34.2.0":
|
||||
version "34.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-word-count/-/ckeditor5-word-count-34.2.0.tgz#d350e68281a617dcce7ccb67f834499981c8da4c"
|
||||
integrity sha512-24Fl/X9qQVDbHG4P+aSi4qcxpiyaA0e3hut3mp/c63WMdEu5FMY6IP1PwwNYBjOmQ7KtbDpQUFkYiv3lFOIcZg==
|
||||
dependencies:
|
||||
ckeditor5 "^34.2.0"
|
||||
lodash-es "^4.17.15"
|
||||
|
||||
"@csstools/selector-specificity@^2.0.0":
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@csstools/selector-specificity/-/selector-specificity-2.0.2.tgz#1bfafe4b7ed0f3e4105837e056e0a89b108ebe36"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue