// Path: src/com/noticeditorteam/noticeditor/model/Attachment.java
// public class Attachment {
// 
//     public static final Attachment EMPTY = new Attachment("", new byte[0]);
// 
//     public static final String PREFIX = "@att:";
//     public static final Pattern PATTERN = Pattern.compile(PREFIX + "([a-zA-Z0-9._\\(\\)]+)");
// 
//     private final String name;
//     private final byte[] data;
//     private final boolean isImage;
//     private final String base64data;
// 
//     public Attachment(String name, byte[] data) {
//         this.name = name;
//         this.data = data;
//         final String nameLowerCase = name.toLowerCase(Locale.ENGLISH);
//         isImage = Stream.of("jpg", "jpeg", "png", "gif")
//                 .anyMatch(ext -> nameLowerCase.endsWith("." + ext));
//         base64data = isImage ? toBase64(data) : "";
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public byte[] getData() {
//         return data;
//     }
// 
//     public String getDataAsBase64() {
//         if (!base64data.isEmpty()) return base64data;
//         return toBase64(data);
//     }
// 
//     private static String toBase64(byte[] data) {
//         return Base64.getEncoder().encodeToString(data);
//     }
// 
//     public boolean isImage() {
//         return isImage;
//     }
// 
//     @Override
//     public String toString() {
//         return name;
//     }
// }
// 
// Path: src/com/noticeditorteam/noticeditor/model/Attachments.java
// public final class Attachments implements Iterable<Attachment> {
// 
//     private final Map<String, Attachment> attachments;
// 
//     public Attachments() {
//         attachments = new HashMap<>();
//     }
// 
//     public Attachments(Map<String, Attachment> map) {
//         attachments = new HashMap<>(map);
//     }
// 
//     public Attachments(List<Attachment> list) {
//         attachments = new HashMap<>(list.size());
//         for (Attachment attachment : list) {
//             attachments.put(attachment.getName(), attachment);
//         }
//     }
// 
//     public Attachments(Attachments other) {
//         this(other.attachments);
//     }
// 
//     public int size() {
//         return attachments.size();
//     }
// 
//     public boolean isEmpty() {
//         return attachments.isEmpty();
//     }
// 
//     public void add(Attachment e) {
//         attachments.put(e.getName(), e);
//     }
// 
//     public void remove(Attachment att) {
//         attachments.remove(att.getName());
//     }
// 
//     public void clear() {
//         attachments.clear();
//     }
// 
//     public Attachment get(String name) {
//         return attachments.get(name);
//     }
// 
//     public Attachment getOrEmpty(String name) {
//         return attachments.getOrDefault(name, Attachment.EMPTY);
//     }
// 
//     public boolean contains(String key) {
//         return attachments.containsKey(key);
//     }
// 
//     @Override
//     public Iterator<Attachment> iterator() {
//         return attachments.values().iterator();
//     }
// }


import com.noticeditorteam.noticeditor.model.Attachment;
import com.noticeditorteam.noticeditor.model.Attachments;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Optional;
import java.util.ResourceBundle;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.concurrent.Task;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.EventHandler;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javax.imageio.ImageIO;
    public ClipboardImageImporter(ResourceBundle resources) {
        super(resources);
        filenameField = new TextField(defaultFilename());
        formatComboBox = new ComboBox<>();
        formatComboBox.getItems().addAll(ImageFormat.values());
        formatComboBox.getSelectionModel().selectFirst();
        imageView = new ImageView();
        imageView.setPreserveRatio(true);
        imageView.setFocusTraversable(true);
        propertiesBox = new HBox();
        propertiesBox.getChildren().add(filenameField);
        propertiesBox.getChildren().add(formatComboBox);
        HBox.setHgrow(filenameField, Priority.ALWAYS);
        mouseHandler = (event) -> {
            container.requestFocus();
        };
        keyHandler = (event) -> {
            if (event.isControlDown() && event.getCode() == KeyCode.V) {
                onPaste();
            }
        };
        clipboardHelper = new ClipboardImageHelper();
    }

    @Override
    public String name() {
        return resources.getString("import_image_from_clipboard");
    }

    @Override
// Path: src/com/noticeditorteam/noticeditor/model/Attachment.java
// public class Attachment {
// 
//     public static final Attachment EMPTY = new Attachment("", new byte[0]);
// 
//     public static final String PREFIX = "@att:";
//     public static final Pattern PATTERN = Pattern.compile(PREFIX + "([a-zA-Z0-9._\\(\\)]+)");
// 
//     private final String name;
//     private final byte[] data;
//     private final boolean isImage;
//     private final String base64data;
// 
//     public Attachment(String name, byte[] data) {
//         this.name = name;
//         this.data = data;
//         final String nameLowerCase = name.toLowerCase(Locale.ENGLISH);
//         isImage = Stream.of("jpg", "jpeg", "png", "gif")
//                 .anyMatch(ext -> nameLowerCase.endsWith("." + ext));
//         base64data = isImage ? toBase64(data) : "";
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public byte[] getData() {
//         return data;
//     }
// 
//     public String getDataAsBase64() {
//         if (!base64data.isEmpty()) return base64data;
//         return toBase64(data);
//     }
// 
//     private static String toBase64(byte[] data) {
//         return Base64.getEncoder().encodeToString(data);
//     }
// 
//     public boolean isImage() {
//         return isImage;
//     }
// 
//     @Override
//     public String toString() {
//         return name;
//     }
// }
// 
// Path: src/com/noticeditorteam/noticeditor/model/Attachments.java
// public final class Attachments implements Iterable<Attachment> {
// 
//     private final Map<String, Attachment> attachments;
// 
//     public Attachments() {
//         attachments = new HashMap<>();
//     }
// 
//     public Attachments(Map<String, Attachment> map) {
//         attachments = new HashMap<>(map);
//     }
// 
//     public Attachments(List<Attachment> list) {
//         attachments = new HashMap<>(list.size());
//         for (Attachment attachment : list) {
//             attachments.put(attachment.getName(), attachment);
//         }
//     }
// 
//     public Attachments(Attachments other) {
//         this(other.attachments);
//     }
// 
//     public int size() {
//         return attachments.size();
//     }
// 
//     public boolean isEmpty() {
//         return attachments.isEmpty();
//     }
// 
//     public void add(Attachment e) {
//         attachments.put(e.getName(), e);
//     }
// 
//     public void remove(Attachment att) {
//         attachments.remove(att.getName());
//     }
// 
//     public void clear() {
//         attachments.clear();
//     }
// 
//     public Attachment get(String name) {
//         return attachments.get(name);
//     }
// 
//     public Attachment getOrEmpty(String name) {
//         return attachments.getOrDefault(name, Attachment.EMPTY);
//     }
// 
//     public boolean contains(String key) {
//         return attachments.containsKey(key);
//     }
// 
//     @Override
//     public Iterator<Attachment> iterator() {
//         return attachments.values().iterator();
//     }
// }


// Path: src/com/noticeditorteam/noticeditor/plugin/attachments/ClipboardImageImporter.java
import com.noticeditorteam.noticeditor.model.Attachment;
import com.noticeditorteam.noticeditor.model.Attachments;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Optional;
import java.util.ResourceBundle;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.concurrent.Task;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.EventHandler;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javax.imageio.ImageIO;

    public ClipboardImageImporter(ResourceBundle resources) {
        super(resources);
        filenameField = new TextField(defaultFilename());
        formatComboBox = new ComboBox<>();
        formatComboBox.getItems().addAll(ImageFormat.values());
        formatComboBox.getSelectionModel().selectFirst();
        imageView = new ImageView();
        imageView.setPreserveRatio(true);
        imageView.setFocusTraversable(true);
        propertiesBox = new HBox();
        propertiesBox.getChildren().add(filenameField);
        propertiesBox.getChildren().add(formatComboBox);
        HBox.setHgrow(filenameField, Priority.ALWAYS);
        mouseHandler = (event) -> {
            container.requestFocus();
        };
        keyHandler = (event) -> {
            if (event.isControlDown() && event.getCode() == KeyCode.V) {
                onPaste();
            }
        };
        clipboardHelper = new ClipboardImageHelper();
    }

    @Override
    public String name() {
        return resources.getString("import_image_from_clipboard");
    }

    @Override
    protected Task<Attachments> createTask() {