Skip to content

Commit

Permalink
freaking renaming again
Browse files Browse the repository at this point in the history
  • Loading branch information
ljm12914 committed Feb 6, 2025
1 parent 23a7d12 commit eb28809
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dist-ssr
*.local

# Editor directories and files
.vscode/*
#.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
Expand Down
20 changes: 20 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "dev",
"problemMatcher": [],
"label": "npm: dev",
"detail": "vite"
},
{
"type": "npm",
"script": "build",
"group": "build",
"problemMatcher": [],
"label": "npm: build",
"detail": "tsc -b && vite build"
}
]
}
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@tiptap/react": "^2.11.5",
"dexie": "^4.0.11",
"dexie-react-hooks": "^1.1.7",
"katex": "^0.16.21",
"lowlight": "^3.3.0",
"motion": "^12.3.1",
"react": "^18.3.1",
Expand Down
10 changes: 7 additions & 3 deletions src/components/Editor/extensions/block/orderedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const OrderedList = Node.create({
default: 1n,
isRequired: true,
keepOnSplit: false,
parseHTML: element=>element.getAttribute("data-ol-index"),
parseHTML: element=>BigInt(element.getAttribute("data-ol-index") ?? 1),
renderHTML: attrs=>({"data-ol-index": attrs.type})
},
type: {
Expand Down Expand Up @@ -140,8 +140,12 @@ function fromBase26(input :string){
}

function OrderedListComp(props :NodeViewProps){

return(<NodeViewWrapper className="dc-ol">
const {node} = props, localAttrs = {
"data-ol-index": node.attrs.index,
"data-ol-type": node.attrs.type,
"data-ol-reversed": node.attrs.reversed
};
return(<NodeViewWrapper className="dc-ol" {...localAttrs}>
<div className="dc-ol-marker-outer"><div className="dc-ol-marker">{props.node.attrs.index + ""}</div></div>
<NodeViewContent className="dc-container-outer" />
</NodeViewWrapper>);
Expand Down
42 changes: 42 additions & 0 deletions src/components/Editor/extensions/inline/formula.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Node, NodeViewContent, NodeViewWrapper, ReactNodeViewRenderer } from "@tiptap/react";

declare module "@tiptap/core"{
interface Commands<ReturnType>{
formulaInline: {
setFormulaInline: ()=>ReturnType;
unsetFormulaInline: ()=>ReturnType;
}
}
}

const FormulaInline = Node.create({
name: "formulaInline",
group: "inline",
inline: true,
atom: true,
selectable: true,
parseHTML: ()=>[
{tag: "div.dc-fm"}
],
addAttributes(){return{
latex: {
default: "",
isRequired: true,
keepOnSplit: false,
parseHTML: element=>element.getAttribute("data-fm-latex"),
renderHTML: attrs=>({"data-fm-latex": attrs.latex})
}
}},
addNodeView: ()=>ReactNodeViewRenderer(FormulaComp),
addCommands(){return{
setFormulaInline: ()=>({dispatch, tr})=>{
return true;
}
}}
});

function FormulaComp(){
return(<NodeViewWrapper className="dc-fm">
<NodeViewContent />
</NodeViewWrapper>);
}

0 comments on commit eb28809

Please sign in to comment.