Commit Graph

2636 Commits

Author SHA1 Message Date
Alberto Fernandez-Capel 05f1e18cf5 Update source to coffeescript 2
There are some breaking changes from v1 to v2 documented at

https://coffeescript.org/#breaking-changes

Most of the changes have to do with this references not being valid
before super is called, as per the es6 spec.
2021-09-02 18:04:51 +01:00
Alberto Fernandez-Capel 596a402134 Upgrade to coffeescript 2 2021-09-02 17:14:32 +01:00
Alberto Fernandez-Capel 07445d4dbd Update ruby and dependencies
ruby 2.3.4 is EOLed and the old dependencies don't compile on a
modern mac.

uglifier version is pinned down because more recent releases don't
support a copyright option.
2021-08-25 16:31:27 +01:00
Javan Makhmali 5102b8f050 Merge pull request #899 from seanpdoyle/trix-editor-form
Add TrixEditorElement.form property
2021-04-26 10:12:57 -04:00
Sean Doyle 86390c3e3b Add TrixEditorElement.form property
The problem:
---

Consider the following HTML:

```html
<form action="/articles" method="post">
  <textarea name="content"></textarea>

  <button type="submit">Save</button>
</form>
```

Then, consider a theoretical event listener:

```js
addEventListener("keydown", ({ key, metaKey, target }) => {
  if (target.form && key == "Enter" && (metaKey || ctrlKey)) {
    form.requestSubmit()
  }
})
```

This relies on [HTMLTextAreaElement.form][] finding its related `<form>`
element. Given the way the `[form]` attribute can reference a `<form>`
element that is _not an ancestor_, that same event listener would
continue to work with this HTML:

```html
<textarea name="content" form="new_article"></textarea>

<!-- elsewhere -->
<form id="new_article" action="/articles" method="post">
  <button type="submit">Save</button>
</form>
```

Unfortunately, if the `<textarea>` element were replaced with a
`<trix-editor>`, the event listener's reliance on accessing the `form`
as a property would break, since the `<trix-editor>` custom element
doesn't declare that property.

[HTMLTextAreaElement.form]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement#properties

The proposed changes:
---

Provide property access for `<trix-editor>` elements, similar to how an
`<input>` or `<textarea>` element can access a form outside of its
direct tree of ancestors via the [form="..."][] attribute and the
corresponding `.form` property.

Related testing changes
---

All other system tests in the suite are rendered into a `<form
id="trix-container">` element on the page. In order to test this new
behavior, the fixture HTML declare several new `<form>` elements.

These are incompatible with an ancestor `<form>`, since HTML forbids
nesting `<form>` elements.

To address that, this commit changes the implementation of how its Test
Helpers create elements from the fixture HTML files.

[form="..."]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#attr-form
2021-04-26 10:02:07 -04:00
Javan Makhmali 66d26af0fd Pin automated Chrome tests to v89 pending further investigation 2021-04-22 11:51:11 -04:00
Javan Makhmali 417c2be5ee Avoid Firefox execCommand insert list bug when there's only a single line of text 2021-04-22 11:38:40 -04:00
Javan Makhmali 7940a9a3b7 Update stale.yml 2021-03-11 10:26:49 -05:00
Javan Makhmali 3e0fb022da master → main 2021-01-20 13:32:00 -05:00
Javan Makhmali 520cc50aff Defer accessing toolbar lang config
Fixes #868
2020-12-15 11:51:06 -05:00
Javan Makhmali c97f990832 Trix 1.3.1 1.3.1 2020-12-04 15:42:26 -05:00
Javan Makhmali 1e8b295f31 Ensure pseudo-placeholder clicks fall through to editor element
Fixes #859
2020-11-30 08:07:01 -05:00
Javan Makhmali 75d0f7e981 Travis CI → GitHub Actions 2020-11-20 09:44:02 -05:00
Javan Makhmali 29c4994505 Cancel paste events when inserting HTML 2020-11-19 15:36:33 -05:00
Javan Makhmali 9601ac9bc1 Ensure JSON.parse() errors don't interrupt parsing HTML 2020-11-19 15:16:07 -05:00
Javan Makhmali f81b606cd0 Skip parsing <iframe>s 2020-11-19 14:33:12 -05:00
Javan Makhmali 80d57a0b18 Optimization: Skip setup work for internal elements 2020-11-05 12:37:19 -05:00
Javan Makhmali 6dd6cc0e91 Group accessibility helpers 2020-11-05 12:14:57 -05:00
Javan Makhmali 103b6fb668 Refactor ensureAriaLabel() 2020-11-05 12:09:37 -05:00
Javan Makhmali ea81c02df0 Tidy accessibility tests 2020-11-05 11:14:34 -05:00
Javan Makhmali 932bcc96d1 Merge pull request #843 from seanpdoyle/default-aria-label
Ensure trix-editor element is ARIA labeled
2020-11-05 07:30:56 -08:00
Sean Doyle 5cc0bab37e Ensure trix-editor element is ARIA labeled
Since the `<trix-editor>` element is custom and not a browser `<input>`,
we can't rely that assistive technology will be able to [read the label
text from a `<label for="...">` that corresponds to a `<trix-editor
id="...">` element][labelable].

When a `<trix-editor>` element is attached to the DOM and initialized,
collect the text from its related `<label>` elements and combine it to
set a default `[aria-label]` value.

If the `<trix-editor>` element is a descendant of any of its `<label>`
elements, *omit* those elements when generating an `[aria-label]` value.

If an [`[aria-label]` value][aria-label] is already specified, *do not*
override it.

Similarly, if a [`[aria-labelledby]` value][aria-labelledby] is
specified, don't set the `[aria-label]` attribute at all.

[labelable]: https://html.spec.whatwg.org/multipage/forms.html#category-label
[aria-label]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute
[aria-labelledby]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-labelledby_attribute
2020-11-04 21:28:40 -05:00
Javan Makhmali 7efb14bb5e Merge pull request #834 from rluba/fix/drop_on_children
Fix dropping a file onto an existing attachment
2020-10-12 09:16:43 -04:00
Javan Makhmali a5524150a4 Trix 1.3.0 1.3.0 2020-09-24 15:34:41 -04:00
Javan Makhmali b2fba5c0a0 Only need to test ancestor <label>s for implicit control 2020-09-24 12:56:44 -04:00
Javan Makhmali e14320526a Tidy form support listeners 2020-09-24 12:10:40 -04:00
Javan Makhmali 8458f0645f Exclude <label>s that control another element 2020-09-24 11:51:38 -04:00
Javan Makhmali a4b8f01156 Group <label> tests and use a dedicated fixture 2020-09-24 11:50:31 -04:00
Javan Makhmali 5c417a63f2 Merge pull request #829 from seanpdoyle/label-click-focus
Focus <trix-editor> on <label> click
2020-09-24 10:48:24 -04:00
Javan Makhmali cd4c68f880 Fix escaping HTML attributes for attachment metadata
Construct DOM nodes directly instead of piecing together HTML strings.
2020-09-24 09:19:59 -04:00
Raphael Luba 55e9f2face Fix dropping a file onto an existing attachment
Without this fix, the file was opened in a new tab when being dropped onto an existing attachment inside the editor.
2020-09-22 09:32:36 +02:00
Sean Doyle 0a55749cf7 code review feedback 2020-09-15 13:48:14 -04:00
Sean Doyle a229b84974 Update src/trix/elements/trix_editor_element.coffee
Co-authored-by: Javan Makhmali <javan@javan.us>
2020-09-15 13:24:09 -04:00
Sean Doyle 7cc6d9e5e6 Focus <trix-editor> on <label> click
Both `<input>` elements and `<textarea>` elements' JavaScript Object
interfaces support the `.labels` property ([HTMLInputElement.labels][]
and [HTMLTextAreaElement.labels][], respectively).

This commit adds the `TrixEditorElement.labels` property to match.

When corresponding `<label>` elements exist within the `.labels`
property, wire-up [`click` event listeners][mdn-click-event] that focus
the corresponding `<trix-editor>` elements.

[HTMLInputElement.labels]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/labels
[HTMLTextAreaElement.labels]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement/labels
[mdn-click-event]: https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event
2020-09-15 11:47:51 -04:00
Javan Makhmali e8631e9485 Merge pull request #824 from basecamp/auto-rtl
Right-to-left (RTL) support
2020-08-25 16:32:47 -04:00
Javan Makhmali 923a8ec948 Rework RTL styles to support all browsers
The (IE 11) fallback styles in e1e9361b7f were LTR-only.
2020-08-25 15:19:57 -04:00
Nabeelah Ali e1e9361b7f Add in logical properties to accomodate RTL languages: keep existing physical properties as a fallback for older browsers. 2020-08-18 11:02:49 +02:00
Javan Makhmali 8bfcade89b Empty blocks can be grouped regardless of direction 2020-08-13 17:26:48 -04:00
Javan Makhmali 5c66420a53 Lean on supported browser APIs for BIDI text detection
See also: https://glitch.com/~dirtect
2020-08-13 09:57:03 -04:00
Javan Makhmali b354e3f30d Add (automatic) RTL text support 2020-08-12 15:57:50 -04:00
Javan Makhmali 13c2beeafe Trix 1.2.4 1.2.4 2020-08-04 10:41:16 -04:00
Nabeelah Ali e1a6a37731 Respect newlines implied by block elements (#773)
* Respect non-empty block elements by allowing them to create a new block, also ensure unwrapped text nodes preceeded by a block element are demarcated with a newline

* Clean up extraneous method

* More robustly, look at the previous sibling rather than element sibling

* Refactor coffeescript to be more pleasing

* Update to ensure we don't create unncessary blocks; instead prefer newlines where possible

* Update test names to be more descriptive

* Add a test for deeply nested divs

* Refactor logic to avoid mocking the guards

* Refactor tests

* Add some intentionally failing tests to investigate

* Skip failing test cases for now

refs: 1f265dd6b8

* Remove extraneous whitespace

Co-authored-by: Javan Makhmali <javan@javan.us>
2020-07-30 12:25:50 -04:00
Abdulwahaab Ahmed 107123b7f8 Sanitize pasted URLs (#793)
* Treat pasted URLs as HTML

Addressing feedback comments

* Update test/src/system/pasting_test.coffee

Co-authored-by: Javan Makhmali <javan@javan.us>

Fixing broken test

Removing newline char and space char
2020-05-29 16:44:14 -04:00
Javan Makhmali a7e9fd37b9 Merge pull request #782 from basecamp/firefox/fix-invisible-cursor
Firefox: Fix invisible cursor when focusing an editor with leading <br>s
2020-04-30 10:31:34 -04:00
Javan Makhmali d33430ce18 Firefox: Fix invisible cursor when focusing an editor with leading <br>s
https://bugzilla.mozilla.org/show_bug.cgi?id=226301
2020-04-30 09:10:47 -04:00
Javan Makhmali 8223961416 Freshen test dependencies 2020-04-16 16:22:03 -04:00
Javan Makhmali ba6f519930 Trix 1.2.3 1.2.3 2020-03-09 15:33:38 -07:00
Javan Makhmali 760a863316 CI: Freshen browser test matrix 2020-03-09 15:05:34 -07:00
Javan Makhmali e997dbfabf Pare down build dependency surface area 2020-03-09 14:52:10 -07:00
Steve Johnson 2bd8aaef73 Parse text after closing tag as separate block (#742)
* Parse text after closing tag as seperate block

* Fixed typo

* Moved and simplified test, paired isBlockElement call with containerElement check
2020-02-13 15:29:39 -08:00