diff --git a/app/src/main/assets/syntax/languages.json b/app/src/main/assets/syntax/languages.json index 69ab05d6c7..16c0c5de55 100644 --- a/app/src/main/assets/syntax/languages.json +++ b/app/src/main/assets/syntax/languages.json @@ -43,6 +43,7 @@ "pascal": "Pascal", "perl": "Perl", "php": "PHP", + "plain": "Plain Text", "powershell": "Power Shell", "prolog": "Prolog", "python": "Python", diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/Code.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/Code.kt index 14d5db6322..c86706e669 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/Code.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/other/Code.kt @@ -11,7 +11,6 @@ import android.widget.FrameLayout import android.widget.TextView import androidx.core.view.updateLayoutParams import com.anytypeio.anytype.core_models.ThemeColor -import com.anytypeio.anytype.core_ui.BuildConfig import com.anytypeio.anytype.core_ui.R import com.anytypeio.anytype.core_ui.databinding.ItemBlockCodeSnippetBinding import com.anytypeio.anytype.core_ui.extensions.veryLight @@ -22,9 +21,7 @@ import com.anytypeio.anytype.core_ui.features.editor.decoration.DecoratableViewH import com.anytypeio.anytype.core_ui.features.editor.decoration.EditorDecorationContainer import com.anytypeio.anytype.core_ui.tools.DefaultTextWatcher import com.anytypeio.anytype.core_ui.widgets.text.CodeTextInputWidget -import com.anytypeio.anytype.core_utils.ext.dimen import com.anytypeio.anytype.core_utils.ext.imm -import com.anytypeio.anytype.core_utils.text.BackspaceKeyDetector import com.anytypeio.anytype.library_syntax_highlighter.Syntaxes import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType import com.anytypeio.anytype.presentation.editor.editor.model.BlockView @@ -116,12 +113,13 @@ class Code( clicked(ListenerType.Code.SelectLanguage(item.id)) } - if (!item.lang.isNullOrEmpty()) { + if (item.lang.isNullOrEmpty() || item.lang.equals("plain", ignoreCase = true)) { + content.setupSyntax(Syntaxes.PLAIN) + menu.setText(R.string.block_code_plain_text) + + } else { content.setupSyntax(item.lang) menu.text = item.lang!!.capitalize() - } else { - content.setupSyntax(Syntaxes.GENERIC) - menu.setText(R.string.block_code_menu_title) } } @@ -232,21 +230,6 @@ class Code( } } - fun enableBackspaceDetector( - onEmptyBlockBackspaceClicked: () -> Unit, - onNonEmptyBlockBackspaceClicked: () -> Unit - ) { - content.setOnKeyListener( - BackspaceKeyDetector { - if (content.text.toString().isEmpty()) { - onEmptyBlockBackspaceClicked() - } else { - onNonEmptyBlockBackspaceClicked() - } - } - ) - } - override fun applyDecorations(decorations: List) { decoratableContainer.decorate(decorations) { rect -> binding.content.updateLayoutParams { diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/CodeTextInputWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/CodeTextInputWidget.kt index e1a1a8fa93..0ff0fc906a 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/CodeTextInputWidget.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/CodeTextInputWidget.kt @@ -134,7 +134,7 @@ class CodeTextInputWidget : AppCompatEditText, SyntaxHighlighter { override fun setupSyntax(lang: String?) { runCatching { - if (lang == null) { + if (lang == null || lang.equals("plain", ignoreCase = true)) { rules.clear() clearHighlights() } else { diff --git a/core-ui/src/main/res/layout/item_block_code_snippet.xml b/core-ui/src/main/res/layout/item_block_code_snippet.xml index 0888ab29a2..36281c4082 100644 --- a/core-ui/src/main/res/layout/item_block_code_snippet.xml +++ b/core-ui/src/main/res/layout/item_block_code_snippet.xml @@ -29,7 +29,7 @@ android:layout_height="wrap_content" android:layout_marginStart="20dp" android:layout_marginTop="13dp" - android:text="@string/block_code_menu_title" /> + android:text="@string/block_code_plain_text" /> Больш Гатова Каб пачаць, выберыце блокі - Мова + Мова Скасаваць Вярнуць Капіяваць diff --git a/localization/src/main/res/values-de-rDE/strings.xml b/localization/src/main/res/values-de-rDE/strings.xml index 5f5901d120..2409ea4edc 100644 --- a/localization/src/main/res/values-de-rDE/strings.xml +++ b/localization/src/main/res/values-de-rDE/strings.xml @@ -221,7 +221,7 @@ Mehr Fertig Blöcke auswählen um zu starten - Sprache + Sprache Rückgängig Wiederholen Kopieren diff --git a/localization/src/main/res/values-es-rES/strings.xml b/localization/src/main/res/values-es-rES/strings.xml index 3c4d695a84..6a2ab86aa6 100644 --- a/localization/src/main/res/values-es-rES/strings.xml +++ b/localization/src/main/res/values-es-rES/strings.xml @@ -221,7 +221,7 @@ Más Listo Para empezar, selecciona bloques - Idioma + Idioma Deshacer Rehacer Copiar diff --git a/localization/src/main/res/values-fr-rFR/strings.xml b/localization/src/main/res/values-fr-rFR/strings.xml index c7121eb88f..76b2a2754e 100644 --- a/localization/src/main/res/values-fr-rFR/strings.xml +++ b/localization/src/main/res/values-fr-rFR/strings.xml @@ -221,7 +221,7 @@ Plus Terminé Pour commencer, sélectionnez des blocs - Langue + Langue Annuler Rétablir Copier diff --git a/localization/src/main/res/values-in-rID/strings.xml b/localization/src/main/res/values-in-rID/strings.xml index dfe8c3e121..26a43a6088 100644 --- a/localization/src/main/res/values-in-rID/strings.xml +++ b/localization/src/main/res/values-in-rID/strings.xml @@ -221,7 +221,7 @@ Lainnya Selesai Untuk mulai, pilih balok - Bahasa + Bahasa Urungkan Ulangi Salin diff --git a/localization/src/main/res/values-it-rIT/strings.xml b/localization/src/main/res/values-it-rIT/strings.xml index fef3652d12..5bd0f280f0 100644 --- a/localization/src/main/res/values-it-rIT/strings.xml +++ b/localization/src/main/res/values-it-rIT/strings.xml @@ -221,7 +221,7 @@ Altro Fatto Per iniziare, seleziona blocchi - Lingua + Lingua Annulla Ripristina Copia diff --git a/localization/src/main/res/values-nl-rNL/strings.xml b/localization/src/main/res/values-nl-rNL/strings.xml index 6175ef04e2..d014adac9c 100644 --- a/localization/src/main/res/values-nl-rNL/strings.xml +++ b/localization/src/main/res/values-nl-rNL/strings.xml @@ -221,7 +221,7 @@ Meer Gereed Selecteer blokken om te starten - Taal + Taal Ongedaan maken Voer opnieuw uit Kopieer diff --git a/localization/src/main/res/values-no-rNO/strings.xml b/localization/src/main/res/values-no-rNO/strings.xml index 96187cad8c..3794c15756 100644 --- a/localization/src/main/res/values-no-rNO/strings.xml +++ b/localization/src/main/res/values-no-rNO/strings.xml @@ -221,7 +221,7 @@ Mer Ferdig To start, select blocks - Språk + Språk Angre Omgjør Kopier diff --git a/localization/src/main/res/values-pt-rBR/strings.xml b/localization/src/main/res/values-pt-rBR/strings.xml index d23e9d9f5e..683180c3b0 100644 --- a/localization/src/main/res/values-pt-rBR/strings.xml +++ b/localization/src/main/res/values-pt-rBR/strings.xml @@ -221,7 +221,7 @@ Mais Concluído Para iniciar, selecione os blocos - Idioma + Idioma Desfazer Refazer Copiar diff --git a/localization/src/main/res/values-ru-rRU/strings.xml b/localization/src/main/res/values-ru-rRU/strings.xml index 686f7fd237..fc0d50eafa 100644 --- a/localization/src/main/res/values-ru-rRU/strings.xml +++ b/localization/src/main/res/values-ru-rRU/strings.xml @@ -221,7 +221,7 @@ Ещё Готово Чтобы начать, выберите блоки - Язык + Язык Отменить Повторить Копировать diff --git a/localization/src/main/res/values-tr-rTR/strings.xml b/localization/src/main/res/values-tr-rTR/strings.xml index 5f90273132..07cdf8d118 100644 --- a/localization/src/main/res/values-tr-rTR/strings.xml +++ b/localization/src/main/res/values-tr-rTR/strings.xml @@ -221,7 +221,7 @@ Daha fazla Bitti Başlamak için blokları seçin - Dil + Dil Geri al Yinele Kopyala diff --git a/localization/src/main/res/values-uk-rUA/strings.xml b/localization/src/main/res/values-uk-rUA/strings.xml index 26f5ffc508..fbb92f152d 100644 --- a/localization/src/main/res/values-uk-rUA/strings.xml +++ b/localization/src/main/res/values-uk-rUA/strings.xml @@ -221,7 +221,7 @@ More Готово To start, select blocks - Language + Language Повернути Redo Копіювати diff --git a/localization/src/main/res/values-zh-rCN/strings.xml b/localization/src/main/res/values-zh-rCN/strings.xml index 176d396df4..02a814f8d0 100644 --- a/localization/src/main/res/values-zh-rCN/strings.xml +++ b/localization/src/main/res/values-zh-rCN/strings.xml @@ -221,7 +221,7 @@ 更多 完成 要开始, 请选择块 - 语言 + 语言 撤消 重做 拷贝 diff --git a/localization/src/main/res/values-zh-rTW/strings.xml b/localization/src/main/res/values-zh-rTW/strings.xml index c314680f61..218a6a2ab8 100644 --- a/localization/src/main/res/values-zh-rTW/strings.xml +++ b/localization/src/main/res/values-zh-rTW/strings.xml @@ -221,7 +221,7 @@ 更多 完成 選取區塊以開始 - 語言 + 語言 撤銷 重做 複製 diff --git a/localization/src/main/res/values/strings.xml b/localization/src/main/res/values/strings.xml index 74fd44bbaf..3fcff2baee 100644 --- a/localization/src/main/res/values/strings.xml +++ b/localization/src/main/res/values/strings.xml @@ -258,7 +258,7 @@ More Done To start, select blocks - Language + Plain text Undo Redo