Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: HTML support #165

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ class CalendarWidget extends FullCalendarWidget
}
```

To add HTML support for the title, you can simply map the event with `->html()` or add the extendedProp `isHTML`. Now add another extendedProp called `html`, this should contain the HTML content.

<br>

# Configuration
Expand Down
20 changes: 10 additions & 10 deletions dist/filament-fullcalendar.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions resources/js/filament-fullcalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ export default function fullcalendar({
selectable,
...config,
locales,
eventContent: function(arg) {
let divEl = document.createElement('div')
let htmlTitle = arg.event._def.extendedProps['html'];
if (arg.event.extendedProps.isHTML) {
divEl.innerHTML = htmlTitle
} else {
divEl.innerHTML = arg.event.title
}
let arrayOfDomNodes = [ divEl ]
return { domNodes: arrayOfDomNodes }
},
events: (info, successCallback, failureCallback) => {
this.$wire.fetchEvents({ start: info.startStr, end: info.endStr, timezone: info.timeZone })
.then(successCallback)
Expand Down
7 changes: 7 additions & 0 deletions src/Data/EventData.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ public function extraProperties(array $extraProperties): static
return $this;
}

public function html(bool $html = true): static
{
$this->extendedProps['isHTML'] = $html;

return $this;
}

public function toArray(): array
{
return [
Expand Down