Skip to content

Commit

Permalink
优化中文输入法下ckeditor的快捷操作
Browse files Browse the repository at this point in the history
  • Loading branch information
Nriver committed Nov 30, 2023
1 parent 9929dc7 commit 170a69f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions 2.trans.py
Expand Up @@ -3664,14 +3664,23 @@ def replace_in_file(file_path, translation, base_path=BASE_PATH):
dest_path = f'{PATCH_FOLDER}/libraries/ckeditor/ckeditor.js'
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
shutil.copy(src_path, dest_path)
# ckeditor 代码块通过中文的 · 触发
# ckeditor code block trigger by chinese ·
with open(dest_path, 'r') as f:
content = f.read()

# ckeditor 代码块通过中文的 · 触发
# ckeditor code block trigger by chinese ·
target_element = '/^```$/'
new_element = '/^(```|···)$/'
if target_element in content:
content = content.replace(target_element, new_element)

# ckeditor 引用通过中文的 》 触发
# ckeditor block quote trigger by chinese 》
target_element = '/^>\s$/'
new_element = '/^(>|》)\s$/'
if target_element in content:
content = content.replace(target_element, new_element)

with open(dest_path, 'w') as f:
f.write(content)

Expand Down

0 comments on commit 170a69f

Please sign in to comment.