prosemirror 0.7.1 → 1.1.0

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/COOKBOOK.md +70 -13
  4. data/README.md +97 -3
  5. data/TYPES.md +5 -3
  6. data/lib/prosemirror/checker.rb +1 -0
  7. data/lib/prosemirror/coerce.rb +4 -0
  8. data/lib/prosemirror/content_expression.rb +1 -0
  9. data/lib/prosemirror/content_match.rb +7 -0
  10. data/lib/prosemirror/document.rb +106 -7
  11. data/lib/prosemirror/extensions/text_align.rb +34 -0
  12. data/lib/prosemirror/html/builder.rb +30 -11
  13. data/lib/prosemirror/html/entities.rb +1 -0
  14. data/lib/prosemirror/html/selector.rb +1 -0
  15. data/lib/prosemirror/html/splitter.rb +17 -4
  16. data/lib/prosemirror/html_parser.rb +45 -15
  17. data/lib/prosemirror/html_renderer.rb +5 -2
  18. data/lib/prosemirror/json_parser.rb +6 -2
  19. data/lib/prosemirror/mark_type.rb +10 -0
  20. data/lib/prosemirror/markdown/builder.rb +4 -2
  21. data/lib/prosemirror/markdown_serializer.rb +10 -0
  22. data/lib/prosemirror/marks/link.rb +1 -0
  23. data/lib/prosemirror/marks/text_style.rb +51 -0
  24. data/lib/prosemirror/naming.rb +1 -0
  25. data/lib/prosemirror/node.rb +19 -4
  26. data/lib/prosemirror/node_type.rb +6 -2
  27. data/lib/prosemirror/nodes/bullet_list.rb +1 -0
  28. data/lib/prosemirror/nodes/code_block.rb +1 -0
  29. data/lib/prosemirror/nodes/heading.rb +1 -1
  30. data/lib/prosemirror/nodes/image.rb +1 -0
  31. data/lib/prosemirror/nodes/mention.rb +1 -0
  32. data/lib/prosemirror/nodes/ordered_list.rb +3 -0
  33. data/lib/prosemirror/nodes/table_cell.rb +2 -2
  34. data/lib/prosemirror/nodes/twitch.rb +7 -2
  35. data/lib/prosemirror/nodes/youtube.rb +6 -2
  36. data/lib/prosemirror/parse_rule.rb +1 -0
  37. data/lib/prosemirror/rendering.rb +7 -0
  38. data/lib/prosemirror/schema.rb +20 -6
  39. data/lib/prosemirror/text_serializer.rb +1 -0
  40. data/lib/prosemirror/transformer.rb +5 -2
  41. data/lib/prosemirror/type_definition.rb +14 -1
  42. data/lib/prosemirror/utf8.rb +1 -0
  43. data/lib/prosemirror/version.rb +1 -1
  44. data/lib/prosemirror.rb +7 -3
  45. metadata +10 -7
  46. data/ROADMAP.md +0 -224
  47. data/lib/prosemirror/text_align.rb +0 -31
  48. data/sig/prosemirror.rbs +0 -4
@@ -30,6 +30,7 @@ module Prosemirror
30
30
  markdown.close_block(node) unless parent.content[index + 1]&.type == node.type
31
31
  end
32
32
 
33
+ # @api private
33
34
  def self.markdown_image(markdown, src, alt, title)
34
35
  "![#{markdown.esc(alt.to_s)}](#{markdown.url(src)}#{markdown.title(title)})"
35
36
  end
@@ -30,6 +30,7 @@ module Prosemirror
30
30
  end
31
31
  end
32
32
 
33
+ # @api private
33
34
  def self.display_text(attrs) = "#{attrs[:mention_suggestion_char] || "@"}#{attrs[:label] || attrs[:id]}"
34
35
  end
35
36
  end
@@ -20,10 +20,12 @@ module Prosemirror
20
20
  parse_html tag: "ol"
21
21
 
22
22
  # From the `type` attribute, or the list style of the list or of its first item.
23
+ # @api private
23
24
  def self.type_from_html(element)
24
25
  element["type"] || list_style_type(element) || element.query("li")&.then { |item| list_style_type(item) }
25
26
  end
26
27
 
28
+ # @api private
27
29
  def self.list_style_type(element)
28
30
  LIST_STYLE_TYPES[element.style["list-style-type"].to_s.downcase]
29
31
  end
@@ -38,6 +40,7 @@ module Prosemirror
38
40
 
39
41
  # Items numbered from `start`, with the numbers aligned. `)` instead of `.` keeps a list right after
40
42
  # another ordered list apart from it.
43
+ # @api private
41
44
  def self.numbered(markdown, node, start, delimiter = ".")
42
45
  width = (start + node.content.size - 1).to_s.length
43
46
  markdown.render_list(node, " " * (width + 2)) { |index| "#{(start + index).to_s.rjust(width)}#{delimiter} " }
@@ -10,7 +10,7 @@ module Prosemirror
10
10
  prop :colspan, _Integer(1..), default: 1, &Coerce::INTEGER
11
11
  prop :rowspan, _Integer(1..), default: 1, &Coerce::INTEGER
12
12
  prop :colwidth, _Array?(_Integer(1..)),
13
- parse_html: ->(element) { element["colwidth"]&.split(",")&.map(&:to_i) }
13
+ parse_html: ->(element) { element["colwidth"].then { |value| value.split(",").map(&:to_i) unless value.to_s.empty? } }
14
14
  # From the `text-align` style, or the old `align` attribute.
15
15
  prop :align, _Union?(*ALIGNMENTS), parse_html: lambda { |element|
16
16
  (element.style["text-align"] || element["align"]).to_s.strip.downcase.then { |value| value if ALIGNMENTS.include?(value) }
@@ -26,7 +26,7 @@ module Prosemirror
26
26
 
27
27
  def cell_attributes
28
28
  {colspan: (@colspan unless @colspan == 1), rowspan: (@rowspan unless @rowspan == 1),
29
- style: @align && "text-align: #{@align}"}
29
+ colwidth: @colwidth&.join(","), style: @align && "text-align: #{@align}"}
30
30
  end
31
31
  end
32
32
  end
@@ -20,9 +20,11 @@ module Prosemirror
20
20
  prop :muted, _Boolean, default: false, parse_html: ->(element) { Twitch.from_embed_url(element["src"])&.fetch(:muted) }
21
21
  prop :time, _String?, parse_html: ->(element) { Twitch.from_embed_url(element["src"])&.fetch(:time) }
22
22
 
23
- # Tiptap's markup, `<div data-twitch-video><iframe>`, or an iframe of a Twitch embed URL.
23
+ # Tiptap's markup, `<div data-twitch-video><iframe>`, or an iframe of a Twitch embed URL. Not with a URL
24
+ # it can't render.
24
25
  parse_html(tag: "iframe[src]") do |element|
25
- (element.parent&.key?("data-twitch-video") || Twitch.from_embed_url(element["src"])) ? {} : false
26
+ src = element["src"]
27
+ (Twitch.from_embed_url(src) || (element.parent&.key?("data-twitch-video") && Twitch.identify(src))) ? {} : false
26
28
  end
27
29
 
28
30
  def view_template
@@ -42,6 +44,7 @@ module Prosemirror
42
44
  end
43
45
 
44
46
  # The video, clip or channel of a Twitch URL, as `[kind, id]`, or nil.
47
+ # @api private
45
48
  def self.identify(src)
46
49
  return unless src.match?(URL)
47
50
 
@@ -56,6 +59,7 @@ module Prosemirror
56
59
  end
57
60
 
58
61
  # The embed URL, as Tiptap builds it, or nil.
62
+ # @api private
59
63
  def self.embed_url(src, parent:, autoplay: false, muted: false, time: nil)
60
64
  kind, id = identify(src)
61
65
  return unless kind
@@ -71,6 +75,7 @@ module Prosemirror
71
75
  end
72
76
 
73
77
  # The URL and options of an embed URL, as Tiptap reads them, or nil.
78
+ # @api private
74
79
  def self.from_embed_url(url)
75
80
  uri = URI.parse(url.to_s)
76
81
  return unless uri.is_a?(URI::HTTP)
@@ -20,9 +20,11 @@ module Prosemirror
20
20
  prop :width, _Integer?(1..), default: 640, &Coerce::INTEGER
21
21
  prop :height, _Integer?(1..), default: 480, &Coerce::INTEGER
22
22
 
23
- # Tiptap's markup, `<div data-youtube-video><iframe>`, or an iframe of a YouTube embed URL.
23
+ # Tiptap's markup, `<div data-youtube-video><iframe>`, or an iframe of a YouTube embed URL. Not with a URL
24
+ # it can't render.
24
25
  parse_html(tag: "iframe[src]") do |element|
25
- (element.parent&.key?("data-youtube-video") || Youtube.from_embed_url(element["src"])) ? {} : false
26
+ src = element["src"]
27
+ (Youtube.from_embed_url(src) || (element.parent&.key?("data-youtube-video") && Youtube.embed_url(src))) ? {} : false
26
28
  end
27
29
 
28
30
  def view_template
@@ -41,6 +43,7 @@ module Prosemirror
41
43
  end
42
44
 
43
45
  # The embed URL of a video or playlist, as Tiptap builds it, or nil.
46
+ # @api private
44
47
  def self.embed_url(src, start: 0, host: "https://www.youtube.com")
45
48
  return unless src.match?(URL)
46
49
 
@@ -53,6 +56,7 @@ module Prosemirror
53
56
  end
54
57
 
55
58
  # The video URL and start time of an embed URL, as Tiptap reads them, or nil.
59
+ # @api private
56
60
  def self.from_embed_url(url)
57
61
  uri = URI.parse(url.to_s)
58
62
  return unless uri.is_a?(URI::HTTP) && EMBED_HOSTS.include?(uri.host.to_s.delete_prefix("www."))
@@ -19,6 +19,7 @@ module Prosemirror
19
19
  # - `get_content`: a block called with the element and the schema, returning the nodes to use as content;
20
20
  # - `preserve_whitespace`: true to keep spaces, `:full` to also keep newlines;
21
21
  # - `clear_mark`: for style rules, true to remove the type's marks, or a block called with each mark.
22
+ # @api private
22
23
  ParseRule = Data.define(
23
24
  :type, :tag, :style, :attrs, :get_attrs, :priority, :consuming, :context, :ignore, :skip,
24
25
  :close_parent, :content_element, :get_content, :preserve_whitespace, :clear_mark
@@ -19,6 +19,12 @@ module Prosemirror
19
19
  prosemirror_schema.safe_url(url, @_prosemirror_urls)
20
20
  end
21
21
 
22
+ # The heading's id from `Document#headings`, when the document is rendered with `heading_ids: true`.
23
+ # Otherwise nil.
24
+ def heading_id
25
+ @_prosemirror_heading_ids&.[](node)
26
+ end
27
+
22
28
  private
23
29
 
24
30
  def render_fragment(nodes, depth)
@@ -65,6 +71,7 @@ module Prosemirror
65
71
  def prepare(component)
66
72
  component.instance_variable_set(:@_prosemirror_schema, prosemirror_schema)
67
73
  component.instance_variable_set(:@_prosemirror_urls, @_prosemirror_urls)
74
+ component.instance_variable_set(:@_prosemirror_heading_ids, @_prosemirror_heading_ids)
68
75
  component
69
76
  end
70
77
  end
@@ -32,14 +32,14 @@ module Prosemirror
32
32
  def self.tiptap(text_align: false, **)
33
33
  new(
34
34
  nodes: [
35
- Nodes::Doc, text_align ? TextAlign::Paragraph : Nodes::Paragraph, Nodes::Text,
36
- text_align ? TextAlign::Heading : Nodes::Heading, Nodes::Blockquote, Nodes::BulletList,
35
+ Nodes::Doc, text_align ? Extensions::TextAlign::Paragraph : Nodes::Paragraph, Nodes::Text,
36
+ text_align ? Extensions::TextAlign::Heading : Nodes::Heading, Nodes::Blockquote, Nodes::BulletList,
37
37
  Nodes::OrderedList, Nodes::ListItem, Nodes::CodeBlock, Nodes::HardBreak, Nodes::HorizontalRule,
38
38
  Nodes::Image, Nodes::Table, Nodes::TableRow, Nodes::TableHeader, Nodes::TableCell, Nodes::TaskList,
39
39
  Nodes::TaskItem, Nodes::Details, Nodes::DetailsSummary, Nodes::DetailsContent, Nodes::Youtube,
40
40
  Nodes::Twitch, Nodes::Mention
41
41
  ],
42
- # In Tiptap's order, which sorts and nests marks.
42
+ # In Tiptap's order, which sorts and nests marks: by priority, then as listed.
43
43
  marks: [
44
44
  Marks::Link, Marks::Bold, Marks::Code, Marks::Italic, Marks::Strike, Marks::Underline,
45
45
  Marks::Subscript, Marks::Superscript, Marks::Highlight
@@ -62,6 +62,8 @@ module Prosemirror
62
62
  end
63
63
 
64
64
  def after_initialize
65
+ # Marks sort and nest in this order, so a mark added with `with` takes its place by priority.
66
+ @marks = @marks.each_with_index.sort_by { |type, index| [-type.priority, index] }.map(&:first).freeze
65
67
  @node_lookup = lookup(@nodes)
66
68
  @mark_lookup = lookup(@marks)
67
69
  @node_names = spellings(@node_lookup)
@@ -73,17 +75,20 @@ module Prosemirror
73
75
  end
74
76
 
75
77
  # The start state of a node type's content expression.
78
+ # @api private
76
79
  def content_match(type)
77
80
  @content_matches.fetch(type)
78
81
  end
79
82
 
80
83
  # The node types with this name or in this group, in schema order.
84
+ # @api private
81
85
  def node_types_named(name)
82
86
  @nodes.select { |type| type.type_name == name || type.group.include?(name) }
83
87
  end
84
88
 
85
89
  # A node of this type, created empty and filled with the content it requires, or nil when its
86
90
  # type, or one it requires, has required attributes.
91
+ # @api private
87
92
  def create_and_fill(type)
88
93
  return nil if type.required_attrs?
89
94
 
@@ -123,18 +128,18 @@ module Prosemirror
123
128
  end
124
129
 
125
130
  # Build a document from HTML, with the parse rules of the schema's types. Needs the `herb` gem.
126
- def parse_html(html)
131
+ def from_html(html)
127
132
  Document.new(HTMLParser.new(self).parse(html), schema: self)
128
133
  end
129
134
 
130
135
  # Build a document from Markdown, with the parse rules of the schema's types. Needs the `commonmarker` gem.
131
- def parse_markdown(markdown)
136
+ def from_markdown(markdown)
132
137
  Document.new(HTMLParser.new(self).parse_element(Markdown::Builder.new.call(markdown)), schema: self)
133
138
  end
134
139
 
135
140
  # Build a document from plain text: blank lines separate paragraphs, and other line breaks become the
136
141
  # schema's line break node, like `hard_break`, or spaces without one. Spaces are kept.
137
- def parse_text(text)
142
+ def from_text(text)
138
143
  paragraph = node_type(:paragraph) || @nodes.find { |type| textblock?(type) }
139
144
  linebreak = @nodes.find(&:linebreak_replacement?)
140
145
  separator = linebreak ? {"type" => linebreak.type_name.to_s} : {"type" => "text", "text" => " "}
@@ -149,12 +154,14 @@ module Prosemirror
149
154
  end
150
155
 
151
156
  # The type name as written in JSON.
157
+ # @api private
152
158
  def json_type_name(name)
153
159
  (@case == :camel) ? Naming.camel(name) : name.to_s
154
160
  end
155
161
 
156
162
  # The set of marks with this mark added, in schema order, as ProseMirror's `Mark#addToSet`: a mark
157
163
  # replaces the marks it excludes, and isn't added when a mark of the set excludes it.
164
+ # @api private
158
165
  def add_mark(mark, set)
159
166
  type = mark_type(mark.type)
160
167
  result = []
@@ -179,6 +186,7 @@ module Prosemirror
179
186
  # Whether a URL's scheme is allowed, or the URL is relative. Browsers ignore leading control characters
180
187
  # and spaces, and tabs and newlines anywhere in a URL.
181
188
  # The URLs resolved with `resolve_urls`, as a Hash, or nil without it.
189
+ # @api private
182
190
  def resolve_urls(urls)
183
191
  return unless @resolve_urls
184
192
  return {} if urls.empty?
@@ -186,6 +194,7 @@ module Prosemirror
186
194
  @resolve_urls.call(urls).to_h
187
195
  end
188
196
 
197
+ # @api private
189
198
  def allowed_url?(url)
190
199
  return false unless url.is_a?(String)
191
200
 
@@ -197,11 +206,13 @@ module Prosemirror
197
206
  end
198
207
 
199
208
  # The order of marks in a node. Marks of unknown types come last.
209
+ # @api private
200
210
  def mark_rank(name)
201
211
  @marks.index(mark_type(name)) || @marks.size
202
212
  end
203
213
 
204
214
  # Whether nodes of this type contain inline content, like a paragraph.
215
+ # @api private
205
216
  def textblock?(type)
206
217
  @textblocks.fetch(type, false)
207
218
  end
@@ -209,6 +220,7 @@ module Prosemirror
209
220
  # The URL after `resolve_url` or `resolve_urls`, when its scheme is allowed. Otherwise nil, and the
210
221
  # problem is reported. `resolved_urls` holds URLs already resolved with `resolve_urls`: others are
211
222
  # resolved one at a time.
223
+ # @api private
212
224
  def safe_url(url, resolved_urls = nil)
213
225
  return nil unless url.is_a?(String)
214
226
 
@@ -222,6 +234,7 @@ module Prosemirror
222
234
  end
223
235
 
224
236
  # Raise in strict mode, otherwise call `on_invalid`.
237
+ # @api private
225
238
  def report(message, path: nil, error_class: InvalidDocument, **details)
226
239
  error = error_class.new(message, path:, **details)
227
240
  raise error if @strict
@@ -231,6 +244,7 @@ module Prosemirror
231
244
  end
232
245
 
233
246
  # The document as JSON, as a Hash.
247
+ # @api private
234
248
  def serialize(node)
235
249
  hash = {"type" => json_type_name(node.type)}
236
250
  hash["text"] = node.text if node.text?
@@ -4,6 +4,7 @@ module Prosemirror
4
4
  # Extracts the text of a document, as ProseMirror's `textBetween` and Tiptap's `getText` do:
5
5
  # textblocks and leaf blocks with text are separated by `block_separator`,
6
6
  # and leaf nodes such as hard breaks are replaced by their `leaf_text`.
7
+ # @api private
7
8
  class TextSerializer
8
9
  def initialize(schema, block_separator: "\n\n")
9
10
  @schema = schema
@@ -8,11 +8,14 @@ module Prosemirror
8
8
  # node's content changed and no longer has what its content expression requires, the required nodes
9
9
  # are added, as an empty paragraph in an empty list item, and reported. Other problems are left for
10
10
  # Document#check.
11
+ # @api private
11
12
  class Transformer
12
- def initialize(schema, &block)
13
+ # With `report: false`, the required nodes are added without reporting them, when adding them is expected.
14
+ def initialize(schema, report: true, &block)
13
15
  raise ArgumentError, "transform needs a block" unless block
14
16
 
15
17
  @schema = schema
18
+ @report = report
16
19
  @block = block
17
20
  end
18
21
 
@@ -74,7 +77,7 @@ module Prosemirror
74
77
  return nil if nodes.include?(nil)
75
78
 
76
79
  names = types.map { |type| @schema.json_type_name(type.type_name) }.join(", ")
77
- @schema.report("added required #{names} to #{@schema.json_type_name(node.type)}", path: path)
80
+ @schema.report("added required #{names} to #{@schema.json_type_name(node.type)}", path: path) if @report
78
81
  nodes
79
82
  end
80
83
  end
@@ -42,18 +42,23 @@ module Prosemirror
42
42
  (@parse_rules ||= []) << ParseRule.new(type: self, tag:, style:, get_attrs:, **options)
43
43
  end
44
44
 
45
+ # @api private
45
46
  def parse_rules
46
47
  inherited_setting(:@parse_rules, [])
47
48
  end
48
49
 
49
50
  # The attributes read from an HTML element, by JSON name, without the missing ones.
51
+ # @api private
50
52
  def attrs_from_html(element)
51
- attribute_names.each_value.with_object({}) do |names, attrs|
53
+ attrs = {}
54
+ attribute_names.each_value do |names|
52
55
  value = names[:parse_html] ? names[:parse_html].call(element) : element[names[:json]]
53
56
  attrs[names[:json]] = value unless value.nil?
54
57
  end
58
+ attrs
55
59
  end
56
60
 
61
+ # @api private
57
62
  def attribute_names
58
63
  @attribute_names ||= concrete_superclass ? concrete_superclass.attribute_names.dup : {}
59
64
  end
@@ -61,6 +66,7 @@ module Prosemirror
61
66
  # Build valid attributes from JSON attributes (a Hash with String or Symbol keys).
62
67
  # Invalid values are converted when the meaning is clear, or replaced by their default.
63
68
  # Returns nil when a required attribute is missing or invalid.
69
+ # @api private
64
70
  def build_attrs(given, report:)
65
71
  given = if !given.is_a?(Hash) then EMPTY_HASH
66
72
  elsif keys?(given) { |key| key.is_a?(String) } then given
@@ -86,16 +92,19 @@ module Prosemirror
86
92
  end
87
93
 
88
94
  # Whether an attribute has no default, so that a node of this type can't be created empty.
95
+ # @api private
89
96
  def required_attrs?
90
97
  literal_properties.any? { |property| !optional_attribute?(property) }
91
98
  end
92
99
 
93
100
  # The attributes of a node of this type created empty: the defaults.
101
+ # @api private
94
102
  def default_attrs
95
103
  build_attrs({}, report: ->(_) {})
96
104
  end
97
105
 
98
106
  # The JSON attributes this type doesn't declare, with String keys, so that `to_h` gives them back.
107
+ # @api private
99
108
  def unknown_attrs(given)
100
109
  return EMPTY_HASH unless given.is_a?(Hash)
101
110
 
@@ -106,20 +115,24 @@ module Prosemirror
106
115
  end
107
116
 
108
117
  # The JSON keys of the declared attributes, in all their spellings.
118
+ # @api private
109
119
  def known_keys
110
120
  @known_keys ||= attribute_names.each_value.flat_map { |names| names[:keys] }.to_set.freeze
111
121
  end
112
122
 
113
123
  # The names of the attributes declared with `url: true`.
124
+ # @api private
114
125
  def url_attributes
115
126
  @url_attributes ||= attribute_names.filter_map { |name, names| name if names[:url] }.freeze
116
127
  end
117
128
 
118
129
  # Attributes as JSON, with their JSON names.
130
+ # @api private
119
131
  def serialize_attrs(attrs)
120
132
  attrs.to_h { |name, value| [attribute_names.dig(name, :json) || name.to_s, value] }
121
133
  end
122
134
 
135
+ # @api private
123
136
  def base_type?
124
137
  false
125
138
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Prosemirror
4
4
  # Imported HTML, Markdown and text, as valid UTF-8.
5
+ # @api private
5
6
  module UTF8
6
7
  module_function
7
8
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prosemirror
4
- VERSION = "0.7.1"
4
+ VERSION = "1.1.0"
5
5
  end
data/lib/prosemirror.rb CHANGED
@@ -29,6 +29,10 @@ module Prosemirror
29
29
  end
30
30
  end
31
31
 
32
+ # Raised, in any mode, for a JSON string or Markdown nested too deeply to import. A Hash nested too deeply
33
+ # is cut and reported instead, as other invalid documents are.
34
+ class TooDeep < Error; end
35
+
32
36
  # A URL that `resolve_url` or `resolve_urls` resolved to nil, like a link to a deleted record. Its own
33
37
  # class, so that error trackers group these problems apart from others.
34
38
  class UnresolvedURL < InvalidDocument
@@ -55,17 +59,17 @@ module Prosemirror
55
59
 
56
60
  # Build a document from HTML, with the schema's parse rules. Needs the `herb` gem.
57
61
  def from_html(html, schema: self.schema)
58
- schema.parse_html(html)
62
+ schema.from_html(html)
59
63
  end
60
64
 
61
65
  # Build a document from Markdown, with the schema's parse rules. Needs the `commonmarker` gem.
62
66
  def from_markdown(markdown, schema: self.schema)
63
- schema.parse_markdown(markdown)
67
+ schema.from_markdown(markdown)
64
68
  end
65
69
 
66
70
  # Build a document from plain text: blank lines separate paragraphs, other line breaks become hard breaks.
67
71
  def from_text(text, schema: self.schema)
68
- schema.parse_text(text)
72
+ schema.from_text(text)
69
73
  end
70
74
  end
71
75
  end
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.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hans Lemuet
@@ -51,8 +51,9 @@ dependencies:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '2.6'
54
- description: Render ProseMirror and Tiptap JSON documents to safe HTML or plain text,
55
- with typed attributes and custom node types.
54
+ description: One schema renders, imports and exports ProseMirror and Tiptap JSON.
55
+ HTML is built with Phlex and escaped as it is written, and attributes are typed.
56
+ Node and mark types are Ruby classes. No Rails dependency.
56
57
  email:
57
58
  - hans@etamin.studio
58
59
  executables: []
@@ -64,7 +65,6 @@ files:
64
65
  - LICENSE.txt
65
66
  - MIGRATING.md
66
67
  - README.md
67
- - ROADMAP.md
68
68
  - TYPES.md
69
69
  - lib/prosemirror.rb
70
70
  - lib/prosemirror/checker.rb
@@ -72,6 +72,7 @@ files:
72
72
  - lib/prosemirror/content_expression.rb
73
73
  - lib/prosemirror/content_match.rb
74
74
  - lib/prosemirror/document.rb
75
+ - lib/prosemirror/extensions/text_align.rb
75
76
  - lib/prosemirror/html/builder.rb
76
77
  - lib/prosemirror/html/element.rb
77
78
  - lib/prosemirror/html/entities.rb
@@ -98,6 +99,7 @@ files:
98
99
  - lib/prosemirror/marks/strike.rb
99
100
  - lib/prosemirror/marks/subscript.rb
100
101
  - lib/prosemirror/marks/superscript.rb
102
+ - lib/prosemirror/marks/text_style.rb
101
103
  - lib/prosemirror/marks/underline.rb
102
104
  - lib/prosemirror/naming.rb
103
105
  - lib/prosemirror/node.rb
@@ -132,19 +134,19 @@ files:
132
134
  - lib/prosemirror/parse_rule.rb
133
135
  - lib/prosemirror/rendering.rb
134
136
  - lib/prosemirror/schema.rb
135
- - lib/prosemirror/text_align.rb
136
137
  - lib/prosemirror/text_serializer.rb
137
138
  - lib/prosemirror/transformer.rb
138
139
  - lib/prosemirror/type_definition.rb
139
140
  - lib/prosemirror/utf8.rb
140
141
  - lib/prosemirror/version.rb
141
- - sig/prosemirror.rbs
142
142
  homepage: https://github.com/etaminstudio/prosemirror
143
143
  licenses:
144
144
  - MIT
145
145
  metadata:
146
146
  source_code_uri: https://github.com/etaminstudio/prosemirror
147
147
  changelog_uri: https://github.com/etaminstudio/prosemirror/blob/main/CHANGELOG.md
148
+ documentation_uri: https://github.com/etaminstudio/prosemirror#readme
149
+ bug_tracker_uri: https://github.com/etaminstudio/prosemirror/issues
148
150
  rubygems_mfa_required: 'true'
149
151
  rdoc_options: []
150
152
  require_paths:
@@ -162,5 +164,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
164
  requirements: []
163
165
  rubygems_version: 4.0.20
164
166
  specification_version: 4
165
- summary: Render ProseMirror and Tiptap documents to HTML and text.
167
+ summary: Convert ProseMirror and Tiptap documents to and from HTML, Markdown and plain
168
+ text.
166
169
  test_files: []