Refactor TextEditor to handle block flags in text
This commit is contained in:
parent
379f356d15
commit
79e6e80d82
@ -202,14 +202,22 @@ class TextEditor(Widget):
|
||||
super().__init__(submit_button_name, cancel_button_name)
|
||||
|
||||
self._title = title
|
||||
self._text = text
|
||||
self._text = self._handle_block_flag(text)
|
||||
|
||||
self._editor_key = self.gen_id(self._id_prefix, 0)
|
||||
self._new_text: Optional[str] = None
|
||||
|
||||
def _handle_block_flag(self, text):
|
||||
"""convert \\ to \\, and ` to \\`"""
|
||||
return text.replace("\\", "\\\\").replace("`", "\\`")
|
||||
|
||||
def _remove_block_flag(self, text):
|
||||
"""convert \\ to \\, and \\` to `"""
|
||||
return text.replace("\\`", "`").replace("\\\\", "\\")
|
||||
|
||||
@property
|
||||
def new_text(self):
|
||||
return self._new_text
|
||||
return self._remove_block_flag(self._new_text)
|
||||
|
||||
def _in_chatmark(self) -> str:
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user