@thangph2146/nextjs-editor 1.0.3 → 1.0.5
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/README.md +181 -2
- package/dist/index.cjs +38 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -1
- package/dist/styles.css +5 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23289,6 +23289,33 @@ function applyListColorToDom(dom, color) {
|
|
|
23289
23289
|
dom.style.setProperty("--list-marker-color", color, "important");
|
|
23290
23290
|
dom.setAttribute("data-list-color", color);
|
|
23291
23291
|
}
|
|
23292
|
+
function getListColorFromDom(dom) {
|
|
23293
|
+
const attr = dom.getAttribute("data-list-color");
|
|
23294
|
+
if (attr) return attr;
|
|
23295
|
+
const style = dom.style.getPropertyValue("list-style-color") || dom.style.getPropertyValue("--list-marker-color");
|
|
23296
|
+
if (style) return style.trim();
|
|
23297
|
+
const computed = typeof window !== "undefined" ? window.getComputedStyle(dom).getPropertyValue("list-style-color") : "";
|
|
23298
|
+
return computed && computed !== "currentcolor" ? computed.trim() : void 0;
|
|
23299
|
+
}
|
|
23300
|
+
function $convertListWithColorElement(domNode) {
|
|
23301
|
+
if (!(domNode instanceof HTMLElement)) return null;
|
|
23302
|
+
const nodeName = domNode.nodeName.toLowerCase();
|
|
23303
|
+
let listType = "bullet";
|
|
23304
|
+
let start = 1;
|
|
23305
|
+
if (nodeName === "ol") {
|
|
23306
|
+
listType = "number";
|
|
23307
|
+
const startAttr = domNode.getAttribute("start");
|
|
23308
|
+
start = startAttr != null ? parseInt(startAttr, 10) || 1 : 1;
|
|
23309
|
+
} else if (nodeName === "ul") {
|
|
23310
|
+
listType = "bullet";
|
|
23311
|
+
} else {
|
|
23312
|
+
return null;
|
|
23313
|
+
}
|
|
23314
|
+
const node = $createListWithColorNode(listType, start);
|
|
23315
|
+
const color = getListColorFromDom(domNode);
|
|
23316
|
+
if (color) node.setListColor(color);
|
|
23317
|
+
return { node };
|
|
23318
|
+
}
|
|
23292
23319
|
var ListWithColorNode = class _ListWithColorNode extends ListNode {
|
|
23293
23320
|
__listColor;
|
|
23294
23321
|
constructor(listType, start, key) {
|
|
@@ -23297,6 +23324,12 @@ var ListWithColorNode = class _ListWithColorNode extends ListNode {
|
|
|
23297
23324
|
static getType() {
|
|
23298
23325
|
return LIST_WITH_COLOR_TYPE;
|
|
23299
23326
|
}
|
|
23327
|
+
static importDOM() {
|
|
23328
|
+
return {
|
|
23329
|
+
ol: () => ({ conversion: $convertListWithColorElement, priority: 0 }),
|
|
23330
|
+
ul: () => ({ conversion: $convertListWithColorElement, priority: 0 })
|
|
23331
|
+
};
|
|
23332
|
+
}
|
|
23300
23333
|
getType() {
|
|
23301
23334
|
return LIST_WITH_COLOR_TYPE;
|
|
23302
23335
|
}
|
|
@@ -23367,6 +23400,11 @@ var ListWithColorNode = class _ListWithColorNode extends ListNode {
|
|
|
23367
23400
|
return json;
|
|
23368
23401
|
}
|
|
23369
23402
|
};
|
|
23403
|
+
function $createListWithColorNode(listType, start) {
|
|
23404
|
+
return $applyNodeReplacement3(
|
|
23405
|
+
new ListWithColorNode(listType, start)
|
|
23406
|
+
);
|
|
23407
|
+
}
|
|
23370
23408
|
function $isListWithColorNode(node) {
|
|
23371
23409
|
return node instanceof ListWithColorNode;
|
|
23372
23410
|
}
|