diff --git a/main.ts b/main.ts index bbd6c8d..64591e2 100644 --- a/main.ts +++ b/main.ts @@ -566,8 +566,8 @@ export default class TextFormat extends Plugin { break; case "space-word-symbol": replacedText = selectedText - .replace(/(\w+)([\(\[\{])/g, "$1 $2") - .replace(/([\)\]\}])(\w+)/g, "$1 $2") + .replace(/([\u4e00-\u9fa5]+)([\(\[\{])/g, "$1 $2") + .replace(/([\)\]\}])([a-zA-Z0-9\u4e00-\u9fa5]+)/g, "$1 $2") .replace(/([\u4e00-\u9fa5])([a-zA-Z])/g, "$1 $2") .replace(/([a-zA-Z])([\u4e00-\u9fa5])/g, "$1 $2"); break; @@ -789,6 +789,7 @@ export default class TextFormat extends Plugin { Error("Unknown command"); } } catch (e) { + new Notice(e); console.error(e); } diff --git a/manifest.json b/manifest.json index 40be752..1d89d1a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-text-format", "name": "Text Format", - "version": "3.0.2", + "version": "3.0.3", "minAppVersion": "0.9.7", "description": "Format text such as lowercase/uppercase/capitalize/titlecase, converting order/bullet list, removing redundant spaces/newline characters.", "author": "Benature", diff --git a/src/format.ts b/src/format.ts index b85b230..2bd5283 100644 --- a/src/format.ts +++ b/src/format.ts @@ -285,9 +285,11 @@ export function textWrapper(selectedText: string, context: any): { editorChange: let resetSelectionOffset; let editorChange: EditorChange; - const metaProperties = context.view.metadataEditor.properties; let meta: Record = {}; - for (const m of metaProperties) { meta[m.key] = m.value; } + const metaProperties = context.view.metadataEditor?.properties; + if (metaProperties) { + for (const m of metaProperties) { meta[m.key] = m.value; } + } let prefix_template = compileTemplate(prefix_setting.replace(/\\n/g, "\n"), { noEscape: true }) let suffix_template = compileTemplate(suffix_setting.replace(/\\n/g, "\n"), { noEscape: true })