@lesjoursfr/edith 2.2.2 → 2.2.4
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/edith.js +1 -1
- package/dist/css/edith.scss +224 -224
- package/dist/ui/editor.js +15 -10
- package/package.json +35 -34
- package/src/css/edith.scss +224 -224
- package/src/ui/editor.ts +16 -10
package/src/ui/editor.ts
CHANGED
|
@@ -270,8 +270,8 @@ export class EdithEditor {
|
|
|
270
270
|
|
|
271
271
|
private _processKeyEvent(e: KeyboardEvent): boolean {
|
|
272
272
|
// Check the key code
|
|
273
|
-
switch (e.
|
|
274
|
-
case
|
|
273
|
+
switch (e.key) {
|
|
274
|
+
case "Enter":
|
|
275
275
|
if (e.type === "keydown") {
|
|
276
276
|
this.replaceByHtml("<br />"); // Insert a line break
|
|
277
277
|
}
|
|
@@ -287,44 +287,50 @@ export class EdithEditor {
|
|
|
287
287
|
|
|
288
288
|
private _processKeyEventWithMeta(e: KeyboardEvent): boolean {
|
|
289
289
|
// Check the key code
|
|
290
|
-
switch (e.
|
|
291
|
-
case
|
|
290
|
+
switch (e.key) {
|
|
291
|
+
case "Enter":
|
|
292
292
|
if (e.type === "keydown") {
|
|
293
293
|
this.replaceByHtml("<br />"); // Insert a line break
|
|
294
294
|
}
|
|
295
295
|
return true;
|
|
296
296
|
|
|
297
|
-
case
|
|
297
|
+
case " ":
|
|
298
298
|
if (e.type === "keydown") {
|
|
299
299
|
this.replaceByHtml('<span class="edith-nbsp" contenteditable="false">¶</span>'); // Insert a non-breaking space
|
|
300
300
|
}
|
|
301
301
|
return true;
|
|
302
302
|
|
|
303
|
-
case
|
|
303
|
+
case "b":
|
|
304
304
|
if (e.type === "keydown") {
|
|
305
305
|
this.wrapInsideTag("b"); // Toggle bold
|
|
306
306
|
}
|
|
307
307
|
return true;
|
|
308
308
|
|
|
309
|
-
case
|
|
309
|
+
case "i":
|
|
310
310
|
if (e.type === "keydown") {
|
|
311
311
|
this.wrapInsideTag("i"); // Toggle italic
|
|
312
312
|
}
|
|
313
313
|
return true;
|
|
314
314
|
|
|
315
|
-
case
|
|
315
|
+
case "k":
|
|
316
|
+
if (e.type === "keydown") {
|
|
317
|
+
this.insertLink();
|
|
318
|
+
}
|
|
319
|
+
return true;
|
|
320
|
+
|
|
321
|
+
case "u":
|
|
316
322
|
if (e.type === "keydown") {
|
|
317
323
|
this.wrapInsideTag("u"); // Toggle underline
|
|
318
324
|
}
|
|
319
325
|
return true;
|
|
320
326
|
|
|
321
|
-
case
|
|
327
|
+
case "s":
|
|
322
328
|
if (e.type === "keydown") {
|
|
323
329
|
this.wrapInsideTag("s"); // Toggle strikethrough
|
|
324
330
|
}
|
|
325
331
|
return true;
|
|
326
332
|
|
|
327
|
-
case
|
|
333
|
+
case "z":
|
|
328
334
|
if (e.type === "keydown") {
|
|
329
335
|
this.restoreSnapshot(); // Undo
|
|
330
336
|
}
|