@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 +23 -27
- package/src/ui/button.js +2 -2
- package/src/ui/editor.js +20 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lesjoursfr/edith",
|
|
3
|
-
"version": "
|
|
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": "
|
|
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.
|
|
48
|
-
"@babel/preset-env": "^7.
|
|
49
|
-
"@codemirror/lang-html": "^6.4.
|
|
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.
|
|
52
|
-
"ava": "^5.
|
|
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.
|
|
56
|
-
"eslint": "^8.
|
|
55
|
+
"css-loader": "^6.8.1",
|
|
56
|
+
"eslint": "^8.44.0",
|
|
57
57
|
"eslint-config-prettier": "^8.8.0",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
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.
|
|
72
|
-
"webpack-cli": "^5.
|
|
73
|
-
"webpack-dev-server": "^4.
|
|
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.
|
|
72
|
+
"@codemirror/lang-html": "^6.4.5",
|
|
77
73
|
"@fortawesome/fontawesome-free": "^6.4.0",
|
|
78
|
-
"@popperjs/core": "^2.11.
|
|
74
|
+
"@popperjs/core": "^2.11.8",
|
|
79
75
|
"codemirror": "^6.0.1"
|
|
80
76
|
},
|
|
81
|
-
"packageManager": "yarn@3.
|
|
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
|
|
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
|
|
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 {
|
|
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, "")
|