aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/linking/LinkPopup.tsx
diff options
context:
space:
mode:
authordinhanhtruong <70963346+dinhanhtruong@users.noreply.github.com>2021-07-24 15:21:23 -0400
committerdinhanhtruong <70963346+dinhanhtruong@users.noreply.github.com>2021-07-24 15:21:23 -0400
commit7b6de64a1244ba0944edf8301a7adc2cb1445f8a (patch)
tree005dc9990f0a3d04e2b0b79d352dabf4aa63bf73 /src/client/views/linking/LinkPopup.tsx
parent492edd8702b2125adc9e4f0e1a9ffb2462f8a308 (diff)
In-progress link popup
Diffstat (limited to 'src/client/views/linking/LinkPopup.tsx')
-rw-r--r--src/client/views/linking/LinkPopup.tsx26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/client/views/linking/LinkPopup.tsx b/src/client/views/linking/LinkPopup.tsx
index 5c4640fdf..89d5b7272 100644
--- a/src/client/views/linking/LinkPopup.tsx
+++ b/src/client/views/linking/LinkPopup.tsx
@@ -23,6 +23,8 @@ import { DefaultStyleProvider } from '../StyleProvider';
import { Transform } from '../../util/Transform';
import { DocUtils } from '../../documents/Documents';
import { SearchBox } from '../search/SearchBox';
+import { EditorView } from 'prosemirror-view';
+import { FormattedTextBox } from '../nodes/formattedText/FormattedTextBox';
interface LinkPopupProps {
showPopup: boolean;
@@ -38,6 +40,24 @@ interface LinkPopupProps {
@observer
export class LinkPopup extends React.Component<LinkPopupProps> {
+ @observable private linkURL: string = "";
+ @observable public view?: EditorView;
+ private Instance: LinkPopup = this;
+
+
+
+ // TODO: should check for valid URL
+ @undoBatch
+ makeLinkToURL = (target: string, lcoation: string) => {
+ ((this as any)?.TextView as FormattedTextBox).makeLinkAnchor(undefined, "onRadd:rightight", target, target);
+ }
+
+ @action
+ onLinkChange = (e: React.ChangeEvent<HTMLInputElement>) => {
+ this.linkURL = e.target.value;
+ console.log(this.linkURL)
+ }
+
getPWidth = () => 500;
getPHeight = () => 500;
@@ -47,9 +67,9 @@ export class LinkPopup extends React.Component<LinkPopupProps> {
return (
<div className="linkPopup-container" style={{ display: popupVisibility }}>
<div className="linkPopup-url-container">
- <input defaultValue={""} autoComplete="off" type="text" placeholder="Enter URL..." id="url-input"
- className="linkPopup-searchBox searchBox-input" />
- <button style={{ display: "block", margin: "10px auto", }}>Apply hyperlink</button>
+ <input autoComplete="off" type="text" value={this.linkURL} placeholder="Enter URL..." onChange={this.onLinkChange} />
+ <button onPointerDown={e => this.makeLinkToURL(this.linkURL, "add:right")}
+ style={{ display: "block", margin: "10px auto", }}>Apply hyperlink</button>
</div>
<div className="divider">
<div className="line"></div>