@lesjoursfr/edith 1.1.1 → 1.1.3

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.
Files changed (2) hide show
  1. package/package.json +10 -10
  2. package/src/ui/editor.js +11 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lesjoursfr/edith",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Simple WYSIWYG editor.",
5
5
  "license": "MIT",
6
6
  "repository": "lesjoursfr/edith",
@@ -47,24 +47,24 @@
47
47
  "devDependencies": {
48
48
  "@babel/core": "^7.20.12",
49
49
  "@babel/preset-env": "^7.20.2",
50
- "@codemirror/lang-html": "^6.4.0",
50
+ "@codemirror/lang-html": "^6.4.1",
51
51
  "@fortawesome/fontawesome-free": "^6.2.1",
52
52
  "@popperjs/core": "^2.11.6",
53
- "ava": "^5.1.0",
53
+ "ava": "^5.1.1",
54
54
  "babel-loader": "^9.1.2",
55
55
  "codemirror": "^6.0.1",
56
56
  "css-loader": "^6.7.3",
57
- "eslint": "^8.31.0",
57
+ "eslint": "^8.33.0",
58
58
  "eslint-config-prettier": "^8.6.0",
59
59
  "eslint-config-standard": "^17.0.0",
60
- "eslint-plugin-import": "^2.26.0",
60
+ "eslint-plugin-import": "^2.27.5",
61
61
  "eslint-plugin-n": "^15.6.1",
62
62
  "eslint-plugin-promise": "^6.1.1",
63
- "jsdom": "^21.0.0",
63
+ "jsdom": "^21.1.0",
64
64
  "mini-css-extract-plugin": "^2.7.2",
65
65
  "postcss": "^8.4.21",
66
- "prettier": "^2.8.2",
67
- "sass": "^1.57.1",
66
+ "prettier": "^2.8.3",
67
+ "sass": "^1.58.0",
68
68
  "sass-loader": "^13.2.0",
69
69
  "style-loader": "^3.3.1",
70
70
  "stylelint": "^14.16.1",
@@ -75,10 +75,10 @@
75
75
  "webpack-dev-server": "^4.11.1"
76
76
  },
77
77
  "peerDependencies": {
78
- "@codemirror/lang-html": "^6.4.0",
78
+ "@codemirror/lang-html": "^6.4.1",
79
79
  "@fortawesome/fontawesome-free": "^6.2.1",
80
80
  "@popperjs/core": "^2.11.6",
81
81
  "codemirror": "^6.0.1"
82
82
  },
83
- "packageManager": "yarn@3.3.1"
83
+ "packageManager": "yarn@3.4.0"
84
84
  }
package/src/ui/editor.js CHANGED
@@ -32,9 +32,9 @@ function EdithEditor(ctx, options) {
32
32
 
33
33
  EdithEditor.prototype.render = function () {
34
34
  // Create a wrapper for the editor
35
- const editorWrapper = document.createElement("div");
36
- editorWrapper.setAttribute("class", "edith-editing-area");
37
- editorWrapper.setAttribute(
35
+ this.editors.wrapper = document.createElement("div");
36
+ this.editors.wrapper.setAttribute("class", "edith-editing-area");
37
+ this.editors.wrapper.setAttribute(
38
38
  "style",
39
39
  this.resizable ? `min-height: ${this.height}px; resize: vertical` : `height: ${this.height}px`
40
40
  );
@@ -44,12 +44,12 @@ EdithEditor.prototype.render = function () {
44
44
  this.editors.visual.setAttribute("class", "edith-visual");
45
45
  this.editors.visual.setAttribute("contenteditable", "true");
46
46
  this.editors.visual.innerHTML = this.content;
47
- editorWrapper.append(this.editors.visual);
47
+ this.editors.wrapper.append(this.editors.visual);
48
48
 
49
49
  // Create the code editor
50
50
  this.editors.code = document.createElement("div");
51
51
  this.editors.code.setAttribute("class", "edith-code edith-hidden");
52
- editorWrapper.append(this.editors.code);
52
+ this.editors.wrapper.append(this.editors.code);
53
53
 
54
54
  // Bind events
55
55
  const keyEventsListener = this.onKeyEvent.bind(this);
@@ -59,7 +59,7 @@ EdithEditor.prototype.render = function () {
59
59
  this.editors.visual.addEventListener("paste", pasteEventListener);
60
60
 
61
61
  // Return the wrapper
62
- return editorWrapper;
62
+ return this.editors.wrapper;
63
63
  };
64
64
 
65
65
  EdithEditor.prototype.getVisualEditorElement = function () {
@@ -356,16 +356,14 @@ EdithEditor.prototype.onPasteEvent = function (e) {
356
356
  };
357
357
 
358
358
  EdithEditor.prototype.destroy = function () {
359
- // Check the current mode
360
- if (this.mode === EditorModes.Visual) {
361
- // Remove the visual editor
362
- this.editors.visual.remove();
363
- } else {
364
- // Remove the code editor
359
+ if (this.mode === EditorModes.Code) {
365
360
  this.codeMirror.destroy();
366
361
  this.codeMirror = null;
367
- this.editors.code.remove();
368
362
  }
363
+
364
+ // Remove editors from the DOM
365
+ this.editors.wrapper.remove();
366
+ this.editors = {};
369
367
  };
370
368
 
371
369
  export { EdithEditor };