Skip to content

Commit

Permalink
fix: wrapper in canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
Benature committed Apr 30, 2024
1 parent 35ea9f4 commit f4cf464
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -789,6 +789,7 @@ export default class TextFormat extends Plugin {
Error("Unknown command");
}
} catch (e) {
new Notice(e);
console.error(e);
}

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 4 additions & 2 deletions src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any> = {};
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 })
Expand Down

0 comments on commit f4cf464

Please sign in to comment.