From 94860fcc1e372f6661e33b2281b5935d9f97c4f3 Mon Sep 17 00:00:00 2001 From: rooyca Date: Wed, 29 Jan 2025 09:39:43 -0500 Subject: [PATCH] update(feat)[#46]: copying response from Modal --- docs/docs/index.md | 1 + docs/mkdocs.yml | 6 ++++++ manifest.json | 2 +- package-lock.json | 2 +- package.json | 2 +- src/main.ts | 13 +++++++++++-- styles.css | 10 ++++++++++ 7 files changed, 31 insertions(+), 5 deletions(-) diff --git a/docs/docs/index.md b/docs/docs/index.md index 4404210..cfae882 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -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) \ No newline at end of file diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 408bbf2..6126c81 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -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 diff --git a/manifest.json b/manifest.json index 8258e84..e0cc50b 100644 --- a/manifest.json +++ b/manifest.json @@ -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", diff --git a/package-lock.json b/package-lock.json index 392581b..d73bc22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "api-request", - "version": "1.4.5", + "version": "1.4.6", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 0bae1a4..e45eb16 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/main.ts b/src/main.ts index 0c84195..10b9242 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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 = { @@ -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); diff --git a/styles.css b/styles.css index 70ebed6..487b165 100644 --- a/styles.css +++ b/styles.css @@ -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; +} +