@lesjoursfr/edith 2.0.0 → 2.0.2
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 +15 -15
- package/src/ui/editor.js +19 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lesjoursfr/edith",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Simple WYSIWYG editor.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "lesjoursfr/edith",
|
|
@@ -44,35 +44,35 @@
|
|
|
44
44
|
"editor"
|
|
45
45
|
],
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@babel/core": "^7.22.
|
|
48
|
-
"@babel/preset-env": "^7.22.
|
|
49
|
-
"@codemirror/lang-html": "^6.4.
|
|
47
|
+
"@babel/core": "^7.22.8",
|
|
48
|
+
"@babel/preset-env": "^7.22.7",
|
|
49
|
+
"@codemirror/lang-html": "^6.4.5",
|
|
50
50
|
"@fortawesome/fontawesome-free": "^6.4.0",
|
|
51
51
|
"@popperjs/core": "^2.11.8",
|
|
52
|
-
"ava": "^5.3.
|
|
52
|
+
"ava": "^5.3.1",
|
|
53
53
|
"babel-loader": "^9.1.2",
|
|
54
54
|
"codemirror": "^6.0.1",
|
|
55
55
|
"css-loader": "^6.8.1",
|
|
56
|
-
"eslint": "^8.
|
|
56
|
+
"eslint": "^8.44.0",
|
|
57
57
|
"eslint-config-prettier": "^8.8.0",
|
|
58
58
|
"jsdom": "^22.1.0",
|
|
59
59
|
"mini-css-extract-plugin": "^2.7.6",
|
|
60
|
-
"postcss": "^8.4.
|
|
61
|
-
"prettier": "^
|
|
62
|
-
"sass": "^1.63.
|
|
63
|
-
"sass-loader": "^13.3.
|
|
60
|
+
"postcss": "^8.4.25",
|
|
61
|
+
"prettier": "^3.0.0",
|
|
62
|
+
"sass": "^1.63.6",
|
|
63
|
+
"sass-loader": "^13.3.2",
|
|
64
64
|
"style-loader": "^3.3.3",
|
|
65
|
-
"stylelint": "^15.
|
|
65
|
+
"stylelint": "^15.10.1",
|
|
66
66
|
"stylelint-config-sass-guidelines": "^10.0.0",
|
|
67
|
-
"webpack": "^5.
|
|
67
|
+
"webpack": "^5.88.1",
|
|
68
68
|
"webpack-cli": "^5.1.4",
|
|
69
|
-
"webpack-dev-server": "^4.15.
|
|
69
|
+
"webpack-dev-server": "^4.15.1"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@codemirror/lang-html": "^6.4.
|
|
72
|
+
"@codemirror/lang-html": "^6.4.5",
|
|
73
73
|
"@fortawesome/fontawesome-free": "^6.4.0",
|
|
74
74
|
"@popperjs/core": "^2.11.8",
|
|
75
75
|
"codemirror": "^6.0.1"
|
|
76
76
|
},
|
|
77
|
-
"packageManager": "yarn@3.6.
|
|
77
|
+
"packageManager": "yarn@3.6.1"
|
|
78
78
|
}
|
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,
|
|
@@ -43,6 +50,10 @@ EdithEditor.prototype.render = function () {
|
|
|
43
50
|
this.editors.visual = document.createElement("div");
|
|
44
51
|
this.editors.visual.setAttribute("class", "edith-visual");
|
|
45
52
|
this.editors.visual.setAttribute("contenteditable", "true");
|
|
53
|
+
this.editors.visual.setAttribute(
|
|
54
|
+
"style",
|
|
55
|
+
this.resizable ? `min-height: ${this.height - 10}px` : `height: ${this.height - 10}px`
|
|
56
|
+
);
|
|
46
57
|
this.editors.visual.innerHTML = this.content;
|
|
47
58
|
this.editors.wrapper.append(this.editors.visual);
|
|
48
59
|
|
|
@@ -113,6 +124,13 @@ EdithEditor.prototype.getContent = function () {
|
|
|
113
124
|
el.removeAttribute("style");
|
|
114
125
|
}
|
|
115
126
|
|
|
127
|
+
// Unwrap span without attributes
|
|
128
|
+
for (const el of placeholder.querySelectorAll("span")) {
|
|
129
|
+
if (el.attributes.length === 0) {
|
|
130
|
+
unwrapNode(el);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
116
134
|
// Return clean code
|
|
117
135
|
return placeholder.innerHTML
|
|
118
136
|
.replace(/\u200B/gi, "")
|