mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11.x) (push) Waiting to run
Python CI / Format Backend (3.12.x) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11.x) (push) Waiting to run
Python CI / Format Backend (3.12.x) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
This commit is contained in:
parent
d81886e315
commit
bf7a18a0f8
@ -301,30 +301,37 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
// Check if the current selection is inside a structured block (like codeBlock or list)
|
if (event.shiftKey) {
|
||||||
const { state } = view;
|
editor.commands.setHardBreak(); // Insert a hard break
|
||||||
const { $head } = state.selection;
|
view.dispatch(view.state.tr.scrollIntoView()); // Move viewport to the cursor
|
||||||
|
event.preventDefault();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// Check if the current selection is inside a structured block (like codeBlock or list)
|
||||||
|
const { state } = view;
|
||||||
|
const { $head } = state.selection;
|
||||||
|
|
||||||
// Recursive function to check ancestors for specific node types
|
// Recursive function to check ancestors for specific node types
|
||||||
function isInside(nodeTypes: string[]): boolean {
|
function isInside(nodeTypes: string[]): boolean {
|
||||||
let currentNode = $head;
|
let currentNode = $head;
|
||||||
while (currentNode) {
|
while (currentNode) {
|
||||||
if (nodeTypes.includes(currentNode.parent.type.name)) {
|
if (nodeTypes.includes(currentNode.parent.type.name)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
if (!currentNode.depth) break; // Stop if we reach the top
|
||||||
|
currentNode = state.doc.resolve(currentNode.before()); // Move to the parent node
|
||||||
}
|
}
|
||||||
if (!currentNode.depth) break; // Stop if we reach the top
|
return false;
|
||||||
currentNode = state.doc.resolve(currentNode.before()); // Move to the parent node
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isInCodeBlock = isInside(['codeBlock']);
|
const isInCodeBlock = isInside(['codeBlock']);
|
||||||
const isInList = isInside(['listItem', 'bulletList', 'orderedList']);
|
const isInList = isInside(['listItem', 'bulletList', 'orderedList']);
|
||||||
const isInHeading = isInside(['heading']);
|
const isInHeading = isInside(['heading']);
|
||||||
|
|
||||||
if (isInCodeBlock || isInList || isInHeading) {
|
if (isInCodeBlock || isInList || isInHeading) {
|
||||||
// Let ProseMirror handle the normal Enter behavior
|
// Let ProseMirror handle the normal Enter behavior
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user