Skip to content

Commit

Permalink
update(feat)[#46]: copying response from Modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Rooyca committed Jan 30, 2025
1 parent 7b08891 commit 94860fc
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

> [![Español](https://img.shields.io/badge/Español-8A2BE2)](es/index.md)
> [![English](https://img.shields.io/badge/English-8A2BE2)](en/index.md)
> [![中文](https://img.shields.io/badge/中文-8A2BE2)](zh/index.md)
![req_img](https://raw.githubusercontent.com/Rooyca/obsidian-api-request/master/showcase_1.gif)
6 changes: 6 additions & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ nav:
- bloques de código: es/codeblocks.md
- configuraciones: es/settings.md
- ejemplos de uso: es/usecase
- 中文:
- 概述: zh/index.md
- 用法:
- 代码块: zh/codeblocks.md
- 设置: zh/settings.md
- 用例: zh/usecase
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "api-request",
"name": "APIRequest",
"version": "1.4.5",
"version": "1.4.6",
"minAppVersion": "0.15.0",
"description": "Fetch data from APIs or other sources. Responses in JSON, MD or HTML directly in your notes.",
"author": "rooyca",
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api-request",
"version": "1.4.5",
"version": "1.4.6",
"description": "Fetch data from APIs or other sources. Responses in JSON, MD or HTML directly in your notes.",
"main": "main.js",
"scripts": {
Expand Down
13 changes: 11 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,16 @@ class ShowOutputModal extends Modal {

const parseAndCreate = (data: object) => (key: string) => {
const value = DataResponse.includes("->") ? nestedValue(data, key) : data.json?.[key];
contentEl.createEl('b', { text: `${key} : ${JSON.stringify(value, null, 2)}` });
contentEl.createEl('b', { text: key });

let textValue;
if (typeof value === "string") {
textValue = value;
} else {
textValue = JSON.stringify(value, null, 2);
}

contentEl.createEl('textarea', { text: textValue, cls: 'modal_textarea' });
};

const requestOptions = {
Expand All @@ -603,7 +612,7 @@ class ShowOutputModal extends Modal {
const DataResponseArray = DataResponse.split(",");
DataResponseArray.forEach(parseAndCreate(data));
} else {
contentEl.createEl('b', { text: JSON.stringify(data.json, null, 2) });
contentEl.createEl('b', { text: JSON.stringify(data.json, null, 2), cls: 'modal_textarea' });
}
})
.catch(handleError);
Expand Down
10 changes: 10 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,13 @@
list-style: none;
}

.modal_textarea {
width: 100%;
min-height: 60px;
border: none;
outline: none;
padding: 8px;
font-size: 16px;
margin-top: 10px;
}

0 comments on commit 94860fc

Please sign in to comment.