prosemirror-flat-list
Advanced tools
Comparing version 0.0.20 to 0.0.21
@@ -90,3 +90,3 @@ // src/commands/dedent-list.ts | ||
nativeList = false, | ||
getMarker = defaultMarkerGetter, | ||
getMarkers = defaultMarkerGetter, | ||
getAttributes = defaultAttributesGetter | ||
@@ -97,21 +97,28 @@ }) { | ||
const markerHidden = ((_a = node.firstChild) == null ? void 0 : _a.type) === node.type; | ||
const marker = markerHidden || nativeList ? null : getMarker(node); | ||
const markers = markerHidden ? null : getMarkers(node); | ||
const domAttrs = getAttributes(node); | ||
const contentContainer = ["div", { class: "list-content" }, 0]; | ||
if (marker) { | ||
const markerContainer = [ | ||
"div", | ||
{ | ||
class: "list-marker list-marker-click-target", | ||
// Set `contenteditable` to `false` so that the cursor won't be | ||
// moved into the mark container when clicking on it. | ||
contenteditable: "false" | ||
}, | ||
...marker | ||
]; | ||
return ["div", domAttrs, markerContainer, contentContainer]; | ||
} else if (!nativeList) { | ||
return ["div", domAttrs, contentContainer]; | ||
const markerContainer = markers && [ | ||
"div", | ||
{ | ||
class: "list-marker list-marker-click-target", | ||
// Set `contenteditable` to `false` so that the cursor won't be | ||
// moved into the mark container when clicking on it. | ||
contenteditable: "false" | ||
}, | ||
...markers | ||
]; | ||
if (nativeList) { | ||
const listTag = attrs.type === "ordered" ? "ol" : "ul"; | ||
if (markerContainer) { | ||
return [listTag, ["li", domAttrs, markerContainer, contentContainer]]; | ||
} else { | ||
return [listTag, ["li", domAttrs, 0]]; | ||
} | ||
} else { | ||
return [attrs.type === "ordered" ? "ol" : "ul", ["li", domAttrs, 0]]; | ||
if (markerContainer) { | ||
return ["div", domAttrs, markerContainer, contentContainer]; | ||
} else { | ||
return ["div", domAttrs, contentContainer]; | ||
} | ||
} | ||
@@ -1108,3 +1115,6 @@ } | ||
const nodes = DOMSerializer2.nodesFromSchema(schema); | ||
return { ...nodes, list: (node) => listToDOM({ node, nativeList: true }) }; | ||
return { | ||
...nodes, | ||
list: (node) => listToDOM({ node, nativeList: true, getMarkers: () => null }) | ||
}; | ||
} | ||
@@ -1111,0 +1121,0 @@ static fromSchema(schema) { |
@@ -190,3 +190,3 @@ import { Attrs } from 'prosemirror-model'; | ||
/** @public */ | ||
export declare function listToDOM({ node, nativeList, getMarker, getAttributes, }: ListToDOMProps): DOMOutputSpec; | ||
export declare function listToDOM({ node, nativeList, getMarkers, getAttributes, }: ListToDOMProps): DOMOutputSpec; | ||
@@ -202,3 +202,3 @@ /** @public */ | ||
* You might want to use {@link joinListElements} to join the list elements | ||
* later. | ||
* afterward. | ||
* | ||
@@ -209,6 +209,6 @@ * @defaultValue false | ||
/** | ||
* An optional function to get the content inside `<div class="list-marker">`. | ||
* If this function returns `null`, the marker will be hidden. | ||
* An optional function to get elements inside `<div class="list-marker">`. | ||
* Return `null` to hide the marker. | ||
*/ | ||
getMarker?: (node: Node_2) => DOMOutputSpec[] | null; | ||
getMarkers?: (node: Node_2) => DOMOutputSpec[] | null; | ||
/** | ||
@@ -215,0 +215,0 @@ * An optional function to get the attributes added to HTML element. |
@@ -90,3 +90,3 @@ // src/commands/dedent-list.ts | ||
nativeList = false, | ||
getMarker = defaultMarkerGetter, | ||
getMarkers = defaultMarkerGetter, | ||
getAttributes = defaultAttributesGetter | ||
@@ -97,21 +97,28 @@ }) { | ||
const markerHidden = ((_a = node.firstChild) == null ? void 0 : _a.type) === node.type; | ||
const marker = markerHidden || nativeList ? null : getMarker(node); | ||
const markers = markerHidden ? null : getMarkers(node); | ||
const domAttrs = getAttributes(node); | ||
const contentContainer = ["div", { class: "list-content" }, 0]; | ||
if (marker) { | ||
const markerContainer = [ | ||
"div", | ||
{ | ||
class: "list-marker list-marker-click-target", | ||
// Set `contenteditable` to `false` so that the cursor won't be | ||
// moved into the mark container when clicking on it. | ||
contenteditable: "false" | ||
}, | ||
...marker | ||
]; | ||
return ["div", domAttrs, markerContainer, contentContainer]; | ||
} else if (!nativeList) { | ||
return ["div", domAttrs, contentContainer]; | ||
const markerContainer = markers && [ | ||
"div", | ||
{ | ||
class: "list-marker list-marker-click-target", | ||
// Set `contenteditable` to `false` so that the cursor won't be | ||
// moved into the mark container when clicking on it. | ||
contenteditable: "false" | ||
}, | ||
...markers | ||
]; | ||
if (nativeList) { | ||
const listTag = attrs.type === "ordered" ? "ol" : "ul"; | ||
if (markerContainer) { | ||
return [listTag, ["li", domAttrs, markerContainer, contentContainer]]; | ||
} else { | ||
return [listTag, ["li", domAttrs, 0]]; | ||
} | ||
} else { | ||
return [attrs.type === "ordered" ? "ol" : "ul", ["li", domAttrs, 0]]; | ||
if (markerContainer) { | ||
return ["div", domAttrs, markerContainer, contentContainer]; | ||
} else { | ||
return ["div", domAttrs, contentContainer]; | ||
} | ||
} | ||
@@ -1108,3 +1115,6 @@ } | ||
const nodes = DOMSerializer2.nodesFromSchema(schema); | ||
return { ...nodes, list: (node) => listToDOM({ node, nativeList: true }) }; | ||
return { | ||
...nodes, | ||
list: (node) => listToDOM({ node, nativeList: true, getMarkers: () => null }) | ||
}; | ||
} | ||
@@ -1111,0 +1121,0 @@ static fromSchema(schema) { |
{ | ||
"name": "prosemirror-flat-list", | ||
"type": "module", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"description": "", | ||
@@ -6,0 +6,0 @@ "author": "ocavue <ocavue@gmail.com>", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120453
3838