@ckeditor/ckeditor5-restricted-editing 38.1.0 → 38.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/restricted-editing.js +1 -1
- package/build/restricted-editing.js.map +1 -0
- package/package.json +2 -2
- package/src/augmentation.d.ts +29 -29
- package/src/augmentation.js +5 -5
- package/src/index.d.ts +17 -17
- package/src/index.js +14 -14
- package/src/restrictededitingconfig.d.ts +60 -60
- package/src/restrictededitingconfig.js +5 -5
- package/src/restrictededitingexceptioncommand.d.ts +30 -30
- package/src/restrictededitingexceptioncommand.js +61 -61
- package/src/restrictededitingmode/converters.d.ts +39 -39
- package/src/restrictededitingmode/converters.js +142 -142
- package/src/restrictededitingmode/utils.d.ts +30 -30
- package/src/restrictededitingmode/utils.js +50 -50
- package/src/restrictededitingmode.d.ts +29 -29
- package/src/restrictededitingmode.js +33 -33
- package/src/restrictededitingmodeediting.d.ts +83 -83
- package/src/restrictededitingmodeediting.js +391 -391
- package/src/restrictededitingmodenavigationcommand.d.ts +42 -42
- package/src/restrictededitingmodenavigationcommand.js +94 -94
- package/src/restrictededitingmodeui.d.ts +32 -32
- package/src/restrictededitingmodeui.js +75 -75
- package/src/standardeditingmode.d.ts +26 -26
- package/src/standardeditingmode.js +30 -30
- package/src/standardeditingmodeediting.d.ts +25 -25
- package/src/standardeditingmodeediting.js +53 -53
- package/src/standardeditingmodeui.d.ts +23 -23
- package/src/standardeditingmodeui.js +48 -48
@@ -1,50 +1,50 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* @module restricted-editing/restrictededitingmode/utils
|
7
|
-
*/
|
8
|
-
/**
|
9
|
-
* Returns a single "restricted-editing-exception" marker at a given position. Contrary to
|
10
|
-
* {@link module:engine/model/markercollection~MarkerCollection#getMarkersAtPosition}, it returnd a marker also when the postion is
|
11
|
-
* equal to one of the marker's start or end positions.
|
12
|
-
*/
|
13
|
-
export function getMarkerAtPosition(editor, position) {
|
14
|
-
for (const marker of editor.model.markers) {
|
15
|
-
const markerRange = marker.getRange();
|
16
|
-
if (isPositionInRangeBoundaries(markerRange, position)) {
|
17
|
-
if (marker.name.startsWith('restrictedEditingException:')) {
|
18
|
-
return marker;
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
/**
|
24
|
-
* Checks if the position is fully contained in the range. Positions equal to range start or end are considered "in".
|
25
|
-
*/
|
26
|
-
export function isPositionInRangeBoundaries(range, position) {
|
27
|
-
return (range.containsPosition(position) ||
|
28
|
-
range.end.isEqual(position) ||
|
29
|
-
range.start.isEqual(position));
|
30
|
-
}
|
31
|
-
/**
|
32
|
-
* Checks if the selection is fully contained in the marker. Positions on marker boundaries are considered "in".
|
33
|
-
*
|
34
|
-
* ```xml
|
35
|
-
* <marker>[]foo</marker> -> true
|
36
|
-
* <marker>f[oo]</marker> -> true
|
37
|
-
* <marker>f[oo</marker> ba]r -> false
|
38
|
-
* <marker>foo</marker> []bar -> false
|
39
|
-
* ```
|
40
|
-
*/
|
41
|
-
export function isSelectionInMarker(selection, marker) {
|
42
|
-
if (!marker) {
|
43
|
-
return false;
|
44
|
-
}
|
45
|
-
const markerRange = marker.getRange();
|
46
|
-
if (selection.isCollapsed) {
|
47
|
-
return isPositionInRangeBoundaries(markerRange, selection.focus);
|
48
|
-
}
|
49
|
-
return markerRange.containsRange(selection.getFirstRange(), true);
|
50
|
-
}
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module restricted-editing/restrictededitingmode/utils
|
7
|
+
*/
|
8
|
+
/**
|
9
|
+
* Returns a single "restricted-editing-exception" marker at a given position. Contrary to
|
10
|
+
* {@link module:engine/model/markercollection~MarkerCollection#getMarkersAtPosition}, it returnd a marker also when the postion is
|
11
|
+
* equal to one of the marker's start or end positions.
|
12
|
+
*/
|
13
|
+
export function getMarkerAtPosition(editor, position) {
|
14
|
+
for (const marker of editor.model.markers) {
|
15
|
+
const markerRange = marker.getRange();
|
16
|
+
if (isPositionInRangeBoundaries(markerRange, position)) {
|
17
|
+
if (marker.name.startsWith('restrictedEditingException:')) {
|
18
|
+
return marker;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* Checks if the position is fully contained in the range. Positions equal to range start or end are considered "in".
|
25
|
+
*/
|
26
|
+
export function isPositionInRangeBoundaries(range, position) {
|
27
|
+
return (range.containsPosition(position) ||
|
28
|
+
range.end.isEqual(position) ||
|
29
|
+
range.start.isEqual(position));
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Checks if the selection is fully contained in the marker. Positions on marker boundaries are considered "in".
|
33
|
+
*
|
34
|
+
* ```xml
|
35
|
+
* <marker>[]foo</marker> -> true
|
36
|
+
* <marker>f[oo]</marker> -> true
|
37
|
+
* <marker>f[oo</marker> ba]r -> false
|
38
|
+
* <marker>foo</marker> []bar -> false
|
39
|
+
* ```
|
40
|
+
*/
|
41
|
+
export function isSelectionInMarker(selection, marker) {
|
42
|
+
if (!marker) {
|
43
|
+
return false;
|
44
|
+
}
|
45
|
+
const markerRange = marker.getRange();
|
46
|
+
if (selection.isCollapsed) {
|
47
|
+
return isPositionInRangeBoundaries(markerRange, selection.focus);
|
48
|
+
}
|
49
|
+
return markerRange.containsRange(selection.getFirstRange(), true);
|
50
|
+
}
|
@@ -1,29 +1,29 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* @module restricted-editing/restrictededitingmode
|
7
|
-
*/
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
9
|
-
import RestrictedEditingModeEditing from './restrictededitingmodeediting';
|
10
|
-
import RestrictedEditingModeUI from './restrictededitingmodeui';
|
11
|
-
import '../theme/restrictedediting.css';
|
12
|
-
/**
|
13
|
-
* The restricted editing mode plugin.
|
14
|
-
*
|
15
|
-
* This is a "glue" plugin which loads the following plugins:
|
16
|
-
*
|
17
|
-
* * The {@link module:restricted-editing/restrictededitingmodeediting~RestrictedEditingModeEditing restricted mode editing feature}.
|
18
|
-
* * The {@link module:restricted-editing/restrictededitingmodeui~RestrictedEditingModeUI restricted mode UI feature}.
|
19
|
-
*/
|
20
|
-
export default class RestrictedEditingMode extends Plugin {
|
21
|
-
/**
|
22
|
-
* @inheritDoc
|
23
|
-
*/
|
24
|
-
static get pluginName(): "RestrictedEditingMode";
|
25
|
-
/**
|
26
|
-
* @inheritDoc
|
27
|
-
*/
|
28
|
-
static get requires(): readonly [typeof RestrictedEditingModeEditing, typeof RestrictedEditingModeUI];
|
29
|
-
}
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module restricted-editing/restrictededitingmode
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
9
|
+
import RestrictedEditingModeEditing from './restrictededitingmodeediting';
|
10
|
+
import RestrictedEditingModeUI from './restrictededitingmodeui';
|
11
|
+
import '../theme/restrictedediting.css';
|
12
|
+
/**
|
13
|
+
* The restricted editing mode plugin.
|
14
|
+
*
|
15
|
+
* This is a "glue" plugin which loads the following plugins:
|
16
|
+
*
|
17
|
+
* * The {@link module:restricted-editing/restrictededitingmodeediting~RestrictedEditingModeEditing restricted mode editing feature}.
|
18
|
+
* * The {@link module:restricted-editing/restrictededitingmodeui~RestrictedEditingModeUI restricted mode UI feature}.
|
19
|
+
*/
|
20
|
+
export default class RestrictedEditingMode extends Plugin {
|
21
|
+
/**
|
22
|
+
* @inheritDoc
|
23
|
+
*/
|
24
|
+
static get pluginName(): "RestrictedEditingMode";
|
25
|
+
/**
|
26
|
+
* @inheritDoc
|
27
|
+
*/
|
28
|
+
static get requires(): readonly [typeof RestrictedEditingModeEditing, typeof RestrictedEditingModeUI];
|
29
|
+
}
|
@@ -1,33 +1,33 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* @module restricted-editing/restrictededitingmode
|
7
|
-
*/
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
9
|
-
import RestrictedEditingModeEditing from './restrictededitingmodeediting';
|
10
|
-
import RestrictedEditingModeUI from './restrictededitingmodeui';
|
11
|
-
import '../theme/restrictedediting.css';
|
12
|
-
/**
|
13
|
-
* The restricted editing mode plugin.
|
14
|
-
*
|
15
|
-
* This is a "glue" plugin which loads the following plugins:
|
16
|
-
*
|
17
|
-
* * The {@link module:restricted-editing/restrictededitingmodeediting~RestrictedEditingModeEditing restricted mode editing feature}.
|
18
|
-
* * The {@link module:restricted-editing/restrictededitingmodeui~RestrictedEditingModeUI restricted mode UI feature}.
|
19
|
-
*/
|
20
|
-
export default class RestrictedEditingMode extends Plugin {
|
21
|
-
/**
|
22
|
-
* @inheritDoc
|
23
|
-
*/
|
24
|
-
static get pluginName() {
|
25
|
-
return 'RestrictedEditingMode';
|
26
|
-
}
|
27
|
-
/**
|
28
|
-
* @inheritDoc
|
29
|
-
*/
|
30
|
-
static get requires() {
|
31
|
-
return [RestrictedEditingModeEditing, RestrictedEditingModeUI];
|
32
|
-
}
|
33
|
-
}
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module restricted-editing/restrictededitingmode
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
9
|
+
import RestrictedEditingModeEditing from './restrictededitingmodeediting';
|
10
|
+
import RestrictedEditingModeUI from './restrictededitingmodeui';
|
11
|
+
import '../theme/restrictedediting.css';
|
12
|
+
/**
|
13
|
+
* The restricted editing mode plugin.
|
14
|
+
*
|
15
|
+
* This is a "glue" plugin which loads the following plugins:
|
16
|
+
*
|
17
|
+
* * The {@link module:restricted-editing/restrictededitingmodeediting~RestrictedEditingModeEditing restricted mode editing feature}.
|
18
|
+
* * The {@link module:restricted-editing/restrictededitingmodeui~RestrictedEditingModeUI restricted mode UI feature}.
|
19
|
+
*/
|
20
|
+
export default class RestrictedEditingMode extends Plugin {
|
21
|
+
/**
|
22
|
+
* @inheritDoc
|
23
|
+
*/
|
24
|
+
static get pluginName() {
|
25
|
+
return 'RestrictedEditingMode';
|
26
|
+
}
|
27
|
+
/**
|
28
|
+
* @inheritDoc
|
29
|
+
*/
|
30
|
+
static get requires() {
|
31
|
+
return [RestrictedEditingModeEditing, RestrictedEditingModeUI];
|
32
|
+
}
|
33
|
+
}
|
@@ -1,83 +1,83 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
/**
|
6
|
-
* @module restricted-editing/restrictededitingmodeediting
|
7
|
-
*/
|
8
|
-
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
9
|
-
/**
|
10
|
-
* The restricted editing mode editing feature.
|
11
|
-
*
|
12
|
-
* * It introduces the exception marker group that renders to `<span>` elements with the `restricted-editing-exception` CSS class.
|
13
|
-
* * It registers the `'goToPreviousRestrictedEditingException'` and `'goToNextRestrictedEditingException'` commands.
|
14
|
-
* * It also enables highlighting exception markers that are selected.
|
15
|
-
*/
|
16
|
-
export default class RestrictedEditingModeEditing extends Plugin {
|
17
|
-
/**
|
18
|
-
* Command names that are enabled outside the non-restricted regions.
|
19
|
-
*/
|
20
|
-
private _alwaysEnabled;
|
21
|
-
/**
|
22
|
-
* Commands allowed in non-restricted areas.
|
23
|
-
*
|
24
|
-
* Commands always enabled combine typing feature commands: `'input'`, `'insertText'`, `'delete'`, and `'deleteForward'` with
|
25
|
-
* commands defined in the feature configuration.
|
26
|
-
*/
|
27
|
-
private _allowedInException;
|
28
|
-
/**
|
29
|
-
* @inheritDoc
|
30
|
-
*/
|
31
|
-
static get pluginName(): "RestrictedEditingModeEditing";
|
32
|
-
/**
|
33
|
-
* @inheritDoc
|
34
|
-
*/
|
35
|
-
constructor(editor: Editor);
|
36
|
-
/**
|
37
|
-
* @inheritDoc
|
38
|
-
*/
|
39
|
-
init(): void;
|
40
|
-
/**
|
41
|
-
* Makes the given command always enabled in the restricted editing mode (regardless
|
42
|
-
* of selection location).
|
43
|
-
*
|
44
|
-
* To enable some commands in non-restricted areas of the content use
|
45
|
-
* {@link module:restricted-editing/restrictededitingconfig~RestrictedEditingConfig#allowedCommands} configuration option.
|
46
|
-
*
|
47
|
-
* @param commandName Name of the command to enable.
|
48
|
-
*/
|
49
|
-
enableCommand(commandName: string): void;
|
50
|
-
/**
|
51
|
-
* Sets up the restricted mode editing conversion:
|
52
|
-
*
|
53
|
-
* * ucpast & downcast converters,
|
54
|
-
* * marker highlighting in the edting area,
|
55
|
-
* * marker post-fixers.
|
56
|
-
*/
|
57
|
-
private _setupConversion;
|
58
|
-
/**
|
59
|
-
* Setups additional editing restrictions beyond command toggling:
|
60
|
-
*
|
61
|
-
* * delete content range trimming
|
62
|
-
* * disabling input command outside exception marker
|
63
|
-
* * restricting clipboard holder to text only
|
64
|
-
* * restricting text attributes in content
|
65
|
-
*/
|
66
|
-
private _setupRestrictions;
|
67
|
-
/**
|
68
|
-
* Sets up the command toggling which enables or disables commands based on the user selection.
|
69
|
-
*/
|
70
|
-
private _setupCommandsToggling;
|
71
|
-
/**
|
72
|
-
* Checks if commands should be enabled or disabled based on the current selection.
|
73
|
-
*/
|
74
|
-
private _checkCommands;
|
75
|
-
/**
|
76
|
-
* Enables commands in non-restricted regions.
|
77
|
-
*/
|
78
|
-
private _enableCommands;
|
79
|
-
/**
|
80
|
-
* Disables commands outside non-restricted regions.
|
81
|
-
*/
|
82
|
-
private _disableCommands;
|
83
|
-
}
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module restricted-editing/restrictededitingmodeediting
|
7
|
+
*/
|
8
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
9
|
+
/**
|
10
|
+
* The restricted editing mode editing feature.
|
11
|
+
*
|
12
|
+
* * It introduces the exception marker group that renders to `<span>` elements with the `restricted-editing-exception` CSS class.
|
13
|
+
* * It registers the `'goToPreviousRestrictedEditingException'` and `'goToNextRestrictedEditingException'` commands.
|
14
|
+
* * It also enables highlighting exception markers that are selected.
|
15
|
+
*/
|
16
|
+
export default class RestrictedEditingModeEditing extends Plugin {
|
17
|
+
/**
|
18
|
+
* Command names that are enabled outside the non-restricted regions.
|
19
|
+
*/
|
20
|
+
private _alwaysEnabled;
|
21
|
+
/**
|
22
|
+
* Commands allowed in non-restricted areas.
|
23
|
+
*
|
24
|
+
* Commands always enabled combine typing feature commands: `'input'`, `'insertText'`, `'delete'`, and `'deleteForward'` with
|
25
|
+
* commands defined in the feature configuration.
|
26
|
+
*/
|
27
|
+
private _allowedInException;
|
28
|
+
/**
|
29
|
+
* @inheritDoc
|
30
|
+
*/
|
31
|
+
static get pluginName(): "RestrictedEditingModeEditing";
|
32
|
+
/**
|
33
|
+
* @inheritDoc
|
34
|
+
*/
|
35
|
+
constructor(editor: Editor);
|
36
|
+
/**
|
37
|
+
* @inheritDoc
|
38
|
+
*/
|
39
|
+
init(): void;
|
40
|
+
/**
|
41
|
+
* Makes the given command always enabled in the restricted editing mode (regardless
|
42
|
+
* of selection location).
|
43
|
+
*
|
44
|
+
* To enable some commands in non-restricted areas of the content use
|
45
|
+
* {@link module:restricted-editing/restrictededitingconfig~RestrictedEditingConfig#allowedCommands} configuration option.
|
46
|
+
*
|
47
|
+
* @param commandName Name of the command to enable.
|
48
|
+
*/
|
49
|
+
enableCommand(commandName: string): void;
|
50
|
+
/**
|
51
|
+
* Sets up the restricted mode editing conversion:
|
52
|
+
*
|
53
|
+
* * ucpast & downcast converters,
|
54
|
+
* * marker highlighting in the edting area,
|
55
|
+
* * marker post-fixers.
|
56
|
+
*/
|
57
|
+
private _setupConversion;
|
58
|
+
/**
|
59
|
+
* Setups additional editing restrictions beyond command toggling:
|
60
|
+
*
|
61
|
+
* * delete content range trimming
|
62
|
+
* * disabling input command outside exception marker
|
63
|
+
* * restricting clipboard holder to text only
|
64
|
+
* * restricting text attributes in content
|
65
|
+
*/
|
66
|
+
private _setupRestrictions;
|
67
|
+
/**
|
68
|
+
* Sets up the command toggling which enables or disables commands based on the user selection.
|
69
|
+
*/
|
70
|
+
private _setupCommandsToggling;
|
71
|
+
/**
|
72
|
+
* Checks if commands should be enabled or disabled based on the current selection.
|
73
|
+
*/
|
74
|
+
private _checkCommands;
|
75
|
+
/**
|
76
|
+
* Enables commands in non-restricted regions.
|
77
|
+
*/
|
78
|
+
private _enableCommands;
|
79
|
+
/**
|
80
|
+
* Disables commands outside non-restricted regions.
|
81
|
+
*/
|
82
|
+
private _disableCommands;
|
83
|
+
}
|