Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 52bbc52

Browse files
committed
Merge branch 'pattern_improvements'
2 parents 2a73bc5 + ea303cf commit 52bbc52

File tree

18 files changed

+308
-295
lines changed

18 files changed

+308
-295
lines changed

package-lock.json

Lines changed: 169 additions & 169 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@
3030
"@testing-library/react": "13.4.0",
3131
"@types/jest": "29.2.4",
3232
"@types/luxon": "3.1.0",
33-
"@types/node": "18.11.17",
33+
"@types/node": "18.11.18",
3434
"@types/react": "18.0.26",
3535
"@types/react-csv": "1.1.3",
3636
"@types/react-datepicker": "4.8.0",
3737
"@types/react-dom": "18.0.10",
3838
"@types/react-window": "1.8.5",
39-
"@typescript-eslint/eslint-plugin": "5.47.0",
40-
"@typescript-eslint/parser": "5.47.0",
39+
"@typescript-eslint/eslint-plugin": "5.47.1",
40+
"@typescript-eslint/parser": "5.47.1",
4141
"eslint": "8.30.0",
4242
"jest": "29.3.1",
4343
"jest-mock-extended": "3.0.1",
4444
"jest-environment-jsdom": "29.3.1",
4545
"obsidian": "1.1.1",
46-
"rollup": "3.8.1",
46+
"rollup": "3.9.0",
4747
"rollup-plugin-typescript2": "0.34.1",
4848
"ts-jest": "29.0.3",
4949
"tslib": "2.4.1",
@@ -52,7 +52,7 @@
5252
"dependencies": {
5353
"@emotion/styled": "11.10.5",
5454
"@mui/icons-material": "5.11.0",
55-
"@mui/material": "5.11.1",
55+
"@mui/material": "5.11.2",
5656
"@popperjs/core": "2.11.6",
5757
"@tanstack/match-sorter-utils": "8.7.2",
5858
"@tanstack/react-table": "8.7.4",

src/components/cellTypes/Editor/MarkdownEditor.tsx

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { forwardRef, Ref, useEffect } from "react";
1+
import React, { forwardRef, MutableRefObject, useEffect } from "react";
22
import { useAutocompleteInputProps } from "components/cellTypes/Editor/autocomplete";
33
import {
44
autoPairBracketsCommands,
@@ -10,22 +10,17 @@ import {
1010
} from "components/cellTypes/Editor/commands";
1111
import { EMITTERS_GROUPS } from "helpers/Constants";
1212
import { MarkdownEditorProps } from "cdm/EditorModel";
13+
import useAutosizeTextArea from "components/styles/hooks/useAutosizeTextArea";
1314

1415
export const MarkdownEditor = forwardRef(function MarkdownEditor(
1516
{ onEnter, onEscape, view, ...inputProps }: MarkdownEditorProps,
16-
ref: Ref<HTMLTextAreaElement>
17+
ref: MutableRefObject<HTMLTextAreaElement>
1718
) {
18-
const shouldAutoPairMarkdown = (app.vault as any).getConfig(
19-
"autoPairMarkdown"
20-
);
21-
const shouldAutoPairBrackets = (app.vault as any).getConfig(
22-
"autoPairBrackets"
23-
);
24-
const shouldUseTab = (app.vault as any).getConfig("useTab");
25-
const tabWidth = (app.vault as any).getConfig("tabSize");
26-
const shouldUseMarkdownLinks = !!(app.vault as any).getConfig(
27-
"useMarkdownLinks"
28-
);
19+
const shouldAutoPairMarkdown = app.vault.getConfig("autoPairMarkdown");
20+
const shouldAutoPairBrackets = app.vault.getConfig("autoPairBrackets");
21+
const shouldUseTab = app.vault.getConfig("useTab");
22+
const tabWidth = app.vault.getConfig("tabSize");
23+
const shouldUseMarkdownLinks = !!app.vault.getConfig("useMarkdownLinks");
2924

3025
const autocompleteProps = useAutocompleteInputProps({
3126
isInputVisible: true,
@@ -97,19 +92,17 @@ export const MarkdownEditor = forwardRef(function MarkdownEditor(
9792
};
9893
}, [view]);
9994

95+
useAutosizeTextArea(ref.current, inputProps.value.toString());
96+
10097
return (
10198
<textarea
10299
{...inputProps}
103100
{...autocompleteProps}
104101
ref={(c: HTMLTextAreaElement) => {
105102
autocompleteProps.ref.current = c;
106-
107-
if (ref && typeof ref === "function") {
108-
ref(c);
109-
} else if (ref) {
110-
(ref as any).current = c;
111-
}
103+
ref.current = c;
112104
}}
105+
rows={inputProps.value.toString()?.split("\n").length || 1}
113106
/>
114107
);
115108
});

src/components/cellTypes/Editor/autocomplete.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ export function constructAutocomplete({
4444
keys: ["file.basename", "alias"],
4545
});
4646

47-
const willAutoPairBrackets = (view.app.vault as any).getConfig(
48-
"autoPairBrackets"
49-
);
47+
const willAutoPairBrackets = view.app.vault.getConfig("autoPairBrackets");
5048

5149
const configs: StrategyProps[] = [
5250
getTagSearchConfig(tags, tagSearch),

src/components/cellTypes/Editor/filepicker.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ export function getFileSearchConfig(
133133
);
134134
}
135135

136-
const shouldUseMarkdownLinks = !!(
137-
app.vault as any
138-
).getConfig('useMarkdownLinks');
136+
const shouldUseMarkdownLinks = !!app.vault.getConfig('useMarkdownLinks');
139137

140138
if (willAutoPairBrackets && !shouldUseMarkdownLinks) {
141139
output[output.length - 1] = output[output.length - 1].slice(0, -2);
@@ -233,9 +231,7 @@ export function getHeadingSearchConfig(
233231
)
234232
);
235233

236-
const shouldUseMarkdownLinks = !!(
237-
app.vault as any
238-
).getConfig('useMarkdownLinks');
234+
const shouldUseMarkdownLinks = !!app.vault.getConfig('useMarkdownLinks');
239235

240236
if (willAutoPairBrackets && !shouldUseMarkdownLinks) {
241237
output[output.length - 1] = output[output.length - 1].slice(0, -2);
@@ -435,9 +431,7 @@ export function getBlockSearchConfig(
435431
)
436432
);
437433

438-
const shouldUseMarkdownLinks = !!(
439-
app.vault as any
440-
).getConfig('useMarkdownLinks');
434+
const shouldUseMarkdownLinks = !!app.vault.getConfig('useMarkdownLinks');
441435

442436
if (willAutoPairBrackets && !shouldUseMarkdownLinks) {
443437
output[output.length - 1] = output[output.length - 1].slice(0, -2);

src/components/cellTypes/EditorCell.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import React, { ChangeEventHandler, useCallback, useRef } from "react";
44
import { useState } from "react";
55
import { MarkdownEditor } from "components/cellTypes/Editor/MarkdownEditor";
66
import { c } from "helpers/StylesHelper";
7-
import useAutosizeTextArea from "components/styles/hooks/useAutosizeTextArea";
87

98
const EditorCell = (props: EditorCellComponentProps) => {
109
const { defaultCell, persistChange, textCell } = props;
@@ -49,8 +48,6 @@ const EditorCell = (props: EditorCellComponentProps) => {
4948
const handleOnBlur = () => {
5049
persistChange(editorValue?.toString());
5150
};
52-
53-
useAutosizeTextArea(editableMdRef.current, editorValue);
5451
return (
5552
<>
5653
<MarkdownEditor

src/helpers/Constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ export const SUGGESTER_REGEX = Object.freeze({
474474
LINK_BLOCK: /\B\[\[([^#\]]+)#?\^([^\]]*)$/,
475475
EMBED_BLOCK: /\B!\[\[([^#\]]+)#?\^([^\]]*)$/,
476476

477-
TEXT_ARRAY: /(^\[{1})([^\[]{1}.*)(\]{1})$/g
477+
TEXT_ARRAY: /(^\[{1})([^\[]{1}.*)(\]{1})$/g,
478+
TEXT_OBJECT: /(^\{{1})(.*)(\}{1})$/g,
478479
});
479480

480481
/******************************************************************************

src/helpers/DataObjectHelper.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import { LocalSettings } from "cdm/SettingsModel";
21
import { DataObject, Literal } from "obsidian-dataview";
32
import { DataviewService } from "services/DataviewService";
4-
import { LOGGER } from "services/Logger";
5-
import { ParseService } from "services/ParseService";
63

74
/**
85
* @description Method to perform a deep merge of two DataObjects
@@ -51,40 +48,4 @@ export function generateLiteral(nestedKey: string, value: Literal): Literal {
5148
} else {
5249
return { [key]: generateLiteral(keys.join("."), value) };
5350
}
54-
}
55-
56-
/**
57-
* Obtain the value of a nested object in function of the nested key (a.b.c) using recursion
58-
* I.E.:
59-
* nestedKey = "a.b.c"
60-
* object = {a: {b: {c: "test"}}}
61-
* expected result = "test"
62-
* @param nestedKey
63-
* @param original
64-
*/
65-
export function obtainAnidatedLiteral(nestedKey: string, original: Literal, type: string, config: LocalSettings): Literal {
66-
const keys = nestedKey.split(".");
67-
const key = keys.shift();
68-
const wrapped = DataviewService.wrapLiteral(original);
69-
if (wrapped.value === undefined) {
70-
LOGGER.debug(
71-
`nested key ${nestedKey} not found in object ${original}`
72-
);
73-
return null;
74-
}
75-
76-
if (keys.length === 0) {
77-
if (wrapped.type === "object") {
78-
return ParseService.parseLiteral((original as DataObject)[key], type, config);
79-
} else {
80-
return original;
81-
}
82-
} else if (wrapped.type !== "object") {
83-
LOGGER.debug(
84-
`nested key ${nestedKey} not found in object ${original}`
85-
);
86-
return null;
87-
} else {
88-
return obtainAnidatedLiteral(keys.join("."), (original as DataObject)[key], type, config);
89-
}
9051
}

src/helpers/FileManagement.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import HelperException from "errors/HelperException";
44
import { normalizePath, TAbstractFile, TFile, TFolder, Vault } from "obsidian";
55
import { SourceDataTypes } from "helpers/Constants";
66
import { RowDataType } from "cdm/FolderModel";
7-
import { VaultManagerDB } from "services/FileManagerService";
87

98
export function resolve_tfile(file_str: string, restrict = true): TFile {
109
file_str = normalizePath(file_str);
@@ -147,40 +146,6 @@ export const resolveNewFilePath = ({
147146
return `${folderPath}${subfolders ? `/${subfolders}` : ""}`;
148147
};
149148

150-
/**
151-
* Generate a new file with the structure of a database view
152-
* @param folderPath
153-
* @param filename
154-
* @param ddbbConfig
155-
* @returns
156-
*/
157-
export async function create_row_file(
158-
folderPath: string,
159-
filename: string,
160-
ddbbConfig: LocalSettings
161-
): Promise<string> {
162-
let trimedFilename = filename.replace(/\.[^/.]+$/, "").trim();
163-
let filepath = `${folderPath}/${trimedFilename}.md`;
164-
// Validate possible duplicates
165-
let sufixOfDuplicate = 0;
166-
while (resolve_tfile(filepath, false)) {
167-
sufixOfDuplicate++;
168-
filepath = `${folderPath}/${trimedFilename}-${sufixOfDuplicate}.md`;
169-
}
170-
171-
if (sufixOfDuplicate > 0) {
172-
trimedFilename = `${trimedFilename}-${sufixOfDuplicate}`;
173-
filename = `${trimedFilename} copy(${sufixOfDuplicate})`;
174-
}
175-
// Add note to persist row
176-
await VaultManagerDB.create_markdown_file(
177-
resolve_tfolder(folderPath),
178-
trimedFilename,
179-
ddbbConfig
180-
);
181-
return filepath;
182-
}
183-
184149
/**
185150
* Remove all not readable characters of yaml and trim the string
186151
*

src/main.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { DatabaseHelperCreationModal } from 'commands/addDatabaseHelper/database
3636
import { generateDbConfiguration, generateNewDatabase } from 'helpers/CommandsHelper';
3737
import { registerDateFnLocale, t } from 'lang/helpers';
3838
import ProjectAPI from 'api/obsidian-projects-api';
39+
3940
interface WindowRegistry {
4041
viewMap: Map<string, DatabaseView>;
4142
viewStateReceivers: Array<(views: DatabaseView[]) => void>;
@@ -545,10 +546,6 @@ export default class DBFolderPlugin extends Plugin {
545546

546547
// internal-link quick preview
547548
this.registerEvent(app.workspace.on("quick-preview", previewMode.hoverEvent));
548-
549-
//monitoring for div.popover.hover-popover.file-embed.is-loaded to be added to the DOM tree
550-
// this.observer = observer;
551-
// this.observer.observe(document, { childList: true, subtree: true });
552549
}
553550

554551
/**

0 commit comments

Comments
 (0)