aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-08-27 10:16:21 -0400
committerbob <bcz@cs.brown.edu>2019-08-27 10:16:21 -0400
commitd31999dd3fce11a886bd402c27f34c35c7c85935 (patch)
tree24026569304f6fb4b3c05f09d5423e78b2b2f5e4 /src
parent074961d68788d2d19b6bfbcc9b95712a7b3940eb (diff)
mostly working. some glitches though.
Diffstat (limited to 'src')
-rw-r--r--src/client/util/ProsemirrorExampleTransfer.ts9
-rw-r--r--src/client/util/RichTextSchema.tsx17
-rw-r--r--src/client/views/nodes/FormattedTextBox.scss23
3 files changed, 23 insertions, 26 deletions
diff --git a/src/client/util/ProsemirrorExampleTransfer.ts b/src/client/util/ProsemirrorExampleTransfer.ts
index d602ce4a1..4ca19eff1 100644
--- a/src/client/util/ProsemirrorExampleTransfer.ts
+++ b/src/client/util/ProsemirrorExampleTransfer.ts
@@ -79,19 +79,21 @@ export default function buildKeymap<S extends Schema<any>>(schema: S, mapKeys?:
bind("Mod-s", TooltipTextMenu.insertStar);
+ // let nodeTypeMark = depth == 2 ? "upper-alpha" : depth == 4 ? "lower-roman" : depth == 6 ? "lower-alpha" : "decimal";
+ let nodeTypeMark = (depth: number) => { return depth == 2 ? "decimal2" : depth == 4 ? "decimal3" : depth == 6 ? "decimal4" : "decimal" }
+
let bulletFunc = (state: EditorState<S>, dispatch: (tx: Transaction<S>) => void) => {
var ref = state.selection;
var range = ref.$from.blockRange(ref.$to);
var marks = state.storedMarks || (state.selection.$to.parentOffset && state.selection.$from.marks());
let depth = range && range.depth ? range.depth : 0;
- let nodeTypeMark = depth == 2 ? "upper-alpha" : depth == 4 ? "lower-roman" : depth == 6 ? "lower-alpha" : "decimal";
if (!sinkListItem(schema.nodes.list_item)(state, (tx2: Transaction) => {
const resolvedPos = tx2.doc.resolve(range!.start);
let path = (resolvedPos as any).path as any;
for (let i = path.length - 1; i > 0; i--) {
if (path[i].type === schema.nodes.ordered_list) {
- path[i].attrs.bulletStyle = nodeTypeMark;
+ path[i].attrs.bulletStyle = nodeTypeMark(depth);
break;
}
}
@@ -118,7 +120,6 @@ export default function buildKeymap<S extends Schema<any>>(schema: S, mapKeys?:
var range = ref.$from.blockRange(ref.$to);
var marks = state.storedMarks || (state.selection.$to.parentOffset && state.selection.$from.marks());
let depth = range && range.depth > 3 ? range.depth - 4 : 0;
- let nodeTypeMark = depth == 2 ? "upper-alpha" : depth == 4 ? "lower-roman" : depth == 6 ? "lower-alpha" : "decimal";
liftListItem(schema.nodes.list_item)(state, (tx2: Transaction) => {
try {
const resolvedPos = tx2.doc.resolve(Math.round((range!.start + range!.end) / 2));
@@ -126,7 +127,7 @@ export default function buildKeymap<S extends Schema<any>>(schema: S, mapKeys?:
let path = (resolvedPos as any).path as any;
for (let i = path.length - 1; i > 0; i--) {
if (path[i].type === schema.nodes.ordered_list) {
- path[i].attrs.bulletStyle = nodeTypeMark;
+ path[i].attrs.bulletStyle = nodeTypeMark(depth);
break;
}
}
diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx
index 655edb68a..2df49d8a4 100644
--- a/src/client/util/RichTextSchema.tsx
+++ b/src/client/util/RichTextSchema.tsx
@@ -178,10 +178,9 @@ export const nodes: { [index: string]: NodeSpec } = {
bulletStyle: { default: "decimal" },
},
toDOM(node: Node<any>) {
- (node.content as any).content.map((x: any) => x.type.attrs.className = node.attrs.bulletStyle);
- let fsize = node.attrs.bulletStyle === "decimal" ? 24 : node.attrs.bulletStyle === "upper-alpha" ? 18 : node.attrs.bulletStyle === "lower-roman" ? 14 : 10;
- return ['ol', { class: `${node.attrs.bulletStyle}-ol`, style: `list-style: none; font-size: ${fsize}` }, 0]
- //return ['ol', { class: `${node.attrs.bulletStyle}`, style: `list-style: ${node.attrs.bulletStyle}; font-size: ${fsize}` }, 0]
+ for (let i = 0; i < node.childCount; i++) node.child(i).attrs.className = node.attrs.bulletStyle;
+ return ['ol', { class: `${node.attrs.bulletStyle}-ol`, style: `list-style: none;` }, 0]
+ //return ['ol', { class: `${node.attrs.bulletStyle}`, style: `list-style: ${node.attrs.bulletStyle};`, 0]
}
},
//this doesn't currently work for some reason
@@ -210,15 +209,7 @@ export const nodes: { [index: string]: NodeSpec } = {
...listItem,
content: 'paragraph block*',
toDOM(node: any) {
- let first = node.firstChild;
- while (first) {
- if (first.marks.find((m: any) => m.type === schema.marks.mbulletType)) {
- let x = first.marks.find((m: any) => m.type === schema.marks.mbulletType);
- return ["li", { class: "XXX" }, 0];
- }
- first = first.firstChild;
- }
- return ["li", { class: node.type.attrs.className }, 0];
+ return ["li", { class: node.attrs.className }, 0];
}
},
};
diff --git a/src/client/views/nodes/FormattedTextBox.scss b/src/client/views/nodes/FormattedTextBox.scss
index 1e429e4be..e93ceda21 100644
--- a/src/client/views/nodes/FormattedTextBox.scss
+++ b/src/client/views/nodes/FormattedTextBox.scss
@@ -67,13 +67,18 @@
font-style: italic;
}
-
ol { counter-reset: deci 0;}
-.decimal-ol {counter-reset: deci 0;}
-.upper-alpha-ol {counter-reset: ualph; }
-.lower-roman-ol {counter-reset: lroman; }
-.lower-alpha-ol {counter-reset: lalpha; }
-.decimal:before { content: counter(deci) " "; counter-increment: deci }
-.upper-alpha:before { content: counter(deci) "." counter(ualph, upper-alpha) " "; counter-increment: ualph }
-.lower-roman:before { content: counter(deci) "." counter(ualph, upper-alpha) "." counter(lroman, lower-roman) " "; counter-increment: lroman }
-.lower-alpha:before { content: counter(deci) "." counter(ualph, upper-alpha) "." counter(lroman, lower-roman) "." counter(lalpha, lower-alpha)" "; counter-increment: lalpha }
+.decimal-ol { counter-reset: deci 0; p { display: inline }; font-size: 24 }
+.decimal2-ol {counter-reset: deci2; p { display: inline }; font-size: 18 }
+.decimal3-ol {counter-reset: deci3; p { display: inline }; font-size: 14 }
+.decimal4-ol {counter-reset: deci4; p { display: inline }; font-size: 10 }
+.upper-alpha-ol {counter-reset: ualph; p { display: inline }; font-size: 18 }
+.lower-roman-ol {counter-reset: lroman; p { display: inline }; font-size: 14; }
+.lower-alpha-ol {counter-reset: lalpha; p { display: inline }; font-size: 10;}
+.decimal:before { content: counter(deci) " "; counter-increment: deci; display:inline-block; width: 30}
+.decimal2:before { content: counter(deci) "." counter(deci2) " "; counter-increment: deci2; display:inline-block; width: 35}
+.decimal3:before { content: counter(deci) "." counter(deci2) "." counter(deci3) " "; counter-increment: deci3; display:inline-block; width: 35}
+.decimal4:before { content: counter(deci) "." counter(deci2) "." counter(deci3) "." counter(deci4) " "; counter-increment: deci4; display:inline-block; width: 40}
+.upper-alpha:before { content: counter(deci) "." counter(ualph, upper-alpha) " "; counter-increment: ualph; display:inline-block; width: 35 }
+.lower-roman:before { content: counter(deci) "." counter(ualph, upper-alpha) "." counter(lroman, lower-roman) " "; counter-increment: lroman;display:inline-block; width: 50 }
+.lower-alpha:before { content: counter(deci) "." counter(ualph, upper-alpha) "." counter(lroman, lower-roman) "." counter(lalpha, lower-alpha)" "; counter-increment: lalpha; display:inline-block; width: 35}