prosemirror 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76385bda3d9b696b80e976154bf40c5d33ad2b9ac79b48e5f3fa8a6f7bf224e8
4
- data.tar.gz: 7acda4288b7bbb2d731a111143dc26b715177551476829ffa6416a7a298180c6
3
+ metadata.gz: 2ad2aa4d8468d9b854e0cd4214e965d9ccd66b0f704f7c93c3967083ebf4f2cc
4
+ data.tar.gz: 748a27e4d904030581b4a7d9b05b347c5fd1c6e793561f3b296d54fa3122e84d
5
5
  SHA512:
6
- metadata.gz: 7c9fdb3905684864d3662c4bdb25c2cee8efb055d59a64b28b4dd414b4a08759deae97a5f071ab605e8c94ce235356c30bb54c364053d5cc2d0b105eee151c0a
7
- data.tar.gz: 42054ca794261591e076b654aac9068bf629f7aeb82d18a5eb51fdbf4602d95dd5199907a4caa5363ad883b6b1628490ab848f32310aea4dbcbd10eadd7b7577
6
+ metadata.gz: 4d8d3c8840d8ef938a25ed3240aa7b779ace824c33b0ed968f17f0e808b37249b966a5884bd8eb122fb659ada2fe9fc9eaef4917cbae8dbf4f048d0182de1402
7
+ data.tar.gz: 4abe5b6e30afc8ec7b98311dc0dddf773c737127d81ce1e47be592f21a4e892ea76193ad04c5a0f05ebf1de18a4b1a5a8494432641d108cb4a0edee7e7e09d52
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.7.1] - 2026-10-24
4
+
5
+ - A URL that `resolve_url` or `resolve_urls` resolves to nil, like a link to a deleted record, is reported as `Prosemirror::UnresolvedURL`, a subclass of `InvalidDocument` with the `url`, so that error trackers group dead links apart from other problems.
6
+
3
7
  ## [0.7.0] - 2026-10-24
4
8
 
5
9
  - `resolve_urls:` resolves all the URLs of a document at once, before rendering it, to look up records in one query, where `resolve_url:` is called once per URL. Attributes holding URLs are declared with `prop … url: true`, like links' `href` and images' `src`, and `Document#urls` lists them.
data/README.md CHANGED
@@ -248,6 +248,8 @@ Prosemirror::Schema.tiptap(on_invalid: ->(error) { Rails.error.report(error) })
248
248
  Prosemirror::Schema.tiptap(strict: true) # raises Prosemirror::InvalidDocument
249
249
  ```
250
250
 
251
+ A URL that `resolve_url` or `resolve_urls` resolves to nil, like a link to a deleted record, is reported as `Prosemirror::UnresolvedURL`, a subclass of `InvalidDocument` with the `url`, so that error trackers group dead links apart from other problems.
252
+
251
253
  ## URLs
252
254
 
253
255
  Links and images allow `http`, `https`, `mailto`, `tel` and relative URLs. Change the list with `url_schemes:`, or rewrite URLs before they are checked with `resolve_url:`:
@@ -213,15 +213,17 @@ module Prosemirror
213
213
  return nil unless url.is_a?(String)
214
214
 
215
215
  resolved = resolve(url, resolved_urls)
216
- return report("URL could not be resolved: #{url.inspect}") unless resolved.is_a?(String)
216
+ unless resolved.is_a?(String)
217
+ return report("URL could not be resolved: #{url.inspect}", error_class: UnresolvedURL, url:)
218
+ end
217
219
  return report("URL scheme not allowed: #{resolved.inspect}") unless allowed_url?(resolved)
218
220
 
219
221
  resolved.gsub("&", "&")
220
222
  end
221
223
 
222
224
  # Raise in strict mode, otherwise call `on_invalid`.
223
- def report(message, path: nil)
224
- error = InvalidDocument.new(message, path: path)
225
+ def report(message, path: nil, error_class: InvalidDocument, **details)
226
+ error = error_class.new(message, path:, **details)
225
227
  raise error if @strict
226
228
 
227
229
  @on_invalid&.call(error)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prosemirror
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.1"
5
5
  end
data/lib/prosemirror.rb CHANGED
@@ -29,6 +29,17 @@ module Prosemirror
29
29
  end
30
30
  end
31
31
 
32
+ # A URL that `resolve_url` or `resolve_urls` resolved to nil, like a link to a deleted record. Its own
33
+ # class, so that error trackers group these problems apart from others.
34
+ class UnresolvedURL < InvalidDocument
35
+ attr_reader :url
36
+
37
+ def initialize(message, url:, path: nil)
38
+ @url = url
39
+ super(message, path:)
40
+ end
41
+ end
42
+
32
43
  class << self
33
44
  attr_writer :schema
34
45
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prosemirror
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hans Lemuet