Skip to content

Commit

Permalink
Added support for new interactive math inline objects, com.apple.note…
Browse files Browse the repository at this point in the history
…s.inlinetextattachment.calculateresult and com.apple.notes.inlinetextattachment.calculategraphexpression.
  • Loading branch information
threeplanetssoftware committed Sep 25, 2024
1 parent deb42f6 commit bac6eed
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/AppleNote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
require_relative 'AppleNotesEmbeddedObject.rb'
require_relative 'AppleDecrypter.rb'
require_relative 'AppleNotesEmbeddedInlineAttachment.rb'
require_relative 'AppleNotesEmbeddedInlineCalculateGraphExpression.rb'
require_relative 'AppleNotesEmbeddedInlineCalculateResult.rb'
require_relative 'AppleNotesEmbeddedInlineHashtag.rb'
require_relative 'AppleNotesEmbeddedInlineLink.rb'
require_relative 'AppleNotesEmbeddedInlineMention.rb'
Expand Down
25 changes: 25 additions & 0 deletions lib/AppleNotesEmbeddedInlineCalculateGraphExpression.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require_relative 'AppleNotesEmbeddedInlineAttachment'

##
# This class represents an inline interactive math graph embedded in an AppleNote.
# These were added in iOS 18.
class AppleNotesEmbeddedInlineCalculateGraphExpression < AppleNotesEmbeddedInlineAttachment

##
# Creates a new AppleNotesEmbeddedInlineCalculateGraphExpression.
# Expects an Integer +primary_key+ from ZICCLOUDSYNCINGOBJECT.Z_PK, String +uuid+ from ZICCLOUDSYNCINGOBJECT.ZIDENTIFIER,
# String +uti+ from ZICCLOUDSYNCINGOBJECT.ZTYPEUTI1, AppleNote +note+ object representing the parent AppleNote,
# a String +alt_text+ from ZICCLOUDSYNCINGOBJECT.ZALTTEXT, and a String +token_identifier+ from
# ZICCLOUDSYNCINGOBJECT.ZTOKENCONTENTIDENTIFIER representing what the result stands for.
def initialize(primary_key, uuid, uti, note, alt_text, token_identifier)
super(primary_key, uuid, uti, note, alt_text, token_identifier)
end

##
# This method just returns the graph equation's variable, which is found in alt_text.
def to_s
return "" if !@alt_text
@alt_text
end

end
25 changes: 25 additions & 0 deletions lib/AppleNotesEmbeddedInlineCalculateResult.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require_relative 'AppleNotesEmbeddedInlineAttachment'

##
# This class represents an inline interactive math result embedded in an AppleNote.
# These were added in iOS 18.
class AppleNotesEmbeddedInlineCalculateResult < AppleNotesEmbeddedInlineAttachment

##
# Creates a new AppleNotesEmbeddedInlineCalculateResult.
# Expects an Integer +primary_key+ from ZICCLOUDSYNCINGOBJECT.Z_PK, String +uuid+ from ZICCLOUDSYNCINGOBJECT.ZIDENTIFIER,
# String +uti+ from ZICCLOUDSYNCINGOBJECT.ZTYPEUTI1, AppleNote +note+ object representing the parent AppleNote,
# a String +alt_text+ from ZICCLOUDSYNCINGOBJECT.ZALTTEXT, and a String +token_identifier+ from
# ZICCLOUDSYNCINGOBJECT.ZTOKENCONTENTIDENTIFIER representing what the result stands for.
def initialize(primary_key, uuid, uti, note, alt_text, token_identifier)
super(primary_key, uuid, uti, note, alt_text, token_identifier)
end

##
# This method just returns the calculation result's text, which is found in alt_text.
def to_s
return "" if !@alt_text
@alt_text
end

end
14 changes: 14 additions & 0 deletions lib/AppleNotesEmbeddedObject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,20 @@ def self.generate_embedded_objects(note, note_proto)
note,
row["ZALTTEXT"],
row["ZTOKENCONTENTIDENTIFIER"])
elsif tmp_uti.uti == "com.apple.notes.inlinetextattachment.calculateresult"
tmp_embedded_object = AppleNotesEmbeddedInlineCalculateResult.new(row["Z_PK"],
row["ZIDENTIFIER"],
row["ZTYPEUTI1"],
note,
row["ZALTTEXT"],
row["ZTOKENCONTENTIDENTIFIER"])
elsif tmp_uti.uti == "com.apple.notes.inlinetextattachment.calculategraphexpression"
tmp_embedded_object = AppleNotesEmbeddedInlineCalculateGraphExpression.new(row["Z_PK"],
row["ZIDENTIFIER"],
row["ZTYPEUTI1"],
note,
row["ZALTTEXT"],
row["ZTOKENCONTENTIDENTIFIER"])
else
puts "#{row["ZTYPEUTI1"]} is unrecognized ZTYPEUTI1, please submit a bug report to this project's GitHub repo to report this: https://github.com/threeplanetssoftware/apple_cloud_notes_parser/issues"
logger.debug("Note #{note.note_id}: #{row["ZTYPEUTI1"]} is unrecognized ZTYPEUTI1, check ZICCLOUDSYNCINGOBJECT Z_PK: #{row["Z_PK"]}")
Expand Down

0 comments on commit bac6eed

Please sign in to comment.