@lesjoursfr/edith 0.1.4 → 0.1.6

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 +18 -18
  2. package/src/ui/editor.js +9 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lesjoursfr/edith",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Simple WYSIWYG editor.",
5
5
  "license": "MIT",
6
6
  "repository": "lesjoursfr/edith",
@@ -45,40 +45,40 @@
45
45
  "editor"
46
46
  ],
47
47
  "devDependencies": {
48
- "@babel/core": "^7.18.10",
49
- "@babel/preset-env": "^7.18.10",
50
- "@codemirror/lang-html": "^6.1.0",
51
- "@fortawesome/fontawesome-free": "^6.1.2",
52
- "@popperjs/core": "^2.11.5",
53
- "ava": "^4.3.1",
48
+ "@babel/core": "^7.19.1",
49
+ "@babel/preset-env": "^7.19.1",
50
+ "@codemirror/lang-html": "^6.1.1",
51
+ "@fortawesome/fontawesome-free": "^6.2.0",
52
+ "@popperjs/core": "^2.11.6",
53
+ "ava": "^4.3.3",
54
54
  "babel-loader": "^8.2.5",
55
55
  "codemirror": "^6.0.1",
56
56
  "css-loader": "^6.7.1",
57
- "eslint": "^8.21.0",
57
+ "eslint": "^8.23.1",
58
58
  "eslint-config-prettier": "^8.5.0",
59
59
  "eslint-config-standard": "^17.0.0",
60
60
  "eslint-plugin-import": "^2.26.0",
61
- "eslint-plugin-n": "^15.2.4",
62
- "eslint-plugin-promise": "^6.0.0",
61
+ "eslint-plugin-n": "^15.3.0",
62
+ "eslint-plugin-promise": "^6.0.1",
63
63
  "jsdom": "^20.0.0",
64
64
  "mini-css-extract-plugin": "^2.6.1",
65
- "postcss": "^8.4.14",
65
+ "postcss": "^8.4.16",
66
66
  "prettier": "^2.7.1",
67
- "sass": "^1.54.0",
67
+ "sass": "^1.55.0",
68
68
  "sass-loader": "^13.0.2",
69
69
  "style-loader": "^3.3.1",
70
- "stylelint": "^14.9.1",
70
+ "stylelint": "^14.12.1",
71
71
  "stylelint-config-prettier": "^9.0.3",
72
72
  "stylelint-config-sass-guidelines": "^9.0.1",
73
73
  "webpack": "^5.74.0",
74
74
  "webpack-cli": "^4.10.0",
75
- "webpack-dev-server": "^4.9.3"
75
+ "webpack-dev-server": "^4.11.1"
76
76
  },
77
77
  "peerDependencies": {
78
- "@codemirror/lang-html": "^6.1.0",
79
- "@fortawesome/fontawesome-free": "^6.1.2",
80
- "@popperjs/core": "^2.11.5",
78
+ "@codemirror/lang-html": "^6.1.1",
79
+ "@fortawesome/fontawesome-free": "^6.2.0",
80
+ "@popperjs/core": "^2.11.6",
81
81
  "codemirror": "^6.0.1"
82
82
  },
83
- "packageManager": "yarn@3.2.2"
83
+ "packageManager": "yarn@3.2.3"
84
84
  }
package/src/ui/editor.js CHANGED
@@ -19,6 +19,7 @@ function EdithEditor(ctx, options) {
19
19
  this.ctx = ctx;
20
20
  this.content = options.initialContent || "";
21
21
  this.height = options.height || 80;
22
+ this.resizable = options.resizable || false;
22
23
  this.mode = EditorModes.Visual;
23
24
  this.editors = {};
24
25
  this.codeMirror = null;
@@ -33,7 +34,10 @@ EdithEditor.prototype.render = function () {
33
34
  // Create a wrapper for the editor
34
35
  const editorWrapper = document.createElement("div");
35
36
  editorWrapper.setAttribute("class", "edith-editing-area");
36
- editorWrapper.setAttribute("style", `height: ${this.height}px`);
37
+ editorWrapper.setAttribute(
38
+ "style",
39
+ this.resizable ? `min-height: ${this.height}px; resize: vertical` : `height: ${this.height}px`
40
+ );
37
41
 
38
42
  // Create the visual editor
39
43
  this.editors.visual = document.createElement("div");
@@ -313,15 +317,15 @@ EdithEditor.prototype.onPasteEvent = function (e) {
313
317
  // Detect style blocs in parents
314
318
  let dest = sel.anchorNode;
315
319
  const style = { B: false, I: false, U: false, S: false, Q: false };
316
- while (!hasClass(dest.parentNode, "edith-visual")) {
317
- // Get the parent
318
- dest = dest.parentNode;
319
-
320
+ while (dest !== null && !hasClass(dest, "edith-visual")) {
320
321
  // Check if it's a style tag
321
322
  if (hasTagName(dest, ["b", "i", "u", "s", "q"])) {
322
323
  // Update the style
323
324
  style[dest.tagName] = true;
324
325
  }
326
+
327
+ // Get the parent
328
+ dest = dest.parentNode;
325
329
  }
326
330
 
327
331
  // We have HTML content