aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/formattedText/RichTextRules.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-05-02 11:19:37 -0400
committerbobzel <zzzman@gmail.com>2024-05-02 11:19:37 -0400
commit9b424c94d7a89950e9cf3f72e684bd15a61e87ae (patch)
tree22490a9d7dcbace5c6c70d8b39c2c8b4d0fdf399 /src/client/views/nodes/formattedText/RichTextRules.ts
parentdd08c20ec6df3fad6ecd6b16c787f10b0c23feb4 (diff)
another push to remove cycles by pushing things onto Doc and DocumentView
Diffstat (limited to 'src/client/views/nodes/formattedText/RichTextRules.ts')
-rw-r--r--src/client/views/nodes/formattedText/RichTextRules.ts14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/client/views/nodes/formattedText/RichTextRules.ts b/src/client/views/nodes/formattedText/RichTextRules.ts
index 1ff862859..bf11dfe62 100644
--- a/src/client/views/nodes/formattedText/RichTextRules.ts
+++ b/src/client/views/nodes/formattedText/RichTextRules.ts
@@ -7,13 +7,11 @@ import { Id } from '../../../../fields/FieldSymbols';
import { List } from '../../../../fields/List';
import { NumCast, StrCast } from '../../../../fields/Types';
import { Utils } from '../../../../Utils';
-import { DocServer } from '../../../DocServer';
import { Docs } from '../../../documents/Documents';
-import { DocUtils } from '../../../documents/DocUtils';
import { CollectionViewType } from '../../../documents/DocumentTypes';
+import { DocUtils } from '../../../documents/DocUtils';
import { CollectionView } from '../../collections/CollectionView';
import { ContextMenu } from '../../ContextMenu';
-import { KeyValueBox } from '../KeyValueBox';
import { FormattedTextBox } from './FormattedTextBox';
import { wrappingInputRule } from './prosemirrorPatches';
import { RichTextMenu } from './RichTextMenu';
@@ -311,10 +309,10 @@ export class RichTextRules {
}
};
const getTitledDoc = (title: string) => {
- if (!DocServer.FindDocByTitle(title)) {
+ if (!Doc.FindDocByTitle(title)) {
Docs.Create.TextDocument('', { title: title, _width: 400, _layout_fitWidth: true, _layout_autoHeight: true });
}
- const titledDoc = DocServer.FindDocByTitle(title);
+ const titledDoc = Doc.FindDocByTitle(title);
return titledDoc ? Doc.BestEmbedding(titledDoc) : titledDoc;
};
const target = getTitledDoc(docTitle);
@@ -337,14 +335,14 @@ export class RichTextRules {
const assign = match[4] === ':' ? (match[4] = '') : match[4];
const value = match[5];
const dataDoc = value === undefined ? !fieldKey.startsWith('_') : !assign?.startsWith('=');
- const getTitledDoc = (title: string) => DocServer.FindDocByTitle(title);
+ const getTitledDoc = (title: string) => Doc.FindDocByTitle(title);
// if the value has commas assume its an array (unless it's part of a chat gpt call indicated by '((' )
if (value?.includes(',') && !value.startsWith('((')) {
const values = value.split(',');
const strs = values.some(v => !v.match(/^[-]?[0-9.]$/));
this.Document[DocData][fieldKey] = strs ? new List<string>(values) : new List<number>(values.map(v => Number(v)));
} else if (value) {
- KeyValueBox.SetField(
+ Doc.SetField(
this.Document,
fieldKey,
assign + value,
@@ -367,7 +365,7 @@ export class RichTextRules {
// pass the contents between '((' and '))' to chatGPT and append the result
new InputRule(/(^|[^=])(\(\(.*\)\))$/, (state, match, start, end) => {
let count = 0; // ignore first return value which will be the notation that chat is pending a result
- KeyValueBox.SetField(this.Document, '', match[2], false, (gptval: FieldResult) => {
+ Doc.SetField(this.Document, '', match[2], false, (gptval: FieldResult) => {
if (count) {
const tr = this.TextBox.EditorView?.state.tr.insertText(' ' + (gptval as string));
tr && this.TextBox.EditorView?.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(end + 2), tr.doc.resolve(end + 2 + (gptval as string).length))));