Skip to content

Simple Text 4.0 for Craft 6 (native) - #17

Open
riasvdv wants to merge 3 commits into
4.xfrom
feature/craft-6-native
Open

riasvdv wants to merge 3 commits into
4.xfrom
feature/craft-6-native

Conversation

@riasvdv

@riasvdv riasvdv commented Nov 8, 2026 •

Copy link
Copy Markdown

Description

Simple Text 4.0: a native Craft 6 plugin. It no longer needs craftcms/yii2-adapter or Yii.

craft\simpletext\…                     →  CraftCms\SimpleText\…
Field::getSettingsHtml()               →  settingsUi() (Number control, min 1, validated)
Field::getInputHtml() + BehaveAsset    →  uiControl(): `simple-text:textarea` control wrapping
                                          core's monospace, auto-growing textarea + Behave.js
                                          (resources/js, loaded via $scripts, no build step)
Tab always indents (focus trap)        →  Markdown-field rules: Tab/Shift+Tab indent a selection,
                                          otherwise move focus; Ctrl/Cmd+] / [ indent the line
“craft\simpletext\Field” stored types  →  migration renames them in fields + project config
ECS / Gulp / bower                     →  Pint / Larastan (level max) / Pest (9 tests), Craft 6 CI

Saved values, field settings and template/GraphQL output are unchanged. See UPGRADE.md and CHANGELOG.md.

The Craft 6 release that runs through the adapter is #16 (3.x).

Evidence

Run against craftcms/cms 6.x 6b18aac (Postgres), hosts built from craftcms/craft 6.x-dev:

  • composer test: 9 passed. Each test was checked by breaking what it covers (dropping the project-config rename, monospace(), the min:1 rule, the custom control, or trimming values). Pint, Larastan and Prettier pass.

  • Behave.js in the real entry editor (keyboard events in Chromium): (, { auto-close and ) steps over; Enter inside {} indents; - lists continue; Tab/Shift+Tab with a selection indent/outdent; Ctrl+]/Ctrl+[ indent/outdent the caret line; Tab with nothing selected moves focus to the next control; a Behave-only edit ([ → []) right before Save is saved; read-only revisions are left alone; the textarea keeps its accessible name. Same results with the adapter still installed, and after an upgrade where composer dump-autoload published the scripts.

  • Fresh install with no adapter (composer show craftcms/yii2-adapter / yiisoft/yii2: not found): field settings render and save initialRows as an int, 0 shows “must be at least 1”, the editor textarea is monospace with the configured rows and grows from 131px to 188px as lines are added, values save, and front-end {{ entry.docs }} and GraphQL output match 3.x byte for byte. Uninstall and reinstall work.

  • Upgrade from 3.x on Craft 6 + adapter (v6 with adapter - compatibility #16 head 1b8db66), both keeping and removing the adapter: craft:up runs the migration, fields.type and the project config YAML become CraftCms\SimpleText\Field, craft:project-config:diff is clean, content is kept, and editing and saving works afterwards.

  • Upgrade straight from a Craft 5.12.0.1 site running Simple Text 3.1.0 (cms 6.x 31ad9f1, adapter 6bbbf5e): craft6-revamp 1.3.1, then require 4.0 and run craft:up. Core migrations and the plugin migration run cleanly, fields.type and the project config YAML become CraftCms\SimpleText\Field, initialRows ("6") is kept, craft:project-config:diff is clean, and front-end and GraphQL output match the Craft 5 site byte for byte. In the editor, Behave.js and the Tab rules work, and a Behave-only edit is saved. Field settings render and save initialRows as an int. After composer remove craftcms/yii2-adapter (with the site's carried-over config/craft/general.php switched to CraftCms\Cms\Config\GeneralConfig and the Yii config/craft/app.php removed), no Yii classes load, and the editor, saving, front end and GraphQL still work.

Simple Text 4.0 requires Craft 6 and PHP 8.5, and runs without
craftcms/yii2-adapter.

- Classes move to the CraftCms\SimpleText namespace. A migration
  points fields saved by 3.x at the new field class, in the database
  and in project config.
- The input is core's monospaced, auto-growing Textarea control, and
  the settings use the Ui API. Behave.js is removed, so Tab no longer
  traps keyboard focus.
- Initial Rows is validated as an integer of 1 or more.
- ECS and Gulp are replaced by Pint, Larastan and Pest, and CI runs
  against Craft 6.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1bb51-0f73-74f7-8955-0fbf49683b7d
Co-authored-by: Amp <amp@ampcode.com>
@riasvdv
riasvdv requested a review from brandonkelly as a code owner November 8, 2026 13:47
The field's input is now a `simple-text:textarea` UI control that
wraps core's textarea and attaches Behave.js, which closes brackets
and quotes, indents new lines inside brackets and continues lists.

Tab follows core's Markdown field so it no longer traps keyboard
focus: with a selection, Tab and Shift+Tab indent and outdent the
lines, otherwise they move focus. Ctrl/Cmd+] and Ctrl/Cmd+[ indent
and outdent the current line. Behave.js edits fire `input` events so
the control's value stays in sync, and read-only textareas are left
alone.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1bb51-0f73-74f7-8955-0fbf49683b7d
Co-authored-by: Amp <amp@ampcode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants