Skip to content

Commit df35813

Browse files
committed
Fix build runing twice on PRs + lint fix
1 parent 20b860b commit df35813

2 files changed

Lines changed: 36 additions & 20 deletions

File tree

.github/workflows/build.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
name: build
2-
on: ["push", "pull_request"]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize, reopened, edited]
8+
branches:
9+
- main
10+
- "project/**"
11+
312
jobs:
413
build:
514
name: Build
Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
1-
import {Plugin, PluginKey} from "prosemirror-state";
1+
import { Plugin, PluginKey } from "prosemirror-state";
22

33
const PLUGIN_KEY = new PluginKey(`ordered-list`);
44

55
export const OrderedListPlugin = () => {
66
return new Plugin({
77
key: PLUGIN_KEY,
88
appendTransaction: (_transactions, _oldState, newState) => {
9-
const newTr = newState.tr
10-
let modified = false
11-
let count = 1
12-
let skip = 0
9+
const newTr = newState.tr;
10+
let modified = false;
11+
let count = 1;
12+
let skip = 0;
1313
newState.doc.descendants((node, pos) => {
14-
if (node.type.name === "tcblock" && !node.attrs.listType) count = 1
15-
if (skip == 0 && node.type.name === "tcblock" && node.attrs.listType === "oli") {
16-
skip = node.content.childCount
14+
if (node.type.name === "tcblock" && !node.attrs.listType) count = 1;
15+
if (
16+
skip === 0 &&
17+
node.type.name === "tcblock" &&
18+
node.attrs.listType === "oli"
19+
) {
20+
skip = node.content.childCount;
1721
// This assumes that the content node is always the first child of the oli block,
1822
// as the content model grows this assumption may need to change
1923
if (node.content.child(0).attrs.position !== `${count}.`) {
2024
// TODO: @DAlperin currently sub-items just continue from the order of the parent,
2125
// sub-items should be ordered separately with letters or roman numerals or some such
22-
newTr.setNodeMarkup(pos+1, undefined, {...node.attrs, position: `${count}.`})
23-
modified = true
26+
newTr.setNodeMarkup(pos + 1, undefined, {
27+
...node.attrs,
28+
position: `${count}.`,
29+
});
30+
modified = true;
2431
}
2532

26-
count++
27-
} else if (skip > 0) skip--
28-
})
29-
if (modified){
30-
return newTr
33+
count++;
34+
} else if (skip > 0) skip--;
35+
});
36+
if (modified) {
37+
return newTr;
3138
}
32-
return null
33-
}
34-
})
35-
}
39+
return null;
40+
},
41+
});
42+
};

0 commit comments

Comments
 (0)