MacBook-Pro-de-Oscar.local 2026-6-13:18:24:58
This commit is contained in:
+22
-23
@@ -94,18 +94,24 @@ function removeHeaderNumber(text, splitor) {
|
||||
function isHeader(text) {
|
||||
return /^#{1,6} .*/.test(text.trim());
|
||||
}
|
||||
function updateCodeBlockState(line, isCodeBlock) {
|
||||
const trimmedLine = line.trimStart();
|
||||
if (!trimmedLine.startsWith("```")) {
|
||||
return isCodeBlock;
|
||||
}
|
||||
isCodeBlock = !isCodeBlock;
|
||||
if (trimmedLine.slice(3).includes("```")) {
|
||||
isCodeBlock = !isCodeBlock;
|
||||
}
|
||||
return isCodeBlock;
|
||||
}
|
||||
function analyzeHeaderLevels(content) {
|
||||
const lines = content.split("\n");
|
||||
const usedLevels = /* @__PURE__ */ new Set();
|
||||
let isCodeBlock = false;
|
||||
let headerCount = 0;
|
||||
for (const line of lines) {
|
||||
if (line.startsWith("```")) {
|
||||
isCodeBlock = !isCodeBlock;
|
||||
if (line.slice(3).includes("```")) {
|
||||
isCodeBlock = !isCodeBlock;
|
||||
}
|
||||
}
|
||||
isCodeBlock = updateCodeBlockState(line, isCodeBlock);
|
||||
if (isCodeBlock)
|
||||
continue;
|
||||
if (isHeader(line)) {
|
||||
@@ -1083,10 +1089,7 @@ var init_dialogs = __esm({
|
||||
let isInCodeBlock = false;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
if (line.startsWith("```")) {
|
||||
isInCodeBlock = !isInCodeBlock;
|
||||
continue;
|
||||
}
|
||||
isInCodeBlock = updateCodeBlockState(line, isInCodeBlock);
|
||||
if (isInCodeBlock) {
|
||||
continue;
|
||||
}
|
||||
@@ -1296,12 +1299,7 @@ var init_dialogs = __esm({
|
||||
let isInCodeBlock = false;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
if (line.startsWith("```")) {
|
||||
isInCodeBlock = !isInCodeBlock;
|
||||
if (line.slice(3).contains("```")) {
|
||||
isInCodeBlock = !isInCodeBlock;
|
||||
}
|
||||
}
|
||||
isInCodeBlock = updateCodeBlockState(line, isInCodeBlock);
|
||||
if (isInCodeBlock) {
|
||||
continue;
|
||||
}
|
||||
@@ -2513,6 +2511,9 @@ var EditorHandlers = class {
|
||||
key: "Backspace",
|
||||
run: (view) => {
|
||||
const state = view.state;
|
||||
if (!state.selection.main.empty) {
|
||||
return false;
|
||||
}
|
||||
const pos = state.selection.main.to;
|
||||
const currentLine = state.doc.lineAt(pos);
|
||||
if (!isHeader(currentLine.text)) {
|
||||
@@ -2576,6 +2577,9 @@ var EditorHandlers = class {
|
||||
handlePressBackspace(view) {
|
||||
let state = view.state;
|
||||
let doc = state.doc;
|
||||
if (!state.selection.main.empty) {
|
||||
return false;
|
||||
}
|
||||
const pos = state.selection.main.to;
|
||||
const changes = [];
|
||||
if (!isHeader(doc.lineAt(pos).text)) {
|
||||
@@ -3282,12 +3286,7 @@ var HeaderEnhancerPlugin = class extends import_obsidian6.Plugin {
|
||||
for (let i = 0; i <= lineCount; i++) {
|
||||
const line = editor.getLine(i);
|
||||
docCharCount += line.length;
|
||||
if (line.startsWith("```")) {
|
||||
isCodeBlock = !isCodeBlock;
|
||||
if (line.slice(3).contains("```")) {
|
||||
isCodeBlock = !isCodeBlock;
|
||||
}
|
||||
}
|
||||
isCodeBlock = updateCodeBlockState(line, isCodeBlock);
|
||||
if (isCodeBlock) {
|
||||
continue;
|
||||
}
|
||||
@@ -3296,7 +3295,7 @@ var HeaderEnhancerPlugin = class extends import_obsidian6.Plugin {
|
||||
line,
|
||||
config.startLevel
|
||||
);
|
||||
if (headerLevel <= 0) {
|
||||
if (headerLevel <= 0 || realHeaderLevel > config.endLevel) {
|
||||
continue;
|
||||
}
|
||||
insertNumber = getNextNumber(insertNumber, headerLevel);
|
||||
|
||||
Reference in New Issue
Block a user