@teriusu/rich-editor 0.7.7 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Indent.d.ts","sourceRoot":"","sources":["../../src/extensions/Indent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,MAAM,EAAE;YACN,MAAM,EAAE,MAAM,UAAU,CAAC;YACzB,OAAO,EAAE,MAAM,UAAU,CAAC;SAC3B,CAAC;KACH;CACF;AAKD,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"Indent.d.ts","sourceRoot":"","sources":["../../src/extensions/Indent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,MAAM,EAAE;YACN,MAAM,EAAE,MAAM,UAAU,CAAC;YACzB,OAAO,EAAE,MAAM,UAAU,CAAC;SAC3B,CAAC;KACH;CACF;AAKD,eAAO,MAAM,MAAM,qBA4GjB,CAAC"}
|
|
@@ -79,9 +79,40 @@ export const Indent = Extension.create({
|
|
|
79
79
|
};
|
|
80
80
|
},
|
|
81
81
|
addKeyboardShortcuts() {
|
|
82
|
+
const isInCodeBlock = () => this.editor.isActive("codeBlock");
|
|
82
83
|
return {
|
|
83
|
-
Tab: () =>
|
|
84
|
-
|
|
84
|
+
Tab: () => {
|
|
85
|
+
// 코드블록 안에서는 들여쓰기 문자(\t) 삽입
|
|
86
|
+
if (isInCodeBlock()) {
|
|
87
|
+
return this.editor.commands.insertContent("\t");
|
|
88
|
+
}
|
|
89
|
+
return this.editor.commands.indent();
|
|
90
|
+
},
|
|
91
|
+
"Shift-Tab": () => {
|
|
92
|
+
// 코드블록 안: 줄 시작의 \t 또는 앞쪽 공백 1단계 제거
|
|
93
|
+
if (isInCodeBlock()) {
|
|
94
|
+
const { state, view } = this.editor;
|
|
95
|
+
const { $from } = state.selection;
|
|
96
|
+
const lineStart = $from.start();
|
|
97
|
+
const textBefore = state.doc.textBetween(lineStart, $from.pos, "\n");
|
|
98
|
+
const lineStartOfCursor = textBefore.lastIndexOf("\n") + 1;
|
|
99
|
+
const lineHead = textBefore.slice(lineStartOfCursor);
|
|
100
|
+
const cursorAbsLineStart = $from.pos - lineHead.length;
|
|
101
|
+
let removeLen = 0;
|
|
102
|
+
if (lineHead.startsWith("\t"))
|
|
103
|
+
removeLen = 1;
|
|
104
|
+
else if (lineHead.startsWith(" "))
|
|
105
|
+
removeLen = 2;
|
|
106
|
+
else if (lineHead.startsWith(" "))
|
|
107
|
+
removeLen = 1;
|
|
108
|
+
if (!removeLen)
|
|
109
|
+
return true;
|
|
110
|
+
const tr = state.tr.delete(cursorAbsLineStart, cursorAbsLineStart + removeLen);
|
|
111
|
+
view.dispatch(tr);
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
return this.editor.commands.outdent();
|
|
115
|
+
},
|
|
85
116
|
};
|
|
86
117
|
},
|
|
87
118
|
});
|