This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #394 from mozilla/ckeditor-concept
Switch to CKEditor
- Loading branch information
Showing
19 changed files
with
711 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ src/vendor/* | |
src/sidebar/vendor/* | ||
src/_locales | ||
web-ext-artifacts/ | ||
ckeditor-build/build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
import ClassicEditorBase from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; | ||
import EssentialsPlugin from '@ckeditor/ckeditor5-essentials/src/essentials'; | ||
import MarkdownPlugin from './markdown'; | ||
import AutoformatPlugin from '@ckeditor/ckeditor5-autoformat/src/autoformat'; | ||
import BoldPlugin from '@ckeditor/ckeditor5-basic-styles/src/bold'; | ||
import ItalicPlugin from '@ckeditor/ckeditor5-basic-styles/src/italic'; | ||
import StrikePlugin from './strike'; | ||
import CodePlugin from '@ckeditor/ckeditor5-basic-styles/src/code'; | ||
import HeadingPlugin from '@ckeditor/ckeditor5-heading/src/heading'; | ||
import ListPlugin from '@ckeditor/ckeditor5-list/src/list'; | ||
import ParagraphPlugin from '@ckeditor/ckeditor5-paragraph/src/paragraph'; | ||
import Range from '@ckeditor/ckeditor5-engine/src/model/range'; | ||
|
||
export default class ClassicEditor extends ClassicEditorBase {} | ||
|
||
ClassicEditor.build = { | ||
plugins: [ | ||
EssentialsPlugin, | ||
MarkdownPlugin, | ||
AutoformatPlugin, | ||
BoldPlugin, | ||
ItalicPlugin, | ||
StrikePlugin, | ||
CodePlugin, | ||
HeadingPlugin, | ||
ListPlugin, | ||
ParagraphPlugin | ||
], | ||
config: { | ||
toolbar: { | ||
items: [ | ||
'headings', | ||
'bulletedList', | ||
'numberedList', | ||
'bold', | ||
'italic', | ||
'strike', | ||
'code' | ||
] | ||
} | ||
} | ||
}; | ||
|
||
ClassicEditor.imports = { range: Range }; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import GFMDataProcessor from '@ckeditor/ckeditor5-markdown-gfm/src/gfmdataprocessor'; | ||
|
||
// Simple plugin which loads the data processor. | ||
export default function Markdown(editor) { | ||
editor.data.processor = new GFMDataProcessor(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* @license Copyright (c) 2017, CKSource - Rémy Hubscher. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/** | ||
* @module notes/ckeditor-build/strike | ||
*/ | ||
|
||
import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; | ||
import StrikeEngine from './strikeengine'; | ||
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview'; | ||
import strikeIcon from './icons/strike.svg'; | ||
|
||
/** | ||
* The strike feature. It introduces the Strike button and the <kbd>Ctrl+Alt+S</kbd> keystroke. | ||
* | ||
* It uses the {@link module:basic-styles/strikeengine~StrikeEngine strike engine feature}. | ||
* | ||
* @extends module:core/plugin~Plugin | ||
*/ | ||
export default class Strike extends Plugin { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
static get requires() { | ||
return [ StrikeEngine ]; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
static get pluginName() { | ||
return 'Strike'; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
init() { | ||
const editor = this.editor; | ||
const t = editor.t; | ||
const command = editor.commands.get( 'strike' ); | ||
|
||
// Add strike button to feature components. | ||
editor.ui.componentFactory.add( 'strike', locale => { | ||
const view = new ButtonView( locale ); | ||
|
||
view.set( { | ||
label: t( 'Strike' ), | ||
icon: strikeIcon, | ||
tooltip: true | ||
} ); | ||
|
||
view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' ); | ||
|
||
// Execute command. | ||
this.listenTo( view, 'execute', () => editor.execute( 'strike' ) ); | ||
|
||
return view; | ||
} ); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* @license Copyright (c) 2017, CKSource - Rémy Hubscher. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/** | ||
* @module notes/ckeditor-build/strikeengine | ||
*/ | ||
|
||
import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; | ||
import buildModelConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildmodelconverter'; | ||
import buildViewConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildviewconverter'; | ||
import AttributeCommand from '@ckeditor/ckeditor5-basic-styles/src/attributecommand'; | ||
|
||
const STRIKE = 'strike'; | ||
|
||
/** | ||
* The strike engine feature. | ||
* | ||
* It registers the `strike` command and introduces the | ||
* `strikesthrough` attribute in the model which renders to the view | ||
* as a `<s>` element. | ||
* | ||
* @extends module:core/plugin~Plugin | ||
*/ | ||
export default class StrikeEngine extends Plugin { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
init() { | ||
const editor = this.editor; | ||
const data = editor.data; | ||
const editing = editor.editing; | ||
|
||
// Allow strike attribute on all inline nodes. | ||
editor.document.schema.allow( { name: '$inline', attributes: STRIKE, inside: '$block' } ); | ||
// Temporary workaround. See https://github.com/ckeditor/ckeditor5/issues/477. | ||
editor.document.schema.allow( { name: '$inline', attributes: STRIKE, inside: '$clipboardHolder' } ); | ||
|
||
// Build converter from model to view for data and editing pipelines. | ||
buildModelConverter().for( data.modelToView, editing.modelToView ) | ||
.fromAttribute( STRIKE ) | ||
.toElement( 's' ); | ||
|
||
// Build converter from view to model for data pipeline. | ||
buildViewConverter().for( data.viewToModel ) | ||
.fromElement( 's' ) | ||
.fromElement( 'del' ) | ||
.fromElement( 'strike' ) | ||
.fromAttribute( 'style', { 'text-decoration': 'line-through' } ) | ||
.toAttribute( STRIKE, true ); | ||
|
||
// Create strike command. | ||
editor.commands.add( STRIKE, new AttributeCommand( editor, STRIKE ) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/* eslint-env node */ | ||
|
||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const {bundler} = require('@ckeditor/ckeditor5-dev-utils'); | ||
const CKEditorWebpackPlugin = require('@ckeditor/ckeditor5-dev-webpack-plugin'); | ||
const BabiliPlugin = require('babel-minify-webpack-plugin'); | ||
|
||
module.exports = { | ||
devtool: 'source-map', | ||
|
||
entry: path.resolve(__dirname, 'src', 'ckeditor.js'), | ||
|
||
output: { | ||
// build to the extension src vendor directory | ||
path: path.resolve(__dirname, '..', 'src', 'sidebar', 'vendor'), | ||
filename: 'ckeditor.js', | ||
libraryTarget: 'umd', | ||
libraryExport: 'default', | ||
library: 'ClassicEditor' | ||
}, | ||
|
||
plugins: [ | ||
new CKEditorWebpackPlugin({ | ||
languages: ['en'] | ||
}), | ||
new BabiliPlugin(null, { | ||
comments: false | ||
}), | ||
new webpack.BannerPlugin({ | ||
banner: bundler.getLicenseBanner(), | ||
raw: true | ||
}) | ||
], | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
test: /\.svg$/, | ||
use: ['raw-loader'] | ||
}, | ||
{ | ||
test: /\.scss$/, | ||
use: [ | ||
'style-loader', | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
minimize: true | ||
} | ||
}, | ||
'sass-loader' | ||
] | ||
} | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.