Coder Social home page Coder Social logo

roslovets-inc / ckeditor5-build-strapi-wysiwyg Goto Github PK

View Code? Open in Web Editor NEW
29.0 3.0 46.0 12.65 MB

Enhanced build of CKEditor 5 to replace default Strapi WYSIWYG editor

Home Page: https://www.npmjs.com/package/ckeditor5-build-strapi-wysiwyg

JavaScript 93.44% CSS 6.56%
ckeditor5 strapi-wysiwyg strapi

ckeditor5-build-strapi-wysiwyg's Introduction

Enhanced build of CKEditor 5 for Strapi

Enhanced build of CKEditor 5 to replace default Strapi WYSIWYG editor (note: this is just a part of Strapi plugin).

ckeditor5-build-strapi-wysiwyg demo screenshot

๐Ÿ‘€ Live Demo

Features

  • Enhanced build of CKEditor 5 with more capabilities then Classic Editor build has
  • Extensive set of features for your rich content
  • Automatically upload Inserted images to Strapi Media Library (thanks to ckeditor5-strapi-upload-plugin)
  • Access Strapi Media Library directly from the editor toolbar ๐Ÿ”ฅ
  • Full screen mode ๐Ÿ”ฅ

How to try

Check out ๐Ÿ‘€ live demo where you can test most of the features.

How to try manually

  1. Clone repository and change directory
git clone https://github.com/Roslovets-Inc/ckeditor5-build-strapi-wysiwyg
cd ckeditor5-build-strapi-wysiwyg
  1. Install dependencies and build CKEditor (automatically)
npm i
  1. Open demo/index.html in your system browser

How to use

Just install to your Strapi strapi-plugin-ckeditor5 plugin based on this build (recommended).

If you want to integrate the build manually examine strapi-plugin-ckeditor5 source code as an integration example.

How to add more features to the editor

If you want to see more features in this build feel free to request it in issues or create pull request. Together we will build a comprehensive editor for common needs.

Links

โญ๏ธ Show your support

Give a star if this project helped you.

ckeditor5-build-strapi-wysiwyg's People

Contributors

anderson-matt avatar evanmalmud avatar ha-akelius avatar irian avatar jorgeperezn avatar roslovets avatar tpkhera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ckeditor5-build-strapi-wysiwyg's Issues

Side-by-Side images

You can workaround this one with the HTML editor I think, but i'm having trouble getting it to work.

I put in -

<div class="container image">
  <div class="row">
    <div class="col-6">
      <img style="height: auto; max-width:100%;" src="IMAGE2">
    </div>
    <div class="col-6">
      <img style="height: auto; max-width:100%;" src="IMAGE1">
    </div>
</div>

And in the editor it looks good, but ultimately on my page they end up stacked.
Unsure why. Might be my css but I can't figure it out.

The fact that this works almost 100% verify's its my css on the site - https://www.codeply.com/go/bp/IAq8t3KYUN

Encountering error when building

Hello,

I'm trying to use this build of ckeditor for strapi v4 in my sub-folder or a sub-directory contained react-app. I already have this working perfectly in the strapi cms itself, however my userbase will be separated into two types, those who can access the Strapi CMS, and those who can only access the react app.

I want to use this exact build with the strapi media library button as well as the full screen button inside my react app, within strapi CMS. How can I use this ckeditor with these two custom buttons (strapi media library + full screen) within the react app as well?

That's my general goal, I did manage to install it however I am now running into problems in my terminal. Here is the error message when I use "yarn build" in my ubuntu inside my react-app:

Failed to compile.

SyntaxError: unknown: Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can set throwIfNamespace: false to bypass this warning.
6 | ...props
7 | }, svgRef) {

8 | return <svg enableBackground="new 0 0 32 32" height="32px" id="svg2" viewBox="0 0 32 32" width="32px" xmlSpace="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg" ref={svgRef} aria-labelledby={titleId} {...props}>{title ? <title id={titleId}>{title}</title> : null};
| ^^^^^^^^
9 | }
10 |
11 | const ForwardRef = React.forwardRef(SvgFullscreenBig);

error Command failed with exit code 1.

Does anyone know why this ckeditor build is not working?

Changing Language of UI Dynamically

I changed the language of Strapi V4 to Arabic , but the Editor still using English UI .
I think it should be changed according to user preferences .

Source editing support for CKEditor 5

Congratulations on the excellent work.
You might consider including the @ckeditor/ckeditor5-source-editing plugin. It's a very relevant feature for some users.

MathJAX functionality

Can you please provide an example of using MathJAX? How we can use this functionality?

Already supporting Strapi 4 ?

A few days ago they released the stable version of Strapi 4, but the folder structure has changed. Will there be any update of the library for this version?

Lack of RemoveFormat

Would be really usefull to have RemoveFormat plugin available, as otherwise the editor will maintain the previous line formatting when pressing enter and you will struggle to change back to default.

Questions About editor.config.get('strapiMediaLib');

Hi @roslovets!

What a wonderful plugin and amazing work! I just wish that I had discovered this earlier after spending around 3 days trying to develop my own plugin using the Strapi official documentation of replacing the WYSIWYG editors. It literally provided me with what I needed within 15minutes. Thank you so much!

Anyway, since I was already midway through the rabbit hole of developing my own plugin. After finding your package, I was wondering if you could point to me some documentation that explains how you managed to integrate the Strapi medialib with editor.config.get('strapiMediaLib'); and subsequently config.onToggle(editor); in the StrapiMediaLib class?

I have found a couple of resources that were guiding me towards developing a plugin for CKEditor 5 but couldn't find out how you figured out to add the strapiMediaLib.

export class StrapiMediaLib extends Plugin {
  
      static get pluginName() {
          return 'strapiMediaLib'
      }
  
      init() {
          const editor = this.editor;
          const config = editor.config.get('strapiMediaLib');
  
          editor.ui.componentFactory.add('strapiMediaLib', locale => {
              
              const view = new ButtonView(locale);
  
              view.set({
                  label: (config && config.label) ? config.label : "Media Library",
                  icon: imageIcon,
                  tooltip: true
              });
  
              view.on('execute', () => {
                  if (config && config.onToggle) {
                      config.onToggle(editor);
                  }
                  else {
                      alert('Properly integrate editor into Strapi to make button work');
                  };
              });
  
              return view;
          });
      }
  }

Thank you once again!

Build time takes to long even using few features

Hi, Im using the plugin in a project but Im having a issue: build takes to long.

My config:

  ckeditor: {
    enabled: true,
    config: {
      plugin: {
        styles: ` // styles applied to editor container `,
      },
      editor: {
        toolbar: {
          items: [
            "paragraph",
            "|",
            "bold",
            "italic",
            "fontColor",
            "fontBackgroundColor",
            "underline",
            "fontSize",
            "removeFormat",
          ],
        },
        fontColor: {
          columns: 5,
          documentColors: 10,
        },
        fontBackgroundColor: {
          columns: 5,
          documentColors: 10,
        },
        heading: {
          options: [
            {
              model: "paragraph",
              title: "Paragraph",
              class: "ck-heading_paragraph",
            },
            {
              model: "heading1",
              view: "h1",
              title: "Heading 1",
              class: "ck-heading_heading1",
            },
            {
              model: "heading2",
              view: "h2",
              title: "Heading 2",
              class: "ck-heading_heading2",
            },
            {
              model: "heading3",
              view: "h3",
              title: "Heading 3",
              class: "ck-heading_heading3",
            },
            {
              model: "heading4",
              view: "h4",
              title: "Heading 4",
              class: "ck-heading_heading4",
            },
            {
              model: "heading5",
              view: "h5",
              title: "Heading 5",
              class: "ck-heading_heading5",
            },
            {
              model: "heading6",
              view: "h6",
              title: "Heading 6",
              class: "ck-heading_heading6",
            },
            {
              model: "h1b",
              view: { name: "h1", classes: "ck-heading_h1_b" },
              title: "H1 (border)",
              class: "ck-heading_heading1",
              converterPriority: "high",
            },
            {
              model: "h2b",
              view: { name: "h2", classes: "ck-heading_h2_b" },
              title: "H2 (border)",
              class: "ck-heading_heading2",
              converterPriority: "high",
            },
            {
              model: "h3b",
              view: { name: "h3", classes: "ck-heading_h3_b" },
              title: "H3 (border)",
              class: "ck-heading_heading3",
              converterPriority: "high",
            },
            {
              model: "custom",
              view: { name: "custom", classes: "Heading 1" },
              title: "custom",
              class: "ck-heading_heading3",
              converterPriority: "high",
            },
          ],
        },
      },
    },
  },

Im using just a few features, but the build time is the same. Is there a way to fix it? Reduce the build time based on the features that Im using?

how to remove buttons from toolbar on the strapi ckeditor?

Hi everyone!
I have been trying to remove the image, media lib, and embedded video icons. What I have done is to comment the icons in the config file in the toolbar array, and I also tried inserting the removePlugins: ['Image', 'ImageCaption', 'ImageStyle', 'ImageToolbar', 'ImageUpload', 'MediaEmbed'], but with no result so far.

How can I remove these icons?
Thanks for your help!

Configuration of fontColor

Hello and thank you for the new release!

From the documentation of CKEditor it is easy to add the fontColor configuration into the ckeditor.js file. This allows developers to specify which colors are available to the users.

The follow code could to be added to the ckeditor.js file:

  // fontColor: {
  //   columns: 5,
  //   documentColors: 24,
  //   colors: [
  //     {
  //       color: 'hsl(0, 0%, 0%)',
  //       label: 'Black',
  //     },
  //     {
  //       color: 'hsl(0, 0%, 30%)',
  //       label: 'Dim grey',
  //     },
  //     {
  //       color: 'hsl(0, 0%, 60%)',
  //       label: 'Grey',
  //     },
  //     {
  //       color: 'hsl(0, 0%, 90%)',
  //       label: 'Light grey',
  //     },
  //     {
  //       color: 'hsl(0, 0%, 100%)',
  //       label: 'White',
  //       hasBorder: true,
  //     },
  //     {
  //       color: 'hsl(0, 75%, 60%)',
  //       label: 'Red',
  //     },
  //     {
  //       color: 'hsl(30, 75%, 60%)',
  //       label: 'Orange',
  //     },
  //     {
  //       color: 'hsl(60, 75%, 60%)',
  //       label: 'Yellow',
  //     },
  //     {
  //       color: 'hsl(90, 75%, 60%)',
  //       label: 'Light green',
  //     },
  //     {
  //       color: 'hsl(120, 75%, 60%)',
  //       label: 'Green',
  //     },
  //     {
  //       color: 'hsl(150, 75%, 60%)',
  //       label: 'Aquamarine',
  //     },
  //     {
  //       color: 'hsl(180, 75%, 60%)',
  //       label: 'Turquoise',
  //     },
  //     {
  //       color: 'hsl(210, 75%, 60%)',
  //       label: 'Light blue',
  //     },
  //     {
  //       color: 'hsl(240, 75%, 60%)',
  //       label: 'Blue',
  //     },
  //     {
  //       color: 'hsl(270, 75%, 60%)',
  //       label: 'Purple',
  //     },
  //   ],
  // },

Kind regards,
Irian

Addition features

Hello, due to my own needs I have added possibility to select list styles and few additional fonts, as follows:

import ClassicEditorBase from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';

import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
import Autoformat from '@ckeditor/ckeditor5-autoformat/src/autoformat';
import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline';
import Subscript from '@ckeditor/ckeditor5-basic-styles/src/subscript';
import Superscript from '@ckeditor/ckeditor5-basic-styles/src/superscript';
import Code from '@ckeditor/ckeditor5-basic-styles/src/code';
import BlockQuote from '@ckeditor/ckeditor5-block-quote/src/blockquote';
import Heading from '@ckeditor/ckeditor5-heading/src/heading';
import Image from '@ckeditor/ckeditor5-image/src/image';
import ImageInsert from '@ckeditor/ckeditor5-image/src/imageinsert';
import ImageCaption from '@ckeditor/ckeditor5-image/src/imagecaption';
import ImageStyle from '@ckeditor/ckeditor5-image/src/imagestyle';
import ImageToolbar from '@ckeditor/ckeditor5-image/src/imagetoolbar';
import ImageResize from '@ckeditor/ckeditor5-image/src/imageresize';
import ImageResizeEditing from '@ckeditor/ckeditor5-image/src/imageresize/imageresizeediting';
import ImageResizeButtons from '@ckeditor/ckeditor5-image/src/imageresize/imageresizebuttons';
import Indent from '@ckeditor/ckeditor5-indent/src/indent';
import Link from '@ckeditor/ckeditor5-link/src/link';
import LinkImage from '@ckeditor/ckeditor5-link/src/linkimage';
import List from '@ckeditor/ckeditor5-list/src/list';
import ListStyle from '@ckeditor/ckeditor5-list/src/liststyle';
import MediaEmbed from '@ckeditor/ckeditor5-media-embed/src/mediaembed';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import PasteFromOffice from '@ckeditor/ckeditor5-paste-from-office/src/pastefromoffice';
import Table from '@ckeditor/ckeditor5-table/src/table';
import TableToolbar from '@ckeditor/ckeditor5-table/src/tabletoolbar';
import TableProperties from '@ckeditor/ckeditor5-table/src/tableproperties';
import TableCellProperties from '@ckeditor/ckeditor5-table/src/tablecellproperties';
import TextTransformation from '@ckeditor/ckeditor5-typing/src/texttransformation';
import HorizontalLine from '@ckeditor/ckeditor5-horizontal-line/src/horizontalline';
import Alignment from '@ckeditor/ckeditor5-alignment/src/alignment';
import AutoLink from '@ckeditor/ckeditor5-link/src/autolink';
import SpecialCharacters from '@ckeditor/ckeditor5-special-characters/src/specialcharacters';
import SpecialCharactersEssentials from '@ckeditor/ckeditor5-special-characters/src/specialcharactersessentials';
import HtmlEmbed from '@ckeditor/ckeditor5-html-embed/src/htmlembed';
import Font from '@ckeditor/ckeditor5-font/src/font';
import CodeBlock from '@ckeditor/ckeditor5-code-block/src/codeblock';
import { StrapiUploadAdapter } from '@gtomato/ckeditor5-strapi-upload-plugin';
import { StrapiMediaLib } from './strapi-medialib-plugin';
import sanitizeHtml from 'sanitize-html';
import FullScreen from './fullscreen-plugin';
import FontFamily from '@ckeditor/ckeditor5-font/src/fontfamily';

export default class ClassicEditor extends ClassicEditorBase { }

// Plugins to include in the build.
ClassicEditor.builtinPlugins = [
Essentials,
Autoformat,
Bold,
Italic,
Underline,
Subscript,
Superscript,
Code,
BlockQuote,
Heading,
Image,
ImageInsert,
ImageCaption,
ImageStyle,
ImageToolbar,
ImageResize,
ImageResizeEditing,
ImageResizeButtons,
Indent,
Link,
LinkImage,
List,
ListStyle,
MediaEmbed,
Paragraph,
PasteFromOffice,
Table,
TableToolbar,
TextTransformation,
HorizontalLine,
Alignment,
AutoLink,
SpecialCharacters,
SpecialCharactersEssentials,
HtmlEmbed,
StrapiUploadAdapter,
StrapiMediaLib,
Font,
FontFamily,
CodeBlock,
FullScreen,
TableProperties,
TableCellProperties,
];

// Editor configuration.
ClassicEditor.defaultConfig = {
toolbar: {
items: [
'heading',
'|',
'fontFamily',
'fontSize',
'fontColor',
'|',
'bold',
'italic',
'underline',
'subscript',
'superscript',
'code',
'link',
'bulletedList',
'numberedList',
'insertImage',
'strapiMediaLib',
'|',
'alignment',
'indent',
'outdent',
'|',
'specialCharacters',
'blockQuote',
'insertTable',
'mediaEmbed',
'htmlEmbed',
'codeBlock',
'horizontalLine',
'|',
'fullScreen',
'undo',
'redo',
],
shouldNotGroupWhenFull: true
},
image: {
styles: [
'alignLeft',
'alignCenter',
'alignRight',
],
resizeOptions: [
{
name: 'resizeImage:original',
value: null,
icon: 'original'
},
{
name: 'resizeImage:50',
value: '50',
icon: 'medium'
},
{
name: 'resizeImage:75',
value: '75',
icon: 'large'
}
],
toolbar: [
'imageStyle:alignLeft',
'imageStyle:alignCenter',
'imageStyle:alignRight',
'|',
'imageTextAlternative',
'|',
'resizeImage:50',
'resizeImage:75',
'resizeImage:original',
'|',
'linkImage',
]
},
table: {
contentToolbar: [
'tableColumn',
'tableRow',
'mergeTableCells',
'tableProperties',
'tableCellProperties',
]
},
heading: {
options: [
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
{ model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
{ model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
{ model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' },
{ model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' },
]
},
htmlEmbed: {
showPreviews: true
},
fontFamily: {
options: [
'default',
'Arial, Helvetica, sans-serif',
'Courier New, Courier, monospace',
'Georgia, serif',
'Lucida Sans Unicode, Lucida Grande, sans-serif',
'Tahoma, Geneva, sans-serif',
'Times New Roman, Times, serif',
'Trebuchet MS, Helvetica, sans-serif',
'Verdana, Geneva, sans-serif',
'JetBrains Mono, monospace',
'Lato, Inter, sans-serif',
]
},
sanitizeHtml: (inputHtml) => {
const outputHtml = sanitizeHtml(inputHtml);
return {
html: outputHtml,
hasChanged: true
};
},
// This value must be kept in sync with the language defined in webpack.config.js.
language: 'en'
};

Add Markdown plugin

I am using the strapi-plugin-ckeditor5 plugin but I would like to add Markdown plugin to get output as markdown instead of HTML. Is that possible to add that plugin as a configurable so users can turn on/off.

I have tried to update the ckeditor.js configure and add plugins configuration, but I am getting [duplicated module](Error codes - CKEditor 5 Documentation) error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.