prosemirror-flat-list
Advanced tools
Comparing version 0.0.23 to 0.0.24
@@ -28,3 +28,3 @@ // src/commands/dedent-list.ts | ||
return { | ||
type: element.getAttribute("data-list-type") || "bullet", | ||
kind: element.getAttribute("data-list-kind") || "bullet", | ||
order: parseInteger(element.getAttribute("data-list-order")), | ||
@@ -43,15 +43,15 @@ checked: element.hasAttribute("data-list-checked"), | ||
return { | ||
type: "task", | ||
kind: "task", | ||
checked: checkbox.hasAttribute("checked") | ||
}; | ||
} | ||
if (element.hasAttribute("data-task-list-item") || element.getAttribute("data-list-type") === "task") { | ||
if (element.hasAttribute("data-task-list-item") || element.getAttribute("data-list-kind") === "task") { | ||
return { | ||
type: "task", | ||
kind: "task", | ||
checked: element.hasAttribute("data-checked") | ||
}; | ||
} | ||
if (element.hasAttribute("data-toggle-list-item") || element.getAttribute("data-list-type") === "toggle") { | ||
if (element.hasAttribute("data-toggle-list-item") || element.getAttribute("data-list-kind") === "toggle") { | ||
return { | ||
type: "toggle", | ||
kind: "toggle", | ||
collapsed: element.hasAttribute("data-list-collapsed") | ||
@@ -62,3 +62,3 @@ }; | ||
return { | ||
type: "bullet" | ||
kind: "bullet" | ||
}; | ||
@@ -72,7 +72,7 @@ } | ||
return { | ||
type: "ordered" | ||
kind: "ordered" | ||
}; | ||
} | ||
return { | ||
type: "ordered", | ||
kind: "ordered", | ||
order: parseInteger(element.getAttribute("data-list-order")) | ||
@@ -109,3 +109,3 @@ }; | ||
if (nativeList) { | ||
const listTag = attrs.type === "ordered" ? "ol" : "ul"; | ||
const listTag = attrs.kind === "ordered" ? "ol" : "ul"; | ||
if (markerContainer) { | ||
@@ -126,3 +126,3 @@ return [listTag, ["li", domAttrs, markerContainer, contentContainer]]; | ||
const attrs = node.attrs; | ||
switch (attrs.type) { | ||
switch (attrs.kind) { | ||
case "task": | ||
@@ -148,6 +148,6 @@ return [ | ||
const markerHidden = ((_a = node.firstChild) == null ? void 0 : _a.type) === node.type; | ||
const markerType = markerHidden ? void 0 : attrs.type || "bullet"; | ||
const markerType = markerHidden ? void 0 : attrs.kind || "bullet"; | ||
const domAttrs = { | ||
class: "prosemirror-flat-list", | ||
"data-list-type": markerType, | ||
"data-list-kind": markerType, | ||
"data-list-order": attrs.order != null ? String(attrs.order) : void 0, | ||
@@ -170,3 +170,3 @@ "data-list-checked": attrs.checked ? "" : void 0, | ||
attrs: { | ||
type: { | ||
kind: { | ||
default: "bullet" | ||
@@ -753,3 +753,8 @@ }, | ||
const pos = $from.after(-1); | ||
tr.insert(pos, listNode.type.createAndFill({ type: attrs.type })); | ||
tr.insert( | ||
pos, | ||
listNode.type.createAndFill({ | ||
kind: attrs.kind | ||
}) | ||
); | ||
tr.setSelection(Selection.near(tr.doc.resolve(pos))); | ||
@@ -766,4 +771,4 @@ dispatch(tr); | ||
// We don't want to inherit all list attributes (e.g. checked) except | ||
// for the list type | ||
type: attrs.type | ||
// for the list kind | ||
kind: attrs.kind | ||
} | ||
@@ -962,5 +967,5 @@ }, | ||
const attrs = node.attrs; | ||
if (attrs.type === "task") { | ||
if (attrs.kind === "task") { | ||
return { ...attrs, checked: !attrs.checked }; | ||
} else if (attrs.type === "toggle") { | ||
} else if (attrs.kind === "toggle") { | ||
return { ...attrs, collapsed: !attrs.collapsed }; | ||
@@ -1013,3 +1018,3 @@ } else { | ||
wrappingListInputRule(bulletRegexp, { | ||
type: "bullet", | ||
kind: "bullet", | ||
collapsed: false | ||
@@ -1020,3 +1025,3 @@ }), | ||
return { | ||
type: "ordered", | ||
kind: "ordered", | ||
collapsed: false, | ||
@@ -1028,3 +1033,3 @@ order: order != null && order >= 2 ? order : null | ||
return { | ||
type: "task", | ||
kind: "task", | ||
checked: ["x", "X"].includes(match[1]), | ||
@@ -1035,3 +1040,3 @@ collapsed: false | ||
wrappingListInputRule(toggleRegexp, { | ||
type: "toggle" | ||
kind: "toggle" | ||
}) | ||
@@ -1050,3 +1055,3 @@ ]; | ||
for (const child of (_a = node.content) != null ? _a : []) { | ||
content.push(migrateNode(child, { type: "bullet" })[0]); | ||
content.push(migrateNode(child, { kind: "bullet" })[0]); | ||
} | ||
@@ -1056,3 +1061,3 @@ } else if (node.type === "ordered_list" || node.type === "orderedList") { | ||
for (const child of (_b = node.content) != null ? _b : []) { | ||
content.push(migrateNode(child, { type: "ordered" })[0]); | ||
content.push(migrateNode(child, { kind: "ordered" })[0]); | ||
} | ||
@@ -1062,3 +1067,3 @@ } else if (node.type === "task_list" || node.type === "taskList") { | ||
for (const child of (_c = node.content) != null ? _c : []) { | ||
content.push(migrateNode(child, { type: "task" })[0]); | ||
content.push(migrateNode(child, { kind: "task" })[0]); | ||
} | ||
@@ -1071,3 +1076,3 @@ } else { | ||
} | ||
function migrateNode(node, { type } = {}) { | ||
function migrateNode(node, { kind } = {}) { | ||
var _a; | ||
@@ -1080,5 +1085,5 @@ if (node.type === "list_item" || node.type === "listItem" || node.type === "taskListItem") { | ||
attrs: { | ||
collapsed: (_a = node.attrs) == null ? void 0 : _a.closed, | ||
collapsed: Boolean((_a = node.attrs) == null ? void 0 : _a.closed), | ||
...node.attrs, | ||
type: type != null ? type : "bullet" | ||
kind: kind != null ? kind : "bullet" | ||
}, | ||
@@ -1085,0 +1090,0 @@ content: node.content ? migrateNodes(node.content)[0] : void 0 |
@@ -93,3 +93,3 @@ import { Attrs } from 'prosemirror-model'; | ||
class: string; | ||
'data-list-type': ListType | undefined; | ||
'data-list-kind': ListKind | undefined; | ||
'data-list-order': string | undefined; | ||
@@ -156,3 +156,3 @@ 'data-list-checked': string | undefined; | ||
export declare interface ListAttributes { | ||
type?: ListType; | ||
kind?: ListKind; | ||
order?: number | null; | ||
@@ -198,2 +198,5 @@ checked?: boolean; | ||
/** @public */ | ||
export declare type ListKind = 'bullet' | 'ordered' | 'task' | 'toggle'; | ||
/** | ||
@@ -230,5 +233,2 @@ * Renders a list node to DOM output spec. | ||
/** @public */ | ||
export declare type ListType = 'bullet' | 'ordered' | 'task' | 'toggle'; | ||
/** | ||
@@ -235,0 +235,0 @@ * All the literal types |
@@ -28,3 +28,3 @@ // src/commands/dedent-list.ts | ||
return { | ||
type: element.getAttribute("data-list-type") || "bullet", | ||
kind: element.getAttribute("data-list-kind") || "bullet", | ||
order: parseInteger(element.getAttribute("data-list-order")), | ||
@@ -43,15 +43,15 @@ checked: element.hasAttribute("data-list-checked"), | ||
return { | ||
type: "task", | ||
kind: "task", | ||
checked: checkbox.hasAttribute("checked") | ||
}; | ||
} | ||
if (element.hasAttribute("data-task-list-item") || element.getAttribute("data-list-type") === "task") { | ||
if (element.hasAttribute("data-task-list-item") || element.getAttribute("data-list-kind") === "task") { | ||
return { | ||
type: "task", | ||
kind: "task", | ||
checked: element.hasAttribute("data-checked") | ||
}; | ||
} | ||
if (element.hasAttribute("data-toggle-list-item") || element.getAttribute("data-list-type") === "toggle") { | ||
if (element.hasAttribute("data-toggle-list-item") || element.getAttribute("data-list-kind") === "toggle") { | ||
return { | ||
type: "toggle", | ||
kind: "toggle", | ||
collapsed: element.hasAttribute("data-list-collapsed") | ||
@@ -62,3 +62,3 @@ }; | ||
return { | ||
type: "bullet" | ||
kind: "bullet" | ||
}; | ||
@@ -72,7 +72,7 @@ } | ||
return { | ||
type: "ordered" | ||
kind: "ordered" | ||
}; | ||
} | ||
return { | ||
type: "ordered", | ||
kind: "ordered", | ||
order: parseInteger(element.getAttribute("data-list-order")) | ||
@@ -109,3 +109,3 @@ }; | ||
if (nativeList) { | ||
const listTag = attrs.type === "ordered" ? "ol" : "ul"; | ||
const listTag = attrs.kind === "ordered" ? "ol" : "ul"; | ||
if (markerContainer) { | ||
@@ -126,3 +126,3 @@ return [listTag, ["li", domAttrs, markerContainer, contentContainer]]; | ||
const attrs = node.attrs; | ||
switch (attrs.type) { | ||
switch (attrs.kind) { | ||
case "task": | ||
@@ -148,6 +148,6 @@ return [ | ||
const markerHidden = ((_a = node.firstChild) == null ? void 0 : _a.type) === node.type; | ||
const markerType = markerHidden ? void 0 : attrs.type || "bullet"; | ||
const markerType = markerHidden ? void 0 : attrs.kind || "bullet"; | ||
const domAttrs = { | ||
class: "prosemirror-flat-list", | ||
"data-list-type": markerType, | ||
"data-list-kind": markerType, | ||
"data-list-order": attrs.order != null ? String(attrs.order) : void 0, | ||
@@ -170,3 +170,3 @@ "data-list-checked": attrs.checked ? "" : void 0, | ||
attrs: { | ||
type: { | ||
kind: { | ||
default: "bullet" | ||
@@ -753,3 +753,8 @@ }, | ||
const pos = $from.after(-1); | ||
tr.insert(pos, listNode.type.createAndFill({ type: attrs.type })); | ||
tr.insert( | ||
pos, | ||
listNode.type.createAndFill({ | ||
kind: attrs.kind | ||
}) | ||
); | ||
tr.setSelection(Selection.near(tr.doc.resolve(pos))); | ||
@@ -766,4 +771,4 @@ dispatch(tr); | ||
// We don't want to inherit all list attributes (e.g. checked) except | ||
// for the list type | ||
type: attrs.type | ||
// for the list kind | ||
kind: attrs.kind | ||
} | ||
@@ -962,5 +967,5 @@ }, | ||
const attrs = node.attrs; | ||
if (attrs.type === "task") { | ||
if (attrs.kind === "task") { | ||
return { ...attrs, checked: !attrs.checked }; | ||
} else if (attrs.type === "toggle") { | ||
} else if (attrs.kind === "toggle") { | ||
return { ...attrs, collapsed: !attrs.collapsed }; | ||
@@ -1013,3 +1018,3 @@ } else { | ||
wrappingListInputRule(bulletRegexp, { | ||
type: "bullet", | ||
kind: "bullet", | ||
collapsed: false | ||
@@ -1020,3 +1025,3 @@ }), | ||
return { | ||
type: "ordered", | ||
kind: "ordered", | ||
collapsed: false, | ||
@@ -1028,3 +1033,3 @@ order: order != null && order >= 2 ? order : null | ||
return { | ||
type: "task", | ||
kind: "task", | ||
checked: ["x", "X"].includes(match[1]), | ||
@@ -1035,3 +1040,3 @@ collapsed: false | ||
wrappingListInputRule(toggleRegexp, { | ||
type: "toggle" | ||
kind: "toggle" | ||
}) | ||
@@ -1050,3 +1055,3 @@ ]; | ||
for (const child of (_a = node.content) != null ? _a : []) { | ||
content.push(migrateNode(child, { type: "bullet" })[0]); | ||
content.push(migrateNode(child, { kind: "bullet" })[0]); | ||
} | ||
@@ -1056,3 +1061,3 @@ } else if (node.type === "ordered_list" || node.type === "orderedList") { | ||
for (const child of (_b = node.content) != null ? _b : []) { | ||
content.push(migrateNode(child, { type: "ordered" })[0]); | ||
content.push(migrateNode(child, { kind: "ordered" })[0]); | ||
} | ||
@@ -1062,3 +1067,3 @@ } else if (node.type === "task_list" || node.type === "taskList") { | ||
for (const child of (_c = node.content) != null ? _c : []) { | ||
content.push(migrateNode(child, { type: "task" })[0]); | ||
content.push(migrateNode(child, { kind: "task" })[0]); | ||
} | ||
@@ -1071,3 +1076,3 @@ } else { | ||
} | ||
function migrateNode(node, { type } = {}) { | ||
function migrateNode(node, { kind } = {}) { | ||
var _a; | ||
@@ -1080,5 +1085,5 @@ if (node.type === "list_item" || node.type === "listItem" || node.type === "taskListItem") { | ||
attrs: { | ||
collapsed: (_a = node.attrs) == null ? void 0 : _a.closed, | ||
collapsed: Boolean((_a = node.attrs) == null ? void 0 : _a.closed), | ||
...node.attrs, | ||
type: type != null ? type : "bullet" | ||
kind: kind != null ? kind : "bullet" | ||
}, | ||
@@ -1085,0 +1090,0 @@ content: node.content ? migrateNodes(node.content)[0] : void 0 |
{ | ||
"name": "prosemirror-flat-list", | ||
"type": "module", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "", | ||
@@ -6,0 +6,0 @@ "author": "ocavue <ocavue@gmail.com>", |
Sorry, the diff of this file is not supported yet
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
121837
3900