Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ export const createFileMention = (sdk: FrontendSDK) => {
syntaxHighlighting(githubDarkHighlight),
EditorView.editable.of(false),
EditorState.readOnly.of(true),
EditorView.lineWrapping,
lineNumbers(),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ function formatFileSize(bytes: number): string {
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i];
}

function escapeHtml(text: string): string {
const div = document.createElement("div");
div.textContent = text;
return div.innerHTML;
}

const isAtLineStart = (state: {
doc: {
resolve: (pos: number) => {
Expand Down Expand Up @@ -387,7 +393,7 @@ export const SlashCommands = Extension.create<SlashCommandsOptions>({
.map(
(file, i) => `
<button class="file-picker-item ${i === fileSelectedIndex ? "selected" : ""}" data-index="${i}">
<span class="file-picker-name">${file.name}</span>
<span class="file-picker-name">${escapeHtml(file.name)}</span>
<span class="file-picker-size">${formatFileSize(file.size)}</span>
</button>
`,
Expand Down
Loading