Move to TanStack Start from Next.js (#184)

This commit is contained in:
Aslam
2024-10-07 16:44:17 +07:00
committed by GitHub
parent 3a89a1c07f
commit 950ebc3dad
514 changed files with 20021 additions and 15508 deletions

View File

@@ -0,0 +1,12 @@
import { Editor } from "@tiptap/core"
import { LAEditorProps } from "../../la-editor"
export function getOutput(editor: Editor, output: LAEditorProps["output"]) {
if (output === "html") return editor.getHTML()
if (output === "json") return editor.getJSON()
if (output === "text") return editor.getText()
return ""
}
export * from "./isCustomNodeSelected"
export * from "./isTextSelected"

View File

@@ -0,0 +1,37 @@
import { HorizontalRule } from "../../extensions/horizontal-rule"
import { Link } from "../../extensions/link"
import { Editor } from "@tiptap/react"
export const isTableGripSelected = (node: HTMLElement) => {
let container = node
while (container && !["TD", "TH"].includes(container.tagName)) {
container = container.parentElement!
}
const gripColumn =
container &&
container.querySelector &&
container.querySelector("a.grip-column.selected")
const gripRow =
container &&
container.querySelector &&
container.querySelector("a.grip-row.selected")
if (gripColumn || gripRow) {
return true
}
return false
}
export const isCustomNodeSelected = (editor: Editor, node: HTMLElement) => {
const customNodes = [HorizontalRule.name, Link.name]
return (
customNodes.some((type) => editor.isActive(type)) ||
isTableGripSelected(node)
)
}
export default isCustomNodeSelected

View File

@@ -0,0 +1,26 @@
import { isTextSelection } from "@tiptap/core"
import { Editor } from "@tiptap/react"
export const isTextSelected = ({ editor }: { editor: Editor }) => {
const {
state: {
doc,
selection,
selection: { empty, from, to },
},
} = editor
// Sometime check for `empty` is not enough.
// Doubleclick an empty paragraph returns a node size of 2.
// So we check also for an empty text size.
const isEmptyTextBlock =
!doc.textBetween(from, to).length && isTextSelection(selection)
if (empty || isEmptyTextBlock || !editor.isEditable) {
return false
}
return true
}
export default isTextSelected