aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
diff options
context:
space:
mode:
authorMelissa Zhang <mzhang19096@gmail.com>2020-07-06 23:43:41 -0700
committerMelissa Zhang <mzhang19096@gmail.com>2020-07-06 23:43:41 -0700
commit4fc843a84a3f3001f749d5152bdc491d8efe7f94 (patch)
treeade4c015b65635febbb5eebdd5a48281df6aa1a0 /src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
parentfbc7a328016af60052dd3f33c2d906e6c6447a5f (diff)
parent0438137cd435c47ce334b15a4ad00cbd70d80662 (diff)
merge with master
Diffstat (limited to 'src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts')
-rw-r--r--src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts b/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
index 9d69f4be7..3f73ec436 100644
--- a/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
+++ b/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts
@@ -16,13 +16,17 @@ const mac = typeof navigator !== "undefined" ? /Mac/.test(navigator.platform) :
export type KeyMap = { [key: string]: any };
-export let updateBullets = (tx2: Transaction, schema: Schema, mapStyle?: string, from?: number, to?: number) => {
+export let updateBullets = (tx2: Transaction, schema: Schema, assignedMapStyle?: string, from?: number, to?: number) => {
+ let mapStyle = assignedMapStyle;
tx2.doc.descendants((node: any, offset: any, index: any) => {
if ((from === undefined || to === undefined || (from <= offset + node.nodeSize && to >= offset)) && (node.type === schema.nodes.ordered_list || node.type === schema.nodes.list_item)) {
const path = (tx2.doc.resolve(offset) as any).path;
let depth = Array.from(path).reduce((p: number, c: any) => p + (c.hasOwnProperty("type") && c.type === schema.nodes.ordered_list ? 1 : 0), 0);
- if (node.type === schema.nodes.ordered_list) depth++;
- tx2.setNodeMarkup(offset, node.type, { ...node.attrs, mapStyle: mapStyle || node.attrs.mapStyle, bulletStyle: depth, }, node.marks);
+ if (node.type === schema.nodes.ordered_list) {
+ if (depth === 0 && !assignedMapStyle) mapStyle = node.attrs.mapStyle;
+ depth++;
+ }
+ tx2.setNodeMarkup(offset, node.type, { ...node.attrs, mapStyle, bulletStyle: depth, }, node.marks);
}
});
return tx2;