diff --git a/.ruby-version b/.ruby-version index 54978911..ea897ac5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-3.4.5 +ruby-4.0.5 diff --git a/__tests__/components/highlighting_text.test.js b/__tests__/components/highlighting_text.test.js index 15280356..c2067a3b 100644 --- a/__tests__/components/highlighting_text.test.js +++ b/__tests__/components/highlighting_text.test.js @@ -1,4 +1,6 @@ +import { Platform } from 'react-native' import HighlightingText from '../../src/components/text/highlighting_text' +import editorHtml from '../../src/components/text/editor_html' import App from '../../src/stores/App' jest.mock('../../src/stores/App', () => ({ @@ -24,6 +26,38 @@ jest.mock('../../src/components/keyboard/editor_keyboard_avoiding_view', () => { }) describe('HighlightingText font scaling', () => { + test('requests native WebView focus when focusing the editor', () => { + const requestFocus = jest.fn() + const editor = new HighlightingText({}) + editor.webview = { current: { requestFocus } } + editor.editorConfig = () => ({ editable: true }) + editor.injectJavaScript = jest.fn() + + editor.syncEditor({ focus: true }) + + expect(requestFocus).toHaveBeenCalled() + }) + + test('keeps Android newlines in place instead of rewriting the document', () => { + expect(editorHtml).toContain('insertLineBreakInPlace') + expect(editorHtml).toContain('execCommand("insertLineBreak")') + expect(editorHtml).toMatch(/if \(!insertedNewline\) \{\s*insertLineBreakInPlace\(\)/) + }) + + test('enables the Android keyboard proxy only when autoFocus is set', () => { + const original = Platform.OS + Platform.OS = 'android' + try { + const with_focus = new HighlightingText({ autoFocus: true }) + const without_focus = new HighlightingText({ autoFocus: false }) + expect(with_focus.state.android_focus_proxy).toBe(true) + expect(without_focus.state.android_focus_proxy).toBe(false) + } + finally { + Platform.OS = original + } + }) + test('uses the full system font scale by default', () => { App.font_scale = 3.5 const editor = new HighlightingText({}) diff --git a/android/app/build.gradle b/android/app/build.gradle index 0e056a34..f28d532d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -102,7 +102,7 @@ android { applicationId "blog.micro.android" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 98 + versionCode 99 versionName "3.0.2" buildConfigField "String", "REACT_NATIVE_RELEASE_LEVEL", "\"${findProperty('reactNativeReleaseLevel') ?: 'stable'}\"" diff --git a/mise.toml b/mise.toml index c85867ad..f3d14c86 100644 --- a/mise.toml +++ b/mise.toml @@ -1,2 +1,2 @@ [tools] -ruby = "3.4.5" +ruby = "4.0.5" diff --git a/src/components/text/editor_html.js b/src/components/text/editor_html.js index 6b29c4dc..69199c28 100644 --- a/src/components/text/editor_html.js +++ b/src/components/text/editor_html.js @@ -194,7 +194,7 @@ const editorHtml = String.raw` -