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

Font size Feature #89

Open
joelsantosbr opened this issue Jul 16, 2024 · 3 comments
Open

Font size Feature #89

joelsantosbr opened this issue Jul 16, 2024 · 3 comments

Comments

@joelsantosbr
Copy link

Describe the bug
Size attribute is not being recognized as default

The delta code which generates the Problem

Example:

{
    "attributes": {
        "color": "#e74c3c",
        "size": "21pt",
        "font": "Lancelot, cursive"
    },
    "insert": "Lorem ipsum!"
}

I create this new listener

class Size extends InlineListener
{
    /**
     * {@inheritDoc}
     */
    public function process(Line $line)
    {
        $size = $line->getAttribute('size');
        if ($size) {
            $this->updateInput($line, $this->applyTemplate($size, $line));
        }
    }

    public function applyTemplate($size, Line $line)
    {
        return '<span style="font-size: '.$line->getLexer()->escape($size).';">'. $line->getInput() . '</span>';
    }
}

Is possible to add by default in your lib?

@nadar
Copy link
Owner

nadar commented Jul 16, 2024

hi @joelsantosbr, nice that you could easy get your job done by extending the parser, but yes i think this would make sense 👍 Would you like to create a pull request? Version would be 3.5

@nadar nadar changed the title Font size is not working Font size Feature Jul 16, 2024
@joelsantosbr
Copy link
Author

great, i will create ; )

@LifeIsHex
Copy link

Quill Editor v1.3.7

Im using

public function process(Line $line)
{
    $size = $line->getAttribute('size');
    if ($size) {
        $condition = match ($size) {
            'small' => 'ql-size-small',
            'normal' => '',
            'large' => 'ql-size-large',
            'huge' => 'ql-size-huge',
            // default => '',
        };
        $this->updateInput($line, $this->applyTemplate($condition, $line));
    }
}

public function applyTemplate($size, Line $line)
{
    return '<span class="' . $line->getLexer()->escape($size) . '">' . $line->getInput() . '</span>';
}

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