Skip to content

Commit

Permalink
Fixes the unable to cast to JToken exception (#40)
Browse files Browse the repository at this point in the history
* Fixes the unable to cast to JToken exception

Fixes #39

* Updated minimum version

* Revert "Updated minimum version"

This reverts commit 2d39a82.

* Changed from feedback

Implemented the changes from @abjerner
  • Loading branch information
AaronSadlerUK authored Oct 23, 2024
1 parent 700a3f5 commit c402a9f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,26 @@ internal class TablePropertyIndexValueFactory : IPropertyIndexValueFactory {
}

private static IEnumerable<string?> ProcessRow(JArray row) {

foreach (JToken cell in row) {
yield return cell.Value<string>("value")?.StripHtml();

JToken? value = cell.Value<JToken>("value");

switch (value?.Type) {

case JTokenType.String:
yield return value.Value<string>()?.StripHtml();
break;

case JTokenType.Object:
string? markup = ((JObject) value).GetValue("markup")?.Value<string>();
yield return markup?.StripHtml();
break;

}

}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
value: cell.value
},
submit: function (model) {
cell.value = model.prop.value?.markup ? model.prop.value.markup : model.prop.value;
cell.value = typeof model.prop.value === "string" ? model.prop.value : model.prop.value?.markup ?? "";
editorService.close();
},
close: function () {
Expand Down

0 comments on commit c402a9f

Please sign in to comment.