From a180574f56447d6f24b4e77f87efba3a1287da9c Mon Sep 17 00:00:00 2001 From: bob Date: Mon, 29 Apr 2019 09:43:10 -0400 Subject: fixed title template and overlay text positioning --- src/client/views/MainOverlayTextBox.tsx | 9 ++++----- src/client/views/Templates.tsx | 2 +- src/client/views/nodes/FormattedTextBox.tsx | 11 +++++------ 3 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/client/views/MainOverlayTextBox.tsx b/src/client/views/MainOverlayTextBox.tsx index 209b1202c..13e661b46 100644 --- a/src/client/views/MainOverlayTextBox.tsx +++ b/src/client/views/MainOverlayTextBox.tsx @@ -21,7 +21,6 @@ export class MainOverlayTextBox extends React.Component public static Instance: MainOverlayTextBox; @observable public TextDoc?: Document = undefined; public TextScroll: number = 0; - @observable _textRect: any; @observable _textXf: () => Transform = () => Transform.Identity(); private _textFieldKey: Key = KeyStore.Data; private _textColor: string | null = null; @@ -47,7 +46,6 @@ export class MainOverlayTextBox extends React.Component if (div) { this._textColor = div.style.color; div.style.color = "transparent"; - this._textRect = div.getBoundingClientRect(); this.TextScroll = div.scrollTop; } } @@ -88,11 +86,12 @@ export class MainOverlayTextBox extends React.Component } render() { - if (this.TextDoc) { + if (this.TextDoc && this._textTargetDiv) { + let textRect = this._textTargetDiv.getBoundingClientRect(); let s = this._textXf().Scale; - return
+ return
+ style={{ width: `${textRect.width * s}px`, height: `${textRect.height * s}px` }}> diff --git a/src/client/views/Templates.tsx b/src/client/views/Templates.tsx index a0f9fe7e5..fef69392d 100644 --- a/src/client/views/Templates.tsx +++ b/src/client/views/Templates.tsx @@ -51,7 +51,7 @@ export namespace Templates { ); export const Title = new Template("Title", TemplatePosition.InnerTop, - `
{layout}
{Title}
` + `
{layout}
{Title}
` ); export const TemplateList: Template[] = [Title, OuterCaption, InnerCaption, SideCaption]; diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index 92957ed19..41ee24498 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -80,7 +80,11 @@ export class FormattedTextBox extends React.Component<(FieldViewProps & Formatte ); this.props.Document.SetDataOnPrototype(KeyStore.DocumentText, state.doc.textBetween(0, state.doc.content.size, "\n\n"), TextField); this._applyingChange = false; - // doc.SetData(fieldKey, JSON.stringify(state.toJSON()), RichTextField); + if (this.props.Document.Title.startsWith("-") && this._editorView) { + let str = this._editorView.state.doc.textContent; + let titlestr = str.substr(0, Math.min(40, str.length)); + this.props.Document.SetText(KeyStore.Title, "-" + titlestr + (str.length > 40 ? "..." : "")); + }; } } @@ -265,11 +269,6 @@ export class FormattedTextBox extends React.Component<(FieldViewProps & Formatte // stop propagation doesn't seem to stop propagation of native keyboard events. // so we set a flag on the native event that marks that the event's been handled. (e.nativeEvent as any).DASHFormattedTextBoxHandled = true; - if (this.props.Document.Title.startsWith("-") && this._editorView) { - let str = this._editorView.state.doc.textContent; - let titlestr = str.substr(0, Math.min(40, str.length)); - this.props.Document.SetText(KeyStore.Title, "-" + titlestr + (str.length > 40 ? "..." : "")); - }; } render() { let style = this.props.isOverlay ? "-scroll" : "-hidden"; -- cgit v1.2.3-70-g09d2