Add a button to upload images into comments (#6092)

This commit is contained in:
Tom Moor
2023-10-29 20:42:49 -04:00
committed by GitHub
parent 44cbf4359f
commit d593976b4d
4 changed files with 72 additions and 10 deletions

View File

@@ -23,6 +23,7 @@ import {
import { Decoration, EditorView, NodeViewConstructor } from "prosemirror-view";
import * as React from "react";
import styled, { css, DefaultTheme, ThemeProps } from "styled-components";
import insertFiles from "@shared/editor/commands/insertFiles";
import Styles from "@shared/editor/components/Styles";
import { EmbedDescriptor } from "@shared/editor/embeds";
import Extension, { CommandFactory } from "@shared/editor/lib/Extension";
@@ -584,6 +585,25 @@ export class Editor extends React.PureComponent<
window?.getSelection()?.removeAllRanges();
};
/**
* Insert files at the current selection.
* =
* @param event The source event
* @param files The files to insert
* @returns True if the files were inserted
*/
public insertFiles = (
event: React.ChangeEvent<HTMLInputElement>,
files: File[]
) =>
insertFiles(
this.view,
event,
this.view.state.selection.to,
files,
this.props
);
/**
* Returns true if the trimmed content of the editor is an empty string.
*