@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/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.keyCode) {
274
- case 13: // Enter : 13
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.keyCode) {
291
- case 13: // Enter : 13
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 32: // Space : 32
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 66: // b : 66
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 73: // i : 73
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 85: // u : 85
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 83: // s : 83
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 90: // z : 90
333
+ case "z":
328
334
  if (e.type === "keydown") {
329
335
  this.restoreSnapshot(); // Undo
330
336
  }