Пример #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"));
  }
Пример #2
0
  public static void initRootRegistries() {
    if (rootRegistriesInitialised) {
      return;
    }
    rootRegistriesInitialised = true;

    // TODO(danilatos/patcoleman): Fix up this kludge
    Editor.TAB_TARGETS.addAll(
        CollectionUtils.newStringSet(Caption.TAGNAME, "profile-field", "text-setting"));

    ImeExtractor.register(ROOT_HANDLER_REGISTRY);
    ContentDocElement.register(ROOT_HANDLER_REGISTRY, ContentDocElement.DEFAULT_TAGNAME);
    Paragraph.register(ROOT_HANDLER_REGISTRY);
    LineRendering.registerLines(ROOT_HANDLER_REGISTRY);

    Caption.register(ROOT_HANDLER_REGISTRY);
    ChunkyElementHandler.register("br", ROOT_HANDLER_REGISTRY);
    AnnotationPaint.register(ROOT_HANDLER_REGISTRY);
    ImgDoodad.register(ROOT_HANDLER_REGISTRY);

    FormDoodads.register(ROOT_HANDLER_REGISTRY);

    // after registries, set selection information:
    ValidSelectionStrategy.registerTagForSelections(
        LineContainers.PARAGRAPH_FULL_TAGNAME, false, Skip.NONE);
    ValidSelectionStrategy.registerTagForSelections(
        AnnotationPaint.SPREAD_FULL_TAGNAME, false, Skip.SHALLOW);
    ValidSelectionStrategy.registerTagForSelections(LineContainers.LINE_TAGNAME, true, Skip.DEEP);
  }