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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/lib/prosemirror/schema.rb +5 -3
- data/lib/prosemirror/version.rb +1 -1
- data/lib/prosemirror.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ad2aa4d8468d9b854e0cd4214e965d9ccd66b0f704f7c93c3967083ebf4f2cc
|
|
4
|
+
data.tar.gz: 748a27e4d904030581b4a7d9b05b347c5fd1c6e793561f3b296d54fa3122e84d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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:`:
|
data/lib/prosemirror/schema.rb
CHANGED
|
@@ -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
|
-
|
|
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 =
|
|
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)
|
data/lib/prosemirror/version.rb
CHANGED
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
|
|