mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
* Disable text selection * Set content-editable=plaintext-only to disable Touch Bar formatting buttons * Enlarge resize handle tap targets for pen/touch * Make the lock button a button in mobile mode * Use icons instead of Unicode characters; add an alternate toolbar for creating multipoint lines * Allow buttons to hide themselves * Fix heuristic for showing shape actions * Refactor icons * Fix label for edit button * Switch edit button icon * Remove lock button on mobile * Add language selector on mobile * Fix showing edit button on mobile * Fix showing edit button on mobile, part 2 * Fix handle touch regions * Fix scroll-back button position * Allow using the text tool on a text object to start editing it * Fix deletion of last point in line
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import "./ProjectName.css";
|
|
|
|
import React, { Component } from "react";
|
|
import { selectNode, removeSelection } from "../utils";
|
|
|
|
type Props = {
|
|
value: string;
|
|
onChange: (value: string) => void;
|
|
label: string;
|
|
};
|
|
|
|
export class ProjectName extends Component<Props> {
|
|
private handleFocus = (e: React.FocusEvent<HTMLElement>) => {
|
|
selectNode(e.currentTarget);
|
|
};
|
|
|
|
private handleBlur = (e: React.FocusEvent<HTMLElement>) => {
|
|
const value = e.currentTarget.innerText.trim();
|
|
if (value !== this.props.value) {
|
|
this.props.onChange(value);
|
|
}
|
|
removeSelection();
|
|
};
|
|
|
|
private handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {
|
|
if (e.key === "Enter") {
|
|
e.preventDefault();
|
|
if (e.nativeEvent.isComposing || e.keyCode === 229) {
|
|
return;
|
|
}
|
|
e.currentTarget.blur();
|
|
}
|
|
};
|
|
|
|
public render() {
|
|
return (
|
|
<span
|
|
suppressContentEditableWarning
|
|
contentEditable={"plaintext-only" as any}
|
|
data-type="wysiwyg"
|
|
className="ProjectName"
|
|
role="textbox"
|
|
aria-label={this.props.label}
|
|
onBlur={this.handleBlur}
|
|
onKeyDown={this.handleKeyDown}
|
|
onFocus={this.handleFocus}
|
|
>
|
|
{this.props.value}
|
|
</span>
|
|
);
|
|
}
|
|
}
|