npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ckeditor5-custom-next

v0.0.4

Published

A custom CKEditor 5 build made by the CKEditor 5 online builder.

Downloads

11

Readme

介绍

基于CKEditor5 自定义的一款编辑器

安装

npm i ckeditor5-custom-next @ckeditor/ckeditor5-vue

使用

1.引入

// mian.js
import CKEditor from '@ckeditor/ckeditor5-vue'

import App from './App.vue'
const app = createApp(App)
app.use(CKEditor)

2.单文件组件使用

template>
    <div id="app">
        <ckeditor :editor="editor" :disabled="editorDisabled"></ckeditor>
    </div>
</template>

<script>
import ClassicEditor from 'ckeditor5-custom-next';
import '@ckeditor/ckeditor5-build-classic/build/translations/zh-cn.js'
export default {
    name: 'app',
    data() {
        return {
            editor: ClassicEditor.Editor,
            // This editor will be read–only when created.
            editorDisabled: true,
            editorConfig: {
              language: 'zh-cn',
            }
        };
    }
}
</script>

3.Events

ready: (editor: any) => void
focus: (editor: any) => void
blur: (editor: any) => void
input: (editor: any) => void
destroy: (editor: any) => void

3.配置-更多配置请参考官方文档 点击文档查看

const editorConfig = reactive({
  language: 'zh-cn',
  toolbar: {
    items: [
      'heading',
      '|',
      'textPartLanguage',
      '|',
      'bold',
      'italic',
      'link',
      'bulletedList',
      'numberedList',
      'outdent',
      'indent',
      'alignment',
      'restrictedEditingException',
      'todoList',
      '|',
      'imageUpload',
      'imageInsert',
      'blockQuote',
      'insertTable',
      'mediaEmbed',
      'undo',
      'redo',
      'specialCharacters',
      '|',
      'code',
      'htmlEmbed',
      'codeBlock',
      'pageBreak',
      'selectAll',
      'showBlocks',
      'findAndReplace',
      'strikethrough',
      '-',
      'style',
      '|',
      'fontSize',
      'fontFamily',
      'fontColor',
      'fontBackgroundColor',
      'superscript',
      'subscript',
      'removeFormat',
      'highlight',
      '|',
      'horizontalLine',
      'accessibilityHelp'
    ],
    shouldNotGroupWhenFull: true
  },
  image: {
    toolbar: [
      'imageTextAlternative',
      'toggleImageCaption',
      'imageStyle:inline',
      'imageStyle:block',
      'imageStyle:side',
      'linkImage'
    ]
  },
  table: {
    contentToolbar: [
      'tableColumn',
      'tableRow',
      'mergeTableCells',
      'tableCellProperties',
      'tableProperties'
    ]
  },
  //自定义设置字体
  fontFamily: {
    options: [
      'default',
      '宋体',
      '新宋体',
      '仿宋',
      '楷体',
      '微软雅黑',
      '黑体',
      '华文仿宋',
      '华文楷体',
      '华文隶书',
      '华文宋体',
      '华文细黑',
      '华文新魏',
      '华文行楷',
      '华文中宋',
      '隶书',
      '苹方 常规',
      '幼圆'
    ]
  },
  ckfinder: {
    uploadUrl: `/uploadfile`, // 上传图片接口
    options: {
      resourceType: 'Images'
    }
  }
})

vite 配置

npm i @ckeditor/vite-plugin-ckeditor5

// vite.config.js / vite.config.ts
import ckeditor5 from '@ckeditor/vite-plugin-ckeditor5'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)

export default defineConfig({
  plugins: [
    ckeditor5({ theme: require.resolve('@ckeditor/ckeditor5-theme-lark'), language: 'zh_CN' })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})

Webpack 配置

// vue.config.js

const path = require( 'path' );
const { CKEditorTranslationsPlugin } = require( '@ckeditor/ckeditor5-dev-translations' );
const { styles } = require( '@ckeditor/ckeditor5-dev-utils' );

module.exports = {
  // The source of CKEditor&nbsp;5 is encapsulated in ES6 modules. By default, the code
  // from the node_modules directory is not transpiled, so you must explicitly tell
  // the CLI tools to transpile JavaScript files in all ckeditor5-* modules.
  transpileDependencies: [
    /ckeditor5-[^/\\]+[/\\]src[/\\].+\.js$/,
  ],

  configureWebpack: {
    plugins: [
      // CKEditor&nbsp;5 needs its own plugin to be built using webpack.
      new CKEditorTranslationsPlugin( {
          // See https://ckeditor.com/docs/ckeditor5/latest/features/ui-language.html
          language: 'en',

          // Append translations to the file matching the `app` name.
          translationsOutputFile: /app/
      } )
    ]
  },

  // Vue CLI would normally use its own loader to load .svg and .css files, however:
  //	1. The icons used by CKEditor&nbsp;5 must be loaded using raw-loader,
  //	2. The CSS used by CKEditor&nbsp;5 must be transpiled using PostCSS to load properly.
  chainWebpack: config => {
    // (1.) To handle the editor icons, get the default rule for *.svg files first:
    const svgRule = config.module.rule( 'svg' );

    // Then you can either:
    //
    // * clear all loaders for existing 'svg' rule:
    //
    //		svgRule.uses.clear();
    //
    // * or exclude ckeditor directory from node_modules:
    svgRule.exclude.add( path.join( __dirname, 'node_modules', '@ckeditor' ) );

    // Add an entry for *.svg files belonging to CKEditor. You can either:
    //
    // * modify the existing 'svg' rule:
    //
    //		svgRule.use( 'raw-loader' ).loader( 'raw-loader' );
    //
    // * or add a new one:
    config.module
        .rule( 'cke-svg' )
        .test( /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/ )
        .use( 'raw-loader' )
        .loader( 'raw-loader' );

    // (2.) Transpile the .css files imported by the editor using PostCSS.
    // Make sure only the CSS belonging to ckeditor5-* packages is processed this way.
    config.module
    .rule( 'cke-css' )
    .test( /ckeditor5-[^/\\]+[/\\].+\.css$/ )
    .use( 'postcss-loader' )
    .loader( 'postcss-loader' )
    .tap( () => {
        return {
            postcssOptions: styles.getPostCssConfig( {
                themeImporter: {
                    themePath: require.resolve( '@ckeditor/ckeditor5-theme-lark' ),
                },
                minify: true
            } )
        };
    } );
  }
};

注:更多详细请访问官方文档