@lesjoursfr/edith 1.1.4 → 2.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lesjoursfr/edith",
3
- "version": "1.1.4",
3
+ "version": "2.0.1",
4
4
  "description": "Simple WYSIWYG editor.",
5
5
  "license": "MIT",
6
6
  "repository": "lesjoursfr/edith",
@@ -12,7 +12,7 @@
12
12
  "access": "public"
13
13
  },
14
14
  "engines": {
15
- "node": ">=16.15.1 || >=18.4.0"
15
+ "node": "18.x || 20.x"
16
16
  },
17
17
  "browserslist": [
18
18
  "Chrome >= 60",
@@ -44,39 +44,35 @@
44
44
  "editor"
45
45
  ],
46
46
  "devDependencies": {
47
- "@babel/core": "^7.21.4",
48
- "@babel/preset-env": "^7.21.4",
49
- "@codemirror/lang-html": "^6.4.3",
47
+ "@babel/core": "^7.22.5",
48
+ "@babel/preset-env": "^7.22.5",
49
+ "@codemirror/lang-html": "^6.4.5",
50
50
  "@fortawesome/fontawesome-free": "^6.4.0",
51
- "@popperjs/core": "^2.11.7",
52
- "ava": "^5.2.0",
51
+ "@popperjs/core": "^2.11.8",
52
+ "ava": "^5.3.1",
53
53
  "babel-loader": "^9.1.2",
54
54
  "codemirror": "^6.0.1",
55
- "css-loader": "^6.7.3",
56
- "eslint": "^8.39.0",
55
+ "css-loader": "^6.8.1",
56
+ "eslint": "^8.44.0",
57
57
  "eslint-config-prettier": "^8.8.0",
58
- "eslint-config-standard": "^17.0.0",
59
- "eslint-plugin-import": "^2.27.5",
60
- "eslint-plugin-n": "^15.7.0",
61
- "eslint-plugin-promise": "^6.1.1",
62
- "jsdom": "^21.1.1",
63
- "mini-css-extract-plugin": "^2.7.5",
64
- "postcss": "^8.4.23",
65
- "prettier": "^2.8.7",
66
- "sass": "^1.62.1",
67
- "sass-loader": "^13.2.2",
68
- "style-loader": "^3.3.2",
69
- "stylelint": "^15.5.0",
58
+ "jsdom": "^22.1.0",
59
+ "mini-css-extract-plugin": "^2.7.6",
60
+ "postcss": "^8.4.24",
61
+ "prettier": "^2.8.8",
62
+ "sass": "^1.63.6",
63
+ "sass-loader": "^13.3.2",
64
+ "style-loader": "^3.3.3",
65
+ "stylelint": "^15.9.0",
70
66
  "stylelint-config-sass-guidelines": "^10.0.0",
71
- "webpack": "^5.80.0",
72
- "webpack-cli": "^5.0.2",
73
- "webpack-dev-server": "^4.13.3"
67
+ "webpack": "^5.88.1",
68
+ "webpack-cli": "^5.1.4",
69
+ "webpack-dev-server": "^4.15.1"
74
70
  },
75
71
  "peerDependencies": {
76
- "@codemirror/lang-html": "^6.4.3",
72
+ "@codemirror/lang-html": "^6.4.5",
77
73
  "@fortawesome/fontawesome-free": "^6.4.0",
78
- "@popperjs/core": "^2.11.7",
74
+ "@popperjs/core": "^2.11.8",
79
75
  "codemirror": "^6.0.1"
80
76
  },
81
- "packageManager": "yarn@3.5.0"
77
+ "packageManager": "yarn@3.6.1"
82
78
  }
package/src/ui/button.js CHANGED
@@ -2,7 +2,7 @@ import { createPopper } from "@popperjs/core";
2
2
  import { Events } from "../core/event.js";
3
3
  import { EditorModes } from "../core/mode.js";
4
4
 
5
- function onButtonClick(context, kind, event) {
5
+ function onButtonClick(context, kind) {
6
6
  switch (kind) {
7
7
  case "bold":
8
8
  context.editor.wrapInsideTag("b");
@@ -51,7 +51,7 @@ EdithButton.prototype.click = function (event) {
51
51
 
52
52
  // Check if the onclick attribute is a internal function ID or a custom function
53
53
  if (typeof this.onclick === "string") {
54
- onButtonClick(this.ctx, this.onclick, event);
54
+ onButtonClick(this.ctx, this.onclick);
55
55
  } else {
56
56
  this.onclick(this.ctx, event);
57
57
  }
package/src/ui/editor.js CHANGED
@@ -1,6 +1,13 @@
1
1
  import { EditorView, basicSetup } from "codemirror";
2
2
  import { html } from "@codemirror/lang-html";
3
- import { hasClass, hasTagName, createNodeWith, isSelfClosing, removeNodesRecursively } from "../core/dom.js";
3
+ import {
4
+ hasClass,
5
+ hasTagName,
6
+ createNodeWith,
7
+ isSelfClosing,
8
+ removeNodesRecursively,
9
+ unwrapNode,
10
+ } from "../core/dom.js";
4
11
  import {
5
12
  wrapInsideTag,
6
13
  replaceSelectionByHtml,
@@ -108,6 +115,18 @@ EdithEditor.prototype.getContent = function () {
108
115
  (el) => el.nodeType === Node.ELEMENT_NODE && !isSelfClosing(el.tagName) && el.textContent.length === 0
109
116
  );
110
117
 
118
+ // Remove any style attribute
119
+ for (const el of placeholder.querySelectorAll("[style]")) {
120
+ el.removeAttribute("style");
121
+ }
122
+
123
+ // Unwrap span without attributes
124
+ for (const el of placeholder.querySelectorAll("span")) {
125
+ if (el.attributes.length === 0) {
126
+ unwrapNode(el);
127
+ }
128
+ }
129
+
111
130
  // Return clean code
112
131
  return placeholder.innerHTML
113
132
  .replace(/\u200B/gi, "")