@ckeditor/ckeditor5-select-all
Advanced tools
Comparing version 35.2.1 to 35.3.0
{ | ||
"name": "@ckeditor/ckeditor5-select-all", | ||
"version": "35.2.1", | ||
"version": "35.3.0", | ||
"description": "Select all feature for CKEditor 5.", | ||
@@ -15,15 +15,18 @@ "keywords": [ | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-core": "^35.2.1", | ||
"@ckeditor/ckeditor5-utils": "^35.2.1", | ||
"@ckeditor/ckeditor5-ui": "^35.2.1" | ||
"@ckeditor/ckeditor5-core": "^35.3.0", | ||
"@ckeditor/ckeditor5-utils": "^35.3.0", | ||
"@ckeditor/ckeditor5-ui": "^35.3.0" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-basic-styles": "^35.2.1", | ||
"@ckeditor/ckeditor5-engine": "^35.2.1", | ||
"@ckeditor/ckeditor5-essentials": "^35.2.1", | ||
"@ckeditor/ckeditor5-heading": "^35.2.1", | ||
"@ckeditor/ckeditor5-image": "^35.2.1", | ||
"@ckeditor/ckeditor5-paragraph": "^35.2.1", | ||
"@ckeditor/ckeditor5-table": "^35.2.1", | ||
"@ckeditor/ckeditor5-editor-classic": "^35.2.1" | ||
"@ckeditor/ckeditor5-basic-styles": "^35.3.0", | ||
"@ckeditor/ckeditor5-engine": "^35.3.0", | ||
"@ckeditor/ckeditor5-essentials": "^35.3.0", | ||
"@ckeditor/ckeditor5-heading": "^35.3.0", | ||
"@ckeditor/ckeditor5-image": "^35.3.0", | ||
"@ckeditor/ckeditor5-paragraph": "^35.3.0", | ||
"@ckeditor/ckeditor5-table": "^35.3.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^35.3.0", | ||
"typescript": "^4.8.4", | ||
"webpack": "^5.58.1", | ||
"webpack-cli": "^4.9.0" | ||
}, | ||
@@ -45,7 +48,12 @@ "engines": { | ||
"lang", | ||
"src", | ||
"src/**/*.js", | ||
"src/**/*.d.ts", | ||
"theme", | ||
"ckeditor5-metadata.json", | ||
"CHANGELOG.md" | ||
] | ||
], | ||
"scripts": { | ||
"build": "tsc -p ./tsconfig.release.json", | ||
"postversion": "npm run build" | ||
} | ||
} |
@@ -5,9 +5,7 @@ /** | ||
*/ | ||
/** | ||
* @module select-all | ||
*/ | ||
export { default as SelectAll } from './selectall'; | ||
export { default as SelectAllEditing } from './selectallediting'; | ||
export { default as SelectAllUI } from './selectallui'; |
@@ -5,11 +5,8 @@ /** | ||
*/ | ||
/** | ||
* @module select-all/selectall | ||
*/ | ||
import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; | ||
import SelectAllEditing from './selectallediting'; | ||
import SelectAllUI from './selectallui'; | ||
/** | ||
@@ -26,15 +23,14 @@ * The select all feature. | ||
export default class SelectAll extends Plugin { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
static get requires() { | ||
return [ SelectAllEditing, SelectAllUI ]; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
static get pluginName() { | ||
return 'SelectAll'; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
static get requires() { | ||
return [SelectAllEditing, SelectAllUI]; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
static get pluginName() { | ||
return 'SelectAll'; | ||
} | ||
} |
@@ -5,9 +5,6 @@ /** | ||
*/ | ||
/** | ||
* @module select-all/selectallcommand | ||
*/ | ||
import Command from '@ckeditor/ckeditor5-core/src/command'; | ||
/** | ||
@@ -30,39 +27,33 @@ * The select all command. | ||
export default class SelectAllCommand extends Command { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
constructor( editor ) { | ||
super( editor ); | ||
// It does not affect data so should be enabled in read-only mode. | ||
this.affectsData = false; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
execute() { | ||
const model = this.editor.model; | ||
const selection = model.document.selection; | ||
let scopeElement = model.schema.getLimitElement( selection ); | ||
// If an entire scope is selected, or the selection's ancestor is not a scope yet, | ||
// browse through ancestors to find the enclosing parent scope. | ||
if ( selection.containsEntireContent( scopeElement ) || !isSelectAllScope( model.schema, scopeElement ) ) { | ||
do { | ||
scopeElement = scopeElement.parent; | ||
// Do nothing, if the entire `root` is already selected. | ||
if ( !scopeElement ) { | ||
return; | ||
} | ||
} while ( !isSelectAllScope( model.schema, scopeElement ) ); | ||
} | ||
model.change( writer => { | ||
writer.setSelection( scopeElement, 'in' ); | ||
} ); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
constructor(editor) { | ||
super(editor); | ||
// It does not affect data so should be enabled in read-only mode. | ||
this.affectsData = false; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
execute() { | ||
const model = this.editor.model; | ||
const selection = model.document.selection; | ||
let scopeElement = model.schema.getLimitElement(selection); | ||
// If an entire scope is selected, or the selection's ancestor is not a scope yet, | ||
// browse through ancestors to find the enclosing parent scope. | ||
if (selection.containsEntireContent(scopeElement) || !isSelectAllScope(model.schema, scopeElement)) { | ||
do { | ||
scopeElement = scopeElement.parent; | ||
// Do nothing, if the entire `root` is already selected. | ||
if (!scopeElement) { | ||
return; | ||
} | ||
} while (!isSelectAllScope(model.schema, scopeElement)); | ||
} | ||
model.change(writer => { | ||
writer.setSelection(scopeElement, 'in'); | ||
}); | ||
} | ||
} | ||
// Checks whether the element is a valid select-all scope. | ||
@@ -75,4 +66,4 @@ // Returns true, if the element is a {@link module:engine/model/schema~Schema#isLimit limit}, | ||
// @return {Boolean} | ||
function isSelectAllScope( schema, element ) { | ||
return schema.isLimit( element ) && ( schema.checkChild( element, '$text' ) || schema.checkChild( element, 'paragraph' ) ); | ||
function isSelectAllScope(schema, element) { | ||
return schema.isLimit(element) && (schema.checkChild(element, '$text') || schema.checkChild(element, 'paragraph')); | ||
} |
@@ -5,13 +5,9 @@ /** | ||
*/ | ||
/** | ||
* @module select-all/selectallediting | ||
*/ | ||
import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; | ||
import { getCode, parseKeystroke } from '@ckeditor/ckeditor5-utils/src/keyboard'; | ||
import SelectAllCommand from './selectallcommand'; | ||
const SELECT_ALL_KEYSTROKE = parseKeystroke( 'Ctrl+A' ); | ||
const SELECT_ALL_KEYSTROKE = parseKeystroke('Ctrl+A'); | ||
/** | ||
@@ -26,26 +22,23 @@ * The select all editing feature. | ||
export default class SelectAllEditing extends Plugin { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
static get pluginName() { | ||
return 'SelectAllEditing'; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
init() { | ||
const editor = this.editor; | ||
const view = editor.editing.view; | ||
const viewDocument = view.document; | ||
editor.commands.add( 'selectAll', new SelectAllCommand( editor ) ); | ||
this.listenTo( viewDocument, 'keydown', ( eventInfo, domEventData ) => { | ||
if ( getCode( domEventData ) === SELECT_ALL_KEYSTROKE ) { | ||
editor.execute( 'selectAll' ); | ||
domEventData.preventDefault(); | ||
} | ||
} ); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
static get pluginName() { | ||
return 'SelectAllEditing'; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
init() { | ||
const editor = this.editor; | ||
const view = editor.editing.view; | ||
const viewDocument = view.document; | ||
editor.commands.add('selectAll', new SelectAllCommand(editor)); | ||
this.listenTo(viewDocument, 'keydown', (eventInfo, domEventData) => { | ||
if (getCode(domEventData) === SELECT_ALL_KEYSTROKE) { | ||
editor.execute('selectAll'); | ||
domEventData.preventDefault(); | ||
} | ||
}); | ||
} | ||
} |
@@ -5,12 +5,8 @@ /** | ||
*/ | ||
/** | ||
* @module select-all/selectallui | ||
*/ | ||
import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; | ||
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview'; | ||
import selectAllIcon from '../theme/icons/select-all.svg'; | ||
/** | ||
@@ -26,38 +22,32 @@ * The select all UI feature. | ||
export default class SelectAllUI extends Plugin { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
static get pluginName() { | ||
return 'SelectAllUI'; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
init() { | ||
const editor = this.editor; | ||
editor.ui.componentFactory.add( 'selectAll', locale => { | ||
const command = editor.commands.get( 'selectAll' ); | ||
const view = new ButtonView( locale ); | ||
const t = locale.t; | ||
view.set( { | ||
label: t( 'Select all' ), | ||
icon: selectAllIcon, | ||
keystroke: 'Ctrl+A', | ||
tooltip: true | ||
} ); | ||
view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' ); | ||
// Execute the command. | ||
this.listenTo( view, 'execute', () => { | ||
editor.execute( 'selectAll' ); | ||
editor.editing.view.focus(); | ||
} ); | ||
return view; | ||
} ); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
static get pluginName() { | ||
return 'SelectAllUI'; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
init() { | ||
const editor = this.editor; | ||
editor.ui.componentFactory.add('selectAll', locale => { | ||
const command = editor.commands.get('selectAll'); | ||
const view = new ButtonView(locale); | ||
const t = locale.t; | ||
view.set({ | ||
label: t('Select all'), | ||
icon: selectAllIcon, | ||
keystroke: 'Ctrl+A', | ||
tooltip: true | ||
}); | ||
view.bind('isEnabled').to(command, 'isEnabled'); | ||
// Execute the command. | ||
this.listenTo(view, 'execute', () => { | ||
editor.execute('selectAll'); | ||
editor.editing.view.focus(); | ||
}); | ||
return view; | ||
}); | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55176
11