Class EventDispatcher

java.lang.Object
com.wontlost.ckeditor.internal.EventDispatcher

public class EventDispatcher extends Object
管理编辑器事件分发的内部类。 提供类型安全的事件注册和分发机制。

此类是内部 API,不应直接由外部代码使用。

  • Constructor Details

    • EventDispatcher

      public EventDispatcher(VaadinCKEditor source)
      创建事件分发器
      Parameters:
      source - 事件源组件
  • Method Details

    • setErrorHandler

      public void setErrorHandler(ErrorHandler errorHandler)
      设置错误处理器
      Parameters:
      errorHandler - 错误处理器
    • getErrorHandler

      public ErrorHandler getErrorHandler()
      获取错误处理器
      Returns:
      错误处理器
    • addEditorReadyListener

      public com.vaadin.flow.shared.Registration addEditorReadyListener(com.vaadin.flow.component.ComponentEventListener<EditorReadyEvent> listener)
      添加编辑器就绪监听器
      Parameters:
      listener - 监听器
      Returns:
      注册句柄,用于移除监听器
    • addEditorErrorListener

      public com.vaadin.flow.shared.Registration addEditorErrorListener(com.vaadin.flow.component.ComponentEventListener<EditorErrorEvent> listener)
      添加错误监听器
      Parameters:
      listener - 监听器
      Returns:
      注册句柄
    • addAutosaveListener

      public com.vaadin.flow.shared.Registration addAutosaveListener(com.vaadin.flow.component.ComponentEventListener<AutosaveEvent> listener)
      添加自动保存监听器
      Parameters:
      listener - 监听器
      Returns:
      注册句柄
    • addContentChangeListener

      public com.vaadin.flow.shared.Registration addContentChangeListener(com.vaadin.flow.component.ComponentEventListener<ContentChangeEvent> listener)
      添加内容变更监听器
      Parameters:
      listener - 监听器
      Returns:
      注册句柄
    • addFallbackListener

      public com.vaadin.flow.shared.Registration addFallbackListener(com.vaadin.flow.component.ComponentEventListener<FallbackEvent> listener)
      添加回退模式监听器
      Parameters:
      listener - 监听器
      Returns:
      注册句柄
    • fireEditorReady

      public void fireEditorReady(long initTimeMs)
      触发编辑器就绪事件
      Parameters:
      initTimeMs - 初始化耗时(毫秒)
    • fireEditorError

      public boolean fireEditorError(EditorErrorEvent.EditorError error)
      触发错误事件
      Parameters:
      error - 错误信息
      Returns:
      如果错误被处理器处理则返回 true
    • fireAutosave

      public void fireAutosave(String content, boolean success, String errorMessage)
      触发自动保存事件
      Parameters:
      content - 保存的内容
      success - 是否成功
      errorMessage - 错误消息(成功时为 null)
    • fireContentChange

      public void fireContentChange(String oldContent, String newContent, ContentChangeEvent.ChangeSource changeSource)
      触发内容变更事件
      Parameters:
      oldContent - 旧内容
      newContent - 新内容
      changeSource - 变更来源
    • fireFallback

      public void fireFallback(FallbackEvent.FallbackMode mode, String reason, String originalError)
      触发回退模式事件
      Parameters:
      mode - 回退模式
      reason - 原因
      originalError - 原始错误
    • cleanup

      public void cleanup()
      清理所有监听器
    • getListenerStats

      public EventDispatcher.ListenerStats getListenerStats()
      获取已注册监听器的统计信息
      Returns:
      监听器统计