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

支持相邻的 TextNode 跨标签合并成 Paragraph #28

Open
temper357 opened this issue Feb 24, 2021 · 0 comments
Open

支持相邻的 TextNode 跨标签合并成 Paragraph #28

temper357 opened this issue Feb 24, 2021 · 0 comments

Comments

@temper357
Copy link
Contributor

实现以下与 web 相同的文本效果:

  1. 将相邻标签内的 TextNode 合并成一整个 Paragraph 进行展示
  2. 对于跨行的文本 border 能进行跨行展示

Web

image

Kraken

image

测试代码

// test file: /Users/andycall/work/kraken/tests/integration/specs/css/css-position/position-absolute.ts
// it: in-inline-002

let BODY = document.body;
BODY.style.margin = '0px';

let split;
let containerSpan;
let outerSpan;
outerSpan = create(
  'span',
  {
    'box-sizing': 'border-box',
  },
  [
    createText(`outer span`),
    (containerSpan = create(
      'span',
      {
        position: 'relative',
        border: '1px solid gray',
        'box-sizing': 'border-box',
      },
      [
        createText(`container span start`),
        (split = create('div', {
          width: '10px',
          height: '10px',
          'box-sizing': 'border-box',
        })),
        createText(`container span end`),
      ]
    )),
    createText(`outer span end`),
  ]
);
BODY.appendChild(outerSpan);


/**
 * Kraken cli compact library. used to preview kraken rendering.
 */
function setStyle(dom, object) {
    if (object == null)
        return;
    for (let key in object) {
        if (object.hasOwnProperty(key)) {
            dom.style[key] = object[key];
        }
    }
}
function setAttributes(dom, object) {
    for (const key in object) {
        if (object.hasOwnProperty(key)) {
            dom.setAttribute(key, object[key]);
        }
    }
}
function sleep(second) {
    return new Promise(done => setTimeout(done, second * 1000));
}
function create(tag, style, child) {
    const el = document.createElement(tag);
    setStyle(el, style);
    if (Array.isArray(child)) {
        child.forEach(c => el.appendChild(c));
    }
    else if (child) {
        el.appendChild(child);
    }
    return el;
}
function createText(content) {
    return document.createTextNode(content);
}
function append(parent, child) {
    parent.appendChild(child);
}
async function matchScreenshot() {
    return new Promise((resolve) => {
        requestAnimationFrame(() => {
            resolve();
        });
    });
}
async function matchElementImageSnapshot(element) {
    return Promise.resolve();
}
async function it(name, fn) {
    console.log('starting ' + name);
    if (fn.length > 0) {
        const timer = setTimeout(() => {
            throw new Error('it execute timeout of 5000ms');
        }, 5000);
        const done = () => {
            console.log('done call');
            clearTimeout(timer);
        };
        fn(done);
    }
    else {
        fn();
    }
}
function xit(name, fn) {
    it(name, fn);
}

    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant