From 81c01ab4fc75f1a6212c8227a52bcf53b0d081e6 Mon Sep 17 00:00:00 2001 From: kimdahey Date: Tue, 27 Aug 2019 16:51:52 -0400 Subject: working on self-healing links --- src/client/views/nodes/FormattedTextBox.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index a98ae76ec..2f4c888f9 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -37,6 +37,7 @@ import { DocumentDecorations } from '../DocumentDecorations'; import { DictationManager } from '../../util/DictationManager'; import { ReplaceStep } from 'prosemirror-transform'; import { DocumentType } from '../../documents/DocumentTypes'; +import { link } from 'fs'; library.add(faEdit); library.add(faSmile, faTextHeight, faUpload); @@ -726,9 +727,22 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe let proto = Doc.GetProto(linkDoc); let targetContext = await Cast(proto.targetContext, Doc); let jumpToDoc = await Cast(linkDoc.anchor2, Doc); + + let guid: string; + if ((e.target as any).attributes.guid) { + guid = (e.target as any).attributes.guid; + } else if (linkDoc.guid) { + guid = StrCast(linkDoc.guid); + (e.target as any).attributes.guid = linkDoc.guid; + } else { + guid = Utils.GenerateGuid(); + (e.target as any).attributes.guid = guid; + linkDoc.guid = guid; + } + if (jumpToDoc) { if (DocumentManager.Instance.getDocumentView(jumpToDoc)) { - + // if !guid, then generate guid and apply to link.... DocumentManager.Instance.jumpToDocument(jumpToDoc, e.altKey, undefined, undefined, NumCast((jumpToDoc === linkDoc.anchor2 ? linkDoc.anchor2Page : linkDoc.anchor1Page))); return; } -- cgit v1.2.3-70-g09d2