From 92a19b30bcfe7fb984de61967fad83fd6068096d Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Thu, 3 Oct 2024 18:43:45 -0400 Subject: [PATCH] Re-submit disabled and validations with backwards compatible support --- README.md | 12 +- karma.conf.js | 2 +- src/test/system/custom_element_test.js | 22 ++- .../fixtures/editor_with_labels.js | 8 +- .../fixtures/editors_with_forms.js | 5 +- src/trix/config/editor.js | 3 + src/trix/config/index.js | 1 + src/trix/controllers/editor_controller.js | 2 +- src/trix/elements/trix_editor_element.js | 176 +++++++++++++----- 9 files changed, 177 insertions(+), 54 deletions(-) create mode 100644 src/trix/config/editor.js diff --git a/README.md b/README.md index e99bb7418..e6f404922 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ This is the approach that all modern, production ready, WYSIWYG editors now take
Trix supports all evergreen, self-updating desktop and mobile browsers.
-Trix is built with established web standards, notably [Custom Elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements), [Mutation Observer](https://dom.spec.whatwg.org/#mutation-observers), and [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). +Trix is built with established web standards, notably [Custom Elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements), [Element Internals](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals), [Mutation Observer](https://dom.spec.whatwg.org/#mutation-observers), and [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). # Getting Started @@ -88,6 +88,16 @@ If the attribute is defined in `Trix.config.blockAttributes`, Trix will apply th Clicking the quote button toggles whether the block should be rendered with `
`. +## Integrating with Element Internals + +Trix will integrate `` elements with forms depending on the browser's support for [Element Internals](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals). By default, Trix will enable support for `ElementInternals` when the feature is enabled in the browser. If there is a need to disable support for `ElementInternals`, set `Trix.config.editor.formAssociated = false`: + +```js +import Trix from "trix" + +Trix.config.editor.formAssociated = false +``` + ## Invoking Internal Trix Actions Internal actions are defined in `controllers/editor_controller.js` and consist of: diff --git a/karma.conf.js b/karma.conf.js index 9fe317624..725a68dcf 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -3,7 +3,7 @@ const config = { frameworks: [ "qunit" ], files: [ { pattern: "dist/test.js", watched: false }, - { pattern: "src/test_helpers/fixtures/*.png", watched: false, included: false, served: true } + { pattern: "src/test/test_helpers/fixtures/*.png", watched: false, included: false, served: true } ], proxies: { "/test_helpers/fixtures/": "/base/src/test_helpers/fixtures/" diff --git a/src/test/system/custom_element_test.js b/src/test/system/custom_element_test.js index a110aff4a..b5babc39b 100644 --- a/src/test/system/custom_element_test.js +++ b/src/test/system/custom_element_test.js @@ -500,7 +500,7 @@ testGroup("Custom element API", { template: "editor_empty" }, () => { testGroup("