The idea dates back to the module's D6 version: #470366: Work with other CCK fields besides FileField/ImageField (Node Reference, Text, Emfield, etc), but was never really pursued in depth. I was not sure whether implementing such an interface is feasible without extremely extending the code base, but I think it is a great idea, so I had a go on that regarding Insert for D8. I thought about things like inserting maps directly into the editor, or just any kind of predefined HTML structure that is to be filled with field values. This also opens up Insert for individual module solutions in custom Drupal installations.

A patch set is attached. It increases the number of hooks invoked by Insert and shuffles some code. Yet, the overall change is on a relatively moderate level.

Existing tests are passing, the change might still need some code clean-up though. Anyway, it would be great, if someone had a short manual test run on that. The patch set contains a proof-of-concept module "insert_text", which will not be part of the final change. It is just there to proof the interface implementation for the simple text field. As to the concept of Insert, at least one style needs to be activated on a field to activate Insert. That is the reason, why a custom style is implemented in "insert_text".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Snater created an issue. See original summary.

Snater’s picture

Status: Active » Needs review
Snater’s picture

Another patch set on that, since I had some time. Tests pass. I am going to take another look at the change during the next couple of days and plan to submit it within the next two weeks. Because it shovels around quite some code, I regard it a blocker for all other changes. So nothing will move on until this issue is solved. While there is quite some structural change, it should not cause any breakage just using the module. It's just that hook_insert_aggregate_variables is removed/replaced. There will be a lot more hooks invoked by Insert with this change, allowing other modules to interface to Insert to a quite broad extent.

Snater’s picture

Moved the placeholder definitions to JavaScript, because there is no need to just shovel them around in PHP and the placeholder replacement logic is part of JS anyway.

Snater’s picture

One hook less.

  • Snater committed a2abe08 on 8.x-2.x
    Issue #2994066: Interface for other modules
    
Snater’s picture

Status: Needs review » Fixed

  • Snater committed 82fdcb8 on 8.x-2.x
    Issue #2994066: Pass $vars by reference to hook_insert_variables to...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.