package leigh.notek.app.javafx;

import com.dansoftware.mdeditor.MarkdownEditorControl;
import com.dansoftware.mdeditor.MarkdownEditorSkin;
import javafx.scene.control.Skin;
import leigh.mecha.lang.Transformer;
import leigh.mecha.log.MechaLogger;
import leigh.mecha.log.MechaLoggerFactory;

import java.util.function.Consumer;

/**
 * NOTO-specific implementation of the {@link MarkdownEditorControl}.
 *
 * @author Alex Leigh
 */
public class NotekMarkdownEditorControl extends MarkdownEditorControl {
    private static final MechaLogger logger = MechaLoggerFactory.getLogger(NotekMarkdownEditorControl.class);
    private final Transformer<String> stringTransformer;

    public NotekMarkdownEditorControl(Transformer<String> stringTransformer) {
        super();
        this.stringTransformer = stringTransformer;
        setOnLinkClicked(new Consumer<String>() {
            @Override
            public void accept(String s) {
                logger.info("Accepted click: {}", s);
            }
        });
    }

    protected Skin<?> createDefaultSkin() {
        MarkdownEditorSkin skin = new MarkdownEditorSkin(this, stringTransformer);
        return skin;
    }
}
