@ckeditor/ckeditor5-restricted-editing 0.0.0-nightly-20240428.0 → 0.0.0-nightly-20240430.0
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/dist/index.js +37 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/restrictededitingmodeediting.js +39 -4
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-restricted-editing",
|
3
|
-
"version": "0.0.0-nightly-
|
3
|
+
"version": "0.0.0-nightly-20240430.0",
|
4
4
|
"description": "Restricted editing feature for CKEditor 5 editors.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -12,7 +12,7 @@
|
|
12
12
|
"type": "module",
|
13
13
|
"main": "src/index.js",
|
14
14
|
"dependencies": {
|
15
|
-
"ckeditor5": "0.0.0-nightly-
|
15
|
+
"ckeditor5": "0.0.0-nightly-20240430.0"
|
16
16
|
},
|
17
17
|
"author": "CKSource (http://cksource.com/)",
|
18
18
|
"license": "GPL-2.0-or-later",
|
@@ -108,8 +108,43 @@ export default class RestrictedEditingModeEditing extends Plugin {
|
|
108
108
|
}
|
109
109
|
}));
|
110
110
|
// Currently the marker helpers are tied to other use-cases and do not render a collapsed marker as highlight.
|
111
|
-
//
|
112
|
-
//
|
111
|
+
// Also, markerToHighlight can not convert marker on an inline object. It handles only text and widgets,
|
112
|
+
// but it is not a case in the data pipeline. That's why there are 3 downcast converters for them:
|
113
|
+
//
|
114
|
+
// 1. The custom inline item (text or inline object) converter (but not the selection).
|
115
|
+
editor.conversion.for('downcast').add(dispatcher => {
|
116
|
+
dispatcher.on('addMarker:restrictedEditingException', (evt, data, conversionApi) => {
|
117
|
+
// Only convert per-item conversion.
|
118
|
+
if (!data.item) {
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
// Do not convert the selection or non-inline items.
|
122
|
+
if (data.item.is('selection') || !conversionApi.schema.isInline(data.item)) {
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
126
|
+
return;
|
127
|
+
}
|
128
|
+
const viewWriter = conversionApi.writer;
|
129
|
+
const viewElement = viewWriter.createAttributeElement('span', {
|
130
|
+
class: 'restricted-editing-exception'
|
131
|
+
}, {
|
132
|
+
id: data.markerName,
|
133
|
+
priority: -10
|
134
|
+
});
|
135
|
+
const viewRange = conversionApi.mapper.toViewRange(data.range);
|
136
|
+
const rangeAfterWrap = viewWriter.wrap(viewRange, viewElement);
|
137
|
+
for (const element of rangeAfterWrap.getItems()) {
|
138
|
+
if (element.is('attributeElement') && element.isSimilar(viewElement)) {
|
139
|
+
conversionApi.mapper.bindElementToMarker(element, data.markerName);
|
140
|
+
// One attribute element is enough, because all of them are bound together by the view writer.
|
141
|
+
// Mapper uses this binding to get all the elements no matter how many of them are registered in the mapper.
|
142
|
+
break;
|
143
|
+
}
|
144
|
+
}
|
145
|
+
});
|
146
|
+
});
|
147
|
+
// 2. The marker-to-highlight converter for the document selection.
|
113
148
|
editor.conversion.for('downcast').markerToHighlight({
|
114
149
|
model: 'restrictedEditingException',
|
115
150
|
// Use callback to return new object every time new marker instance is created - otherwise it will be seen as the same marker.
|
@@ -121,8 +156,8 @@ export default class RestrictedEditingModeEditing extends Plugin {
|
|
121
156
|
};
|
122
157
|
}
|
123
158
|
});
|
124
|
-
//
|
125
|
-
// Additionally the editing pipeline should always display a collapsed marker.
|
159
|
+
// 3. And for collapsed marker we need to render it as an element.
|
160
|
+
// Additionally, the editing pipeline should always display a collapsed marker.
|
126
161
|
editor.conversion.for('editingDowncast').markerToElement({
|
127
162
|
model: 'restrictedEditingException',
|
128
163
|
view: (markerData, { writer }) => {
|