mirror of
https://github.com/Wanxp/obsidian-douban.git
synced 2026-04-04 16:48:44 +08:00
1. add array spilt , start, end
This commit is contained in:
parent
0dd68ff8cb
commit
4bf64965bb
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "obsidian-douban-plugin",
|
"id": "obsidian-douban-plugin",
|
||||||
"name": "Douban",
|
"name": "Douban",
|
||||||
"version": "1.9.2",
|
"version": "1.9.3",
|
||||||
"minAppVersion": "0.12.0",
|
"minAppVersion": "0.12.0",
|
||||||
"description": "This is a plugin that can import movies/books/musics/notes/games info data from Douban for Obsidian .",
|
"description": "This is a plugin that can import movies/books/musics/notes/games info data from Douban for Obsidian .",
|
||||||
"author": "Wanxp",
|
"author": "Wanxp",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "obsidian-douban-plugin",
|
"name": "obsidian-douban-plugin",
|
||||||
"version": "1.9.2",
|
"version": "1.9.3",
|
||||||
"description": "This is a plugin for Obsidian (https://obsidian.md) that can import data from Douban (https://www.douban.com/).",
|
"description": "This is a plugin for Obsidian (https://obsidian.md) that can import data from Douban (https://www.douban.com/).",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -13,9 +13,11 @@ export const DEFAULT_SETTINGS: DoubanPluginSetting = {
|
|||||||
searchUrl: 'https://www.douban.com/search?q=',
|
searchUrl: 'https://www.douban.com/search?q=',
|
||||||
dateFormat: "yyyy-MM-DD",
|
dateFormat: "yyyy-MM-DD",
|
||||||
timeFormat: "HH:mm:ss",
|
timeFormat: "HH:mm:ss",
|
||||||
arrayStart: "[",
|
arrayStart: "",
|
||||||
arraySpilt: ", ",
|
arrayElementStart: "\\n - ",
|
||||||
arrayEnd: "]",
|
arraySpiltV2: "",
|
||||||
|
arrayElementEnd: "",
|
||||||
|
arrayEnd: "",
|
||||||
personNameMode: PersonNameMode.CH_NAME,
|
personNameMode: PersonNameMode.CH_NAME,
|
||||||
dataFilePath: "",
|
dataFilePath: "",
|
||||||
dataFileNamePath: "/{{type}}/{{title}}",
|
dataFileNamePath: "/{{type}}/{{title}}",
|
||||||
|
|||||||
@ -12,7 +12,8 @@ datePublished: {{datePublished}}
|
|||||||
director: {{director}}
|
director: {{director}}
|
||||||
actor: {{actor}}
|
actor: {{actor}}
|
||||||
author: {{author}}
|
author: {{author}}
|
||||||
tags: {{type}}
|
tags:
|
||||||
|
- {{type}}
|
||||||
url: {{url}}
|
url: {{url}}
|
||||||
aliases: {{aliases}}
|
aliases: {{aliases}}
|
||||||
country: {{country}}
|
country: {{country}}
|
||||||
@ -42,7 +43,8 @@ isbn: {{isbn}}
|
|||||||
url: {{url}}
|
url: {{url}}
|
||||||
totalPage: {{totalPage}}
|
totalPage: {{totalPage}}
|
||||||
price: {{price}}
|
price: {{price}}
|
||||||
tags: Book
|
tags:
|
||||||
|
- {{type}}
|
||||||
binding: {{binding}}
|
binding: {{binding}}
|
||||||
createTime: {{currentDate}} {{currentTime}}
|
createTime: {{currentDate}} {{currentTime}}
|
||||||
desc: {{desc}}
|
desc: {{desc}}
|
||||||
@ -66,7 +68,8 @@ publisher: {{publisher}}
|
|||||||
barcode: {{barcode}}
|
barcode: {{barcode}}
|
||||||
url: {{url}}
|
url: {{url}}
|
||||||
records: {{records}}
|
records: {{records}}
|
||||||
tags: Music
|
tags:
|
||||||
|
- {{type}}
|
||||||
createTime: {{currentDate}} {{currentTime}}
|
createTime: {{currentDate}} {{currentTime}}
|
||||||
desc: {{desc}}
|
desc: {{desc}}
|
||||||
---
|
---
|
||||||
@ -81,7 +84,8 @@ author: {{author}}
|
|||||||
authorUrl: {{authorUrl}}
|
authorUrl: {{authorUrl}}
|
||||||
dateTimePublished: {{datePublished}} {{timePublished}}
|
dateTimePublished: {{datePublished}} {{timePublished}}
|
||||||
url: {{url}}
|
url: {{url}}
|
||||||
tags: Article
|
tags:
|
||||||
|
- {{type}}
|
||||||
createTime: {{currentDate}} {{currentTime}}
|
createTime: {{currentDate}} {{currentTime}}
|
||||||
desc: {{desc}}
|
desc: {{desc}}
|
||||||
---
|
---
|
||||||
@ -100,7 +104,8 @@ genre: {{genre}}
|
|||||||
developer: {{developer}}
|
developer: {{developer}}
|
||||||
platform: {{platform}}
|
platform: {{platform}}
|
||||||
url: {{url}}
|
url: {{url}}
|
||||||
tags: Game
|
tags:
|
||||||
|
- {{type}}
|
||||||
createTime: {{currentDate}} {{currentTime}}
|
createTime: {{currentDate}} {{currentTime}}
|
||||||
desc: {{desc}}
|
desc: {{desc}}
|
||||||
---
|
---
|
||||||
@ -117,7 +122,8 @@ datePublished: {{datePublished}}
|
|||||||
director: {{director}}
|
director: {{director}}
|
||||||
actor: {{actor}}
|
actor: {{actor}}
|
||||||
author: {{author}}
|
author: {{author}}
|
||||||
tags: {{type}}
|
tags:
|
||||||
|
- {{type}}
|
||||||
url: {{url}}
|
url: {{url}}
|
||||||
aliases: {{aliases}}
|
aliases: {{aliases}}
|
||||||
country: {{country}}
|
country: {{country}}
|
||||||
@ -146,7 +152,7 @@ datePublished: {{datePublished}}
|
|||||||
director: {{director}}
|
director: {{director}}
|
||||||
actor: {{actor}}
|
actor: {{actor}}
|
||||||
author: {{author}}
|
author: {{author}}
|
||||||
tags: {{type}}, {{myTags}}
|
tags: {{myTags}}
|
||||||
state: {{myState}}
|
state: {{myState}}
|
||||||
url: {{url}}
|
url: {{url}}
|
||||||
aliases: {{aliases}}
|
aliases: {{aliases}}
|
||||||
@ -183,7 +189,7 @@ isbn: {{isbn}}
|
|||||||
url: {{url}}
|
url: {{url}}
|
||||||
totalPage: {{totalPage}}
|
totalPage: {{totalPage}}
|
||||||
price: {{price}}
|
price: {{price}}
|
||||||
tags: Book, {{myTags}}
|
tags: {{myTags}}
|
||||||
state: {{myState}}
|
state: {{myState}}
|
||||||
binding: {{binding}}
|
binding: {{binding}}
|
||||||
createTime: {{currentDate}} {{currentTime}}
|
createTime: {{currentDate}} {{currentTime}}
|
||||||
@ -214,7 +220,7 @@ publisher: {{publisher}}
|
|||||||
barcode: {{barcode}}
|
barcode: {{barcode}}
|
||||||
url: {{url}}
|
url: {{url}}
|
||||||
records: {{records}}
|
records: {{records}}
|
||||||
tags: Music, {{myTags}}
|
tags: {{myTags}}
|
||||||
state: {{myState}}
|
state: {{myState}}
|
||||||
createTime: {{currentDate}} {{currentTime}}
|
createTime: {{currentDate}} {{currentTime}}
|
||||||
collectionDate: {{myCollectionDate}}
|
collectionDate: {{myCollectionDate}}
|
||||||
@ -236,7 +242,8 @@ author: {{author}}
|
|||||||
authorUrl: {{authorUrl}}
|
authorUrl: {{authorUrl}}
|
||||||
dateTimePublished: {{datePublished}} {{timePublished}}
|
dateTimePublished: {{datePublished}} {{timePublished}}
|
||||||
url: {{url}}
|
url: {{url}}
|
||||||
tags: Article
|
tags:
|
||||||
|
- {{type}}
|
||||||
createTime: {{currentDate}} {{currentTime}}
|
createTime: {{currentDate}} {{currentTime}}
|
||||||
desc: {{desc}}
|
desc: {{desc}}
|
||||||
---
|
---
|
||||||
@ -256,7 +263,7 @@ genre: {{genre}}
|
|||||||
developer: {{developer}}
|
developer: {{developer}}
|
||||||
platform: {{platform}}
|
platform: {{platform}}
|
||||||
url: {{url}}
|
url: {{url}}
|
||||||
tags: Game, {{myTags}}
|
tags: {{myTags}}
|
||||||
state: {{myState}}
|
state: {{myState}}
|
||||||
createTime: {{currentDate}} {{currentTime}}
|
createTime: {{currentDate}} {{currentTime}}
|
||||||
collectionDate: {{myCollectionDate}}
|
collectionDate: {{myCollectionDate}}
|
||||||
@ -280,7 +287,7 @@ datePublished: {{datePublished}}
|
|||||||
director: {{director}}
|
director: {{director}}
|
||||||
actor: {{actor}}
|
actor: {{actor}}
|
||||||
author: {{author}}
|
author: {{author}}
|
||||||
tags: {{type}}, {{myTags}}
|
tags: {{myTags}}
|
||||||
state: {{myState}}
|
state: {{myState}}
|
||||||
url: {{url}}
|
url: {{url}}
|
||||||
aliases: {{aliases}}
|
aliases: {{aliases}}
|
||||||
|
|||||||
@ -334,7 +334,13 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
|
|||||||
if (!userState) {
|
if (!userState) {
|
||||||
return resultContent;
|
return resultContent;
|
||||||
}
|
}
|
||||||
return resultContent.replaceAll(DoubanUserParameter.MY_TAGS, this.handleSpecialContent(userState.tags, textMode, context))
|
let tags: string[] = [];
|
||||||
|
if (userState.tags && userState.tags.length > 0 ) {
|
||||||
|
tags = [extract.type, ...userState.tags.map(tag => tag.trim())];
|
||||||
|
}else {
|
||||||
|
tags = [extract.type];
|
||||||
|
}
|
||||||
|
return resultContent.replaceAll(DoubanUserParameter.MY_TAGS, this.handleSpecialContent(tags, textMode, context))
|
||||||
.replaceAll(DoubanUserParameter.MY_RATING, this.handleSpecialContent(userState.rate, textMode))
|
.replaceAll(DoubanUserParameter.MY_RATING, this.handleSpecialContent(userState.rate, textMode))
|
||||||
.replaceAll(DoubanUserParameter.MY_STATE, this.getUserStateName(userState.state))
|
.replaceAll(DoubanUserParameter.MY_STATE, this.getUserStateName(userState.state))
|
||||||
.replaceAll(DoubanUserParameter.MY_COMMENT, this.handleSpecialContent(userState.comment, textMode))
|
.replaceAll(DoubanUserParameter.MY_COMMENT, this.handleSpecialContent(userState.comment, textMode))
|
||||||
@ -538,8 +544,8 @@ export default abstract class DoubanAbstractLoadHandler<T extends DoubanSubject>
|
|||||||
|
|
||||||
protected handleArray(arr: string[], context: HandleContext): string {
|
protected handleArray(arr: string[], context: HandleContext): string {
|
||||||
const {settings} = context;
|
const {settings} = context;
|
||||||
let content :string = arr ? arr.join(settings.arraySpilt) : "";
|
return StringUtil.handleArray(arr, settings);
|
||||||
content = settings.arrayStart + content + settings.arrayEnd;
|
|
||||||
return content;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import {i18nHelper} from "../../lang/helper";
|
import {i18nHelper} from "../../lang/helper";
|
||||||
import {Setting} from "obsidian";
|
import {Setting, TextComponent} from "obsidian";
|
||||||
import {createFolderSelectionSetting} from "./TemplateSettingHelper";
|
import {createFolderSelectionSetting} from "./TemplateSettingHelper";
|
||||||
import {DEFAULT_SETTINGS} from "../../constant/DefaultSettings";
|
import {DEFAULT_SETTINGS} from "../../constant/DefaultSettings";
|
||||||
import {PersonNameMode, PersonNameModeRecords} from "../../constant/Constsant";
|
import {PersonNameMode, PersonNameModeRecords} from "../../constant/Constsant";
|
||||||
import SettingsManager from "./SettingsManager";
|
import SettingsManager from "./SettingsManager";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function constructOutUI(containerEl: HTMLElement, manager: SettingsManager) {
|
export function constructOutUI(containerEl: HTMLElement, manager: SettingsManager) {
|
||||||
containerEl.createEl('h3', { text: i18nHelper.getMessage('1220') });
|
containerEl.createEl('h3', { text: i18nHelper.getMessage('1220') });
|
||||||
|
|
||||||
@ -17,34 +19,88 @@ export function constructOutUI(containerEl: HTMLElement, manager: SettingsManage
|
|||||||
|
|
||||||
constructOutputFileNameUI(outfolder, manager);
|
constructOutputFileNameUI(outfolder, manager);
|
||||||
|
|
||||||
new Setting(containerEl)
|
let arrSettings = containerEl.createDiv('array-settings');
|
||||||
|
let arrShow = containerEl.createDiv('array-show');
|
||||||
|
|
||||||
|
const descFrag:DocumentFragment = new DocumentFragment();
|
||||||
|
const desc: HTMLElement = descFrag.createDiv('array-setting-desc')
|
||||||
|
desc.innerHTML = i18nHelper.getMessage('120602');
|
||||||
|
new Setting(arrSettings)
|
||||||
.setName(i18nHelper.getMessage('120601'))
|
.setName(i18nHelper.getMessage('120601'))
|
||||||
.setDesc(i18nHelper.getMessage('120602'))
|
.setDesc(descFrag);
|
||||||
.addText((textField) => {
|
arrSettings;
|
||||||
textField.setPlaceholder(DEFAULT_SETTINGS.arrayStart)
|
|
||||||
.setValue(manager.plugin.settings.arrayStart)
|
arrSettings.createEl('label', { text: i18nHelper.getMessage('124109') })
|
||||||
.onChange(async (value) => {
|
const arrayStart = new TextComponent(arrSettings);
|
||||||
manager.plugin.settings.arrayStart = value;
|
arrayStart.setPlaceholder(DEFAULT_SETTINGS.arrayStart)
|
||||||
await manager.plugin.saveSettings();
|
.setValue(manager.settings.arrayStart)
|
||||||
});
|
.onChange(async (value) => {
|
||||||
})
|
manager.plugin.settings.arrayStart = value;
|
||||||
.addText((textField) => {
|
await manager.plugin.saveSettings();
|
||||||
textField.setPlaceholder(DEFAULT_SETTINGS.arraySpilt)
|
showArrayExample(arrShow, manager);
|
||||||
.setValue(manager.plugin.settings.arraySpilt)
|
});
|
||||||
.onChange(async (value) => {
|
let arrayStartEl = arrayStart.inputEl;
|
||||||
manager.plugin.settings.arraySpilt = value;
|
arrayStartEl.size = 3;
|
||||||
await manager.plugin.saveSettings();
|
arrayStartEl.addClass('obsidian_douban_settings_input')
|
||||||
});
|
arrSettings.appendChild(arrayStartEl).appendText(" ");
|
||||||
})
|
|
||||||
.addText((textField) => {
|
arrSettings.createEl('label', { text: i18nHelper.getMessage('124110') })
|
||||||
textField.setPlaceholder(DEFAULT_SETTINGS.arrayEnd)
|
const arrayElementStart = new TextComponent(arrSettings);
|
||||||
.setValue(manager.plugin.settings.arrayEnd)
|
arrayElementStart.setPlaceholder(DEFAULT_SETTINGS.arrayElementStart)
|
||||||
.onChange(async (value) => {
|
.setValue(manager.settings.arrayElementStart)
|
||||||
manager.plugin.settings.arrayEnd = value;
|
.onChange(async (value) => {
|
||||||
await manager.plugin.saveSettings();
|
manager.plugin.settings.arrayElementStart = value;
|
||||||
});
|
await manager.plugin.saveSettings();
|
||||||
})
|
showArrayExample(arrShow, manager);
|
||||||
;
|
});
|
||||||
|
let arrayElementStartEl = arrayElementStart.inputEl;
|
||||||
|
arrayElementStartEl.addClass('obsidian_douban_settings_input')
|
||||||
|
arrayElementStartEl.size = 3;
|
||||||
|
arrSettings.appendChild(arrayElementStartEl).appendText(" ");
|
||||||
|
|
||||||
|
arrSettings.createEl('label', { text: i18nHelper.getMessage('124111') })
|
||||||
|
const arraySpiltV2 = new TextComponent(arrSettings);
|
||||||
|
arraySpiltV2.setPlaceholder(DEFAULT_SETTINGS.arraySpiltV2)
|
||||||
|
.setValue(manager.settings.arraySpiltV2)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
manager.plugin.settings.arraySpiltV2 = value;
|
||||||
|
await manager.plugin.saveSettings();
|
||||||
|
showArrayExample(arrShow, manager);
|
||||||
|
});
|
||||||
|
let arraySpiltV2El = arraySpiltV2.inputEl;
|
||||||
|
arraySpiltV2El.addClass('obsidian_douban_settings_input')
|
||||||
|
arraySpiltV2El.size = 3;
|
||||||
|
arrSettings.appendChild(arraySpiltV2El).appendText(" ");
|
||||||
|
|
||||||
|
arrSettings.createEl('label', { text: i18nHelper.getMessage('124112') })
|
||||||
|
const arrayElementEnd = new TextComponent(arrSettings);
|
||||||
|
arrayElementEnd.setPlaceholder(DEFAULT_SETTINGS.arrayElementEnd)
|
||||||
|
.setValue(manager.settings.arrayElementEnd)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
manager.plugin.settings.arrayElementEnd = value;
|
||||||
|
await manager.plugin.saveSettings();
|
||||||
|
showArrayExample(arrShow, manager);
|
||||||
|
});
|
||||||
|
let arrayElementEndEl = arrayElementEnd.inputEl;
|
||||||
|
arrayElementEndEl.addClass('obsidian_douban_settings_input')
|
||||||
|
arrayElementEndEl.size = 3;
|
||||||
|
arrSettings.appendChild(arrayElementEndEl).appendText(" ");
|
||||||
|
|
||||||
|
arrSettings.createEl('label', { text: i18nHelper.getMessage('124113') })
|
||||||
|
const arrayEnd = new TextComponent(arrSettings);
|
||||||
|
arrayEnd.setPlaceholder(DEFAULT_SETTINGS.arrayEnd)
|
||||||
|
.setValue(manager.settings.arrayEnd)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
manager.plugin.settings.arrayEnd = value;
|
||||||
|
await manager.plugin.saveSettings();
|
||||||
|
showArrayExample(arrShow, manager);
|
||||||
|
});
|
||||||
|
let arrayEndEl = arrayEnd.inputEl;
|
||||||
|
arrayEndEl.addClass('obsidian_douban_settings_input')
|
||||||
|
arrayEndEl.size = 3;
|
||||||
|
arrSettings.appendChild(arrayEndEl).appendText(" ");
|
||||||
|
showArrayExample(arrShow, manager);
|
||||||
|
|
||||||
|
|
||||||
new Setting(containerEl).setName(i18nHelper.getMessage('121201')).then((setting) => {
|
new Setting(containerEl).setName(i18nHelper.getMessage('121201')).then((setting) => {
|
||||||
setting.addDropdown((dropdwon) => {
|
setting.addDropdown((dropdwon) => {
|
||||||
@ -134,3 +190,14 @@ export function constructAttachmentFileSettingsUI(containerEl: HTMLElement, mana
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function showArrayExample(arrShow: HTMLDivElement, manager: SettingsManager) {
|
||||||
|
arrShow.empty();
|
||||||
|
let document = new DocumentFragment();
|
||||||
|
document.createDiv('array-show-title')
|
||||||
|
.innerHTML = `propertyName:${manager.handleArray(['value1', 'value2', 'value3'])}`;
|
||||||
|
|
||||||
|
new Setting(arrShow)
|
||||||
|
.setName(i18nHelper.getMessage('120603'))
|
||||||
|
.setDesc(document);
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import GithubUtil from "../../utils/GithubUtil";
|
|||||||
import {DoubanPluginOnlineData} from "./model/DoubanPluginOnlineData";
|
import {DoubanPluginOnlineData} from "./model/DoubanPluginOnlineData";
|
||||||
import {DoubanPluginOnlineSettings} from "./model/DoubanPluginOnlineSettings";
|
import {DoubanPluginOnlineSettings} from "./model/DoubanPluginOnlineSettings";
|
||||||
import {DoubanPluginSubjectProperty} from "./model/DoubanPluginSubjectProperty";
|
import {DoubanPluginSubjectProperty} from "./model/DoubanPluginSubjectProperty";
|
||||||
|
import HandleContext from "../data/model/HandleContext";
|
||||||
|
import HtmlUtil from "../../utils/HtmlUtil";
|
||||||
|
|
||||||
export default class SettingsManager {
|
export default class SettingsManager {
|
||||||
app: App;
|
app: App;
|
||||||
@ -91,4 +93,9 @@ export default class SettingsManager {
|
|||||||
return ONLINE_SETTING_DEFAULT.properties.find(subjectProperty => subjectProperty.type === itemType && subjectProperty.name === propertyName).selectors;
|
return ONLINE_SETTING_DEFAULT.properties.find(subjectProperty => subjectProperty.type === itemType && subjectProperty.name === propertyName).selectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleArray(arr: string[]): string {
|
||||||
|
let result:string = StringUtil.handleArray(arr, this.settings);
|
||||||
|
return HtmlUtil.strToHtml(result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,9 @@ export interface DoubanPluginSetting {
|
|||||||
timeFormat: string,
|
timeFormat: string,
|
||||||
searchUrl: string,
|
searchUrl: string,
|
||||||
arrayStart: string,
|
arrayStart: string,
|
||||||
arraySpilt: string,
|
arrayElementStart: string,
|
||||||
|
arraySpiltV2: string,
|
||||||
|
arrayElementEnd: string,
|
||||||
arrayEnd: string,
|
arrayEnd: string,
|
||||||
personNameMode: string,
|
personNameMode: string,
|
||||||
dataFilePath: string,
|
dataFilePath: string,
|
||||||
|
|||||||
@ -119,6 +119,11 @@ PS: This file could be delete if you want to.
|
|||||||
'124105': `Input custom variable value`,
|
'124105': `Input custom variable value`,
|
||||||
'124106': `Active type`,
|
'124106': `Active type`,
|
||||||
'124107': `Delete custom variable`,
|
'124107': `Delete custom variable`,
|
||||||
|
'124109': `ArrayBegin:`,
|
||||||
|
'124110': `ElementBegin:`,
|
||||||
|
'124111': `Spilt:`,
|
||||||
|
'124112': `ElementEnd:`,
|
||||||
|
'124113': `ArrayEnd:`,
|
||||||
|
|
||||||
'121101': `Template File`,
|
'121101': `Template File`,
|
||||||
'121102': `This template will be used when creating new notes. If keep empty, it will use default template`,
|
'121102': `This template will be used when creating new notes. If keep empty, it will use default template`,
|
||||||
@ -178,9 +183,8 @@ PS: This file could be delete if you want to.
|
|||||||
'120507': `Your current syntax looks like this`,
|
'120507': `Your current syntax looks like this`,
|
||||||
'120508': `format reference`,
|
'120508': `format reference`,
|
||||||
'120601': `Array Spilt String`,
|
'120601': `Array Spilt String`,
|
||||||
'120602': `string to join between array type, start、end string for array, such as authors, actors. .
|
'120602': `string to join between array type, start、end string for array, such as authors, actors.
|
||||||
example: start:'[' spilt:',' end:']'
|
support \n (enter)`,
|
||||||
the list of actor's name will be shown as: '[actor1,actor2,actor3]'`,
|
|
||||||
'120701': `Douban Request Headers`,
|
'120701': `Douban Request Headers`,
|
||||||
'120801': `This type of import is not supported temporarily, please go to github to submit issues for help`,
|
'120801': `This type of import is not supported temporarily, please go to github to submit issues for help`,
|
||||||
'120901': `Douban`,
|
'120901': `Douban`,
|
||||||
@ -214,6 +218,8 @@ PS: This file could be delete if you want to.
|
|||||||
'121601': `Note Name`,
|
'121601': `Note Name`,
|
||||||
'121602': `Nodes created from Obsidian-Douban will use this fileName as template(also support filePath),
|
'121602': `Nodes created from Obsidian-Douban will use this fileName as template(also support filePath),
|
||||||
If blank, they will be created by default name. support all basic template variables. example: {{type}}/{{title}}`,
|
If blank, they will be created by default name. support all basic template variables. example: {{type}}/{{title}}`,
|
||||||
|
'120603': `Array Display Example`,
|
||||||
|
|
||||||
'121603': `assets`,
|
'121603': `assets`,
|
||||||
|
|
||||||
'121701': `Search Template File`,
|
'121701': `Search Template File`,
|
||||||
|
|||||||
@ -184,10 +184,14 @@ export default {
|
|||||||
'120506': `详细介绍请参考`,
|
'120506': `详细介绍请参考`,
|
||||||
'120507': `时间参数时间格式预览`,
|
'120507': `时间参数时间格式预览`,
|
||||||
'120508': `格式参考`,
|
'120508': `格式参考`,
|
||||||
'120601': `数组分割字符串`,
|
'120601': `数组显示形式`,
|
||||||
'120602': `当模板中的变量存在数组, 则需要设定数组元素中的分割符号以及起始与结束符号,比如演员列表等.
|
'120602': `当模板中的变量存在数组, 则需要设定数组元素中的分割符号以及起始与结束符号, 比如演员列表,
|
||||||
举例: 开始字符'[', 分隔符',', 结束字符']',
|
支持转义字符\n(回车)`,
|
||||||
则演员表将会显示为: '[演员1,演员2,演员3]'`,
|
'124109': `首:`,
|
||||||
|
'124110': `元素首:`,
|
||||||
|
'124111': `分隔符:`,
|
||||||
|
'124112': `元素尾:`,
|
||||||
|
'124113': `尾:`,
|
||||||
|
|
||||||
'120701': `豆瓣HTTP请求头`,
|
'120701': `豆瓣HTTP请求头`,
|
||||||
'120702': `如果豆瓣搜索或者获取数据失败,请尝试修改这个参数,\n
|
'120702': `如果豆瓣搜索或者获取数据失败,请尝试修改这个参数,\n
|
||||||
@ -225,6 +229,9 @@ export default {
|
|||||||
'121601': `笔记名称`,
|
'121601': `笔记名称`,
|
||||||
'121602': `创建的笔记将会使用此名称作为模板, 支持所有'通用'的参数作为名称(如:{{type}}/{{title}}), 且支持路径, 比如: 'MyData/{{title}}'. 如果为空, 笔记将会使用默认名称. `,
|
'121602': `创建的笔记将会使用此名称作为模板, 支持所有'通用'的参数作为名称(如:{{type}}/{{title}}), 且支持路径, 比如: 'MyData/{{title}}'. 如果为空, 笔记将会使用默认名称. `,
|
||||||
|
|
||||||
|
'120603': `数组分割字符串显示效果`,
|
||||||
|
|
||||||
|
|
||||||
'121701': `选择模板文件`,
|
'121701': `选择模板文件`,
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -19,8 +19,15 @@ export default class HtmlUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static strToHtml(str: string): string {
|
||||||
|
let result = str.replace(/\n/g, '<br/>');
|
||||||
|
result.replace(/\s/g, ' ');
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import {DoubanPluginSetting} from "../douban/setting/model/DoubanPluginSetting";
|
||||||
|
|
||||||
export default class StringUtil {
|
export default class StringUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,4 +68,53 @@ export default class StringUtil {
|
|||||||
}
|
}
|
||||||
return newTexts.join('');
|
return newTexts.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转义字符串 替换为 实际转义
|
||||||
|
*/
|
||||||
|
public static escape(text: string): string {
|
||||||
|
if (!text) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
let newText = text;
|
||||||
|
EscapeMap.forEach((value, key) => {
|
||||||
|
newText = newText.replace(key, value);
|
||||||
|
});
|
||||||
|
return newText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static handleArray(arr: string[], settings: DoubanPluginSetting): string {
|
||||||
|
let content :string = "";
|
||||||
|
const elementStart:string = StringUtil.escape(settings.arrayElementStart);
|
||||||
|
const elementEnd:string = StringUtil.escape(settings.arrayElementEnd);
|
||||||
|
const spilt:string = StringUtil.escape(settings.arraySpiltV2);
|
||||||
|
const start:string = StringUtil.escape(settings.arrayStart);
|
||||||
|
const end:string = StringUtil.escape(settings.arrayEnd);
|
||||||
|
for (let i = 0; i < arr.length; i++) {
|
||||||
|
let el = arr[i];
|
||||||
|
if (!el) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (i == arr.length - 1) {
|
||||||
|
content += elementStart + el + elementEnd
|
||||||
|
} else {
|
||||||
|
content += elementStart + el + elementEnd + spilt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
content = start + content + end;
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const EscapeMap:Map< { [Symbol.replace](string: string, replaceValue: string): string; }, string> = new Map([
|
||||||
|
[/\\n/g, "\n"],
|
||||||
|
[/\\t/g, "\t"],
|
||||||
|
[/\\r/g, "\r"],
|
||||||
|
[/\\f/g, "\f"],
|
||||||
|
[/\\b/g, "\b"],
|
||||||
|
[/\\'/g, "'"],
|
||||||
|
[/\\"/g, '"'],
|
||||||
|
[/\\\\/g, "\\"],
|
||||||
|
])
|
||||||
|
|||||||
27
test.html
Normal file
27
test.html
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>输入框</title>
|
||||||
|
<style>
|
||||||
|
/* 样式代码,将label和input都设置为inline-block */
|
||||||
|
label, input {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form>
|
||||||
|
<label for="input1">输入框1:</label>
|
||||||
|
<input type="text" id="input1" name="input1">
|
||||||
|
<label for="input2">输入框2:</label>
|
||||||
|
<input type="text" id="input2" name="input2">
|
||||||
|
<label for="input3">输入框3:</label>
|
||||||
|
<input type="text" id="input3" name="input3">
|
||||||
|
<label for="input4">输入框4:</label>
|
||||||
|
<input type="text" id="input4" name="input4">
|
||||||
|
<label for="input5">输入框5:</label>
|
||||||
|
<input type="text" id="input5" name="input5">
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -37,6 +37,7 @@
|
|||||||
"1.8.9": "0.12.0",
|
"1.8.9": "0.12.0",
|
||||||
"1.9.0": "0.12.0",
|
"1.9.0": "0.12.0",
|
||||||
"1.9.1": "0.12.0",
|
"1.9.1": "0.12.0",
|
||||||
"1.9.2": "0.12.0"
|
"1.9.2": "0.12.0",
|
||||||
|
"1.9.3": "0.12.0"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user