From 0e686ba64cfe34d62390ca634b7da336cdf1f4d9 Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Sun, 6 Oct 2024 13:50:01 +0100 Subject: [PATCH] Revert `Trix.config.editor` changes --- .github/workflows/ci.yml | 7 +----- README.md | 4 ++-- karma.conf.js | 10 +------- src/test/system/custom_element_test.js | 6 ++--- .../fixtures/form_associated_false.js | 1 - src/trix/config/editor.js | 3 --- src/trix/config/index.js | 1 - src/trix/elements/trix_editor_element.js | 24 +++++++++---------- 8 files changed, 18 insertions(+), 38 deletions(-) delete mode 100644 src/test/test_helpers/fixtures/form_associated_false.js delete mode 100644 src/trix/config/editor.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7dd3d3971..8ab86c134 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,12 +8,7 @@ on: jobs: build: - name: "Browser tests (Trix.config.editor.formAssociated = ${{ matrix.formAssociated }})" - strategy: - matrix: - formAssociated: [true, false] - env: - FORM_ASSOCIATED: "${{ matrix.formAssociated }}" + name: Browser tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index e6f404922..c4008b844 100644 --- a/README.md +++ b/README.md @@ -90,12 +90,12 @@ Clicking the quote button toggles whether the block should be rendered with `` 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`: +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). If there is a need to disable support for `ElementInternals`, set `Trix.elements.TrixEditorElement.formAssociated = false`: ```js import Trix from "trix" -Trix.config.editor.formAssociated = false +Trix.elements.TrixEditorElement.formAssociated = false ``` ## Invoking Internal Trix Actions diff --git a/karma.conf.js b/karma.conf.js index fc5c6ad82..9fe317624 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/test_helpers/fixtures/*.png", watched: false, included: false, served: true } + { pattern: "src/test_helpers/fixtures/*.png", watched: false, included: false, served: true } ], proxies: { "/test_helpers/fixtures/": "/base/src/test_helpers/fixtures/" @@ -29,14 +29,6 @@ const config = { /* eslint camelcase: "off", */ -if (process.env.FORM_ASSOCIATED === "false") { - config.files.push({ - pattern: "src/test/test_helpers/fixtures/form_associated_false.js", - watched: false, - included: true - }) -} - if (process.env.SAUCE_ACCESS_KEY) { config.customLaunchers = { sl_chrome_latest: { diff --git a/src/test/system/custom_element_test.js b/src/test/system/custom_element_test.js index 5af7d6043..13e28dda4 100644 --- a/src/test/system/custom_element_test.js +++ b/src/test/system/custom_element_test.js @@ -1,5 +1,5 @@ -import * as config from "trix/config" import { rangesAreEqual } from "trix/core/helpers" +import TrixEditorElement from "trix/elements/trix_editor_element" import { TEST_IMAGE_URL, @@ -690,10 +690,10 @@ testGroup("form property references its
", { template: "editors_with_forms function testIfFormAssociated(name, callback) { test(name, async () => { - if (config.editor.formAssociated) { + if (TrixEditorElement.formAssociated) { await callback() } else { - assert.equal(config.editor.formAssociated, false, "skipping test that requires ElementInternals") + assert.equal(TrixEditorElement.formAssociated, false, "skipping test that requires ElementInternals") } }) } diff --git a/src/test/test_helpers/fixtures/form_associated_false.js b/src/test/test_helpers/fixtures/form_associated_false.js deleted file mode 100644 index 2b95f2bc5..000000000 --- a/src/test/test_helpers/fixtures/form_associated_false.js +++ /dev/null @@ -1 +0,0 @@ -window.Trix.config.editor.formAssociated = false diff --git a/src/trix/config/editor.js b/src/trix/config/editor.js deleted file mode 100644 index cc11f166f..000000000 --- a/src/trix/config/editor.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - formAssociated: "ElementInternals" in window -} diff --git a/src/trix/config/index.js b/src/trix/config/index.js index 64684bc1e..27f7abc2f 100644 --- a/src/trix/config/index.js +++ b/src/trix/config/index.js @@ -2,7 +2,6 @@ export { default as attachments } from "./attachments" export { default as blockAttributes } from "./block_attributes" export { default as browser } from "./browser" export { default as css } from "./css" -export { default as editor } from "./editor" export { default as fileSize } from "./file_size_formatting" export { default as input } from "./input" export { default as keyNames } from "./key_names" diff --git a/src/trix/elements/trix_editor_element.js b/src/trix/elements/trix_editor_element.js index e99a898e5..cb96822e1 100644 --- a/src/trix/elements/trix_editor_element.js +++ b/src/trix/elements/trix_editor_element.js @@ -161,9 +161,7 @@ installDefaultCSSForTagName("trix-editor", `\ }`) export default class TrixEditorElement extends HTMLElement { - static get formAssociated() { - return config.editor.formAssociated - } + static formAssociated = "ElementInternals" in window #customValidationMessage #internals @@ -261,7 +259,7 @@ export default class TrixEditorElement extends HTMLElement { if (this.#internals) { return this.inputElement.disabled } else { - console.warn("Trix is not configured to support the [disabled] attribute. Set Trix.config.editor.formAssociated = true") + console.warn("This browser does not support the [disabled] attribute for trix-editor elements.") return false } @@ -271,7 +269,7 @@ export default class TrixEditorElement extends HTMLElement { if (this.#internals) { this.toggleAttribute("disabled", value) } else { - console.warn("Trix is not configured to support the [disabled] attribute. Set Trix.config.editor.formAssociated = true") + console.warn("This browser does not support the [disabled] attribute for trix-editor elements.") } } @@ -279,7 +277,7 @@ export default class TrixEditorElement extends HTMLElement { if (this.#internals) { return this.hasAttribute("required") } else { - console.warn("Trix is not configured to support the [required] attribute. Set Trix.config.editor.formAssociated = true") + console.warn("This browser does not support the [required] attribute for trix-editor elements.") return false } @@ -290,7 +288,7 @@ export default class TrixEditorElement extends HTMLElement { this.toggleAttribute("required", value) this.#synchronizeValidation() } else { - console.warn("Trix is not configured to support the [required] attribute. Set Trix.config.editor.formAssociated = true") + console.warn("This browser does not support the [required] attribute for trix-editor elements.") } } @@ -298,7 +296,7 @@ export default class TrixEditorElement extends HTMLElement { if (this.#internals) { return this.#internals.validity } else { - console.warn("Trix is not configured to support the validity property. Set Trix.config.editor.formAssociated = true") + console.warn("This browser does not support the validity property for trix-editor elements.") return null } } @@ -307,7 +305,7 @@ export default class TrixEditorElement extends HTMLElement { if (this.#internals) { return this.#internals.validationMessage } else { - console.warn("Trix is not configured to support the validationMessage property. Set Trix.config.editor.formAssociated = true") + console.warn("This browser does not support the validationMessage property for trix-editor elements.") return "" } @@ -317,7 +315,7 @@ export default class TrixEditorElement extends HTMLElement { if (this.#internals) { return this.#internals.willValidate } else { - console.warn("Trix is not configured to support the willValidate property. Set Trix.config.editor.formAssociated = true") + console.warn("This browser does not support the willValidate property for trix-editor elements.") return false } @@ -425,7 +423,7 @@ export default class TrixEditorElement extends HTMLElement { if (this.#internals) { return this.#internals.checkValidity() } else { - console.warn("Trix is not configured to support checkValidity(). Set Trix.config.editor.formAssociated = true") + console.warn("This browser does not support checkValidity() for trix-editor elements.") return true } @@ -435,7 +433,7 @@ export default class TrixEditorElement extends HTMLElement { if (this.#internals) { return this.#internals.reportValidity() } else { - console.warn("Trix is not configured to support reportValidity(). Set Trix.config.editor.formAssociated = true") + console.warn("This browser does not support reportValidity() for trix-editor elements.") return true } @@ -447,7 +445,7 @@ export default class TrixEditorElement extends HTMLElement { this.#synchronizeValidation() } else { - console.warn("Trix is not configured to support setCustomValidity(validationMessage). Set Trix.config.editor.formAssociated = true") + console.warn("This browser does not support setCustomValidity(validationMessage) for trix-editor elements.") } }