예제 #1
0
  public void testImageIsRendered() {
    LineContainers.setTopLevelContainerTagname(Blips.BODY_TAGNAME);
    EditorStaticDeps.setPopupProvider(Popup.LIGHTWEIGHT_POPUP_PROVIDER);
    LineRendering.registerContainer(Blips.BODY_TAGNAME, Editor.ROOT_HANDLER_REGISTRY);
    Editors.initRootRegistries();
    Editor editor = Editors.create();
    editor.init(Editor.ROOT_REGISTRIES, KeyBindingRegistry.NONE, EditorSettings.DEFAULT);

    // seed editor and find image in content:
    ContentSerialisationUtil.setContentString(
        editor, "<body><line/><img src=\"imageSource\"></img></body>");
    ContentElement imgTag =
        editor
            .getDocument()
            .getDocumentElement()
            .getFirstChild()
            .getLastChild()
            .getFirstChild()
            .asElement();

    // check image in html:
    Element elt = imgTag.getImplNodelet();
    assertEquals("IMG", elt.getTagName().toUpperCase());
    assertEquals("imageSource", elt.getAttribute("src"));
  }
 /** {@inheritDoc} */
 @Override
 public void assertHealthy(ContentElement paragraph) {
   ContentView renderedContent = paragraph.getRenderedContentView();
   if (renderedContent.getFirstChild(paragraph) != null) {
     Node child = paragraph.getImplNodelet().getFirstChild();
     while (child != null) {
       assert !isSpacer(child) : "Non-empty paragraph should not have spacer";
       child = child.getNextSibling();
     }
   }
   super.assertHealthy(paragraph);
 }
 /**
  * Sets an EditModeChange listener on this node.
  *
  * @param element
  * @param listener
  */
 public static void setEditModeListener(ContentElement element, EditModeListener listener) {
   element.setProperty(EDIT_MODE_LISTENER_PROP, listener);
 }
 private static EditModeListener getListener(ContentNode node) {
   ContentElement e = node.asElement();
   return e.asElement() != null ? e.getProperty(EDIT_MODE_LISTENER_PROP) : null;
 }
 /** {@inheritDoc} */
 @Override
 public void onRepair(ContentElement paragraph) {
   if (paragraph.getFirstChild() == null) {
     appendSpacer(paragraph.getImplNodelet());
   }
 }