I agree that there needs to be a way to preview content (easily) without requiring a save. Not performing a save (and moderation state change) would alleviate the following ...
There is an issue with the approach of saving and setting moderation state - hard setting to 'draft'. It may not obey the set workflow for the content or be what is desired even in a basic setup. The assumption that a moderation state change is required is incorrect. A user (and a workflow) could easily become confused when content is 'unpublished' as an unexpected consequence of attempting to preview the content. The applied workflow would (should) already be enforcing any necessary state change and it does not necessarily mean a return to the draft state.
I am having a similar issue with Live Preview to a locally running Gatsby and with Lando Drupal. The refresh endpoint is not being called when a node is saved. Hitting the endpoint manually will trigger a refresh, but then the instance gets corrupted and I can not access any pages.
Issue is still present in 10.1.2
An approach would be to default to the 'Default State' of the workflow in these instances. Or when deleting a state require the new state be selected and update all the revisions.
I would prefer the later to avoid stale data being present. Removing the ability to delete states (if there are revisions in that state) is rather heavy handed and virtually guarantees that no state could ever be deleted, and would not reflect changes to human workflow.
Can confirm that this is still an issue in 2.0.0-rc7 and the provided patch (#7) resolves the problem
wweibel β created an issue.
I had the same need for this. IMHO this is not something I believe Linkit should manage - there may be cases where the link should not be converted. So, having this in a content (node, block, paragraph, etc) presave hook is what I ended up doing:
<?php
/**
* Convert hyperlinks to entity links.
*/
protected function convertHyperlinks(FieldableEntityInterface &$entity, $content, $field) {
$doc = Html::load($content);
foreach ($doc->getElementsByTagName('a') as $element) {
$href = parse_url($element->getAttribute('href'));
if (!(empty($href['host']) || str_contains(strtolower($href['host']), 'YOUR-SITE-HOSTNAME'))) {
// Not the healthcare site.
continue;
}
if (!empty($href['scheme']) && $href['scheme'] == 'mailto') {
// Content still using `mailto` links.
continue;
}
if (empty($href['path']) || $href['path'] === '/' || str_starts_with($href['path'], '#')) {
// Nothing, link to the homepage, or anchor.
continue;
}
$path = $href['path'];
if (!str_starts_with($path, '/')) {
$path = '/' . $path;
}
try {
// Would prefer not to use try-catch but 'bad' href could sneak through.
$url = Url::fromUri("internal:" . $path);
}
catch (InvalidArgumentException $e) {
continue;
}
if (!($url->isRouted() && str_starts_with($url->getRouteName(), 'entity.'))) {
// Not an entity route.
continue;
}
$route = $url->getRouteParameters();
$entity_type = key($route);
if (!in_array($entity_type, ['node', 'media'])) {
// Not an entity type to link.
continue;
}
$linked_entity = $this->entityTypeManager->getStorage($entity_type)->load($route[$entity_type]);
if ($entity) {
// Add data attributes same as when created in CKEditor.
// Linkit.
$element->setAttribute('data-entity-type', $entity_type);
$element->setAttribute('data-entity-substitution', 'canonical');
$element->setAttribute('data-entity-uuid', $linked_entity->uuid());
// Custom.
$element->setAttribute('data-entity-id', $linked_entity->id());
$element->setAttribute('data-entity-bundle', $linked_entity->bundle());
$element->setAttribute('data-internal-href', $this->pathAliasManager->getPathByAlias($path));
// Update to Drupal aware path.
$element->setAttribute('href', $this->pathAliasManager->getAliasByPath($path));
}
}
$content = $doc->saveHTML();
$content = Html::decodeEntities(Html::serialize($doc));
$entity->$field->value = $content;
}
?>
I found `pathauto_state.[entity_type_id]` in the key_value table, with the `name == entity_id` and the `value as 0|1`. Deleting the rows for the entity you want to bulk generate (in my case media) allowed it to work as expected. There should be an option to clear these in the UI, the 'Regenerate URL aliases for all paths' does not do this
Looking in `pathauto/src/PathautoState.php` in `bulkDelete` this will "Only delete aliases that were created by this module."
Updated Gin to 3.0.0-rc3 and toolbar 3.3.2 and the ugly arrows is resolved.
It seems this is fixed on already on 1.x-dev
wweibel β created an issue.