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

Placeholder doesn't appear when content is deleted #171

Closed
rlivsey opened this issue Oct 13, 2015 · 5 comments
Closed

Placeholder doesn't appear when content is deleted #171

rlivsey opened this issue Oct 13, 2015 · 5 comments
Milestone

Comments

@rlivsey
Copy link
Collaborator

rlivsey commented Oct 13, 2015

Post#isBlank returns false if you type something and then delete all the content resulting in the placeholder text not re-appearing.

The current implementation checks that there are no sections, but I'm guessing at this point there's one blank section.

Should this change to be blank if there are no sections OR one blank section?

Post#isBlank looks to be used internally in a few places, so not sure if that would break those.

Alternatively, there could be a public Editor#isBlank which is to be used instead & change the placeholder behaviour to use this?

@rlivsey
Copy link
Collaborator Author

rlivsey commented Oct 13, 2015

Example mobiledoc from the demo before/after deleting all content:

{
  "version": "0.2.0",
  "sections": [
    [],
    []
  ]
}

after

{
  "version": "0.2.0",
  "sections": [
    [],
    [
      [
        1,
        "p",
        []
      ]
    ]
  ]
}

So looks like the section has an empty item, should this be deleted returning it to the original when you clear content?

@bantic
Copy link
Collaborator

bantic commented Oct 14, 2015

@rlivsey Good question. Some of the code surrounding the post#isBlank was to work around the difficulty of showing a placeholder when also showing a "cursorable" <br> (in order to make it so the cursor can be shown reliably, an empty markup section is rendered as a <p><br></p>).

It may make the most sense to preserve the implementation of post#isBlank and instead ensure that when removing the last text from the only markup section it is also removed. That also allows the placeholder to reappear, which seems good. It also preserves a 1-1 mapping of a mobiledoc with a blank post, rather than having two visually-indistinguishable "blank" mobiledocs (your before/after mobiledocs, above).

What do you think?

@rlivsey
Copy link
Collaborator Author

rlivsey commented Oct 14, 2015

@bantic yep that makes complete sense, I'll see if I can figure out how to make it do that…

@mixonic
Copy link
Contributor

mixonic commented Oct 14, 2015

it is probably a little wonky, and will take some work on the renderer. I'd be happy to take a look next week.

@mixonic mixonic modified the milestone: 0.7 Nov 16, 2015
bantic added a commit that referenced this issue Aug 23, 2016
This causes the placeholder to appear even when the editor div is not
wholly devoid of elements.

Possible BREAKING CHANGE: The placeholder text is now absolutely
positioned (at `top: 0`) of the editor div. If a user has applied their
own padding to the editor div the placeholder may not show up in the
correct location. The solution is to add a CSS rule that overrides the
`top` to match the value of the `padding-top`:
```
.__mobiledoc-editor.__has-no-content:after {
  top: <value of padding-top>;
}
```

Also: The editor now has a `min-height: 1em;`
to ensure that the placeholder has a space in which to be displayed.

Fixes #407 #171
bantic added a commit that referenced this issue Aug 23, 2016
This causes the placeholder to appear even when the editor div is not
wholly devoid of elements.

Possible BREAKING CHANGE: The placeholder text is now absolutely
positioned (at `top: 0`) of the editor div. If a user has applied their
own padding to the editor div the placeholder may not show up in the
correct location. The solution is to add a CSS rule that overrides the
`top` to match the value of the `padding-top`:
```
.__mobiledoc-editor.__has-no-content:after {
  top: <value of padding-top>;
}
```

Also: The editor now has a `min-height: 1em;`
to ensure that the placeholder has a space in which to be displayed.

Fixes #407 #171
bantic added a commit that referenced this issue Aug 25, 2016
This causes the placeholder to appear even when the editor div is not
wholly devoid of elements.

Possible BREAKING CHANGE: The placeholder text is now absolutely
positioned (at `top: 0`) of the editor div. If a user has applied their
own padding to the editor div the placeholder may not show up in the
correct location. The solution is to add a CSS rule that overrides the
`top` to match the value of the `padding-top`:
```
.__mobiledoc-editor.__has-no-content:after {
  top: <value of padding-top>;
}
```

Also: The editor now has a `min-height: 1em;`
to ensure that the placeholder has a space in which to be displayed.

Fixes #407 #171
bantic added a commit that referenced this issue Aug 25, 2016
…older text (#461)

This causes the placeholder to appear even when the editor div is not
wholly devoid of elements.

Possible BREAKING CHANGE: The placeholder text is now absolutely
positioned (at `top: 0`) of the editor div. If a user has applied their
own padding to the editor div the placeholder may not show up in the
correct location. The solution is to add a CSS rule that overrides the
`top` to match the value of the `padding-top`:
```
.__mobiledoc-editor.__has-no-content:after {
  top: <value of padding-top>;
}
```

Also: The editor now has a `min-height: 1em;`
to ensure that the placeholder has a space in which to be displayed.

Fixes #407 #171
@bantic
Copy link
Collaborator

bantic commented Aug 25, 2016

closed by #461

@bantic bantic closed this as completed Aug 25, 2016
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

3 participants