Package org.waveprotocol.wave.client.editor.content

Examples of org.waveprotocol.wave.client.editor.content.ContentElement


  private String renderPasteHtml(Editor editor) {
    ReadableDocumentView<ContentNode, ContentElement, ContentTextNode> view =
        editor.getContent().getRenderedView();

    System.out.println("doc: " + XmlStringBuilder.innerXml(view).toString());
    ContentElement topLevelElement = view.getDocumentElement().getFirstChild().asElement();
    assertEquals(LineContainers.topLevelContainerTagname(), topLevelElement.getTagName());
    Point<ContentNode> start = Point.inElement(topLevelElement, topLevelElement.getFirstChild());
    Point<ContentNode> end = Point.<ContentNode> end(topLevelElement);

    Element fragment =
        PasteFormatRenderer.get().renderTree(view, topLevelElement,
            new SelectionMatcher(start, end));
View Full Code Here


  }

  public void testFindsTextNodeWrapperNormally() throws HtmlInserted, HtmlMissing {
    ContentDocument dom = TestEditors.createTestDocument();
    c = dom.debugGetRawDocument();
    ContentElement root = c.getDocumentElement();
    m = dom.getContext().rendering().getNodeManager();

    String s1 = "some text", s2 = "other writings", s3 = "more information";

    // t1
    ContentTextNode t1 = c.createTextNode(s1, root, null);
    Text n1 = t1.getImplNodelet();
    checkWrapper(t1, n1);

    // b1 t1
    ContentElement b1 = c.createElement("b", root, t1);
    checkWrapper(t1, n1);

    // b1 t1 b2
    ContentElement b2 = c.createElement("b", root, null);
    checkWrapper(t1, n1);
    Text n1b = n1.splitText(2);
    checkWrapper(t1, n1b);

    // b1 t1 t2 b2
View Full Code Here

  }

  public void testRepairsWherePossible() throws HtmlInserted, HtmlMissing {
    ContentDocument dom = TestEditors.createTestDocument();
    c = dom.debugGetRawDocument();
    ContentElement root = c.getDocumentElement();
    m = dom.getContext().rendering().getNodeManager();

    // TODO(danilatos): Expand this and other test cases

    String s1 = "some text", s2 = "other writings", s3 = "more information";
View Full Code Here

  public void testWrapperElementPointToNodeletPoint() {
    ContentDocument dom = TestEditors.createTestDocument();
    c = dom.debugGetRawDocument();

    ContentElement root = c.getDocumentElement();
    m = dom.getContext().rendering().getNodeManager();

    Element rootNodelet = root.getImplNodelet();
    // meta element, null impl nodelet
    ContentElement n1 = c.createElement("m", root, null);
    n1.setImplNodelets(null, null);

    // regular node
    ContentNode n2 = c.createElement("a", root, null);

    // basic check
View Full Code Here

    public boolean isTabTarget(ContentNode node) {
      if (node == null || node.asElement() == null) {
        return false;
      }
      ContentElement elem = node.asElement();
      String nodeTagName = elem.getTagName();
      return TAB_TARGETS.contains(nodeTagName);
    }
View Full Code Here

  }

  @Override
  public void showSuggestionsFor(HasSuggestions suggestable) {
    popupCloser.cancelScheduledClose();
    ContentElement element = suggestable.getSuggestionElement();
    // NOTE(user): If content is not attached, then at the moment, we don't
    // bring up any suggestions. In the future, we may decide to look for other
    // suggestions that are sufficiently near.
    if (element.isContentAttached()) {
      setCurrent(suggestables.getElement(element));
    }
  }
View Full Code Here

      // HACK(danilatos): I had to patch MenuBar to make this method public.
      // Getting more and more tempting to write own menu class...
      // Calling this makes the first item in the menu selected by default,
      // so just pressing enter will choose it.
      menu.moveSelectionDown();
      ContentElement element = suggestable.getSuggestionElement();

      popupAnchor = element.getImplNodelet();
      // If savedSelection is null, it should be the first time we are showing a popup (not moving
      // around). So, we save the selection because it becomes null later when we lose focus,
      // at least in IE.
      if (savedSelection == null) {
        savedSelection = selectionHelper.getSelectionRange();
View Full Code Here

  @Override
  protected ContentElement maybePlaceMissingCursorContainer(Point.El<ContentNode> at) {
    logger.error().log("PROBLEM: Had to create a line container to accommodate the cursor!");

    ContentElement line = null;
    if (!LineContainers.isLineContainer(FullContentView.INSTANCE, at.getContainer())) {
      // create line container and line atomically:
      line = LineContainers.appendLine(mutableDocument, null, Attributes.EMPTY_MAP);
    } else {
      line = LineContainers.appendLine(mutableDocument, (ContentElement) at.getContainer(), null);
    }
    // return the local p element as the target for the cursor:
    ContentElement inserted = Line.fromLineElement(line).getParagraph();
    needsCorrection = true;
    return inserted;
  }
View Full Code Here

  @VisibleForTesting
  Point<ContentNode> findOrCreateValidSelectionPoint(Point.El<ContentNode> point) {
    // TODO(patcoleman): refactor this into cleaner code - possible separating find and create.
    ValidSelectionContainerView validContainerView =
      new ValidSelectionContainerView(renderedContentView);
    ContentElement container = (ContentElement) point.getContainer();
    assert renderedContentView.getVisibleNode(container) == container : "Container: " + container;

    // Valid position for cursor, so stop where we are:
    if (!isKnownInvalidTopContainerForCursor(container)) {
      return point;
View Full Code Here

    return null;
  }

  /** {@inheritDoc} */
  public Point<ContentNode> getFirstValidSelectionPoint() {
    ContentElement root = renderedContentView.getDocumentElement();
    // Must use filtered view, because of assertion in findOrCreateValidSelectionPoint
    ContentNode first = renderedContentView.getFirstChild(root);

    // assert there's no transparent wrapper, which would render the point invalid
    // for many uses
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.client.editor.content.ContentElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.