-
Notifications
You must be signed in to change notification settings - Fork 385
Screenshot #1481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Screenshot #1481
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
"dependencies": { | ||
"@floating-ui/dom": "^1.7.4", | ||
"@hypr/plugin-db": "workspace:^", | ||
"@hypr/plugin-misc": "workspace:^", | ||
"@hypr/ui": "workspace:^", | ||
Comment on lines
+19
to
20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 🧩 Analysis chainNew deps OK; keep TipTap versions aligned. Both additions make sense for image handling. Ensure the lockfile resolves all @tiptap/* to the same 3.4.x to avoid duplicate installs. Run to inspect @tiptap versions across the workspace: Also applies to: 28-29 🏁 Script executed: #!/bin/bash
fd -a package.json -E node_modules -E dist -E build -E out \
| xargs -I{} sh -c 'jq -r "\"\(.name)//deps\" as \$p | (.dependencies//{} + .devDependencies//{} + .peerDependencies//{}) | to_entries[] | select(.key|startswith(\"@tiptap/\")) | "\$p:\(.key)@\(.value)\"" "{}"' \
| sort -u Length of output: 1187 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find package.json files excluding common build dirs
mapfile -t files < <(find . -type f -name package.json -not -path "*/node_modules/*" -not -path "*/dist/*" -not -path "*/build/*" -not -path "*/out/*")
if [ ${#files[@]} -eq 0 ]; then
echo "NO_PACKAGE_JSON_FOUND"
exit 0
fi
for f in "${files[@]}"; do
name=$(jq -r '.name // empty' "$f" 2>/dev/null || true)
if [ -z "$name" ]; then name="$f"; fi
jq -r '(.dependencies // {} + .devDependencies // {} + .peerDependencies // {} + .optionalDependencies // {}) | to_entries[] | select(.key | startswith("@tiptap/")) | "\(.key)@\(.value)"' "$f" 2>/dev/null \
| awk -v p="$f" -v n="$name" '{print p " // " n ":" $0}'
done | sort -u || true Length of output: 56 🏁 Script executed: #!/bin/bash
set -euo pipefail
if ! command -v jq >/dev/null 2>&1; then
echo "MISSING_JQ"
exit 0
fi
echo "---- PACKAGE.JSON SCAN ----"
find . -type f -name package.json -not -path "*/node_modules/*" -not -path "*/dist/*" -not -path "*/build/*" -not -path "*/out/*" -print0 \
| while IFS= read -r -d '' f; do
name=$(jq -r '.name // empty' "$f" 2>/dev/null || true)
if [ -z "$name" ]; then name="$f"; fi
jq -r '(.dependencies // {} + .devDependencies // {} + .peerDependencies // {} + .optionalDependencies // {})
| to_entries[]
| select(.key | test("^@tiptap/"))
| "\(.key)@\(.value)"' "$f" 2>/dev/null \
| awk -v f="$f" -v n="$name" '{print f " // " n ":" $0}'
done | sort -u || true
echo "---- LOCKFILE SCAN ----"
find . -type f \( -name "pnpm-lock.yaml" -o -name "yarn.lock" -o -name "package-lock.json" -o -name "npm-shrinkwrap.json" \) -not -path "*/node_modules/*" -print0 \
| while IFS= read -r -d '' lf; do
echo "LOCKFILE: $lf"
if grep -n --color=never -E "@tiptap/" "$lf" >/dev/null 2>&1; then
grep -n -E "@tiptap/" "$lf" | sed -n '1,200p'
else
echo "NO_TIPTAP_FOUND_IN_LOCKFILE"
fi
done || true Length of output: 13537 New deps OK; align @tiptap versions in lockfile. @hypr/plugin-misc and @hypr/ui additions are fine for image handling. packages/tiptap/package.json pulls @tiptap/extension-file-handler@^3.4.2, but pnpm-lock.yaml shows most @tiptap/* resolved to 3.4.1 while extension-file-handler (and extension-text-style transitively) resolved to 3.4.2. Align all @tiptap/* to a single 3.4.x (either upgrade everything to 3.4.2 or pin file-handler/text-style to 3.4.1) and regenerate the lockfile to avoid duplicate installs. |
||
"@hypr/utils": "workspace:^", | ||
"@remixicon/react": "^4.6.0", | ||
|
@@ -24,6 +25,7 @@ | |
"@tiptap/core": "^3.4.1", | ||
"@tiptap/extension-bubble-menu": "^3.4.1", | ||
"@tiptap/extension-document": "^3.4.1", | ||
"@tiptap/extension-file-handler": "^3.4.2", | ||
"@tiptap/extension-highlight": "^3.4.1", | ||
"@tiptap/extension-history": "^3.4.1", | ||
"@tiptap/extension-image": "^3.4.1", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,23 @@ import TaskItem from "@tiptap/extension-task-item"; | |
import TaskList from "@tiptap/extension-task-list"; | ||
import Underline from "@tiptap/extension-underline"; | ||
import StarterKit from "@tiptap/starter-kit"; | ||
import FileHandler from "@tiptap/extension-file-handler"; | ||
|
||
import { commands as miscCommands } from "@hypr/plugin-misc"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gate FileHandler behind sessionId and avoid bundling Tauri in web/SSR; drop PII-y debug logs.
Apply this diff: -import { commands as miscCommands } from "@hypr/plugin-misc";
@@
ClipboardTextSerializer,
- FileHandler.configure({
+ ...(sessionId ? [
+ FileHandler.configure({
allowedMimeTypes: ['image/png', 'image/jpeg', 'image/gif', 'image/webp'],
onDrop: async (currentEditor, files, pos) => {
- console.log("onDrop", files, pos)
for (const file of files) {
try {
// Convert file to bytes
const arrayBuffer = await file.arrayBuffer()
const bytes = new Uint8Array(arrayBuffer)
const extension = getFileExtension(file.name)
- // Upload via Tauri command
- const imageUrl = await miscCommands.imageUpload(sessionId, Array.from(bytes), extension)
- console.log("full note html: ", currentEditor.getHTML())
+ const { commands: miscCommands } = await import("@hypr/plugin-misc")
+ const imageUrl = await miscCommands.imageUpload(sessionId, Array.from(bytes), extension)
// Insert URL (not base64!)
currentEditor
.chain()
.insertContentAt(pos, {
type: 'image',
attrs: {
src: imageUrl,
},
})
.focus()
.run()
} catch (error) {
console.error('Failed to upload image:', error)
}
}
},
onPaste: async (currentEditor, files, htmlContent) => {
for (const file of files) {
- console.log("onPaste", files, htmlContent)
if (htmlContent) {
- // if there is htmlContent, stop manual insertion & let other extensions handle insertion via inputRule
- console.log(htmlContent) // eslint-disable-line no-console
return false
}
try {
// Convert file to bytes
const arrayBuffer = await file.arrayBuffer()
const bytes = new Uint8Array(arrayBuffer)
const extension = getFileExtension(file.name)
- // Upload via Tauri command
- const imageUrl = await miscCommands.imageUpload(sessionId, Array.from(bytes), extension)
- console.log("full note html: ", currentEditor.getHTML())
+ const { commands: miscCommands } = await import("@hypr/plugin-misc")
+ const imageUrl = await miscCommands.imageUpload(sessionId, Array.from(bytes), extension)
// Insert URL (not base64!)
currentEditor
.chain()
.insertContentAt(currentEditor.state.selection.anchor, {
type: 'image',
attrs: {
src: imageUrl,
},
})
.focus()
.run()
} catch (error) {
console.error('Failed to upload image:', error)
}
}
},
- }),
+ }),
+ ] : []), Also applies to: 101-167 🤖 Prompt for AI Agents
|
||
|
||
import { AIHighlight } from "./ai-highlight"; | ||
import { StreamingAnimation } from "./animation"; | ||
import { ClipboardTextSerializer } from "./clipboard"; | ||
import CustomListKeymap from "./custom-list-keymap"; | ||
import { Hashtag } from "./hashtag"; | ||
|
||
export const extensions = [ | ||
// Helper function to extract file extension | ||
const getFileExtension = (filename: string): string => { | ||
const ext = filename.split('.').pop()?.toLowerCase(); | ||
return ext || 'png'; | ||
}; | ||
|
||
export const createExtensions = (sessionId: string) => [ | ||
StarterKit.configure({ | ||
heading: { | ||
levels: [1], | ||
|
@@ -89,4 +98,74 @@ export const extensions = [ | |
CustomListKeymap, | ||
StreamingAnimation, | ||
ClipboardTextSerializer, | ||
FileHandler.configure({ | ||
allowedMimeTypes: ['image/png', 'image/jpeg', 'image/gif', 'image/webp'], | ||
onDrop: async (currentEditor, files, pos) => { | ||
console.log("onDrop", files, pos) | ||
for (const file of files) { | ||
try { | ||
// Convert file to bytes | ||
const arrayBuffer = await file.arrayBuffer() | ||
const bytes = new Uint8Array(arrayBuffer) | ||
const extension = getFileExtension(file.name) | ||
|
||
// Upload via Tauri command | ||
const imageUrl = await miscCommands.imageUpload(sessionId, Array.from(bytes), extension) | ||
console.log("full note html: ", currentEditor.getHTML()) | ||
|
||
// Insert URL (not base64!) | ||
currentEditor | ||
.chain() | ||
.insertContentAt(pos, { | ||
type: 'image', | ||
attrs: { | ||
src: imageUrl, | ||
}, | ||
}) | ||
.focus() | ||
.run() | ||
} catch (error) { | ||
console.error('Failed to upload image:', error) | ||
} | ||
} | ||
}, | ||
onPaste: async (currentEditor, files, htmlContent) => { | ||
for (const file of files) { | ||
console.log("onPaste", files, htmlContent) | ||
if (htmlContent) { | ||
// if there is htmlContent, stop manual insertion & let other extensions handle insertion via inputRule | ||
console.log(htmlContent) // eslint-disable-line no-console | ||
return false | ||
} | ||
|
||
try { | ||
// Convert file to bytes | ||
const arrayBuffer = await file.arrayBuffer() | ||
const bytes = new Uint8Array(arrayBuffer) | ||
const extension = getFileExtension(file.name) | ||
|
||
// Upload via Tauri command | ||
const imageUrl = await miscCommands.imageUpload(sessionId, Array.from(bytes), extension) | ||
console.log("full note html: ", currentEditor.getHTML()) | ||
|
||
// Insert URL (not base64!) | ||
currentEditor | ||
.chain() | ||
.insertContentAt(currentEditor.state.selection.anchor, { | ||
type: 'image', | ||
attrs: { | ||
src: imageUrl, | ||
}, | ||
}) | ||
.focus() | ||
.run() | ||
} catch (error) { | ||
console.error('Failed to upload image:', error) | ||
} | ||
} | ||
}, | ||
}), | ||
]; | ||
|
||
// For backward compatibility - default extensions without session ID | ||
export const extensions = createExtensions(''); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Automatically generated - DO NOT EDIT! | ||
|
||
"$schema" = "../../schemas/schema.json" | ||
|
||
[[permission]] | ||
identifier = "allow-image-delete" | ||
description = "Enables the image_delete command without any pre-configured scope." | ||
commands.allow = ["image_delete"] | ||
|
||
[[permission]] | ||
identifier = "deny-image-delete" | ||
description = "Denies the image_delete command without any pre-configured scope." | ||
commands.deny = ["image_delete"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Automatically generated - DO NOT EDIT! | ||
|
||
"$schema" = "../../schemas/schema.json" | ||
|
||
[[permission]] | ||
identifier = "allow-image-upload" | ||
description = "Enables the image_upload command without any pre-configured scope." | ||
commands.allow = ["image_upload"] | ||
|
||
[[permission]] | ||
identifier = "deny-image-upload" | ||
description = "Denies the image_upload command without any pre-configured scope." | ||
commands.deny = ["image_upload"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused callbacks to meet repo guidelines.
handleImagePaste
andhandleImageCopy
are unused; violates “no unused functions.”Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents