Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editable element #2

Open
bernardodiasc opened this issue Apr 30, 2015 · 0 comments
Open

Editable element #2

bernardodiasc opened this issue Apr 30, 2015 · 0 comments

Comments

@bernardodiasc
Copy link
Owner

This element is a piece of text that can be editable using HTML contenteditable capabilities.

Early conclusion: contenteditable needs a wysiwyg or markdown editor.
The browser built-in feature is very simple and don't allow to edit text elements properly.

XML

Input

<data>
  <element id="element-id" contenteditable="true">
    <h1>Text</h1>
    <a>http://</a>
    <span>value</span>
  <element>
</data>

XSL

In this layer I can mess around XML nodes and turn into HTML using a XSL template:

Place <xsl:apply-templates select="data/element[@id = 'element-id']" mode="mode-name"/> where in HTML you want to show this element data. Usage sample: index.xsl#L17-L19

Template being applied:

<xsl:template match="data/element" mode="mode-name">
  <element id="{@id}" contenteditable="{@contenteditable}">
    <h1>
      <a href="{a}">
        <xsl:value-of select="h1"/> <span><xsl:value-of select="span"/></span>
      </a>
    </h1>
  <element>
</xsl:template>

HTML

Output

<element contenteditable="true">
  <h1>
    <a href="http://">Text <span>value</span></a>
  </h1>
</element>

CSS

Basic presentation

element {
  display: inline-block;
  position: relative;
  width: auto;
  line-height: 1;
}

element[contenteditable="true"]:before {
  border: 1px solid silver;
  display: block;
  content: '';
  position: absolute;
  height: 100%;
  clear: both;
  top: 0px;
  left: 0px;
  width: 100%;
  padding: 2em;
}

element[contenteditable="true"]:after {
  content: '';
  display: block;
  background: rgb(250, 235, 215);
}

JS

storage stuff. connection via rest api

@bernardodiasc bernardodiasc changed the title Control element Editable element Apr 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant