Skip to content

Commit

Permalink
2.4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
cumany committed Apr 3, 2024
1 parent 5a7efc0 commit 76e7e29
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "editing-toolbar",
"name": "Editing Toolbar",
"version": "2.4.8",
"version": "2.4.9",
"minAppVersion": "0.14.0",
"description": "The Obsidian Editing Toolbar is modified from cmenu, which provides more powerful customization settings and has many built-in editing commands to be a MS Word-like toolbar editing experience.",
"author": "Cuman",
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": "editing-toolbar",
"name": "Editing Toolbar",
"version": "2.4.8",
"version": "2.4.9",
"minAppVersion": "0.14.0",
"description": "The Obsidian Editing Toolbar is modified from cmenu, which provides more powerful customization settings and has many built-in editing commands to be a MS Word-like toolbar editing experience.",
"author": "Cuman",
Expand Down
8 changes: 4 additions & 4 deletions src/modals/cMenuToolbarModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export function setFontcolor(app: App, plugin: cMenuToolbarPlugin, color: string
const activeLeaf = app.workspace.getActiveViewOfType(MarkdownView);

const view = activeLeaf;
const editor = app.workspace.activeEditor.editor;
const editor = app.workspace.activeLeaf.view?.editor;
let selectText = editor.getSelection();
// if (selectText == null || selectText.trim() == "") {
// //如果没有选中内容激活格式刷
Expand Down Expand Up @@ -284,7 +284,7 @@ export function setBackgroundcolor(app: App, plugin: cMenuToolbarPlugin, color:
const activeLeaf = app.workspace.getActiveViewOfType(MarkdownView);

const view = activeLeaf;
const editor = app.workspace.activeEditor.editor;
const editor = app.workspace.activeLeaf.view?.editor;
let selectText = editor.getSelection();
// console.log(selectText,'selectText')
// if (selectText == null || selectText.trim() == "") {
Expand Down Expand Up @@ -408,7 +408,7 @@ export function setHeader(_str: string) {
const activeLeaf = app.workspace.getActiveViewOfType(MarkdownView);

const view = activeLeaf;
const editor = app.workspace.activeEditor.editor;;
const editor = app.workspace.activeLeaf.view?.editor;;
let linetext = editor.getLine(editor.getCursor().line);
let newstr, linend = "";
const regex = /^(\>*(\[[!\w]+\])?\s*)#+\s/;
Expand Down Expand Up @@ -439,7 +439,7 @@ export function setHeader(_str: string) {
export function setFormateraser(app: App, plugin: cMenuToolbarPlugin) {


const editor = app.workspace.activeEditor.editor;
const editor = app.workspace.activeLeaf.view?.editor;
let linend;
let selstart = editor.getRange({ line: editor.getCursor().line, ch: 0 }, editor.getCursor());
let linetext = editor.getLine(editor.getCursor().line);
Expand Down
20 changes: 10 additions & 10 deletions src/plugin/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ export default class cMenuToolbarPlugin extends Plugin {
if (!this.isView()) { return; };

//let cmEditor = view.sourceMode.cmEditor;

let cmEditor = this.app.workspace.activeEditor.editor;
let cmEditor = this.app.workspace.activeLeaf.view?.editor;
if (cmEditor.hasFocus()) {
let cMenuToolbarModalBar = isExistoolbar(this.app, this.settings)

Expand Down Expand Up @@ -315,7 +315,7 @@ export default class cMenuToolbarPlugin extends Plugin {
callback: () => {
//const activeLeaf = this.app.workspace.getActiveViewOfType(MarkdownView);
//const view = activeLeaf;
const editor = this.app.workspace.activeEditor.editor;
const editor = this.app.workspace.activeLeaf.view?.editor;
//@ts-ignore
return editor.indentList();
},
Expand All @@ -328,7 +328,7 @@ export default class cMenuToolbarPlugin extends Plugin {
callback: () => {
const activeLeaf = this.app.workspace.getActiveViewOfType(MarkdownView);
const view = activeLeaf;
const editor = this.app.workspace.activeEditor.editor;
const editor = this.app.workspace.activeLeaf.view?.editor;
//@ts-ignore
return editor.unindentList();
},
Expand All @@ -341,7 +341,7 @@ export default class cMenuToolbarPlugin extends Plugin {
callback: () => {
const activeLeaf = this.app.workspace.getActiveViewOfType(MarkdownView);
const view = activeLeaf;
const editor = this.app.workspace.activeEditor.editor;
const editor = this.app.workspace.activeLeaf.view?.editor;
return editor.undo();
},
icon: "undo-glyph"
Expand All @@ -353,7 +353,7 @@ export default class cMenuToolbarPlugin extends Plugin {
callback: () => {
const activeLeaf = this.app.workspace.getActiveViewOfType(MarkdownView);
const view = activeLeaf;
const editor = this.app.workspace.activeEditor.editor;
const editor = this.app.workspace.activeLeaf.view?.editor;
return editor.redo();
},
icon: "redo-glyph"
Expand All @@ -365,7 +365,7 @@ export default class cMenuToolbarPlugin extends Plugin {
callback: async () => {
const activeLeaf = this.app.workspace.getActiveViewOfType(MarkdownView);
const view = activeLeaf;
const editor = this.app.workspace.activeEditor.editor;
const editor = this.app.workspace.activeLeaf.view?.editor;
try {
await window.navigator.clipboard.writeText(editor.getSelection()); // 使用 window.navigator.clipboard.writeText() 方法将选定的文本写入剪贴板
app.commands.executeCommandById("editor:focus");
Expand All @@ -382,7 +382,7 @@ export default class cMenuToolbarPlugin extends Plugin {
callback: async () => {
const activeLeaf = this.app.workspace.getActiveViewOfType(MarkdownView);
const view = activeLeaf;
const editor = this.app.workspace.activeEditor.editor;
const editor = this.app.workspace.activeLeaf.view?.editor;
try {
var replaceSelection = editor.replaceSelection; // 获取编辑器的替换选区方法
var text = await window.navigator.clipboard.readText(); // 使用 window.navigator.clipboard.readText() 方法读取剪贴板中的文本
Expand All @@ -401,7 +401,7 @@ export default class cMenuToolbarPlugin extends Plugin {
callback: async () => {
const activeLeaf = this.app.workspace.getActiveViewOfType(MarkdownView);
const view = activeLeaf;
const editor = this.app.workspace.activeEditor.editor;
const editor = this.app.workspace.activeLeaf.view?.editor;
try {
await window.navigator.clipboard.writeText(editor.getSelection()); // 使用 window.navigator.clipboard.writeText() 方法将选定的文本写入剪贴板
editor.replaceSelection(""); // 清空选定的文本
Expand Down Expand Up @@ -598,7 +598,7 @@ export default class cMenuToolbarPlugin extends Plugin {
callback: async () => {

const view = activeLeaf;
const editor = this.app.workspace.activeEditor.editor;
const editor = this.app.workspace.activeLeaf.view?.editor;
applyCommand(commandsMap[type], editor);
await wait(10);
//@ts-ignore
Expand Down

0 comments on commit 76e7e29

Please sign in to comment.